// File: /workspace/github_cpp_makefile_star2_O3/mouda[P]LTE_random_access-simulate/alglibinternal.cpp
// Function: alglib_impl::ftbase_ftbasegenerateplanrec(long, long, alglib_impl::ftplan*, long*, long*, long*, long*, long*, long, alglib_impl::ae_state*)
static void ftbase_ftbasegenerateplanrec(ae_int_t n,
     ae_int_t tasktype,
     ftplan* plan,
     ae_int_t* plansize,
     ae_int_t* precomputedsize,
     ae_int_t* planarraysize,
     ae_int_t* tmpmemsize,
     ae_int_t* stackmemsize,
     ae_int_t stackptr,
     ae_state *_state)
{
    ae_int_t k;
    ae_int_t m;
    ae_int_t n1;
    ae_int_t n2;
    ae_int_t esize;
    ae_int_t entryoffset;


    
    /*
     * prepare
     */
    if( *plansize+ftbase_ftbaseplanentrysize>(*planarraysize) )
    {
        ftbase_fftarrayresize(&plan->plan, planarraysize, 8*(*planarraysize), _state);
    }
    entryoffset = *plansize;
    esize = ftbase_ftbaseplanentrysize;
    *plansize = *plansize+esize;
    
    /*
     * if N=1, generate empty plan and exit
     */
    if( n==1 )
    {
        plan->plan.ptr.p_int[entryoffset+0] = esize;
        plan->plan.ptr.p_int[entryoffset+1] = -1;
        plan->plan.ptr.p_int[entryoffset+2] = -1;
        plan->plan.ptr.p_int[entryoffset+3] = ftbase_fftemptyplan;
        plan->plan.ptr.p_int[entryoffset+4] = -1;
        plan->plan.ptr.p_int[entryoffset+5] = -1;
        plan->plan.ptr.p_int[entryoffset+6] = -1;
        plan->plan.ptr.p_int[entryoffset+7] = -1;
        return;
    }
    
    /*
     * generate plans
     */
    ftbasefactorize(n, tasktype, &n1, &n2, _state);
    if( tasktype==ftbase_ftbasecffttask||tasktype==ftbase_ftbaserffttask )
    {
        
        /*
         * complex FFT plans
         */
        if( n1!=1 )
        {
            
            /*
             * Cooley-Tukey plan (real or complex)
             *
             * Note that child plans are COMPLEX
             * (whether plan itself is complex or not).
             */
            *tmpmemsize = ae_maxint(*tmpmemsize, 2*n1*n2, _state);
            plan->plan.ptr.p_int[entryoffset+0] = esize;
            plan->plan.ptr.p_int[entryoffset+1] = n1;
            plan->plan.ptr.p_int[entryoffset+2] = n2;
            if( tasktype==ftbase_ftbasecffttask )
            {
                plan->plan.ptr.p_int[entryoffset+3] = ftbase_fftcooleytukeyplan;
            }
            else
            {
                plan->plan.ptr.p_int[entryoffset+3] = ftbase_fftrealcooleytukeyplan;
            }
            plan->plan.ptr.p_int[entryoffset+4] = 0;
            plan->plan.ptr.p_int[entryoffset+5] = *plansize;
            ftbase_ftbasegenerateplanrec(n1, ftbase_ftbasecffttask, plan, plansize, precomputedsize, planarraysize, tmpmemsize, stackmemsize, stackptr, _state);
            plan->plan.ptr.p_int[entryoffset+6] = *plansize;
            ftbase_ftbasegenerateplanrec(n2, ftbase_ftbasecffttask, plan, plansize, precomputedsize, planarraysize, tmpmemsize, stackmemsize, stackptr, _state);
            plan->plan.ptr.p_int[entryoffset+7] = -1;
            return;
        }
        else
        {
            if( ((n==2||n==3)||n==4)||n==5 )
            {
                
                /*
                 * hard-coded plan
                 */
                plan->plan.ptr.p_int[entryoffset+0] = esize;
                plan->plan.ptr.p_int[entryoffset+1] = n1;
                plan->plan.ptr.p_int[entryoffset+2] = n2;
                plan->plan.ptr.p_int[entryoffset+3] = ftbase_fftcodeletplan;
                plan->plan.ptr.p_int[entryoffset+4] = 0;
                plan->plan.ptr.p_int[entryoffset+5] = -1;
                plan->plan.ptr.p_int[entryoffset+6] = -1;
                plan->plan.ptr.p_int[entryoffset+7] = *precomputedsize;
                if( n==3 )
                {
                    *precomputedsize = *precomputedsize+2;
                }
                if( n==5 )
                {
                    *precomputedsize = *precomputedsize+5;
                }
                return;
            }
            else
            {
                
                /*
                 * Bluestein's plan
                 *
                 * Select such M that M>=2*N-1, M is composite, and M's
                 * factors are 2, 3, 5
                 */
                k = 2*n2-1;
                m = ftbasefindsmooth(k, _state);
                *tmpmemsize = ae_maxint(*tmpmemsize, 2*m, _state);
                plan->plan.ptr.p_int[entryoffset+0] = esize;
                plan->plan.ptr.p_int[entryoffset+1] = n2;
                plan->plan.ptr.p_int[entryoffset+2] = -1;
                plan->plan.ptr.p_int[entryoffset+3] = ftbase_fftbluesteinplan;
                plan->plan.ptr.p_int[entryoffset+4] = m;
                plan->plan.ptr.p_int[entryoffset+5] = *plansize;
                stackptr = stackptr+2*2*m;
                *stackmemsize = ae_maxint(*stackmemsize, stackptr, _state);
                ftbase_ftbasegenerateplanrec(m, ftbase_ftbasecffttask, plan, plansize, precomputedsize, planarraysize, tmpmemsize, stackmemsize, stackptr, _state);
                stackptr = stackptr-2*2*m;
                plan->plan.ptr.p_int[entryoffset+6] = -1;
                plan->plan.ptr.p_int[entryoffset+7] = *precomputedsize;
                *precomputedsize = *precomputedsize+2*m+2*n;
                return;
            }
        }
    }
    if( tasktype==ftbase_ftbaserfhttask )
    {
        
        /*
         * real FHT plans
         */
        if( n1!=1 )
        {
            
            /*
             * Cooley-Tukey plan
             *
             */
            *tmpmemsize = ae_maxint(*tmpmemsize, 2*n1*n2, _state);
            plan->plan.ptr.p_int[entryoffset+0] = esize;
            plan->plan.ptr.p_int[entryoffset+1] = n1;
            plan->plan.ptr.p_int[entryoffset+2] = n2;
            plan->plan.ptr.p_int[entryoffset+3] = ftbase_fhtcooleytukeyplan;
            plan->plan.ptr.p_int[entryoffset+4] = 0;
            plan->plan.ptr.p_int[entryoffset+5] = *plansize;
            ftbase_ftbasegenerateplanrec(n1, tasktype, plan, plansize, precomputedsize, planarraysize, tmpmemsize, stackmemsize, stackptr, _state);
            plan->plan.ptr.p_int[entryoffset+6] = *plansize;
            ftbase_ftbasegenerateplanrec(n2, tasktype, plan, plansize, precomputedsize, planarraysize, tmpmemsize, stackmemsize, stackptr, _state);
            plan->plan.ptr.p_int[entryoffset+7] = -1;
            return;
        }
        else
        {
            
            /*
             * N2 plan
             */
            plan->plan.ptr.p_int[entryoffset+0] = esize;
            plan->plan.ptr.p_int[entryoffset+1] = n1;
            plan->plan.ptr.p_int[entryoffset+2] = n2;
            plan->plan.ptr.p_int[entryoffset+3] = ftbase_fhtn2plan;
            plan->plan.ptr.p_int[entryoffset+4] = 0;
            plan->plan.ptr.p_int[entryoffset+5] = -1;
            plan->plan.ptr.p_int[entryoffset+6] = -1;
            plan->plan.ptr.p_int[entryoffset+7] = -1;
            if( ((n==2||n==3)||n==4)||n==5 )
            {
                
                /*
                 * hard-coded plan
                 */
                plan->plan.ptr.p_int[entryoffset+0] = esize;
                plan->plan.ptr.p_int[entryoffset+1] = n1;
                plan->plan.ptr.p_int[entryoffset+2] = n2;
                plan->plan.ptr.p_int[entryoffset+3] = ftbase_fhtcodeletplan;
                plan->plan.ptr.p_int[entryoffset+4] = 0;
                plan->plan.ptr.p_int[entryoffset+5] = -1;
                plan->plan.ptr.p_int[entryoffset+6] = -1;
                plan->plan.ptr.p_int[entryoffset+7] = *precomputedsize;
                if( n==3 )
                {
                    *precomputedsize = *precomputedsize+2;
                }
                if( n==5 )
                {
                    *precomputedsize = *precomputedsize+5;
                }
                return;
            }
            return;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r15
movq %r8, 0x8(%rsp)
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, (%rsp)
movq %rdi, %rbp
movq (%rcx), %r14
leaq 0x8(%r14), %rax
movq (%r9), %r12
cmpq %r12, %rax
jle 0x21eb8
movq %rbp, 0x18(%rsp)
shlq $0x3, %r12
leaq 0x20(%rsp), %rsi
movq 0xb8(%rsp), %rbp
movq %rbp, %rdi
callq 0x25055
leaq 0x38(%rsp), %r14
movl $0x2, %edx
movq %r14, %rdi
xorl %esi, %esi
movq %rbp, %rcx
movl $0x1, %r8d
callq 0x251ec
movq (%r15), %rsi
movq %r14, %rdi
movq %rbp, %rdx
callq 0x25326
cmpq $0x0, (%r15)
jle 0x21e67
xorl %eax, %eax
movq 0x28(%rbx), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x60(%rsp), %rdx
movq %rcx, (%rdx,%rax,8)
incq %rax
cmpq (%r15), %rax
jl 0x21e4e
movq %rbx, %rdi
movq %r12, %rsi
movq 0xb8(%rsp), %rdx
callq 0x25326
cmpq $0x0, (%r15)
jle 0x21e9b
xorl %eax, %eax
movq 0x60(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x28(%rbx), %rdx
movq %rcx, (%rdx,%rax,8)
incq %rax
cmpq (%r15), %rax
jl 0x21e82
movq %r12, (%r15)
movq 0xb8(%rsp), %rdi
callq 0x24ff2
movq (%r13), %r14
leaq 0x8(%r14), %rax
movq 0x18(%rsp), %rbp
movq %rax, (%r13)
cmpq $0x1, %rbp
jne 0x21f1d
movq 0x28(%rbx), %rax
movq $0x8, (%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $-0x1, %rcx
movq %rcx, 0x8(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x10(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x6, 0x18(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x20(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x28(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x30(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x38(%rax,%r14,8)
jmp 0x22417
leaq 0x20(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %rbp, %rdi
callq 0x24239
testq $-0x3, (%rsp)
jne 0x21fe2
movq 0x20(%rsp), %r12
cmpq $0x1, %r12
jne 0x220de
leaq -0x2(%rbp), %rax
cmpq $0x3, %rax
ja 0x222bc
movq 0x28(%rbx), %rax
movq $0x8, (%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x1, 0x8(%rax,%r14,8)
movq 0x10(%rsp), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x10(%rcx,%r14,8)
movq 0x28(%rbx), %rax
movq $0x2, 0x18(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x0, 0x20(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $-0x1, %rcx
movq %rcx, 0x28(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x30(%rax,%r14,8)
movq 0x8(%rsp), %rdx
movq (%rdx), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x38(%rcx,%r14,8)
cmpq $0x5, %rbp
je 0x22407
cmpq $0x3, %rbp
jne 0x22417
addq $0x2, %rax
jmp 0x2240b
movq 0x20(%rsp), %r12
cmpq $0x1, %r12
jne 0x221b0
movq 0x28(%rbx), %rax
movq $0x8, (%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x1, 0x8(%rax,%r14,8)
movq 0x10(%rsp), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x10(%rcx,%r14,8)
movq 0x28(%rbx), %rcx
movq $0x3e7, 0x18(%rcx,%r14,8) # imm = 0x3E7
movq 0x28(%rbx), %rcx
movq $0x0, 0x20(%rcx,%r14,8)
movq 0x28(%rbx), %rdx
movq $-0x1, %rcx
movq %rcx, 0x28(%rdx,%r14,8)
movq 0x28(%rbx), %rdx
movq %rcx, 0x30(%rdx,%r14,8)
movq 0x28(%rbx), %rdx
movq %rcx, 0x38(%rdx,%r14,8)
leaq -0x2(%rbp), %rdx
cmpq $0x3, %rdx
movq 0x8(%rsp), %rsi
ja 0x22417
movq 0x28(%rbx), %rdx
movq $0x8, (%rdx,%r14,8)
movq 0x28(%rbx), %rdx
movq $0x1, 0x8(%rdx,%r14,8)
movq 0x28(%rbx), %rdx
movq %rax, 0x10(%rdx,%r14,8)
movq 0x28(%rbx), %rax
movq $0x4, 0x18(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x0, 0x20(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x28(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rcx, 0x30(%rax,%r14,8)
movq (%rsi), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x38(%rcx,%r14,8)
cmpq $0x5, %rbp
je 0x22410
cmpq $0x3, %rbp
jne 0x22417
addq $0x2, %rax
jmp 0x22414
movq 0xa0(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rbp
movq %r12, %rsi
imulq %rbp, %rsi
addq %rsi, %rsi
movq 0xb8(%rsp), %rdx
callq 0x25ec6
movq 0xa0(%rsp), %r10
movq %rax, (%r10)
movq 0x28(%rbx), %rax
movq $0x8, (%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %r12, 0x8(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rbp, 0x10(%rax,%r14,8)
xorl %eax, %eax
cmpq $0x0, (%rsp)
setne %al
movq 0x28(%rbx), %rcx
leaq (%rax,%rax,4), %rax
movq %rax, 0x18(%rcx,%r14,8)
movq 0x28(%rbx), %rax
movq $0x0, 0x20(%rax,%r14,8)
movq (%r13), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x28(%rcx,%r14,8)
movq %r12, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r12
movq %r12, %r8
movq %r15, %r9
pushq 0xb8(%rsp)
movq 0xb8(%rsp), %rax
pushq %rax
movq 0xb8(%rsp), %rax
pushq %rax
pushq %r10
callq 0x21dc7
addq $0x20, %rsp
movq (%r13), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x30(%rcx,%r14,8)
movq %rbp, %rdi
xorl %esi, %esi
jmp 0x22279
movq 0xa0(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rbp
movq %r12, %rsi
imulq %rbp, %rsi
addq %rsi, %rsi
movq 0xb8(%rsp), %rdx
callq 0x25ec6
movq 0xa0(%rsp), %r10
movq %rax, (%r10)
movq 0x28(%rbx), %rax
movq $0x8, (%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %r12, 0x8(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %rbp, 0x10(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x3, 0x18(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x0, 0x20(%rax,%r14,8)
movq (%r13), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x28(%rcx,%r14,8)
movl $0x1, %esi
movq %r12, %rdi
movq %rbx, %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r12
movq %r12, %r8
movq %r15, %r9
pushq 0xb8(%rsp)
movq 0xb8(%rsp), %rax
pushq %rax
movq 0xb8(%rsp), %rax
pushq %rax
pushq %r10
callq 0x21dc7
addq $0x20, %rsp
movq (%r13), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x30(%rcx,%r14,8)
movl $0x1, %esi
movq %rbp, %rdi
movq %rbx, %rdx
movq %r13, %rcx
movq %r12, %r8
movq %r15, %r9
pushq 0xb8(%rsp)
pushq 0xb8(%rsp)
pushq 0xb8(%rsp)
pushq 0xb8(%rsp)
callq 0x21dc7
addq $0x20, %rsp
movq 0x28(%rbx), %rax
movq $-0x1, 0x38(%rax,%r14,8)
jmp 0x22417
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
leaq -0x1(,%rax,2), %rdi
movl $0x2, %ecx
movq %rcx, %rax
addq %rcx, %rcx
cmpq %rdi, %rax
jl 0x222d2
leaq 0x38(%rsp), %r12
movq %rax, (%r12)
movl $0x1, %esi
movl $0x2, %edx
movq %r12, %rcx
movq 0xb8(%rsp), %r8
callq 0x2435a
movq (%r12), %r12
movq 0xa0(%rsp), %rax
movq (%rax), %rdi
leaq (%r12,%r12), %rsi
movq 0xb8(%rsp), %rdx
callq 0x25ec6
movq 0xa0(%rsp), %rcx
movq %rax, (%rcx)
movq 0x28(%rbx), %rax
movq $0x8, (%rax,%r14,8)
movq 0x28(%rbx), %rax
movq (%rsp), %rcx
movq %rcx, 0x8(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $-0x1, %rcx
movq %rcx, 0x10(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq $0x1, 0x18(%rax,%r14,8)
movq 0x28(%rbx), %rax
movq %r12, 0x20(%rax,%r14,8)
movq (%r13), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x28(%rcx,%r14,8)
movq 0xb0(%rsp), %rax
leaq (%rax,%r12,4), %rsi
movq %rsi, (%rsp)
movq 0xa8(%rsp), %rax
movq (%rax), %rdi
movq 0xb8(%rsp), %rdx
callq 0x25ec6
movq 0xa8(%rsp), %r10
movq %rax, (%r10)
movq %r12, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r13
movq %r13, %r8
movq %r15, %r9
pushq 0xb8(%rsp)
pushq 0x8(%rsp)
pushq %r10
pushq 0xb8(%rsp)
callq 0x21dc7
addq $0x20, %rsp
movq 0x28(%rbx), %rax
movq $-0x1, %rcx
movq %rcx, 0x30(%rax,%r14,8)
movq (%r13), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x38(%rcx,%r14,8)
addq %r12, %rbp
leaq (%rax,%rbp,2), %rax
movq %rax, (%r13)
jmp 0x22417
addq $0x5, %rax
movq %rax, (%rdx)
jmp 0x22417
addq $0x5, %rax
movq %rax, (%rsi)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq