#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 */
float RAND_MAX;
scalar_t__ rand();
float randn(void) {
  float r = 0.0;
  for (int j = 0; j < 12; j++) {
    r += 12.0 * (((float)rand()) / RAND_MAX - 0.5);
  }
  return r / 12.0;
}


x86 assembly (clang, -O0):
<randn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    1188 <randn+0x78>
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2ea4(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb4(%rip),%xmm1
subsd  %xmm1,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe97(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1127 <randn+0x17>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe67(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randn>:
push   %r14
push   %rbx
push   %rax
xorps  %xmm1,%xmm1
mov    $0xc,%ebx
mov    0x2ec5(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm1,(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  (%r14),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xeab(%rip),%xmm0
mulsd  0xeab(%rip),%xmm0
addsd  (%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
add    $0xffffffff,%ebx
jne    1130 <randn+0x20>
divss  0xe96(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
define float @randn() {
br label %3
1: ; preds = %3
%2 = fdiv float %13, 1.200000e+01
ret float %2
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %14, %3 ]
%5 = phi double [ 0.000000e+00, %0 ], [ %15, %3 ]
%6 = tail call i64 (...) @rand()
%7 = sitofp i64 %6 to float
%8 = load float, float* @RAND_MAX
%9 = fdiv float %7, %8
%10 = fpext float %9 to double
%11 = fadd double %10, -5.000000e-01
%12 = tail call double @llvm.fmuladd.f64(double %11, double 1.200000e+01, double %5)
%13 = fptrunc double %12 to float
%14 = add nuw nsw i32 %4, 1
%15 = fpext float %13 to double
%16 = icmp eq i32 %14, 12
br i1 %16, label %1, label %3
}