#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 */
float exp(float);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float, float);
int main() {
  float lambda = 1.0 / 5.0;
  float N0 = 10.0;
  float dt = 0.001;
  float t_total = 3.0 / lambda;
  int n_points = (int)t_total / dt;
  int i;
  float t = 0.0;
  float n = N0 * exp(-lambda * t);
  FILE *out = fopen("data.txt", "w+");
  fprintf(out, "%f %f\n", t, n);
  for (i = 0; i < n_points; i++) {
    t += dt;
    n = N0 * exp(-lambda * t);
    fprintf(out, "%f %f\n", t, n);
  }
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xeb9(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xea8(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe97(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe79(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
cvttss2si -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
divss  -0x10(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xe25(%rip),%rdi
lea    0xe27(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
lea    0xe0c(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    129a <main+0x15a>
movss  -0x10(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
lea    0xd99(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1220 <main+0xe0>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xeb3(%rip),%r14
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0xe8a(%rip),%xmm1
xorps  %xmm0,%xmm0
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
mov    $0x3a97,%ebp
nopl   0x0(%rax)
movss  0xc(%rsp),%xmm0
addss  0xe66(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
mulss  0xe5c(%rip),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
mulss  0xe44(%rip),%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
movss  0xc(%rsp),%xmm0
call   1040 <fprintf@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"data.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca i32*
store i32 0, i32* %1
store float 0x3FC99999A0000000, float* %2
store float 1.000000e+01, float* %3
store float 0x3F50624DE0000000, float* %4
%11 = load float, float* %2
%12 = fpext float %11 to double
%13 = fdiv double 3.000000e+00, %12
%14 = fptrunc double %13 to float
store float %14, float* %5
%15 = load float, float* %5
%16 = fptosi float %15 to i32
%17 = sitofp i32 %16 to float
%18 = load float, float* %4
%19 = fdiv float %17, %18
%20 = fptosi float %19 to i32
store i32 %20, i32* %6
store float 0.000000e+00, float* %8
%21 = load float, float* %3
%22 = load float, float* %2
%23 = fneg float %22
%24 = load float, float* %8
%25 = fmul float %23, %24
%26 = call float @exp(float %25)
%27 = fmul float %21, %26
store float %27, float* %9
%28 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %10
%29 = load i32*, i32** %10
%30 = load float, float* %8
%31 = load float, float* %9
%32 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %30, float %31)
store i32 0, i32* %7
br label %33
33: ; preds = %52, %0
%34 = load i32, i32* %7
%35 = load i32, i32* %6
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %55
37: ; preds = %33
%38 = load float, float* %4
%39 = load float, float* %8
%40 = fadd float %39, %38
store float %40, float* %8
%41 = load float, float* %3
%42 = load float, float* %2
%43 = fneg float %42
%44 = load float, float* %8
%45 = fmul float %43, %44
%46 = call float @exp(float %45)
%47 = fmul float %41, %46
store float %47, float* %9
%48 = load i32*, i32** %10
%49 = load float, float* %8
%50 = load float, float* %9
%51 = call i32 @fprintf(i32* %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %49, float %50)
br label %52
52: ; preds = %37
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %33
55: ; preds = %33
%56 = load i32*, i32** %10
%57 = call i32 @fclose(i32* %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"data.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float 0.000000e+00, float 1.000000e+01)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %11, %3 ]
%5 = phi float [ 0.000000e+00, %0 ], [ %6, %3 ]
%6 = fadd float %5, 0x3F50624DE0000000
%7 = fmul float %6, 0xBFC99999A0000000
%8 = tail call float @exp(float %7)
%9 = fmul float %8, 1.000000e+01
%10 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %6, float %9)
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 14999
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = tail call i32 @fclose(i32* %1)
ret i32 0
}