//
// This file was generated by the Retargetable Decompiler
// Website: https://retdec.com
// Copyright (c) 2019 Retargetable Decompiler <info@retdec.com>
//

#include <math.h>
#include <stdint.h>

// ---------------- Integer Types Definitions -----------------

typedef int8_t int3_t;

// ----------------- Float Types Definitions ------------------

typedef double float64_t;
typedef long double float80_t;

// ------------------- Function Prototypes --------------------

int32_t function_0(int32_t a1);
int32_t function_30(void);
int32_t function_35(int32_t a1, int32_t a2, int32_t a3);
int32_t function_4c(void);
int32_t function_51(int32_t a1, int32_t a2, int32_t a3);

// --------------------- Global Variables ---------------------

int32_t g1 = 0; // eax
int32_t g2 = 0; // ebp
int32_t g3 = 0; // ebx
int32_t g4 = 0; // ecx
int32_t g5 = 0; // edi
int32_t g6 = 0; // edx
int32_t g7 = 0; // esi
char g8 = -117;
int32_t g9;

// ------------------------ Functions -------------------------

// Address range: 0x0 - 0x30
int32_t function_0(int32_t a1) {
    int32_t v1; // edi
    int32_t v2; // esi
    int32_t v3; // bp+12
    int32_t v4;
    int32_t v5;
    int32_t v6;
    int32_t result;
    int32_t v7;
    // 0x0
    v4 = g3;
    v5 = v2;
    v6 = v1;
    g7 = a1;
    v7 = *(int32_t *)(a1 + 48);
    g5 = v7;
    v3 = g1;
    g3 = v3;
    result = function_35(v6, v5, v4);
    g1 = result;
    return result;
}

// Address range: 0x30 - 0x35
int32_t function_30(void) {
    int32_t v1; // ebp
    int3_t v2; // fpu_stat_TOP
    float80_t v3; // st7
    int3_t v4; // bp+32
    float80_t v5; // bp+30
    int32_t v6; // bp+32
    float80_t v7; // bp+30
    int32_t result; // bp+32
    // 0x30
    v5 = v3;
    v7 = v5 - v5;
    v3 = v7;
    v4 = v2;
    v6 = v1;
    *(float64_t *)(v6 + -8) = (float64_t)v7;
    v2 = v4 + (int3_t)&g8;
    result = g1;
    return result;
}

// Address range: 0x35 - 0x4c
int32_t function_35(int32_t a1, int32_t a2, int32_t a3) {
    float64_t v1;
    float64_t v2;
    int32_t v3; // bp+35
    int32_t v4;
    int32_t v5; // bp+47
    int32_t result;
    float64_t v6; // bp+35
    float64_t v7;
    float64_t v8; // bp+44
    // 0x35
    v3 = g7;
    v6 = *(float64_t *)(v3 + 24);
    v1 = fabs(v6);
    v2 = fabs(v6);
    v4 = g5;
    v7 = *(float64_t *)(v4 + -64);
    v8 = *(float64_t *)(v4 + -72);
    v5 = g2;
    *(float64_t *)(v5 + -16) = (float64_t)(((float80_t)v2 + (float80_t)v7) * (float80_t)v1 * (float80_t)v8);
    result = function_51((int32_t)&g9, (int32_t)&g9, (int32_t)&g9);
    g1 = result;
    return result;
}

// Address range: 0x4c - 0x51
int32_t function_4c(void) {
    int32_t v1; // ebp
    int3_t v2; // fpu_stat_TOP
    float80_t v3; // st7
    int3_t v4;
    float80_t v5;
    int32_t v6;
    float80_t v7;
    int32_t result;
    // 0x4c
    v5 = v3;
    v7 = v5 - v5;
    v3 = v7;
    v4 = v2;
    v6 = v1;
    *(float64_t *)(v6 + -16) = (float64_t)v7;
    v2 = v4 + (int3_t)&g8;
    result = g1;
    return result;
}

// Address range: 0x51 - 0x7b
int32_t function_51(int32_t a1, int32_t a2, int32_t a3) {
    int32_t result; // bp+70
    float80_t v1;
    int32_t v2;
    int32_t v3; // bp+60
    float64_t v4; // bp+51
    float64_t v5; // bp+55
    float80_t v6; // bp+51
    float80_t v7; // bp+55
    float64_t v8; // bp+68
    float64_t v9;
    float64_t v10; // bp+60
    float64_t v11; // bp+63
    // 0x51
    v4 = *(float64_t *)&g6;
    v6 = (float80_t)v4;
    v5 = *(float64_t *)&g4;
    v7 = (float80_t)v5;
    v1 = sqrtl(v6 * v6 + v7 * v7);
    v2 = g5;
    v9 = *(float64_t *)(v2 + -48);
    v3 = g2;
    v10 = *(float64_t *)(v3 + -8);
    v11 = *(float64_t *)(v3 + -16);
    v8 = *(float64_t *)&g3;
    *(float64_t *)(int32_t)(int64_t)v8 = (float64_t)((float80_t)v8 - (v1 * (float80_t)v9 + (float80_t)v10 + (float80_t)v11));
    result = g3;
    g1 = result;
    g3 = a3;
    return result;
}

// --------------------- Meta-Information ---------------------

// Detected functions: 5
// Decompilation date: 2019-09-05 22:22:41
