#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 drand48();
float log(float);
float rnorm(void) {
  const float sig = 1.0;
  const float mu = 0.0;
  float u, v;
  float x, y;
  for (;;) {
    u = drand48();
    v = drand48();
    v = (v - 0.5) * 1.71552776992141;
    x = u * u * log(u) * -4.0;
    y = v * v;
    if (x >= y)
      break;
  }
  return mu + sig * (v / u);
}


x86 assembly (clang, -O0):
<rnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xed0(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <drand48@plt>
movss  %xmm0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <drand48@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb2(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe9e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe58(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jb     11e0 <rnorm+0xc0>
jmp    11e5 <rnorm+0xc5>
jmp    113d <rnorm+0x1d>
movss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnorm>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <drand48@plt>
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1040 <drand48@plt>
cvtss2sd %xmm0,%xmm0
addsd  0xeb0(%rip),%xmm0
mulsd  0xeb0(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
call   1030 <log@plt>
movss  0x10(%rsp),%xmm2
mulss  0x14(%rsp),%xmm0
mulss  0xe82(%rip),%xmm0
movaps %xmm2,%xmm1
mulss  %xmm2,%xmm1
ucomiss %xmm1,%xmm0
jb     1130 <rnorm+0x10>
divss  0xc(%rsp),%xmm2
xorps  %xmm0,%xmm0
addss  %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @rnorm() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float 1.000000e+00, float* %1
store float 0.000000e+00, float* %2
br label %7
7: ; preds = %31, %0
%8 = call float (...) @drand48()
store float %8, float* %3
%9 = call float (...) @drand48()
store float %9, float* %4
%10 = load float, float* %4
%11 = fpext float %10 to double
%12 = fsub double %11, 5.000000e-01
%13 = fmul double %12, 0x3FFB72CD3F331388
%14 = fptrunc double %13 to float
store float %14, float* %4
%15 = load float, float* %3
%16 = load float, float* %3
%17 = fmul float %15, %16
%18 = load float, float* %3
%19 = call float @log(float %18)
%20 = fmul float %17, %19
%21 = fpext float %20 to double
%22 = fmul double %21, -4.000000e+00
%23 = fptrunc double %22 to float
store float %23, float* %5
%24 = load float, float* %4
%25 = load float, float* %4
%26 = fmul float %24, %25
store float %26, float* %6
%27 = load float, float* %5
%28 = load float, float* %6
%29 = fcmp oge float %27, %28
br i1 %29, label %30, label %31
30: ; preds = %7
br label %32
31: ; preds = %7
br label %7
32: ; preds = %30
%33 = load float, float* %4
%34 = load float, float* %3
%35 = fdiv float %33, %34
%36 = call float @llvm.fmuladd.f32(float 1.000000e+00, float %35, float 0.000000e+00)
ret float %36
}

LLVM IR (-O2):
define float @rnorm() {
br label %1
1: ; preds = %1, %0
%2 = tail call float (...) @drand48()
%3 = tail call float (...) @drand48()
%4 = fpext float %3 to double
%5 = fadd double %4, -5.000000e-01
%6 = fmul double %5, 0x3FFB72CD3F331388
%7 = fptrunc double %6 to float
%8 = fmul float %2, %2
%9 = tail call float @log(float %2)
%10 = fmul float %8, %9
%11 = fmul float %10, -4.000000e+00
%12 = fmul float %7, %7
%13 = fcmp ult float %11, %12
br i1 %13, label %1, label %14
14: ; preds = %1
%15 = fdiv float %7, %2
%16 = fadd float %15, 0.000000e+00
ret float %16
}