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


x86 assembly (clang, -O0):
<NRgdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jge    1154 <NRgdev+0x24>
movl   $0x0,0x2ee8(%rip)
cmpl   $0x0,0x2ee1(%rip)
jne    1271 <NRgdev+0x141>
jmp    1166 <NRgdev+0x36>
mov    -0x10(%rbp),%rdi
call   1030 <NRran@plt>
addsd  %xmm0,%xmm0
movsd  0xe85(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <NRran@plt>
addsd  %xmm0,%xmm0
movsd  0xe63(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
movss  -0x20(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
movsd  0xe2a(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jae    1206 <NRgdev+0xd6>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1166 <NRgdev+0x36>
movss  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdea(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,0x2ded(%rip)
movl   $0x1,0x2ddf(%rip)
movss  -0x20(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1288 <NRgdev+0x158>
movl   $0x0,0x2dc1(%rip)
movss  0x2dbd(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NRgdev>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
cmpq   $0x0,(%rdi)
js     115b <NRgdev+0x2b>
cmpb   $0x0,0x2ef7(%rip)
je     1170 <NRgdev+0x40>
movb   $0x0,0x2eee(%rip)
movss  0x2eea(%rip),%xmm2
jmp    1221 <NRgdev+0xf1>
movb   $0x0,0x2eda(%rip)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <NRran@plt>
addsd  %xmm0,%xmm0
movsd  0xe7c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <NRran@plt>
addsd  %xmm0,%xmm0
addsd  0xe5b(%rip),%xmm0
xorps  %xmm2,%xmm2
cvtsd2ss %xmm0,%xmm2
movaps %xmm2,%xmm1
mulss  %xmm2,%xmm1
movss  (%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xe49(%rip),%xmm0
jae    1170 <NRgdev+0x40>
ucomiss 0xe44(%rip),%xmm0
jne    11d4 <NRgdev+0xa4>
jnp    1170 <NRgdev+0x40>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movss  %xmm2,0x4(%rsp)
call   1040 <log@plt>
mulsd  0xe14(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1050 <sqrt@plt>
movss  0x4(%rsp),%xmm2
movss  (%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x2e2a(%rip)
movb   $0x1,0x2e1f(%rip)
mulss  %xmm0,%xmm2
movaps %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

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