#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 */
scalar_t__ rand01();
double randg01() {
  int i;
  double sum = 0;
  for (i = 0; i < 12; i++)
    sum += rand01();
  return sum - 6.;
}


x86 assembly (clang, -O0):
<randg01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xc,-0x4(%rbp)
jge    1155 <randg01+0x45>
mov    $0x0,%al
call   1030 <rand01@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1127 <randg01+0x17>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
subsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randg01>:
push   %rax
xor    %eax,%eax
call   1030 <rand01@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
addsd  0xdc8(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @randg01() {
%1 = alloca i32
%2 = alloca double
store double 0.000000e+00, double* %2
store i32 0, i32* %1
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 12
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = call i64 (...) @rand01()
%8 = sitofp i64 %7 to double
%9 = load double, double* %2
%10 = fadd double %9, %8
store double %10, double* %2
br label %11
11: ; preds = %6
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %3
14: ; preds = %3
%15 = load double, double* %2
%16 = fsub double %15, 6.000000e+00
ret double %16
}

LLVM IR (-O2):
define double @randg01() {
%1 = tail call i64 (...) @rand01()
%2 = sitofp i64 %1 to double
%3 = tail call i64 (...) @rand01()
%4 = sitofp i64 %3 to double
%5 = fadd double %2, %4
%6 = tail call i64 (...) @rand01()
%7 = sitofp i64 %6 to double
%8 = fadd double %5, %7
%9 = tail call i64 (...) @rand01()
%10 = sitofp i64 %9 to double
%11 = fadd double %8, %10
%12 = tail call i64 (...) @rand01()
%13 = sitofp i64 %12 to double
%14 = fadd double %11, %13
%15 = tail call i64 (...) @rand01()
%16 = sitofp i64 %15 to double
%17 = fadd double %14, %16
%18 = tail call i64 (...) @rand01()
%19 = sitofp i64 %18 to double
%20 = fadd double %17, %19
%21 = tail call i64 (...) @rand01()
%22 = sitofp i64 %21 to double
%23 = fadd double %20, %22
%24 = tail call i64 (...) @rand01()
%25 = sitofp i64 %24 to double
%26 = fadd double %23, %25
%27 = tail call i64 (...) @rand01()
%28 = sitofp i64 %27 to double
%29 = fadd double %26, %28
%30 = tail call i64 (...) @rand01()
%31 = sitofp i64 %30 to double
%32 = fadd double %29, %31
%33 = tail call i64 (...) @rand01()
%34 = sitofp i64 %33 to double
%35 = fadd double %32, %34
%36 = fadd double %35, -6.000000e+00
ret double %36
}