#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 */
double RAND_MAX;
double log(float);
scalar_t__ rand();
float sqrt(double);
float gran_() {
  float fac, rsq, v1, v2;
  static float gset;
  static int iset;
  if (iset) {
    iset = 0;
    return gset;
  }
  do {
    v1 = 2.0 * (float)rand() / RAND_MAX - 1;
    v2 = 2.0 * (float)rand() / RAND_MAX - 1;
    rsq = v1 * v1 + v2 * v2;
  } while (rsq >= 1.0 || rsq == 0.0);
  fac = sqrt(-2.0 * log(rsq) / rsq);
  gset = v1 * fac;
  iset++;
  return v2 * fac;
}


x86 assembly (clang, -O0):
<gran_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
cmpl   $0x0,0x2f05(%rip)
je     1161 <gran_+0x31>
movl   $0x0,0x2ef5(%rip)
movss  0x2ee9(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a5 <gran_+0x175>
jmp    1166 <gran_+0x36>
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe8a(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e5f(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xe6b(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe4e(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e23(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xe2f(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
movsd  0xdee(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x15(%rbp)
jae    123a <gran_+0x10a>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1166 <gran_+0x36>
movss  -0xc(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdb6(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,0x2db9(%rip)
mov    0x2db7(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2dae(%rip)
movss  -0x14(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gran_>:
push   %rbx
sub    $0x10,%rsp
cmpl   $0x0,0x2f08(%rip)
je     1155 <gran_+0x25>
movl   $0x0,0x2efc(%rip)
movss  0x2ef0(%rip),%xmm2
jmp    1233 <gran_+0x103>
mov    0x2e8c(%rip),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm0
divsd  (%rbx),%xmm0
movsd  0xe7d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm0
divsd  (%rbx),%xmm0
addsd  0xe4d(%rip),%xmm0
xorps  %xmm2,%xmm2
cvtsd2ss %xmm0,%xmm2
movaps %xmm2,%xmm1
mulss  %xmm2,%xmm1
movss  (%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xe3b(%rip),%xmm0
jae    1160 <gran_+0x30>
ucomiss 0xe36(%rip),%xmm0
jne    11e6 <gran_+0xb6>
jnp    1160 <gran_+0x30>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movss  %xmm2,0x4(%rsp)
call   1030 <log@plt>
mulsd  0xe02(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <sqrt@plt>
movss  0x4(%rsp),%xmm2
movss  (%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x2e18(%rip)
addl   $0x1,0x2e15(%rip)
mulss  %xmm0,%xmm2
movaps %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

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