#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 */
int /*<<< orphan*/ DRanU();
double log(int /*<<< orphan*/);
double DRanNormalTail(double dMin, int iNegative) {
  double x, y;
  do {
    x = log(DRanU()) / dMin;
    y = log(DRanU());
  } while (-2 * y < x * x);
  return iNegative ? x - dMin : dMin - x;
}


x86 assembly (clang, -O0):
<DRanNormalTail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    $0x0,%al
call   1030 <DRanU@plt>
mov    %eax,%edi
call   1040 <log@plt>
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <DRanU@plt>
mov    %eax,%edi
call   1040 <log@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9d(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     1130 <DRanNormalTail+0x10>
cmpl   $0x0,-0xc(%rbp)
je     119a <DRanNormalTail+0x7a>
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11a9 <DRanNormalTail+0x89>
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DRanNormalTail>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movsd  %xmm0,(%rsp)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <DRanU@plt>
mov    %eax,%edi
call   1040 <log@plt>
divsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <DRanU@plt>
mov    %eax,%edi
call   1040 <log@plt>
movsd  0x8(%rsp),%xmm2
mulsd  0xe9b(%rip),%xmm0
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
ja     1130 <DRanNormalTail+0x10>
movsd  (%rsp),%xmm0
test   %ebx,%ebx
je     1186 <DRanNormalTail+0x66>
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
jmp    118a <DRanNormalTail+0x6a>
subsd  %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @DRanNormalTail(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
br label %7
7: ; preds = %14, %2
%8 = call i32 (...) @DRanU()
%9 = call double @log(i32 %8)
%10 = load double, double* %3
%11 = fdiv double %9, %10
store double %11, double* %5
%12 = call i32 (...) @DRanU()
%13 = call double @log(i32 %12)
store double %13, double* %6
br label %14
14: ; preds = %7
%15 = load double, double* %6
%16 = fmul double -2.000000e+00, %15
%17 = load double, double* %5
%18 = load double, double* %5
%19 = fmul double %17, %18
%20 = fcmp olt double %16, %19
br i1 %20, label %7, label %21
21: ; preds = %14
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load double, double* %5
%26 = load double, double* %3
%27 = fsub double %25, %26
br label %32
28: ; preds = %21
%29 = load double, double* %3
%30 = load double, double* %5
%31 = fsub double %29, %30
br label %32
32: ; preds = %28, %24
%33 = phi double [ %27, %24 ], [ %31, %28 ]
ret double %33
}

LLVM IR (-O2):
define double @DRanNormalTail(double %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 (...) @DRanU()
%5 = tail call double @log(i32 %4)
%6 = fdiv double %5, %0
%7 = tail call i32 (...) @DRanU()
%8 = tail call double @log(i32 %7)
%9 = fmul double %8, -2.000000e+00
%10 = fmul double %6, %6
%11 = fcmp olt double %9, %10
br i1 %11, label %3, label %12
12: ; preds = %3
%13 = icmp eq i32 %1, 0
%14 = fsub double %6, %0
%15 = fsub double %0, %6
%16 = select i1 %13, double %15, double %14
ret double %16
}