#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;
int log(float);
float pow(float, int);
scalar_t__ rand();
float sqrt(int);
float normrand(float mu, float sigma) {
  float U1, U2, W, mult;
  static float X1, X2;
  static int call = 0;
  if (call == 1) {
    call = !call;
    return (mu + sigma * (float)X2);
  }
  do {
    U1 = -1 + ((float)rand() / RAND_MAX) * 2;
    U2 = -1 + ((float)rand() / RAND_MAX) * 2;
    W = pow(U1, 2) + pow(U2, 2);
  } while (W >= 1 || W == 0);
  mult = sqrt((-2 * log(W)) / W);
  X1 = U1 * mult;
  X2 = U2 * mult;
  call = !call;
  return (mu + sigma * (float)X1);
}


x86 assembly (clang, -O0):
<normrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
cmpl   $0x1,0x2ef3(%rip)
jne    119a <normrand+0x5a>
cmpl   $0x0,0x2ee6(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2ed6(%rip)
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movss  0x2ec0(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e8 <normrand+0x1a8>
jmp    119f <normrand+0x5f>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e36(%rip),%rax
divss  (%rax),%xmm0
addss  %xmm0,%xmm0
movss  0xe3e(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e0a(%rip),%rax
divss  (%rax),%xmm0
addss  %xmm0,%xmm0
movss  0xe12(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mov    $0x1,%al
movss  0xdca(%rip),%xmm1
ucomiss %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jae    125c <normrand+0x11c>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119f <normrand+0x5f>
movss  -0x18(%rbp),%xmm0
call   1030 <log@plt>
imul   $0xfffffffe,%eax,%eax
cvtsi2ss %eax,%xmm0
divss  -0x18(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1050 <sqrt@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,0x2da4(%rip)
movss  -0x14(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,0x2d96(%rip)
cmpl   $0x0,0x2d93(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d83(%rip)
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movss  0x2d69(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normrand>:
push   %rbx
sub    $0x20,%rsp
cmpl   $0x1,0x2efc(%rip)
jne    1165 <normrand+0x25>
movl   $0x0,0x2ef0(%rip)
movss  0x2ee4(%rip),%xmm2
jmp    1275 <normrand+0x135>
movss  %xmm0,0x18(%rsp)
movss  %xmm1,0x1c(%rsp)
mov    0x2e70(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
divss  (%rbx),%xmm1
addss  %xmm1,%xmm1
movss  0xe61(%rip),%xmm0
addss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  (%rbx),%xmm0
addss  %xmm0,%xmm0
addss  0xe38(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x14(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addss  0xc(%rsp),%xmm0
ucomiss 0xe03(%rip),%xmm0
jae    1180 <normrand+0x40>
ucomiss 0xdfa(%rip),%xmm0
jne    1216 <normrand+0xd6>
jnp    1180 <normrand+0x40>
movss  %xmm0,0xc(%rsp)
call   1030 <log@plt>
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1050 <sqrt@plt>
movss  0x14(%rsp),%xmm2
mulss  %xmm0,%xmm2
movss  0x10(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x2ded(%rip)
xor    %eax,%eax
cmpl   $0x0,0x2de8(%rip)
sete   %al
mov    %eax,0x2ddf(%rip)
movss  0x1c(%rsp),%xmm1
movss  0x18(%rsp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@normrand.X1 = internal global float 0.000000e+00
@normrand.X2 = internal global float 0.000000e+00
@normrand.call = internal global i32 0
@RAND_MAX = global float 0.000000e+00
define float @normrand(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %4
store float %1, float* %5
%10 = load i32, i32* @normrand.call
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = load i32, i32* @normrand.call
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
%16 = zext i1 %15 to i32
store i32 %16, i32* @normrand.call
%17 = load float, float* %4
%18 = load float, float* %5
%19 = load float, float* @normrand.X2
%20 = call float @llvm.fmuladd.f32(float %18, float %19, float %17)
store float %20, float* %3
br label %69
21: ; preds = %2
br label %22
22: ; preds = %44, %21
%23 = call i64 (...) @rand()
%24 = sitofp i64 %23 to float
%25 = load float, float* @RAND_MAX
%26 = fdiv float %24, %25
%27 = call float @llvm.fmuladd.f32(float %26, float 2.000000e+00, float -1.000000e+00)
store float %27, float* %6
%28 = call i64 (...) @rand()
%29 = sitofp i64 %28 to float
%30 = load float, float* @RAND_MAX
%31 = fdiv float %29, %30
%32 = call float @llvm.fmuladd.f32(float %31, float 2.000000e+00, float -1.000000e+00)
store float %32, float* %7
%33 = load float, float* %6
%34 = call float @pow(float %33, i32 2)
%35 = load float, float* %7
%36 = call float @pow(float %35, i32 2)
%37 = fadd float %34, %36
store float %37, float* %8
br label %38
38: ; preds = %22
%39 = load float, float* %8
%40 = fcmp oge float %39, 1.000000e+00
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load float, float* %8
%43 = fcmp oeq float %42, 0.000000e+00
br label %44
44: ; preds = %41, %38
%45 = phi i1 [ true, %38 ], [ %43, %41 ]
br i1 %45, label %22, label %46
46: ; preds = %44
%47 = load float, float* %8
%48 = call i32 @log(float %47)
%49 = mul nsw i32 -2, %48
%50 = sitofp i32 %49 to float
%51 = load float, float* %8
%52 = fdiv float %50, %51
%53 = fptosi float %52 to i32
%54 = call float @sqrt(i32 %53)
store float %54, float* %9
%55 = load float, float* %6
%56 = load float, float* %9
%57 = fmul float %55, %56
store float %57, float* @normrand.X1
%58 = load float, float* %7
%59 = load float, float* %9
%60 = fmul float %58, %59
store float %60, float* @normrand.X2
%61 = load i32, i32* @normrand.call
%62 = icmp ne i32 %61, 0
%63 = xor i1 %62, true
%64 = zext i1 %63 to i32
store i32 %64, i32* @normrand.call
%65 = load float, float* %4
%66 = load float, float* %5
%67 = load float, float* @normrand.X1
%68 = call float @llvm.fmuladd.f32(float %66, float %67, float %65)
store float %68, float* %3
br label %69
69: ; preds = %46, %12
%70 = load float, float* %3
ret float %70
}

LLVM IR (-O2):
@normrand.X2 = internal unnamed_addr global float 0.000000e+00
@normrand.call = internal unnamed_addr global i32 0
@RAND_MAX = global float 0.000000e+00
define float @normrand(float %0, float %1) {
%3 = load i32, i32* @normrand.call
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %2
store i32 0, i32* @normrand.call
%6 = load float, float* @normrand.X2
br label %36
7: ; preds = %2, %7
%8 = tail call i64 (...) @rand()
%9 = sitofp i64 %8 to float
%10 = load float, float* @RAND_MAX
%11 = fdiv float %9, %10
%12 = tail call float @llvm.fmuladd.f32(float %11, float 2.000000e+00, float -1.000000e+00)
%13 = tail call i64 (...) @rand()
%14 = sitofp i64 %13 to float
%15 = load float, float* @RAND_MAX
%16 = fdiv float %14, %15
%17 = tail call float @llvm.fmuladd.f32(float %16, float 2.000000e+00, float -1.000000e+00)
%18 = tail call float @pow(float %12, i32 2)
%19 = tail call float @pow(float %17, i32 2)
%20 = fadd float %18, %19
%21 = fcmp oge float %20, 1.000000e+00
%22 = fcmp oeq float %20, 0.000000e+00
%23 = or i1 %21, %22
br i1 %23, label %7, label %24
24: ; preds = %7
%25 = tail call i32 @log(float %20)
%26 = mul nsw i32 %25, -2
%27 = sitofp i32 %26 to float
%28 = fdiv float %27, %20
%29 = fptosi float %28 to i32
%30 = tail call float @sqrt(i32 %29)
%31 = fmul float %12, %30
%32 = fmul float %17, %30
store float %32, float* @normrand.X2
%33 = load i32, i32* @normrand.call
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
store i32 %35, i32* @normrand.call
br label %36
36: ; preds = %24, %5
%37 = phi float [ %31, %24 ], [ %6, %5 ]
%38 = tail call float @llvm.fmuladd.f32(float %1, float %37, float %0)
ret float %38
}