#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*/ CondIni(double *, double);
int /*<<< orphan*/ Evol(double *, double *, double);
int /*<<< orphan*/ copy(double *, double *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double);
double *malloc(int);
int main() {
  double dx = 2.0 / 100;
  double dt = 0.3 / 300;
  double r = 1.0 * dt / dx;
  double *u_historia = malloc(100 * sizeof(double));
  double *u_regalo = malloc(100 * sizeof(double));
  double *u_misterio = malloc(100 * sizeof(double));
  FILE *datos;
  datos = fopen("datos.csv", "w");
  CondIni(u_historia, dx);
  for (int j = 0; j < 100; j++) {
    if (j == 100 - 1) {
      fprintf(datos, "%lf\n", u_historia[j]);
    } else {
      fprintf(datos, "%lf,", u_historia[j]);
    }
  }
  for (int i = 1; i < 300; i++) {
    Evol(u_regalo, u_historia, r);
    copy(u_regalo, u_historia);
    for (int j = 0; j < 100; j++) {
      if (j == 100 - 1) {
        fprintf(datos, "%lf\n", u_regalo[j]);
      } else {
        fprintf(datos, "%lf,", u_regalo[j]);
      }
    }
  }
  fclose(datos);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe74(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe5f(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x320,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x320,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x320,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
lea    0xe37(%rip),%rdi
lea    0xe3a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
call   1080 <CondIni@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x64,-0x44(%rbp)
jge    126c <main+0xfc>
cmpl   $0x63,-0x44(%rbp)
jne    123c <main+0xcc>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdf2(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1259 <main+0xe9>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdd5(%rip),%rsi
call   1050 <fprintf@plt>
jmp    125e <main+0xee>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1206 <main+0x96>
movl   $0x1,-0x48(%rbp)
cmpl   $0x12c,-0x48(%rbp)
jge    131f <main+0x1af>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
call   1090 <Evol@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <copy@plt>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x64,-0x4c(%rbp)
jge    130c <main+0x19c>
cmpl   $0x63,-0x4c(%rbp)
jne    12dc <main+0x16c>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd52(%rip),%rsi
call   1050 <fprintf@plt>
jmp    12f9 <main+0x189>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd35(%rip),%rsi
call   1050 <fprintf@plt>
jmp    12fe <main+0x18e>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12a6 <main+0x136>
jmp    1311 <main+0x1a1>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1273 <main+0x103>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x320,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x320,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x320,%edi
call   1060 <malloc@plt>
lea    0xe6a(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
movsd  0xe43(%rip),%xmm0
mov    %r14,%rdi
call   1080 <CondIni@plt>
xor    %ebp,%ebp
lea    0xe53(%rip),%r12
xchg   %ax,%ax
movsd  (%r14,%rbp,8),%xmm0
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <fprintf@plt>
add    $0x1,%rbp
cmp    $0x63,%rbp
jne    11d0 <main+0x60>
movsd  0x318(%r14),%xmm0
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fprintf@plt>
mov    $0x1,%ebp
lea    0xe12(%rip),%r13
nop
mov    %r15,%rdi
mov    %r14,%rsi
movsd  0xdea(%rip),%xmm0
call   1090 <Evol@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <copy@plt>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%r12,8),%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <fprintf@plt>
add    $0x1,%r12
cmp    $0x63,%r12
jne    1240 <main+0xd0>
movsd  0x318(%r15),%xmm0
mov    %rbx,%rdi
lea    0xdae(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x12c,%ebp
jne    1210 <main+0xa0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"datos.csv\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%lf\0A\00"
@.str.3 = [5 x i8] c"%lf,\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store double 2.000000e-02, double* %2
store double 1.000000e-03, double* %3
%12 = load double, double* %3
%13 = fmul double 1.000000e+00, %12
%14 = load double, double* %2
%15 = fdiv double %13, %14
store double %15, double* %4
%16 = call double* @malloc(i32 800)
store double* %16, double** %5
%17 = call double* @malloc(i32 800)
store double* %17, double** %6
%18 = call double* @malloc(i32 800)
store double* %18, double** %7
%19 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %8
%20 = load double*, double** %5
%21 = load double, double* %2
%22 = call i32 @CondIni(double* %20, double %21)
store i32 0, i32* %9
br label %23
23: ; preds = %46, %0
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 100
br i1 %25, label %26, label %49
26: ; preds = %23
%27 = load i32, i32* %9
%28 = icmp eq i32 %27, 99
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32*, i32** %8
%31 = load double*, double** %5
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %35)
br label %45
37: ; preds = %26
%38 = load i32*, i32** %8
%39 = load double*, double** %5
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %43)
br label %45
45: ; preds = %37, %29
br label %46
46: ; preds = %45
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %23
49: ; preds = %23
store i32 1, i32* %10
br label %50
50: ; preds = %88, %49
%51 = load i32, i32* %10
%52 = icmp slt i32 %51, 300
br i1 %52, label %53, label %91
53: ; preds = %50
%54 = load double*, double** %6
%55 = load double*, double** %5
%56 = load double, double* %4
%57 = call i32 @Evol(double* %54, double* %55, double %56)
%58 = load double*, double** %6
%59 = load double*, double** %5
%60 = call i32 @copy(double* %58, double* %59)
store i32 0, i32* %11
br label %61
61: ; preds = %84, %53
%62 = load i32, i32* %11
%63 = icmp slt i32 %62, 100
br i1 %63, label %64, label %87
64: ; preds = %61
%65 = load i32, i32* %11
%66 = icmp eq i32 %65, 99
br i1 %66, label %67, label %75
67: ; preds = %64
%68 = load i32*, i32** %8
%69 = load double*, double** %6
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = call i32 @fprintf(i32* %68, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %73)
br label %83
75: ; preds = %64
%76 = load i32*, i32** %8
%77 = load double*, double** %6
%78 = load i32, i32* %11
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = call i32 @fprintf(i32* %76, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %81)
br label %83
83: ; preds = %75, %67
br label %84
84: ; preds = %83
%85 = load i32, i32* %11
%86 = add nsw i32 %85, 1
store i32 %86, i32* %11
br label %61
87: ; preds = %61
br label %88
88: ; preds = %87
%89 = load i32, i32* %10
%90 = add nsw i32 %89, 1
store i32 %90, i32* %10
br label %50
91: ; preds = %50
%92 = load i32*, i32** %8
%93 = call i32 @fclose(i32* %92)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"datos.csv\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%lf\0A\00"
@.str.3 = [5 x i8] c"%lf,\00"
define i32 @main() {
%1 = tail call double* @malloc(i32 800)
%2 = tail call double* @malloc(i32 800)
%3 = tail call double* @malloc(i32 800)
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @CondIni(double* %1, double 2.000000e-02)
%6 = getelementptr inbounds double, double* %1, i64 99
br label %11
7: ; preds = %11
%8 = load double, double* %6
%9 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %8)
%10 = getelementptr inbounds double, double* %2, i64 99
br label %20
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %16, %11 ]
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = load double, double* %13
%15 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, 99
br i1 %17, label %7, label %11
18: ; preds = %24
%19 = tail call i32 @fclose(i32* %4)
ret i32 0
20: ; preds = %7, %24
%21 = phi i32 [ 1, %7 ], [ %27, %24 ]
%22 = tail call i32 @Evol(double* %2, double* %1, double 5.000000e-02)
%23 = tail call i32 @copy(double* %2, double* %1)
br label %29
24: ; preds = %29
%25 = load double, double* %10
%26 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = add nuw nsw i32 %21, 1
%28 = icmp eq i32 %27, 300
br i1 %28, label %18, label %20
29: ; preds = %20, %29
%30 = phi i64 [ 0, %20 ], [ %34, %29 ]
%31 = getelementptr inbounds double, double* %2, i64 %30
%32 = load double, double* %31
%33 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %32)
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, 99
br i1 %35, label %24, label %29
}