#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 */
scalar_t__ Random(long *);
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double log(scalar_t__);
int /*<<< orphan*/ stderr;
double Expent(long *idum, double mean) {
  if (mean < 0) {
    fprintf(stderr,
            "Error in call to Expent(): passed a negative mean value\n");
    abort();
  }
  return (-mean * log(1 - Random(idum)));
}


x86 assembly (clang, -O0):
<Expent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117b <Expent+0x3b>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <Random@plt>
mov    $0x1,%edi
sub    %rax,%rdi
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Expent>:
sub    $0x18,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1177 <Expent+0x37>
xorpd  0xeaa(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <Random@plt>
mov    $0x1,%edi
sub    %rax,%rdi
call   1060 <log@plt>
mulsd  (%rsp),%xmm0
add    $0x18,%rsp
ret
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"Error in call to Expent(): passed a negative mean value\0A\00"
define double @Expent(i64* %0, double %1) {
%3 = alloca i64*
%4 = alloca double
store i64* %0, i64** %3
store double %1, double* %4
%5 = load double, double* %4
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %2
%12 = load double, double* %4
%13 = fneg double %12
%14 = load i64*, i64** %3
%15 = call i64 @Random(i64* %14)
%16 = sub nsw i64 1, %15
%17 = call double @log(i64 %16)
%18 = fmul double %13, %17
ret double %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"Error in call to Expent(): passed a negative mean value\0A\00"
define double @Expent(i64* %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @abort()
unreachable
8: ; preds = %2
%9 = fneg double %1
%10 = tail call i64 @Random(i64* %0)
%11 = sub nsw i64 1, %10
%12 = tail call double @log(i64 %11)
%13 = fmul double %12, %9
ret double %13
}