// File: DavidLBruce[P]sim3dof/build/../src/MathUtils.cpp
// Function: ran1(long*)
double ran1(long *idum)
{
  int j;
  long k;
  static long iy = 0;
  static long iv[NTAB];
  double temp;

  if (*idum <= 0 || !iy) {
    if (-(*idum) < 1)
      *idum = 1;
    else *idum
      = -(*idum);
    for (j = NTAB + 7; j >= 0; j--) {
      k = (*idum) / IQ;
      *idum = IA * (*idum-k * IQ) - IR * k;
      if (*idum<0)
        *idum += IM;
      if (j < NTAB)
       iv[j] = *idum;
    }
    iy = iv[0];
  }

  k = (*idum) / IQ;
  *idum = IA * (*idum - k * IQ) - IR * k;
  if (*idum <= 0) *idum += IM;
  j = iy / NDIV;
  iy = iv[j];
  iv[j] = *idum;
  if ( (temp = AM * iy) > RNMX )
    return RNMX;
  else
    return temp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jle 0xca30
cmpq $0x0, 0x22836(%rip)     # 0x2f260
jne 0xcb02
movq -0x10(%rbp), %rcx
xorl %eax, %eax
subq (%rcx), %rax
cmpq $0x1, %rax
jge 0xca4c
movq -0x10(%rbp), %rax
movq $0x1, (%rax)
jmp 0xca5c
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
subq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x27, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xcaf4
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x1f31d, %ecx          # imm = 0x1F31D
cqto
idivq %rcx
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1f31d, -0x20(%rbp), %rcx # imm = 0x1F31D
subq %rcx, %rax
imulq $0x41a7, %rax, %rcx     # imm = 0x41A7
imulq $0xb14, -0x20(%rbp), %rax # imm = 0xB14
subq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jge 0xcac8
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq %rcx, (%rax)
cmpl $0x20, -0x14(%rbp)
jge 0xcae4
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movslq -0x14(%rbp), %rcx
leaq 0x22790(%rip), %rax     # 0x2f270
movq %rdx, (%rax,%rcx,8)
jmp 0xcae6
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xca63
movq 0x22775(%rip), %rax     # 0x2f270
movq %rax, 0x2275e(%rip)     # 0x2f260
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x1f31d, %ecx          # imm = 0x1F31D
cqto
idivq %rcx
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1f31d, -0x20(%rbp), %rcx # imm = 0x1F31D
subq %rcx, %rax
imulq $0x41a7, %rax, %rcx     # imm = 0x41A7
imulq $0xb14, -0x20(%rbp), %rax # imm = 0xB14
subq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jg 0xcb5d
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq %rcx, (%rax)
movq 0x226fc(%rip), %rax     # 0x2f260
movl $0x4000000, %ecx        # imm = 0x4000000
cqto
idivq %rcx
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x226f4(%rip), %rax     # 0x2f270
movq (%rax,%rcx,8), %rax
movq %rax, 0x226d9(%rip)     # 0x2f260
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movslq -0x14(%rbp), %rcx
leaq 0x226d7(%rip), %rax     # 0x2f270
movq %rdx, (%rax,%rcx,8)
cvtsi2sdq 0x226ba(%rip), %xmm1 # 0x2f260
movsd 0x17a3a(%rip), %xmm0    # 0x245e8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd 0x17a21(%rip), %xmm1    # 0x245e0
ucomisd %xmm1, %xmm0
jbe 0xcbd4
movsd 0x17a13(%rip), %xmm0    # 0x245e0
movsd %xmm0, -0x8(%rbp)
jmp 0xcbde
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
popq %rbp
retq
nopw %cs:(%rax,%rax)