double ran1(idum)
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);
  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
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jl     1122 <ran1+0x22>
cmpl   $0x0,0x3244(%rip)
jne    1268 <ran1+0x168>
movl   $0x1,0x3234(%rip)
mov    -0x8(%rbp),%rcx
mov    $0xd5f5,%eax
sub    (%rcx),%eax
mov    $0x3f480,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,0x2ee7(%rip)
imul   $0x1be5,0x2edc(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2ec5(%rip)
mov    0x2ebe(%rip),%rax
mov    $0x20d38,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2eb5(%rip)
imul   $0x1be5,0x2ea2(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e8b(%rip)
mov    0x2e84(%rip),%rax
mov    $0x3b538,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e83(%rip)
movl   $0x1,-0x14(%rbp)
cmpl   $0x61,-0x14(%rbp)
jg     125e <ran1+0x15e>
imul   $0x1be5,0x2e57(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e40(%rip)
imul   $0x1fb9,0x2e3d(%rip),%rax
add    $0x6efb,%rax
mov    $0x20d38,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e26(%rip)
cvtsi2sdq 0x2e15(%rip),%xmm1
cvtsi2sdq 0x2e14(%rip),%xmm0
movsd  0xddc(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdc4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rcx
lea    0x2e05(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c4 <ran1+0xc4>
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
imul   $0x1be5,0x2dbd(%rip),%rax
add    $0xd5f5,%rax
mov    $0x3f480,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2da6(%rip)
imul   $0x1fb9,0x2da3(%rip),%rax
add    $0x6efb,%rax
mov    $0x20d38,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2d8c(%rip)
imul   $0x11d1,0x2d89(%rip),%rax
add    $0xc895,%rax
mov    $0x3b538,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2d72(%rip)
imul   $0x61,0x2d6a(%rip),%rax
61
mov    $0x3b538,%ecx
cqto
idiv   %rcx
add    $0x1,%rax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2d5e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdq 0x2d2b(%rip),%xmm1
cvtsi2sdq 0x2d2a(%rip),%xmm0
movsd  0xcf2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xcda(%rip),%xmm1
mulsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rcx
lea    0x2d1b(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ran1>:
push   %r14
push   %rbx
mov    (%rdi),%eax
movabs $0x81742e044c5b8725,%r9
2e 74 81
movabs $0x1f31d2b36647fc39,%r8
d2 31 1f
test   %eax,%eax
js     1140 <ran1+0x40>
testb  $0x1,0x323c(%rip)
je     1140 <ran1+0x40>
mov    0x2f03(%rip),%rsi
mov    0x2f04(%rip),%rcx
mov    0x2f05(%rip),%r10
jmp    12d8 <ran1+0x1d8>
movb   $0x1,0x3219(%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  0xdd0(%rip),%xmm0
movsd  0xdd0(%rip),%xmm1
lea    0x2e11(%rip),%r14
nop
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    1240 <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,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x2f,%rax
add    %edx,%eax
cltq
lea    0x2ca9(%rip),%rdx
movsd  0x8(%rdx,%rax,8),%xmm0
cvtsi2sd %rsi,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
mulsd  0xc3e(%rip),%xmm2
addsd  %xmm1,%xmm2
mulsd  0xc3a(%rip),%xmm2
movsd  %xmm2,0x8(%rdx,%rax,8)
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
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 = sext i32 %73 to i64
%75 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %74
%76 = load double, double* %75
store double %76, double* %3
%77 = load i64, i64* @ran1.ix1
%78 = sitofp i64 %77 to double
%79 = load i64, i64* @ran1.ix2
%80 = sitofp i64 %79 to double
%81 = call double @llvm.fmuladd.f64(double %80, double 0x3EDF31D2B36647FC, double %78)
%82 = fmul double %81, 0x3ED02E85C0898B71
%83 = load i32, i32* %4
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %84
store double %82, double* %85
%86 = load double, double* %3
ret double %86
}

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
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 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [98 x double], [98 x double]* @ran1.r, i64 0, i64 %60
%62 = load double, double* %61
%63 = sitofp i64 %49 to double
%64 = sitofp i64 %52 to double
%65 = tail call double @llvm.fmuladd.f64(double %64, double 0x3EDF31D2B36647FC, double %63)
%66 = fmul double %65, 0x3ED02E85C0898B71
store double %66, double* %61
ret double %62
}