#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ drand48();
float fun(int /*<<< orphan*/);
int /*<<< orphan*/ print_array(float *, int);
float *reserva(int);
int /*<<< orphan*/ srand48(scalar_t__);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int n_iterations = atoi(argv[1]);
  int n_puntos = 1000;
  int i;
  int j;
  float *valores = reserva(n_iterations);
  float suma;
  for (j = 0; j < n_iterations; j++) {
    suma = 0;
    srand48(time(NULL) + 1000 * j);
    for (i = 0; i < 1000; i++) {
      suma = suma + fun(drand48());
    }
    valores[j] = suma / 1000.0;
  }
  print_array(valores, n_iterations);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x3e8,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <reserva@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1260 <main+0xf0>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,%rdi
imul   $0x3e8,-0x20(%rbp),%eax
cltq
add    %rax,%rdi
call   1060 <srand48@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    122c <main+0xbc>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1090 <drand48@plt>
mov    %eax,%edi
call   1040 <fun@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e8 <main+0x78>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdc3(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b0 <main+0x40>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1070 <reserva@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1206 <main+0x96>
mov    %r14d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %edi,%edi
call   1050 <time@plt>
imul   $0x3e8,%ebx,%edi
add    %rax,%rdi
call   1060 <srand48@plt>
xorps  %xmm0,%xmm0
mov    $0x3e8,%ebp
nopl   (%rax)
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1090 <drand48@plt>
mov    %eax,%edi
call   1040 <fun@plt>
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0xc(%rsp),%xmm0
add    $0xffffffff,%ebp
jne    11c0 <main+0x50>
divss  0xe09(%rip),%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %r12,%rbx
jne    11a0 <main+0x30>
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float*
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
store i32 1000, i32* %7
%16 = load i32, i32* %6
%17 = call float* @reserva(i32 %16)
store float* %17, float** %10
store i32 0, i32* %9
br label %18
18: ; preds = %49, %2
%19 = load i32, i32* %9
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %52
22: ; preds = %18
store float 0.000000e+00, float* %11
%23 = call i64 @time(i32* null)
%24 = load i32, i32* %9
%25 = mul nsw i32 1000, %24
%26 = sext i32 %25 to i64
%27 = add nsw i64 %23, %26
%28 = call i32 @srand48(i64 %27)
store i32 0, i32* %8
br label %29
29: ; preds = %37, %22
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 1000
br i1 %31, label %32, label %40
32: ; preds = %29
%33 = load float, float* %11
%34 = call i32 (...) @drand48()
%35 = call float @fun(i32 %34)
%36 = fadd float %33, %35
store float %36, float* %11
br label %37
37: ; preds = %32
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %29
40: ; preds = %29
%41 = load float, float* %11
%42 = fpext float %41 to double
%43 = fdiv double %42, 1.000000e+03
%44 = fptrunc double %43 to float
%45 = load float*, float** %10
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds float, float* %45, i64 %47
store float %44, float* %48
br label %49
49: ; preds = %40
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %18
52: ; preds = %18
%53 = load float*, float** %10
%54 = load i32, i32* %6
%55 = call i32 @print_array(float* %53, i32 %54)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call float* @reserva(i32 %5)
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %30
8: ; preds = %2
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %8, %25
%11 = phi i64 [ 0, %8 ], [ %28, %25 ]
%12 = tail call i64 @time(i32* null)
%13 = mul i64 %11, 1000
%14 = and i64 %13, 4294967288
%15 = add nsw i64 %12, %14
%16 = tail call i32 @srand48(i64 %15)
br label %17
17: ; preds = %10, %17
%18 = phi float [ 0.000000e+00, %10 ], [ %22, %17 ]
%19 = phi i32 [ 0, %10 ], [ %23, %17 ]
%20 = tail call i32 (...) @drand48()
%21 = tail call float @fun(i32 %20)
%22 = fadd float %18, %21
%23 = add nuw nsw i32 %19, 1
%24 = icmp eq i32 %23, 1000
br i1 %24, label %25, label %17
25: ; preds = %17
%26 = fdiv float %22, 1.000000e+03
%27 = getelementptr inbounds float, float* %6, i64 %11
store float %26, float* %27
%28 = add nuw nsw i64 %11, 1
%29 = icmp eq i64 %28, %9
br i1 %29, label %30, label %10
30: ; preds = %25, %2
%31 = tail call i32 @print_array(float* %6, i32 %5)
ret i32 0
}