#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ Euler(double *, double *, double *, double *, double, double,
                         double *);
int M_PI;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double, double,
                           double);
double sqrt(double);
int main(void) {
  double t = 0, dt = 0.001, ratio[2];
  FILE *graf;
  double GM = 4 * M_PI * M_PI, x[2] = {2.52, 5.24};
  double y[2] = {0, 0}, vx[2] = {0, 0}, vy[2];
  ratio[0] = 0.04 * GM;
  ratio[1] = -0.001 * GM;
  vy[0] = sqrt(GM / x[0]);
  vy[1] = sqrt(GM / x[1]);
  graf = fopen("graf.dat", "w");
  for (t = 0; t <= 100; t += dt) {
    Euler(x, y, vx, vy, GM, dt, ratio);
    fprintf(graf, "%f\t %f\t %f\t %f\n", x[0], y[0], x[1], y[1]);
  }
  fclose(graf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
shl    $0x2,%eax
mov    0x2e4e(%rip),%rcx
imul   (%rcx),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
movsd  0xe24(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe0a(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
lea    0xe01(%rip),%rdi
lea    0xe03(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xdc9(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     12b5 <main+0x155>
lea    -0x50(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    -0x80(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x30(%rbp),%r8
call   1040 <Euler@plt>
mov    -0x38(%rbp),%rdi
movsd  -0x50(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
lea    0xd9f(%rip),%rsi
call   1060 <fprintf@plt>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1247 <main+0xe7>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
imul   %eax,%eax
shl    $0x2,%eax
cvtsi2sd %eax,%xmm2
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x50(%rsp)
movapd %xmm2,%xmm1
unpcklpd %xmm2,%xmm1
mulpd  0xe67(%rip),%xmm1
movapd %xmm2,%xmm0
divsd  0xe7b(%rip),%xmm0
movapd %xmm1,0x60(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm2,0x30(%rsp)
jb     11c1 <main+0x71>
sqrtsd %xmm0,%xmm0
jmp    11d0 <main+0x80>
call   1070 <sqrt@plt>
xorpd  %xmm1,%xmm1
movapd 0x30(%rsp),%xmm2
movsd  %xmm0,0x40(%rsp)
movapd %xmm2,%xmm0
divsd  0xe46(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11ee <main+0x9e>
sqrtsd %xmm0,%xmm0
jmp    11f3 <main+0xa3>
call   1070 <sqrt@plt>
movsd  %xmm0,0x48(%rsp)
lea    0xe40(%rip),%rdi
lea    0xe42(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
xorpd  %xmm0,%xmm0
mov    %rsp,%r15
lea    0x50(%rsp),%r12
lea    0x40(%rsp),%r13
lea    0x60(%rsp),%rbp
lea    0xe1f(%rip),%r14
nopl   0x0(%rax)
movsd  %xmm0,0x28(%rsp)
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
movaps 0x30(%rsp),%xmm0
movsd  0xddf(%rip),%xmm1
mov    %rbp,%r8
call   1040 <Euler@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm3
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
movsd  0x28(%rsp),%xmm0
addsd  0xda7(%rip),%xmm0
movsd  0xda7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1230 <main+0xe0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
@__const.main.x = [2 x double] [double 2.520000e+00, double 5.240000e+00]
@.str = [9 x i8] c"graf.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"%f\09 %f\09 %f\09 %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca [2 x double]
%5 = alloca i32*
%6 = alloca double
%7 = alloca [2 x double]
%8 = alloca [2 x double]
%9 = alloca [2 x double]
%10 = alloca [2 x double]
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 1.000000e-03, double* %3
%11 = load i32, i32* @M_PI
%12 = mul nsw i32 4, %11
%13 = load i32, i32* @M_PI
%14 = mul nsw i32 %12, %13
%15 = sitofp i32 %14 to double
store double %15, double* %6
%16 = bitcast [2 x double]* %7 to i8*
%17 = bitcast [2 x double]* %8 to i8*
%18 = bitcast [2 x double]* %9 to i8*
%19 = load double, double* %6
%20 = fmul double 4.000000e-02, %19
%21 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
store double %20, double* %21
%22 = load double, double* %6
%23 = fmul double -1.000000e-03, %22
%24 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 1
store double %23, double* %24
%25 = load double, double* %6
%26 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%27 = load double, double* %26
%28 = fdiv double %25, %27
%29 = call double @sqrt(double %28)
%30 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
store double %29, double* %30
%31 = load double, double* %6
%32 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
%33 = load double, double* %32
%34 = fdiv double %31, %33
%35 = call double @sqrt(double %34)
%36 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 1
store double %35, double* %36
%37 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %5
store double 0.000000e+00, double* %2
br label %38
38: ; preds = %60, %0
%39 = load double, double* %2
%40 = fcmp ole double %39, 1.000000e+02
br i1 %40, label %41, label %64
41: ; preds = %38
%42 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%43 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%44 = getelementptr inbounds [2 x double], [2 x double]* %9, i64 0, i64 0
%45 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%46 = load double, double* %6
%47 = load double, double* %3
%48 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%49 = call i32 @Euler(double* %42, double* %43, double* %44, double* %45, double %46, double %47, double* %48)
%50 = load i32*, i32** %5
%51 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%52 = load double, double* %51
%53 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%54 = load double, double* %53
%55 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
%56 = load double, double* %55
%57 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 1
%58 = load double, double* %57
%59 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %52, double %54, double %56, double %58)
br label %60
60: ; preds = %41
%61 = load double, double* %3
%62 = load double, double* %2
%63 = fadd double %62, %61
store double %63, double* %2
br label %38
64: ; preds = %38
%65 = load i32*, i32** %5
%66 = call i32 @fclose(i32* %65)
ret i32 0
}

LLVM IR (-O2):
@M_PI = global i32 0
@__const.main.x = [2 x double] [double 2.520000e+00, double 5.240000e+00]
@.str = [9 x i8] c"graf.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"%f\09 %f\09 %f\09 %f\0A\00"
define i32 @main() {
%1 = alloca <2 x double>
%2 = alloca [2 x double]
%3 = alloca [2 x double]
%4 = alloca [2 x double]
%5 = alloca [2 x double]
%6 = bitcast <2 x double>* %1 to i8*
%7 = load i32, i32* @M_PI
%8 = shl nsw i32 %7, 2
%9 = mul nsw i32 %8, %7
%10 = sitofp i32 %9 to double
%11 = bitcast [2 x double]* %2 to i8*
%12 = bitcast [2 x double]* %3 to i8*
%13 = bitcast [2 x double]* %4 to i8*
%14 = bitcast [2 x double]* %5 to i8*
%15 = getelementptr inbounds <2 x double>, <2 x double>* %1, i64 0, i64 0
%16 = insertelement <2 x double> poison, double %10, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = fmul <2 x double> %17, <double 4.000000e-02, double -1.000000e-03>
store <2 x double> %18, <2 x double>* %1
%19 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%20 = fdiv double %10, 2.520000e+00
%21 = tail call double @sqrt(double %20)
%22 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
store double %21, double* %22
%23 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 1
%24 = fdiv double %10, 5.240000e+00
%25 = tail call double @sqrt(double %24)
%26 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
store double %25, double* %26
%27 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%29 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%30 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
br label %31
31: ; preds = %0, %31
%32 = phi double [ 0.000000e+00, %0 ], [ %39, %31 ]
%33 = call i32 @Euler(double* %19, double* %28, double* %29, double* %22, double %10, double 1.000000e-03, double* %15)
%34 = load double, double* %19
%35 = load double, double* %28
%36 = load double, double* %23
%37 = load double, double* %30
%38 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %34, double %35, double %36, double %37)
%39 = fadd double %32, 1.000000e-03
%40 = fcmp ugt double %39, 1.000000e+02
br i1 %40, label %41, label %31
41: ; preds = %31
%42 = call i32 @fclose(i32* %27)
ret i32 0
}