#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 /*<<< orphan*/ printArray(double *, int);
int /*<<< orphan*/ printf(char *, double);
double randomDouble(int, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
double sumArray(double *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  double d[10];
  for (int i = 0; i < 10; i++)
    d[i] = randomDouble(1000000, 100);
  printArray(d, 10);
  printf("suma = %f\n", sumArray(d, 10));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0xa,-0x64(%rbp)
jge    11b7 <main+0x57>
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movslq -0x64(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1186 <main+0x26>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1080 <printArray@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1030 <sumArray@plt>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x20(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x28(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x30(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x38(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x40(%rsp)
mov    $0xf4240,%edi
mov    $0x64,%esi
call   1060 <randomDouble@plt>
movsd  %xmm0,0x48(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <printArray@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <sumArray@plt>
lea    0xd98(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"suma = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x double]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = call double @randomDouble(i32 1000000, i32 100)
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 %12
store double %10, double* %13
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%19 = call i32 @printArray(double* %18, i32 10)
%20 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%21 = call double @sumArray(double* %20, i32 10)
%22 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [11 x i8] c"suma = %f\0A\00"
define i32 @main() {
%1 = alloca [10 x double]
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast [10 x double]* %1 to i8*
%5 = tail call double @randomDouble(i32 1000000, i32 100)
%6 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 0
store double %5, double* %6
%7 = tail call double @randomDouble(i32 1000000, i32 100)
%8 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 1
store double %7, double* %8
%9 = tail call double @randomDouble(i32 1000000, i32 100)
%10 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 2
store double %9, double* %10
%11 = tail call double @randomDouble(i32 1000000, i32 100)
%12 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 3
store double %11, double* %12
%13 = tail call double @randomDouble(i32 1000000, i32 100)
%14 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 4
store double %13, double* %14
%15 = tail call double @randomDouble(i32 1000000, i32 100)
%16 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 5
store double %15, double* %16
%17 = tail call double @randomDouble(i32 1000000, i32 100)
%18 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 6
store double %17, double* %18
%19 = tail call double @randomDouble(i32 1000000, i32 100)
%20 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 7
store double %19, double* %20
%21 = tail call double @randomDouble(i32 1000000, i32 100)
%22 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 8
store double %21, double* %22
%23 = tail call double @randomDouble(i32 1000000, i32 100)
%24 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 9
store double %23, double* %24
%25 = call i32 @printArray(double* %6, i32 10)
%26 = call double @sumArray(double* %6, i32 10)
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %26)
ret i32 0
}