#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ single_decay(int *, float, float, float, int);
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  float N_0 = 10.0;
  float Lambda = 1.0 / 2.0;
  float Dt = 0.001;
  int *enes = (int *)malloc(1000 * 10000 * sizeof(int));
  srand48(time(NULL));
  int i, j;
  for (j = 0; j < 1000; j++) {
    single_decay(enes, N_0, Lambda, Dt, j);
  }
  FILE *fout;
  fout = fopen("decaimientos.txt", "w");
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 1000; j++) {
      if (j == 1000 - 1) {
        fprintf(fout, "%d\n", enes[i * 1000 + j]);
      } else {
        fprintf(fout, "%d,", enes[i * 1000 + j]);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe91(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe80(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe6f(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x2625a00,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1060 <srand48@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    11f1 <main+0x91>
mov    -0x18(%rbp),%rdi
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
mov    -0x20(%rbp),%esi
call   1080 <single_decay@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11bb <main+0x5b>
lea    0xe14(%rip),%rdi
lea    0xe1e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2710,-0x1c(%rbp)
jge    12b0 <main+0x150>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    129d <main+0x13d>
cmpl   $0x3e7,-0x20(%rbp)
jne    1266 <main+0x106>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
imul   $0x3e8,-0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xdc3(%rip),%rsi
call   1030 <fprintf@plt>
jmp    128a <main+0x12a>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
imul   $0x3e8,-0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd9e(%rip),%rsi
call   1030 <fprintf@plt>
jmp    128f <main+0x12f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1223 <main+0xc3>
jmp    12a2 <main+0x142>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120f <main+0xaf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2625a00,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1060 <srand48@plt>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
movss  0xe65(%rip),%xmm0
movss  0xe61(%rip),%xmm1
movss  0xe5d(%rip),%xmm2
mov    %ebx,%esi
call   1080 <single_decay@plt>
add    $0x1,%ebx
cmp    $0x3e8,%ebx
jne    1190 <main+0x30>
lea    0xe48(%rip),%rdi
lea    0xe52(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
xor    %r13d,%r13d
lea    0xe46(%rip),%r15
mov    %r14,%rbp
mov    %r14,(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
imul   $0x3e8,%r13,%r12
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,4),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <fprintf@plt>
add    $0x1,%r14
cmp    $0x3e7,%r14
jne    1200 <main+0xa0>
mov    (%rsp),%r14
mov    0xf9c(%r14,%r12,4),%edx
mov    %rbx,%rdi
lea    0xdec(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x1,%r13
add    $0xfa0,%rbp
cmp    $0x2710,%r13
jne    11f0 <main+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"decaimientos.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"%d,\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %1
store float 1.000000e+01, float* %2
store float 5.000000e-01, float* %3
store float 0x3F50624DE0000000, float* %4
%9 = call i64 @malloc(i32 40000000)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %5
%11 = call i32 @time(i32* null)
%12 = call i32 @srand48(i32 %11)
store i32 0, i32* %7
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 1000
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32*, i32** %5
%18 = load float, float* %2
%19 = load float, float* %3
%20 = load float, float* %4
%21 = load i32, i32* %7
%22 = call i32 @single_decay(i32* %17, float %18, float %19, float %20, i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %13
26: ; preds = %13
%27 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %8
store i32 0, i32* %6
br label %28
28: ; preds = %65, %26
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 10000
br i1 %30, label %31, label %68
31: ; preds = %28
store i32 0, i32* %7
br label %32
32: ; preds = %61, %31
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 1000
br i1 %34, label %35, label %64
35: ; preds = %32
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 999
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = load i32*, i32** %8
%40 = load i32*, i32** %5
%41 = load i32, i32* %6
%42 = mul nsw i32 %41, 1000
%43 = load i32, i32* %7
%44 = add nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %40, i64 %45
%47 = load i32, i32* %46
%48 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %60
49: ; preds = %35
%50 = load i32*, i32** %8
%51 = load i32*, i32** %5
%52 = load i32, i32* %6
%53 = mul nsw i32 %52, 1000
%54 = load i32, i32* %7
%55 = add nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %51, i64 %56
%58 = load i32, i32* %57
%59 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %49, %38
br label %61
61: ; preds = %60
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %32
64: ; preds = %32
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %28
68: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"decaimientos.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"%d,\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 40000000)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand48(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %8, %5 ]
%7 = tail call i32 @single_decay(i32* %2, float 1.000000e+01, float 5.000000e-01, float 0x3F50624DE0000000, i32 %6)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 1000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %25
%13 = phi i64 [ 0, %10 ], [ %28, %25 ]
%14 = mul nuw nsw i64 %13, 1000
%15 = add nuw nsw i64 %14, 999
%16 = getelementptr inbounds i32, i32* %2, i64 %15
br label %17
17: ; preds = %12, %17
%18 = phi i64 [ 0, %12 ], [ %23, %17 ]
%19 = add nuw nsw i64 %18, %14
%20 = getelementptr inbounds i32, i32* %2, i64 %19
%21 = load i32, i32* %20
%22 = tail call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, 999
br i1 %24, label %25, label %17
25: ; preds = %17
%26 = load i32, i32* %16
%27 = tail call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %13, 1
%29 = icmp eq i64 %28, 10000
br i1 %29, label %30, label %12
30: ; preds = %25
ret i32 0
}