#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 cos(double);
float distributions_uniform(double, double);
double fabs(float);
double log(float);
int sqrt(double);
float distributions_normal(float mean, float sigma) {
  float u1, u2, x, y;
  u1 = distributions_uniform(0.0, 1.0);
  u2 = distributions_uniform(0.0, 1.0);
  x = (float)(cos(6.283185307179586 * (float)u1) * sqrt(-2.0 * log((float)u2)));
  y = sigma * x + mean;
  while (fabs(y - mean) > 20.0 * sigma) {
    u1 = distributions_uniform(0.0, 1.0);
    u2 = distributions_uniform(0.0, 1.0);
    x = (float)(cos(6.283185307179586 * (float)u1) *
                sqrt(-2.0 * log((float)u2)));
    y = sigma * x + mean;
  }
  return (y);
}


x86 assembly (clang, -O0):
<distributions_normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  0xea3(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  0xe8e(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe6b(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
mov    %eax,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe42(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
call   1040 <fabs@plt>
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe04(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    12b9 <distributions_normal+0x169>
xorps  %xmm0,%xmm0
movsd  0xde3(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  0xdce(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdab(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
mov    %eax,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  0xd82(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11f4 <distributions_normal+0xa4>
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distributions_normal>:
push   %rbx
sub    $0x20,%rsp
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x14(%rsp)
movsd  0xe97(%rip),%xmm1
xorps  %xmm0,%xmm0
call   1030 <distributions_uniform@plt>
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movsd  0xe7e(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,0x8(%rsp)
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe69(%rip),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebx
movss  0x8(%rsp),%xmm0
call   1060 <log@plt>
mulsd  0xe57(%rip),%xmm0
call   1070 <sqrt@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
subss  %xmm1,%xmm0
call   1040 <fabs@plt>
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  0xe1f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a6 <distributions_normal+0x156>
movsd  %xmm1,0x18(%rsp)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
movsd  0xde5(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movsd  0xdcf(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,0x8(%rsp)
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xdba(%rip),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebx
movss  0x8(%rsp),%xmm0
call   1060 <log@plt>
mulsd  0xda8(%rip),%xmm0
call   1070 <sqrt@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
subss  %xmm1,%xmm0
call   1040 <fabs@plt>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm0
ja     1210 <distributions_normal+0xc0>
movss  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @distributions_normal(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %3
store float %1, float* %4
%9 = call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
store float %9, float* %5
%10 = call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
store float %10, float* %6
%11 = load float, float* %5
%12 = fpext float %11 to double
%13 = fmul double 0x401921FB54442D18, %12
%14 = call i32 @cos(double %13)
%15 = load float, float* %6
%16 = call double @log(float %15)
%17 = fmul double -2.000000e+00, %16
%18 = call i32 @sqrt(double %17)
%19 = mul nsw i32 %14, %18
%20 = sitofp i32 %19 to float
store float %20, float* %7
%21 = load float, float* %4
%22 = load float, float* %7
%23 = load float, float* %3
%24 = call float @llvm.fmuladd.f32(float %21, float %22, float %23)
store float %24, float* %8
br label %25
25: ; preds = %34, %2
%26 = load float, float* %8
%27 = load float, float* %3
%28 = fsub float %26, %27
%29 = call double @fabs(float %28)
%30 = load float, float* %4
%31 = fpext float %30 to double
%32 = fmul double 2.000000e+01, %31
%33 = fcmp ogt double %29, %32
br i1 %33, label %34, label %51
34: ; preds = %25
%35 = call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
store float %35, float* %5
%36 = call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
store float %36, float* %6
%37 = load float, float* %5
%38 = fpext float %37 to double
%39 = fmul double 0x401921FB54442D18, %38
%40 = call i32 @cos(double %39)
%41 = load float, float* %6
%42 = call double @log(float %41)
%43 = fmul double -2.000000e+00, %42
%44 = call i32 @sqrt(double %43)
%45 = mul nsw i32 %40, %44
%46 = sitofp i32 %45 to float
store float %46, float* %7
%47 = load float, float* %4
%48 = load float, float* %7
%49 = load float, float* %3
%50 = call float @llvm.fmuladd.f32(float %47, float %48, float %49)
store float %50, float* %8
br label %25
51: ; preds = %25
%52 = load float, float* %8
ret float %52
}

LLVM IR (-O2):
define float @distributions_normal(float %0, float %1) {
%3 = tail call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
%4 = tail call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
%5 = fpext float %3 to double
%6 = fmul double %5, 0x401921FB54442D18
%7 = tail call i32 @cos(double %6)
%8 = tail call double @log(float %4)
%9 = fmul double %8, -2.000000e+00
%10 = tail call i32 @sqrt(double %9)
%11 = mul nsw i32 %10, %7
%12 = sitofp i32 %11 to float
%13 = tail call float @llvm.fmuladd.f32(float %1, float %12, float %0)
%14 = fsub float %13, %0
%15 = tail call double @fabs(float %14)
%16 = fpext float %1 to double
%17 = fmul double %16, 2.000000e+01
%18 = fcmp ogt double %15, %17
br i1 %18, label %19, label %34
19: ; preds = %2, %19
%20 = tail call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
%21 = tail call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
%22 = fpext float %20 to double
%23 = fmul double %22, 0x401921FB54442D18
%24 = tail call i32 @cos(double %23)
%25 = tail call double @log(float %21)
%26 = fmul double %25, -2.000000e+00
%27 = tail call i32 @sqrt(double %26)
%28 = mul nsw i32 %27, %24
%29 = sitofp i32 %28 to float
%30 = tail call float @llvm.fmuladd.f32(float %1, float %29, float %0)
%31 = fsub float %30, %0
%32 = tail call double @fabs(float %31)
%33 = fcmp ogt double %32, %17
br i1 %33, label %19, label %34
34: ; preds = %19, %2
%35 = phi float [ %13, %2 ], [ %30, %19 ]
ret float %35
}