// File: /workspace/github_c_makefile_star2_O0/ranbenbasat[P]RHHH/prng.c
// Function: ran2
long ran2(prng_type * prng) {

  // A Random Number Generator that picks a uniform random number
  // from the range of long integers.
  // From Numerical Recipes, page 280
  // Should be called with a NEGATIVE value of idum to initialize
  // subsequent calls should not alter idum
  // This is a hacked version of the above procedure, so proceed with
  // caution.

  int j;
  long k;

  if (prng->intidum <= 0 || !prng->iy) {
    if (-(prng->intidum) < 1) prng->intidum=1;
    else prng->intidum = -(prng->intidum);
    for (j=NTAB+7;j>=0;j--) {
      k=(prng->intidum)/IQ;
      prng->intidum=IA*(prng->intidum-k*IQ)-IR*k;
      if (prng->intidum < 0) prng->intidum+=IM;
      if (j<NTAB) prng->iv[j]=prng->intidum;
    }
    prng->iy=prng->iv[0];
  }
  k = (prng->intidum)/IQ;
  prng->intidum=IA*(prng->intidum-k*IQ)-IR*k;
  if (prng->intidum<0) prng->intidum += IM;
  j = prng->iy/NDIV;
  prng->iy=prng->iv[j];
  prng->iv[j]=prng->intidum;
  return prng->iy;
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq -0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jle 0x3ab1
movq -0x8(%rsp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x3ba4
movq -0x8(%rsp), %rcx
xorl %eax, %eax
subq 0x10(%rcx), %rax
cmpq $0x1, %rax
jge 0x3ad1
movq -0x8(%rsp), %rax
movq $0x1, 0x10(%rax)
jmp 0x3ae5
movq -0x8(%rsp), %rax
xorl %ecx, %ecx
subq 0x10(%rax), %rcx
movq -0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movl $0x27, -0xc(%rsp)
cmpl $0x0, -0xc(%rsp)
jl 0x3b92
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl $0x1f31d, %ecx          # imm = 0x1F31D
cqto
idivq %rcx
movq %rax, -0x18(%rsp)
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rax
imulq $0x1f31d, -0x18(%rsp), %rcx # imm = 0x1F31D
subq %rcx, %rax
imulq $0x41a7, %rax, %rcx     # imm = 0x41A7
imulq $0xb14, -0x18(%rsp), %rax # imm = 0xB14
subq %rax, %rcx
movq -0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jge 0x3b61
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq %rcx, 0x10(%rax)
cmpl $0x20, -0xc(%rsp)
jge 0x3b80
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rdx
movq -0x8(%rsp), %rax
movslq -0xc(%rsp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
jmp 0x3b82
movl -0xc(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rsp)
jmp 0x3aed
movq -0x8(%rsp), %rax
movq 0x20(%rax), %rcx
movq -0x8(%rsp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl $0x1f31d, %ecx          # imm = 0x1F31D
cqto
idivq %rcx
movq %rax, -0x18(%rsp)
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rax
imulq $0x1f31d, -0x18(%rsp), %rcx # imm = 0x1F31D
subq %rcx, %rax
imulq $0x41a7, %rax, %rcx     # imm = 0x41A7
imulq $0xb14, -0x18(%rsp), %rax # imm = 0xB14
subq %rax, %rcx
movq -0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jge 0x3c0d
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq %rcx, 0x10(%rax)
movq -0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x4000000, %ecx        # imm = 0x4000000
cqto
idivq %rcx
movl %eax, -0xc(%rsp)
movq -0x8(%rsp), %rax
movslq -0xc(%rsp), %rcx
movq 0x20(%rax,%rcx,8), %rcx
movq -0x8(%rsp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rsp), %rax
movq 0x10(%rax), %rdx
movq -0x8(%rsp), %rax
movslq -0xc(%rsp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movq -0x8(%rsp), %rax
movq 0x18(%rax), %rax
retq
nop