#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__ RAND_MAX;
double cos(double);
double fabs(double);
scalar_t__ floor(double);
double log(double);
int rand();
double sin(double);
double sqrt(double);
int randomGaussian(int mean, int stddev) {
  double mu = 0.5 + (double)mean;
  double sigma = fabs((double)stddev);
  double f1 = sqrt(-2.0 * log((double)rand() / (double)RAND_MAX));
  double f2 = 2.0 * 3.14159265359 * (double)rand() / (double)RAND_MAX;
  if (rand() & (1 << 5))
    return (int)floor(mu + sigma * cos(f2) * f1);
  else
    return (int)floor(mu + sigma * sin(f2) * f1);
}


x86 assembly (clang, -O0):
<randomGaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe95(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movaps 0xe90(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    0x2e3d(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe44(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe1b(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2df8(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
and    $0x20,%eax
cmp    $0x0,%eax
je     125a <randomGaussian+0xfa>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <floor@plt>
mov    %eax,-0x4(%rbp)
jmp    129e <randomGaussian+0x13e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <floor@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomGaussian>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%r14d
xor    %eax,%eax
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    0x2e69(%rip),%rbx
cvtsi2sdq (%rbx),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
mulsd  0xe6b(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a5 <randomGaussian+0x45>
sqrtsd %xmm0,%xmm0
jmp    11aa <randomGaussian+0x4a>
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe42(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdq (%rbx),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
test   $0x20,%al
jne    11ee <randomGaussian+0x8e>
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
jmp    11f8 <randomGaussian+0x98>
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
andpd  0xe19(%rip),%xmm1
cvtsi2sd %r14d,%xmm2
addsd  0xdfc(%rip),%xmm2
mulsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <floor@plt>

LLVM IR (-O0):
@RAND_MAX = global i64 0
define i32 @randomGaussian(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to double
%12 = fadd double 5.000000e-01, %11
store double %12, double* %6
%13 = load i32, i32* %5
%14 = sitofp i32 %13 to double
%15 = call double @llvm.fabs.f64(double %14)
store double %15, double* %7
%16 = call i32 (...) @rand()
%17 = sitofp i32 %16 to double
%18 = load i64, i64* @RAND_MAX
%19 = sitofp i64 %18 to double
%20 = fdiv double %17, %19
%21 = call double @log(double %20)
%22 = fmul double -2.000000e+00, %21
%23 = call double @sqrt(double %22)
store double %23, double* %8
%24 = call i32 (...) @rand()
%25 = sitofp i32 %24 to double
%26 = fmul double 0x401921FB54442EEA, %25
%27 = load i64, i64* @RAND_MAX
%28 = sitofp i64 %27 to double
%29 = fdiv double %26, %28
store double %29, double* %9
%30 = call i32 (...) @rand()
%31 = and i32 %30, 32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %2
%34 = load double, double* %6
%35 = load double, double* %7
%36 = load double, double* %9
%37 = call double @cos(double %36)
%38 = fmul double %35, %37
%39 = load double, double* %8
%40 = call double @llvm.fmuladd.f64(double %38, double %39, double %34)
%41 = call i64 @floor(double %40)
%42 = trunc i64 %41 to i32
store i32 %42, i32* %3
br label %53
43: ; preds = %2
%44 = load double, double* %6
%45 = load double, double* %7
%46 = load double, double* %9
%47 = call double @sin(double %46)
%48 = fmul double %45, %47
%49 = load double, double* %8
%50 = call double @llvm.fmuladd.f64(double %48, double %49, double %44)
%51 = call i64 @floor(double %50)
%52 = trunc i64 %51 to i32
store i32 %52, i32* %3
br label %53
53: ; preds = %43, %33
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define i32 @randomGaussian(i32 %0, i32 %1) {
%3 = tail call i32 (...) @rand()
%4 = sitofp i32 %3 to double
%5 = load i64, i64* @RAND_MAX
%6 = sitofp i64 %5 to double
%7 = fdiv double %4, %6
%8 = tail call double @log(double %7)
%9 = fmul double %8, -2.000000e+00
%10 = tail call double @sqrt(double %9)
%11 = tail call i32 (...) @rand()
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 0x401921FB54442EEA
%14 = load i64, i64* @RAND_MAX
%15 = sitofp i64 %14 to double
%16 = fdiv double %13, %15
%17 = tail call i32 (...) @rand()
%18 = and i32 %17, 32
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %2
%21 = tail call double @cos(double %16)
br label %24
22: ; preds = %2
%23 = tail call double @sin(double %16)
br label %24
24: ; preds = %22, %20
%25 = phi double [ %23, %22 ], [ %21, %20 ]
%26 = sitofp i32 %1 to double
%27 = tail call double @llvm.fabs.f64(double %26)
%28 = sitofp i32 %0 to double
%29 = fadd double %28, 5.000000e-01
%30 = fmul double %27, %25
%31 = tail call double @llvm.fmuladd.f64(double %30, double %10, double %29)
%32 = tail call i64 @floor(double %31)
%33 = trunc i64 %32 to i32
ret i32 %33
}