#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 random_normal(double mean, double sigma) {
  int i;
  double sum = 0;
  const int samples = 12;
  for (i = 0; i < samples; i++) {
    sum += rand01();
  }
  return mean + (sum / samples - 0.5) * sigma;
}


x86 assembly (clang, -O0):
<random_normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0xc,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    1166 <random_normal+0x56>
mov    $0x0,%al
call   1030 <rand01@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <random_normal+0x28>
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe90(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  0xe7c(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_normal>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <rand01@plt>
xorps  %xmm0,%xmm0
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  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  (%rsp),%xmm1
divsd  0xdb6(%rip),%xmm1
addsd  0xdb6(%rip),%xmm1
mulsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @random_normal(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
store double %0, double* %3
store double %1, double* %4
store double 0.000000e+00, double* %6
store i32 12, i32* %7
store i32 0, i32* %5
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 12
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = call i64 (...) @rand01()
%13 = sitofp i64 %12 to double
%14 = load double, double* %6
%15 = fadd double %14, %13
store double %15, double* %6
br label %16
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %8
19: ; preds = %8
%20 = load double, double* %3
%21 = load double, double* %6
%22 = fdiv double %21, 1.200000e+01
%23 = fsub double %22, 5.000000e-01
%24 = load double, double* %4
%25 = call double @llvm.fmuladd.f64(double %23, double %24, double %20)
ret double %25
}

LLVM IR (-O2):
define double @random_normal(double %0, double %1) {
%3 = tail call i64 (...) @rand01()
%4 = sitofp i64 %3 to double
%5 = tail call i64 (...) @rand01()
%6 = sitofp i64 %5 to double
%7 = fadd double %4, %6
%8 = tail call i64 (...) @rand01()
%9 = sitofp i64 %8 to double
%10 = fadd double %7, %9
%11 = tail call i64 (...) @rand01()
%12 = sitofp i64 %11 to double
%13 = fadd double %10, %12
%14 = tail call i64 (...) @rand01()
%15 = sitofp i64 %14 to double
%16 = fadd double %13, %15
%17 = tail call i64 (...) @rand01()
%18 = sitofp i64 %17 to double
%19 = fadd double %16, %18
%20 = tail call i64 (...) @rand01()
%21 = sitofp i64 %20 to double
%22 = fadd double %19, %21
%23 = tail call i64 (...) @rand01()
%24 = sitofp i64 %23 to double
%25 = fadd double %22, %24
%26 = tail call i64 (...) @rand01()
%27 = sitofp i64 %26 to double
%28 = fadd double %25, %27
%29 = tail call i64 (...) @rand01()
%30 = sitofp i64 %29 to double
%31 = fadd double %28, %30
%32 = tail call i64 (...) @rand01()
%33 = sitofp i64 %32 to double
%34 = fadd double %31, %33
%35 = tail call i64 (...) @rand01()
%36 = sitofp i64 %35 to double
%37 = fadd double %34, %36
%38 = fdiv double %37, 1.200000e+01
%39 = fadd double %38, -5.000000e-01
%40 = tail call double @llvm.fmuladd.f64(double %39, double %1, double %0)
ret double %40
}