#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double ran1(int *idum) {
  static long ix1, ix2, ix3;
  static double r[98];
  double temp;
  static int iff = 0;
  int j;
  if (*idum < 0 || iff == 0) {
    iff = 1;
    ix1 = (54773 - (*idum)) % 259200;
    ix1 = (7141 * ix1 + 54773) % 259200;
    ix2 = ix1 % 134456;
    ix1 = (7141 * ix1 + 54773) % 259200;
    ix3 = ix1 % 243000;
    for (j = 1; j <= 97; j++) {
      ix1 = (7141 * ix1 + 54773) % 259200;
      ix2 = (8121 * ix2 + 28411) % 134456;
      r[j] = (ix1 + ix2 * (1.0 / 134456)) * (1.0 / 259200);
    }
    *idum = 1;
  }
  ix1 = (7141 * ix1 + 54773) % 259200;
  ix2 = (8121 * ix2 + 28411) % 134456;
  ix3 = (4561 * ix3 + 51349) % 243000;
  j = 1 + ((97 * ix3) / 243000);
  if (j > 97 || j < 1)
    fprintf(stderr, "RAN1: This cannot happen.\n");
  temp = r[j];
  r[j] = (ix1 + ix2 * (1.0 / 134456)) * (1.0 / 259200);
  return temp;
}


