#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 bp_sw_sre_random();
float log(int);
float bp_sw_EVDrandom(float mu, float lambda) {
  float p = 0.0;
  while (p == 0. || p == 1.)
    p = bp_sw_sre_random();
  return mu - log(-1. * log(p)) / lambda;
}


x86 assembly (clang, -O0):
<bp_sw_EVDrandom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0xd(%rbp)
jne    1160 <bp_sw_EVDrandom+0x40>
jp     1160 <bp_sw_EVDrandom+0x40>
jmp    1180 <bp_sw_EVDrandom+0x60>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8f(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1190 <bp_sw_EVDrandom+0x70>
jmp    11a1 <bp_sw_EVDrandom+0x81>
mov    $0x0,%al
call   1040 <bp_sw_sre_random@plt>
movss  %xmm0,-0xc(%rbp)
jmp    113a <bp_sw_EVDrandom+0x1a>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cvttss2si -0xc(%rbp),%edi
call   1030 <log@plt>
cvtss2sd %xmm0,%xmm1
movsd  0xe47(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  -0x8(%rbp),%xmm1
subss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bp_sw_EVDrandom>:
push   %rax
movss  %xmm1,(%rsp)
movss  %xmm0,0x4(%rsp)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <bp_sw_sre_random@plt>
ucomiss 0xec6(%rip),%xmm0
jne    1142 <bp_sw_EVDrandom+0x22>
jnp    1130 <bp_sw_EVDrandom+0x10>
ucomiss 0xeb7(%rip),%xmm0
jne    114d <bp_sw_EVDrandom+0x2d>
jnp    1130 <bp_sw_EVDrandom+0x10>
cvttss2si %xmm0,%edi
call   1030 <log@plt>
cvtss2sd %xmm0,%xmm0
xorps  0xeaf(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
divss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @bp_sw_EVDrandom(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
store float 0.000000e+00, float* %5
br label %6
6: ; preds = %16, %2
%7 = load float, float* %5
%8 = fpext float %7 to double
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load float, float* %5
%12 = fpext float %11 to double
%13 = fcmp oeq double %12, 1.000000e+00
br label %14
14: ; preds = %10, %6
%15 = phi i1 [ true, %6 ], [ %13, %10 ]
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = call float (...) @bp_sw_sre_random()
store float %17, float* %5
br label %6
18: ; preds = %14
%19 = load float, float* %3
%20 = load float, float* %5
%21 = fptosi float %20 to i32
%22 = call float @log(i32 %21)
%23 = fpext float %22 to double
%24 = fmul double -1.000000e+00, %23
%25 = fptosi double %24 to i32
%26 = call float @log(i32 %25)
%27 = load float, float* %4
%28 = fdiv float %26, %27
%29 = fsub float %19, %28
ret float %29
}

LLVM IR (-O2):
define float @bp_sw_EVDrandom(float %0, float %1) {
br label %3
3: ; preds = %2, %3
%4 = tail call float (...) @bp_sw_sre_random()
%5 = fcmp oeq float %4, 0.000000e+00
%6 = fcmp oeq float %4, 1.000000e+00
%7 = or i1 %5, %6
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = fptosi float %4 to i32
%10 = tail call float @log(i32 %9)
%11 = fpext float %10 to double
%12 = fneg double %11
%13 = fptosi double %12 to i32
%14 = tail call float @log(i32 %13)
%15 = fdiv float %14, %1
%16 = fsub float %0, %15
ret float %16
}