// File: chfeder[P]turbulence_generator/./TurbGen.h
// Function: TurbGen::ran2(int*)
double ran2(int * idum) {
        // ******************************************************
        // Long period (> 2 x 10^18) random number generator of L'Ecuyer
        // with Bays-Durham shuffle and added safeguards.
        // Returns a uniform random deviate between 0.0 and 1.0 (exclusive of the endpoint values).
        // Call with idum a negative integer to initialize; thereafter,
        // do not alter idum between successive deviates in a sequence.
        // RNMX should approximate the largest floating value that is less than 1.
        // ******************************************************
        static const int IM1=2147483563, IM2=2147483399, IMM1=IM1-1, IA1=40014, IA2=40692, IQ1=53668,
                        IQ2=52774, IR1=12211, IR2=3791, NTAB=32, NDIV=1+IMM1/NTAB;
        static const double AM=1.0/IM1, RNMX=1.0-1.2e-7;
        static int idum2 = 123456789;
        static int iy = 0;
        static int iv[NTAB];
        int j, k;
        if (*idum <= 0) {
            *idum = std::max(-*idum, 1);
            idum2 = *idum;
            for (j = NTAB+7; j >= 0; j--) {
                k = *idum/IQ1;
                *idum = IA1*(*idum-k*IQ1)-k*IR1;
                if (*idum < 0) *idum += IM1;
                if (j < NTAB) iv[j] = *idum;
            }
            iy = iv[0];
        }
        k = *idum/IQ1;
        *idum = IA1*(*idum-k*IQ1)-k*IR1;
        if (*idum < 0) *idum += IM1;
        k = idum2/IQ2;
        idum2 = IA2*(idum2-k*IQ2)-k*IR2;
        if (idum2 < 0) idum2 += IM2;
        j = iy/NDIV;
        iy = iv[j]-idum2;
        iv[j] = *idum;
        if (iy < 1) iy += IMM1;
        double ret = std::min(AM*iy, RNMX);
        return ret;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jg 0x10e6c
movq -0x10(%rbp), %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
leaq -0x1c(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x10fa0
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, 0xa538(%rip)      # 0x1b318
movl $0x27, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x10e60
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl $0xd1a4, %ecx           # imm = 0xD1A4
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
imull $0xd1a4, -0x18(%rbp), %ecx # imm = 0xD1A4
subl %ecx, %eax
imull $0x9c4e, %eax, %ecx     # imm = 0x9C4E
imull $0x2fb3, -0x18(%rbp), %eax # imm = 0x2FB3
subl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jge 0x10e39
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x7fffffab, %ecx       # imm = 0x7FFFFFAB
movl %ecx, (%rax)
cmpl $0x20, -0x14(%rbp)
jge 0x10e53
movq -0x10(%rbp), %rax
movl (%rax), %edx
movslq -0x14(%rbp), %rcx
leaq 0xa4f0(%rip), %rax      # 0x1b340
movl %edx, (%rax,%rcx,4)
jmp 0x10e55
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x10de7
movl 0xa4da(%rip), %eax      # 0x1b340
movl %eax, 0xa4c8(%rip)      # 0x1b334
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl $0xd1a4, %ecx           # imm = 0xD1A4
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
imull $0xd1a4, -0x18(%rbp), %ecx # imm = 0xD1A4
subl %ecx, %eax
imull $0x9c4e, %eax, %ecx     # imm = 0x9C4E
imull $0x2fb3, -0x18(%rbp), %eax # imm = 0x2FB3
subl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jge 0x10eb8
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x7fffffab, %ecx       # imm = 0x7FFFFFAB
movl %ecx, (%rax)
movl 0xa45a(%rip), %eax      # 0x1b318
movl $0xce26, %ecx           # imm = 0xCE26
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movl 0xa449(%rip), %eax      # 0x1b318
imull $0xce26, -0x18(%rbp), %ecx # imm = 0xCE26
subl %ecx, %eax
imull $0x9ef4, %eax, %eax     # imm = 0x9EF4
imull $0xecf, -0x18(%rbp), %ecx # imm = 0xECF
subl %ecx, %eax
movl %eax, 0xa42b(%rip)      # 0x1b318
cmpl $0x0, 0xa424(%rip)      # 0x1b318
jge 0x10f07
movl 0xa41c(%rip), %eax      # 0x1b318
addl $0x7fffff07, %eax       # imm = 0x7FFFFF07
movl %eax, 0xa411(%rip)      # 0x1b318
movl 0xa427(%rip), %eax      # 0x1b334
movl $0x3fffffe, %ecx        # imm = 0x3FFFFFE
cltd
idivl %ecx
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0xa41d(%rip), %rax      # 0x1b340
movl (%rax,%rcx,4), %eax
subl 0xa3ec(%rip), %eax      # 0x1b318
movl %eax, 0xa402(%rip)      # 0x1b334
movq -0x10(%rbp), %rax
movl (%rax), %edx
movslq -0x14(%rbp), %rcx
leaq 0xa3fd(%rip), %rax      # 0x1b340
movl %edx, (%rax,%rcx,4)
cmpl $0x1, 0xa3e7(%rip)      # 0x1b334
jge 0x10f60
movl 0xa3df(%rip), %eax      # 0x1b334
addl $0x7fffffaa, %eax       # imm = 0x7FFFFFAA
movl %eax, 0xa3d4(%rip)      # 0x1b334
cvtsi2sdl 0xa3cc(%rip), %xmm1 # 0x1b334
movsd 0x4138(%rip), %xmm0     # 0x150a8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
leaq 0x53ec(%rip), %rsi      # 0x16370
callq 0x11290
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)