#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 drand48();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand48(int);
double wranc_(int *iseed) {
  static int first = 1;
  int ntries;
  double rand_val;
  if (first) {
    srand48(*iseed);
    first = 0;
  }
  for (ntries = 0; ntries < 10; ++ntries) {
    rand_val = drand48();
    if (rand_val >= 1.0e-20)
      break;
  }
  if (ntries == 10) {
    printf("ERROR:  Read past end of RANFILE. Aborting.\n");
    exit(1);
  }
  return rand_val;
}


x86 assembly (clang, -O0):
<wranc_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2eed(%rip)
je     116e <wranc_+0x2e>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <srand48@plt>
movl   $0x0,0x2ed2(%rip)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11ba <wranc_+0x7a>
mov    $0x0,%al
call   1060 <drand48@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11a7 <wranc_+0x67>
jmp    11ba <wranc_+0x7a>
jmp    11ac <wranc_+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1175 <wranc_+0x35>
cmpl   $0xa,-0xc(%rbp)
jne    11da <wranc_+0x9a>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wranc_>:
push   %rax
cmpb   $0x0,0x2efc(%rip)
jne    1158 <wranc_+0x18>
mov    (%rdi),%edi
call   1040 <srand48@plt>
movb   $0x1,0x2eec(%rip)
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe99(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe84(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe6f(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe5e(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe4d(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe3c(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe2b(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe1a(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xe09(%rip),%xmm0
jae    120a <wranc_+0xca>
xor    %eax,%eax
call   1060 <drand48@plt>
ucomisd 0xdf8(%rip),%xmm0
jb     120c <wranc_+0xcc>
pop    %rax
ret
lea    0xdf5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@wranc_.first = internal global i32 1
@.str = [45 x i8] c"ERROR: Read past end of RANFILE. Aborting.\0A\00"
define double @wranc_(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca double
store i32* %0, i32** %2
%5 = load i32, i32* @wranc_.first
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = call i32 @srand48(i32 %9)
store i32 0, i32* @wranc_.first
br label %11
11: ; preds = %7, %1
store i32 0, i32* %3
br label %12
12: ; preds = %21, %11
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = call double (...) @drand48()
store double %16, double* %4
%17 = load double, double* %4
%18 = fcmp oge double %17, 0x3BC79CA10C924223
br i1 %18, label %19, label %20
19: ; preds = %15
br label %24
20: ; preds = %15
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %12
24: ; preds = %19, %12
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 10
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %24
%31 = load double, double* %4
ret double %31
}

LLVM IR (-O2):
@wranc_.first = internal unnamed_addr global i1 false
@str = [44 x i8] c"ERROR: Read past end of RANFILE. Aborting.\00"
define double @wranc_(i32* nocapture %0) {
%2 = load i1, i1* @wranc_.first
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i32, i32* %0
%5 = tail call i32 @srand48(i32 %4)
store i1 true, i1* @wranc_.first
br label %6
6: ; preds = %3, %1
%7 = tail call double (...) @drand48()
%8 = fcmp ult double %7, 0x3BC79CA10C924223
br i1 %8, label %9, label %39
9: ; preds = %6
%10 = tail call double (...) @drand48()
%11 = fcmp ult double %10, 0x3BC79CA10C924223
br i1 %11, label %12, label %39
12: ; preds = %9
%13 = tail call double (...) @drand48()
%14 = fcmp ult double %13, 0x3BC79CA10C924223
br i1 %14, label %15, label %39
15: ; preds = %12
%16 = tail call double (...) @drand48()
%17 = fcmp ult double %16, 0x3BC79CA10C924223
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = tail call double (...) @drand48()
%20 = fcmp ult double %19, 0x3BC79CA10C924223
br i1 %20, label %21, label %39
21: ; preds = %18
%22 = tail call double (...) @drand48()
%23 = fcmp ult double %22, 0x3BC79CA10C924223
br i1 %23, label %24, label %39
24: ; preds = %21
%25 = tail call double (...) @drand48()
%26 = fcmp ult double %25, 0x3BC79CA10C924223
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = tail call double (...) @drand48()
%29 = fcmp ult double %28, 0x3BC79CA10C924223
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = tail call double (...) @drand48()
%32 = fcmp ult double %31, 0x3BC79CA10C924223
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = tail call double (...) @drand48()
%35 = fcmp ult double %34, 0x3BC79CA10C924223
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %6, %9, %12, %15, %18, %21, %24, %27, %30, %33
%40 = phi double [ %7, %6 ], [ %10, %9 ], [ %13, %12 ], [ %16, %15 ], [ %19, %18 ], [ %22, %21 ], [ %25, %24 ], [ %28, %27 ], [ %31, %30 ], [ %34, %33 ]
ret double %40
}