#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(double);
scalar_t__ rand();
double expVA(double x) {
  double z;
  do {
    z = ((double)rand() / RAND_MAX);
  } while ((z == 0) || (z == 1));
  return (-x * log(z));
}


x86 assembly (clang, -O0):
<expVA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2ea8(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x11(%rbp)
jne    116b <expVA+0x4b>
jp     116b <expVA+0x4b>
jmp    1187 <expVA+0x67>
movsd  -0x10(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    112d <expVA+0xd>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expVA>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,(%rsp)
mov    0x2eb7(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
ucomisd 0xead(%rip),%xmm0
jne    115f <expVA+0x3f>
jnp    1140 <expVA+0x20>
ucomisd 0xe99(%rip),%xmm0
jne    116b <expVA+0x4b>
jnp    1140 <expVA+0x20>
movaps (%rsp),%xmm1
xorps  0xe9a(%rip),%xmm1
movaps %xmm1,(%rsp)
call   1030 <log@plt>
mulsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define double @expVA(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
br label %4
4: ; preds = %15, %1
%5 = call i64 (...) @rand()
%6 = sitofp i64 %5 to double
%7 = load double, double* @RAND_MAX
%8 = fdiv double %6, %7
store double %8, double* %3
br label %9
9: ; preds = %4
%10 = load double, double* %3
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load double, double* %3
%14 = fcmp oeq double %13, 1.000000e+00
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %4, label %17
17: ; preds = %15
%18 = load double, double* %2
%19 = fneg double %18
%20 = load double, double* %3
%21 = call double @log(double %20)
%22 = fmul double %19, %21
ret double %22
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define double @expVA(double %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call i64 (...) @rand()
%4 = sitofp i64 %3 to double
%5 = load double, double* @RAND_MAX
%6 = fdiv double %4, %5
%7 = fcmp oeq double %6, 0.000000e+00
%8 = fcmp oeq double %6, 1.000000e+00
%9 = or i1 %7, %8
br i1 %9, label %2, label %10
10: ; preds = %2
%11 = fneg double %0
%12 = tail call double @log(double %6)
%13 = fmul double %12, %11
ret double %13
}