x86 assembly (clang, -O0):
<ran1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jl     1136 <ran1+0x26>
cmpl   $0x0,0x3240(%rip)
jne    127c <ran1+0x16c>
movl   $0x1,0x3230(%rip)
mov    -0x8(%rbp),%rcx
mov    $0xd5f5,%eax
sub    (%rcx),%eax
mov    $0x3f480,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,0x2ee3(%rip)
imul   $0x1be5,0x2ed8(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2ec1(%rip)
mov    0x2eba(%rip),%rax
mov    $0x20d38,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2eb1(%rip)
imul   $0x1be5,0x2e9e(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e87(%rip)
mov    0x2e80(%rip),%rax
mov    $0x3b538,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e7f(%rip)
movl   $0x1,-0x14(%rbp)
cmpl   $0x61,-0x14(%rbp)
jg     1272 <ran1+0x162>
imul   $0x1be5,0x2e53(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e3c(%rip)
imul   $0x1fb9,0x2e39(%rip),%rax
add    $0x6efb,%rax
mov    $0x20d38,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e22(%rip)
cvtsi2sdq 0x2e11(%rip),%xmm1
cvtsi2sdq 0x2e10(%rip),%xmm0
movsd  0xdc8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdb0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rcx
lea    0x2e01(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d8 <ran1+0xc8>
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
imul   $0x1be5,0x2db9(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2da2(%rip)
imul   $0x1fb9,0x2d9f(%rip),%rax
add    $0x6efb,%rax
mov    $0x20d38,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2d88(%rip)
imul   $0x11d1,0x2d85(%rip),%rax
add    $0xc895,%rax
mov    $0x3b538,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2d6e(%rip)
imul   $0x61,0x2d66(%rip),%rax
61
mov    $0x3b538,%ecx
cqto
idiv   %rcx
add    $0x1,%rax
mov    %eax,-0x14(%rbp)
cmpl   $0x61,-0x14(%rbp)
jg     130f <ran1+0x1ff>
cmpl   $0x1,-0x14(%rbp)
jge    1324 <ran1+0x214>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xcf1(%rip),%rsi
call   1030 <fprintf@plt>
movslq -0x14(%rbp),%rcx
lea    0x2d31(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdq 0x2cfe(%rip),%xmm1
cvtsi2sdq 0x2cfd(%rip),%xmm0
movsd  0xcb5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xc9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rcx
lea    0x2cee(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ran1>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%eax
movabs $0x81742e044c5b8725,%r9
2e 74 81
movabs $0x1f31d2b36647fc39,%r8
d2 31 1f
test   %eax,%eax
js     1151 <ran1+0x41>
testb  $0x1,0x323b(%rip)
je     1151 <ran1+0x41>
mov    0x2f02(%rip),%rsi
mov    0x2f03(%rip),%rcx
mov    0x2f04(%rip),%r10
jmp    12e8 <ran1+0x1d8>
movb   $0x1,0x3218(%rip)
mov    $0xd5f5,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff81742e05,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x11,%ecx
add    %edx,%ecx
imul   $0x3f480,%ecx,%ecx
sub    %ecx,%eax
imul   $0x1be5,%eax,%eax
mov    %eax,%ecx
add    $0xd5f5,%ecx
movslq %ecx,%rcx
imul   $0xffffffff81742e05,%rcx,%rdx
shr    $0x20,%rdx
add    %edx,%eax
add    $0xd5f5,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x11,%eax
add    %edx,%eax
imul   $0x3f480,%eax,%eax
sub    %eax,%ecx
movslq %ecx,%rax
imul   $0x3e63a567,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xf,%ecx
add    %edx,%ecx
imul   $0x20d38,%ecx,%ecx
imul   $0x1be5,%eax,%edx
sub    %ecx,%eax
movslq %eax,%rcx
mov    %edx,%eax
add    $0xd5f5,%eax
cltq
imul   $0xffffffff81742e05,%rax,%rsi
shr    $0x20,%rsi
add    %esi,%edx
add    $0xd5f5,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x11,%edx
add    %esi,%edx
imul   $0x3f480,%edx,%edx
sub    %edx,%eax
movslq %eax,%rsi
imul   $0x2285619b,%rsi,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x2f,%rax
add    %edx,%eax
imul   $0x3b538,%eax,%eax
mov    %esi,%edx
sub    %eax,%edx
movslq %edx,%r10
mov    $0x1,%r11d
movsd  0xdbf(%rip),%xmm0
movsd  0xdbf(%rip),%xmm1
lea    0x2e10(%rip),%r14
imul   $0x1be5,%rsi,%rbx
lea    0xd5f5(%rbx),%rsi
mov    %rsi,%rax
imul   %r9
lea    (%rdx,%rbx,1),%rax
add    $0xd5f5,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x11,%rax
add    %rdx,%rax
imul   $0x3f480,%rax,%rbx
imul   $0x1fb9,%rcx,%rcx
add    $0x6efb,%rcx
mov    %rcx,%rax
imul   %r8
sub    %rbx,%rsi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xe,%rdx
add    %rax,%rdx
imul   $0x20d38,%rdx,%rax
sub    %rax,%rcx
xorps  %xmm2,%xmm2
cvtsi2sd %rsi,%xmm2
xorps  %xmm3,%xmm3
cvtsi2sd %rcx,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,(%r14,%r11,8)
add    $0x1,%r11
cmp    $0x62,%r11
jne    1250 <ran1+0x140>
movl   $0x1,(%rdi)
imul   $0x1be5,%rsi,%rdi
lea    0xd5f5(%rdi),%rsi
mov    %rsi,%rax
imul   %r9
lea    (%rdx,%rdi,1),%rax
add    $0xd5f5,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x11,%rax
add    %rdx,%rax
imul   $0x3f480,%rax,%rax
sub    %rax,%rsi
mov    %rsi,0x2d1b(%rip)
imul   $0x1fb9,%rcx,%rcx
add    $0x6efb,%rcx
mov    %rcx,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xe,%rdx
add    %rax,%rdx
imul   $0x20d38,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,0x2cf0(%rip)
imul   $0x11d1,%r10,%rdi
add    $0xc895,%rdi
movabs $0x2285619abf07573d,%rdx
61 85 22
mov    %rdi,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xf,%rdx
add    %rax,%rdx
imul   $0x3b538,%rdx,%rax
sub    %rax,%rdi
mov    %rdi,0x2cbb(%rip)
imul   $0x61,%edi,%eax
cltq
imul   $0x2285619b,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x2f,%rbx
add    %eax,%ebx
cmp    $0x7fffffff,%ebx
jb     13d9 <ran1+0x2c9>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
lea    0xc4a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2c6e(%rip),%rsi
mov    0x2c6f(%rip),%rcx
movslq %ebx,%rax
lea    0x2c7d(%rip),%rdx
movsd  0x8(%rdx,%rax,8),%xmm0
cvtsi2sd %rsi,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
mulsd  0xc02(%rip),%xmm2
addsd  %xmm1,%xmm2
mulsd  0xbfe(%rip),%xmm2
movsd  %xmm2,0x8(%rdx,%rax,8)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ran1.ix1 = internal global i64 0
@ran1.ix2 = internal global i64 0
@ran1.ix3 = internal global i64 0
@ran1.r = internal global [98 x double] zeroinitializer
@ran1.iff = internal global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"RAN1: This cannot happen.\0A\00"
define double @ran1(i32* %0) {
%2 = alloca i32*
%3 = alloca double
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = load i32, i32* %5
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @ran1.iff
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %55
11: ; preds = %8, %1
store i32 1, i32* @ran1.iff
%12 = load i32*, i32** %2
%13 = load i32, i32* %12
%14 = sub nsw i32 54773, %13
%15 = srem i32 %14, 259200
%16 = sext i32 %15 to i64
store i64 %16, i64* @ran1.ix1
%17 = load i64, i64* @ran1.ix1
%18 = mul nsw i64 7141, %17
%19 = add nsw i64 %18, 54773
%20 = srem i64 %19, 259200
store i64 %20, i64* @ran1.ix1
%21 = load i64, i64* @ran1.ix1
%22 = srem i64 %21, 134456
store i64 %22, i64* @ran1.ix2
%23 = load i64, i64* @ran1.ix1
%24 = mul nsw i64 7141, %23
%25 = add nsw i64 %24, 54773
%26 = srem i64 %25, 259200
store i64 %26, i64* @ran1.ix1
%27 = load i64, i64* @ran1.ix1
%28 = srem i64 %27, 243000
store i64 %28, i64* @ran1.ix3
store i32 1, i32* %4
br label %29
29: ; preds = %50, %11
%30 = load i32, i32* %4
%31 = icmp sle i32 %30, 97
br i1 %31, label %32, label %53
32: ; preds = %29
%33 = load i64, i64* @ran1.ix1
%34 = mul nsw i64 7141, %33
%35 = add nsw i64 %34, 54773
%36 = srem i64 %35, 259200
store i64 %36, i64* @ran1.ix1
%37 = load i64, i64* @ran1.ix2
%38 = mul nsw i64 8121, %37
%39 = add nsw i64 %38, 28411
%40 = srem i64 %39, 134456
store i64 %40, i64* @ran1.ix2
%41 = load i64, i64* @ran1.ix1
%42 = sitofp i64 %41 to double
%43 = load i64, i64* @ran1.ix2
%44 = sitofp i64 %43 to double
%45 = call double @llvm.fmuladd.f64(double %44, double 0x3EDF31D2B36647FC, double %42)
%46 = fmul double %45, 0x3ED02E85C0898B71
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %48
store double %46, double* %49
br label %50
50: ; preds = %32
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %29
53: ; preds = %29
%54 = load i32*, i32** %2
store i32 1, i32* %54
br label %55
55: ; preds = %53, %8
%56 = load i64, i64* @ran1.ix1
%57 = mul nsw i64 7141, %56
%58 = add nsw i64 %57, 54773
%59 = srem i64 %58, 259200
store i64 %59, i64* @ran1.ix1
%60 = load i64, i64* @ran1.ix2
%61 = mul nsw i64 8121, %60
%62 = add nsw i64 %61, 28411
%63 = srem i64 %62, 134456
store i64 %63, i64* @ran1.ix2
%64 = load i64, i64* @ran1.ix3
%65 = mul nsw i64 4561, %64
%66 = add nsw i64 %65, 51349
%67 = srem i64 %66, 243000
store i64 %67, i64* @ran1.ix3
%68 = load i64, i64* @ran1.ix3
%69 = mul nsw i64 97, %68
%70 = sdiv i64 %69, 243000
%71 = add nsw i64 1, %70
%72 = trunc i64 %71 to i32
store i32 %72, i32* %4
%73 = load i32, i32* %4
%74 = icmp sgt i32 %73, 97
br i1 %74, label %78, label %75
75: ; preds = %55
%76 = load i32, i32* %4
%77 = icmp slt i32 %76, 1
br i1 %77, label %78, label %81
78: ; preds = %75, %55
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %81
81: ; preds = %78, %75
%82 = load i32, i32* %4
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %83
%85 = load double, double* %84
store double %85, double* %3
%86 = load i64, i64* @ran1.ix1
%87 = sitofp i64 %86 to double
%88 = load i64, i64* @ran1.ix2
%89 = sitofp i64 %88 to double
%90 = call double @llvm.fmuladd.f64(double %89, double 0x3EDF31D2B36647FC, double %87)
%91 = fmul double %90, 0x3ED02E85C0898B71
%92 = load i32, i32* %4
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %93
store double %91, double* %94
%95 = load double, double* %3
ret double %95
}

LLVM IR (-O2):
@ran1.ix1 = internal unnamed_addr global i64 0
@ran1.ix2 = internal unnamed_addr global i64 0
@ran1.ix3 = internal unnamed_addr global i64 0
@ran1.r = internal unnamed_addr global [98 x double] zeroinitializer
@ran1.iff = internal unnamed_addr global i1 false
@stderr = global i32 0
@.str = [27 x i8] c"RAN1: This cannot happen.\0A\00"
define double @ran1(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp slt i32 %2, 0
%4 = load i1, i1* @ran1.iff
%5 = xor i1 %4, true
%6 = select i1 %3, i1 true, i1 %5
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i64, i64* @ran1.ix1
%9 = load i64, i64* @ran1.ix2
%10 = load i64, i64* @ran1.ix3
br label %43
11: ; preds = %1
store i1 true, i1* @ran1.iff
%12 = sub nsw i32 54773, %2
%13 = srem i32 %12, 259200
%14 = mul nsw i32 %13, 7141
%15 = add nsw i32 %14, 54773
%16 = srem i32 %15, 259200
%17 = srem i32 %16, 134456
%18 = sext i32 %17 to i64
%19 = mul nsw i32 %16, 7141
%20 = add nsw i32 %19, 54773
%21 = srem i32 %20, 259200
%22 = sext i32 %21 to i64
%23 = srem i32 %21, 243000
%24 = sext i32 %23 to i64
br label %25
25: ; preds = %11, %25
%26 = phi i64 [ 1, %11 ], [ %40, %25 ]
%27 = phi i64 [ %22, %11 ], [ %31, %25 ]
%28 = phi i64 [ %18, %11 ], [ %34, %25 ]
%29 = mul nsw i64 %27, 7141
%30 = add nsw i64 %29, 54773
%31 = srem i64 %30, 259200
%32 = mul nsw i64 %28, 8121
%33 = add nsw i64 %32, 28411
%34 = srem i64 %33, 134456
%35 = sitofp i64 %31 to double
%36 = sitofp i64 %34 to double
%37 = tail call double @llvm.fmuladd.f64(double %36, double 0x3EDF31D2B36647FC, double %35)
%38 = fmul double %37, 0x3ED02E85C0898B71
%39 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %26
store double %38, double* %39
%40 = add nuw nsw i64 %26, 1
%41 = icmp eq i64 %40, 98
br i1 %41, label %42, label %25
42: ; preds = %25
store i32 1, i32* %0
br label %43
43: ; preds = %7, %42
%44 = phi i64 [ %10, %7 ], [ %24, %42 ]
%45 = phi i64 [ %9, %7 ], [ %34, %42 ]
%46 = phi i64 [ %8, %7 ], [ %31, %42 ]
%47 = mul nsw i64 %46, 7141
%48 = add nsw i64 %47, 54773
%49 = srem i64 %48, 259200
store i64 %49, i64* @ran1.ix1
%50 = mul nsw i64 %45, 8121
%51 = add nsw i64 %50, 28411
%52 = srem i64 %51, 134456
store i64 %52, i64* @ran1.ix2
%53 = mul nsw i64 %44, 4561
%54 = add nsw i64 %53, 51349
%55 = srem i64 %54, 243000
store i64 %55, i64* @ran1.ix3
%56 = trunc i64 %55 to i32
%57 = mul nsw i32 %56, 97
%58 = sdiv i32 %57, 243000
%59 = icmp ugt i32 %58, 2147483646
br i1 %59, label %60, label %65
60: ; preds = %43
%61 = load i32, i32* @stderr
%62 = tail call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%63 = load i64, i64* @ran1.ix1
%64 = load i64, i64* @ran1.ix2
br label %65
65: ; preds = %43, %60
%66 = phi i64 [ %52, %43 ], [ %64, %60 ]
%67 = phi i64 [ %49, %43 ], [ %63, %60 ]
%68 = add nsw i32 %58, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %69
%71 = load double, double* %70
%72 = sitofp i64 %67 to double
%73 = sitofp i64 %66 to double
%74 = tail call double @llvm.fmuladd.f64(double %73, double 0x3EDF31D2B36647FC, double %72)
%75 = fmul double %74, 0x3ED02E85C0898B71
store double %75, double* %70
ret double %71
}