#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 rand();
float gaussian(float mean, float std_deviation) {
  int i;
  int temp;
  int sum;
  float dtemp;
  sum = 0;
  for (i = 0; i < 12; i++) {
    temp = rand();
    sum += temp;
  }
  dtemp = (float)((sum - 196602.0) / 32767.0);
  return dtemp * std_deviation + mean;
}


x86 assembly (clang, -O0):
<gaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jge    115b <gaussian+0x4b>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1130 <gaussian+0x20>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian>:
push   %rbp
push   %rbx
push   %rax
movss  %xmm1,(%rsp)
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
add    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe53(%rip),%xmm0
divsd  0xe53(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
mulss  (%rsp),%xmm1
movss  0x4(%rsp),%xmm0
addss  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @gaussian(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store float %0, float* %3
store float %1, float* %4
store i32 0, i32* %7
store i32 0, i32* %5
br label %9
9: ; preds = %17, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 12
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = call i32 (...) @rand()
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = add nsw i32 %15, %14
store i32 %16, i32* %7
br label %17
17: ; preds = %12
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %9
20: ; preds = %9
%21 = load i32, i32* %7
%22 = sitofp i32 %21 to double
%23 = fsub double %22, 1.966020e+05
%24 = fdiv double %23, 3.276700e+04
%25 = fptrunc double %24 to float
store float %25, float* %8
%26 = load float, float* %8
%27 = load float, float* %4
%28 = load float, float* %3
%29 = call float @llvm.fmuladd.f32(float %26, float %27, float %28)
ret float %29
}

LLVM IR (-O2):
define float @gaussian(float %0, float %1) {
%3 = tail call i32 (...) @rand()
%4 = tail call i32 (...) @rand()
%5 = add nsw i32 %4, %3
%6 = tail call i32 (...) @rand()
%7 = add nsw i32 %6, %5
%8 = tail call i32 (...) @rand()
%9 = add nsw i32 %8, %7
%10 = tail call i32 (...) @rand()
%11 = add nsw i32 %10, %9
%12 = tail call i32 (...) @rand()
%13 = add nsw i32 %12, %11
%14 = tail call i32 (...) @rand()
%15 = add nsw i32 %14, %13
%16 = tail call i32 (...) @rand()
%17 = add nsw i32 %16, %15
%18 = tail call i32 (...) @rand()
%19 = add nsw i32 %18, %17
%20 = tail call i32 (...) @rand()
%21 = add nsw i32 %20, %19
%22 = tail call i32 (...) @rand()
%23 = add nsw i32 %22, %21
%24 = tail call i32 (...) @rand()
%25 = add nsw i32 %24, %23
%26 = sitofp i32 %25 to double
%27 = fadd double %26, -1.966020e+05
%28 = fdiv double %27, 3.276700e+04
%29 = fptrunc double %28 to float
%30 = tail call float @llvm.fmuladd.f32(float %29, float %1, float %0)
ret float %30
}