// File: mouda[P]LTE_random_access-simulate/alglibinternal.cpp
// Function: alglib_impl::armijoiteration(alglib_impl::armijostate*, alglib_impl::ae_state*)
ae_bool armijoiteration(armijostate* state, ae_state *_state)
{
    double v;
    ae_int_t n;
    ae_bool result;


    
    /*
     * Reverse communication preparations
     * I know it looks ugly, but it works the same way
     * anywhere from C++ to Python.
     *
     * This code initializes locals by:
     * * random values determined during code
     *   generation - on first subroutine call
     * * values from previous call - on subsequent calls
     */
    if( state->rstate.stage>=0 )
    {
        n = state->rstate.ia.ptr.p_int[0];
        v = state->rstate.ra.ptr.p_double[0];
    }
    else
    {
        n = -983;
        v = -989;
    }
    if( state->rstate.stage==0 )
    {
        goto lbl_0;
    }
    if( state->rstate.stage==1 )
    {
        goto lbl_1;
    }
    if( state->rstate.stage==2 )
    {
        goto lbl_2;
    }
    if( state->rstate.stage==3 )
    {
        goto lbl_3;
    }
    
    /*
     * Routine body
     */
    if( (ae_fp_less_eq(state->stplen,0)||ae_fp_less(state->stpmax,0))||state->fmax<2 )
    {
        state->info = 0;
        result = ae_false;
        return result;
    }
    if( ae_fp_less_eq(state->stplen,linmin_stpmin) )
    {
        state->info = 4;
        result = ae_false;
        return result;
    }
    n = state->n;
    state->nfev = 0;
    
    /*
     * We always need F
     */
    state->needf = ae_true;
    
    /*
     * Bound StpLen
     */
    if( ae_fp_greater(state->stplen,state->stpmax)&&ae_fp_neq(state->stpmax,0) )
    {
        state->stplen = state->stpmax;
    }
    
    /*
     * Increase length
     */
    v = state->stplen*linmin_armijofactor;
    if( ae_fp_greater(v,state->stpmax)&&ae_fp_neq(state->stpmax,0) )
    {
        v = state->stpmax;
    }
    ae_v_move(&state->x.ptr.p_double[0], 1, &state->xbase.ptr.p_double[0], 1, ae_v_len(0,n-1));
    ae_v_addd(&state->x.ptr.p_double[0], 1, &state->s.ptr.p_double[0], 1, ae_v_len(0,n-1), v);
    state->rstate.stage = 0;
    goto lbl_rcomm;
lbl_0:
    state->nfev = state->nfev+1;
    if( ae_fp_greater_eq(state->f,state->fcur) )
    {
        goto lbl_4;
    }
    state->stplen = v;
    state->fcur = state->f;
lbl_6:
    if( ae_false )
    {
        goto lbl_7;
    }
    
    /*
     * test stopping conditions
     */
    if( state->nfev>=state->fmax )
    {
        state->info = 3;
        result = ae_false;
        return result;
    }
    if( ae_fp_greater_eq(state->stplen,state->stpmax) )
    {
        state->info = 5;
        result = ae_false;
        return result;
    }
    
    /*
     * evaluate F
     */
    v = state->stplen*linmin_armijofactor;
    if( ae_fp_greater(v,state->stpmax)&&ae_fp_neq(state->stpmax,0) )
    {
        v = state->stpmax;
    }
    ae_v_move(&state->x.ptr.p_double[0], 1, &state->xbase.ptr.p_double[0], 1, ae_v_len(0,n-1));
    ae_v_addd(&state->x.ptr.p_double[0], 1, &state->s.ptr.p_double[0], 1, ae_v_len(0,n-1), v);
    state->rstate.stage = 1;
    goto lbl_rcomm;
lbl_1:
    state->nfev = state->nfev+1;
    
    /*
     * make decision
     */
    if( ae_fp_less(state->f,state->fcur) )
    {
        state->stplen = v;
        state->fcur = state->f;
    }
    else
    {
        state->info = 1;
        result = ae_false;
        return result;
    }
    goto lbl_6;
lbl_7:
lbl_4:
    
    /*
     * Decrease length
     */
    v = state->stplen/linmin_armijofactor;
    ae_v_move(&state->x.ptr.p_double[0], 1, &state->xbase.ptr.p_double[0], 1, ae_v_len(0,n-1));
    ae_v_addd(&state->x.ptr.p_double[0], 1, &state->s.ptr.p_double[0], 1, ae_v_len(0,n-1), v);
    state->rstate.stage = 2;
    goto lbl_rcomm;
lbl_2:
    state->nfev = state->nfev+1;
    if( ae_fp_greater_eq(state->f,state->fcur) )
    {
        goto lbl_8;
    }
    state->stplen = state->stplen/linmin_armijofactor;
    state->fcur = state->f;
lbl_10:
    if( ae_false )
    {
        goto lbl_11;
    }
    
    /*
     * test stopping conditions
     */
    if( state->nfev>=state->fmax )
    {
        state->info = 3;
        result = ae_false;
        return result;
    }
    if( ae_fp_less_eq(state->stplen,linmin_stpmin) )
    {
        state->info = 4;
        result = ae_false;
        return result;
    }
    
    /*
     * evaluate F
     */
    v = state->stplen/linmin_armijofactor;
    ae_v_move(&state->x.ptr.p_double[0], 1, &state->xbase.ptr.p_double[0], 1, ae_v_len(0,n-1));
    ae_v_addd(&state->x.ptr.p_double[0], 1, &state->s.ptr.p_double[0], 1, ae_v_len(0,n-1), v);
    state->rstate.stage = 3;
    goto lbl_rcomm;
lbl_3:
    state->nfev = state->nfev+1;
    
    /*
     * make decision
     */
    if( ae_fp_less(state->f,state->fcur) )
    {
        state->stplen = state->stplen/linmin_armijofactor;
        state->fcur = state->f;
    }
    else
    {
        state->info = 1;
        result = ae_false;
        return result;
    }
    goto lbl_10;
lbl_11:
lbl_8:
    
    /*
     * Nothing to be done
     */
    state->info = 1;
    result = ae_false;
    return result;
    
    /*
     * Saving state
     */
lbl_rcomm:
    result = ae_true;
    state->rstate.ia.ptr.p_int[0] = n;
    state->rstate.ra.ptr.p_double[0] = v;
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xd8(%rax)
jl 0x335a8
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x335bd
movq $-0x3d7, -0x28(%rbp)    # imm = 0xFC29
movsd 0x242c8(%rip), %xmm0    # 0x57880
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xd8(%rax)
jne 0x335cf
jmp 0x33816
movq -0x10(%rbp), %rax
cmpl $0x1, 0xd8(%rax)
jne 0x335e1
jmp 0x339f3
movq -0x10(%rbp), %rax
cmpl $0x2, 0xd8(%rax)
jne 0x335f3
jmp 0x33b3c
movq -0x10(%rbp), %rax
cmpl $0x3, 0xd8(%rax)
jne 0x33605
jmp 0x33cf5
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
xorps %xmm1, %xmm1
callq 0x3c480
testb $0x1, %al
jne 0x33643
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
xorps %xmm1, %xmm1
callq 0x3c440
testb $0x1, %al
jne 0x33643
movq -0x10(%rbp), %rax
cmpq $0x2, 0xc0(%rax)
jge 0x33663
movq -0x10(%rbp), %rax
movq $0x0, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
movsd 0x31c89(%rip), %xmm1    # 0x65300
callq 0x3c480
testb $0x1, %al
jne 0x33682
jmp 0x336a2
movq -0x10(%rbp), %rax
movq $0x4, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0xc8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x336e7
jmp 0x33719
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
xorps %xmm1, %xmm1
callq 0x3c410
testb $0x1, %al
jne 0x33701
jmp 0x33719
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
mulsd 0x31bf3(%rip), %xmm0    # 0x65320
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x3374e
jmp 0x33779
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
xorps %xmm1, %xmm1
callq 0x3c410
testb $0x1, %al
jne 0x33768
jmp 0x33779
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq %rax, %r8
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41b10
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq %rax, %r8
movsd -0x20(%rbp), %xmm0
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41fe0
movq -0x10(%rbp), %rax
movl $0x0, 0xd8(%rax)
jmp 0x33da5
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb0(%rax), %xmm1
callq 0x3c500
testb $0x1, %al
jne 0x33850
jmp 0x33855
jmp 0x33a7a
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xb0(%rax)
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0xc0(%rcx), %rax
jl 0x338b3
movq -0x10(%rbp), %rax
movq $0x3, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm1
callq 0x3c500
testb $0x1, %al
jne 0x338d6
jmp 0x338f6
movq -0x10(%rbp), %rax
movq $0x5, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
mulsd 0x31a16(%rip), %xmm0    # 0x65320
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x3392b
jmp 0x33956
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
xorps %xmm1, %xmm1
callq 0x3c410
testb $0x1, %al
jne 0x33945
jmp 0x33956
movq -0x10(%rbp), %rax
movsd 0xb8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq %rax, %r8
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41b10
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq %rax, %r8
movsd -0x20(%rbp), %xmm0
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41fe0
movq -0x10(%rbp), %rax
movl $0x1, 0xd8(%rax)
jmp 0x33da5
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb0(%rax), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0x33a2d
jmp 0x33a55
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xb0(%rax)
jmp 0x33a75
movq -0x10(%rbp), %rax
movq $0x1, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
jmp 0x3387b
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
divsd 0x31892(%rip), %xmm0    # 0x65320
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rdx
movq %rax, %r8
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41b10
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rdx
movq %rax, %r8
movsd -0x20(%rbp), %xmm0
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41fe0
movq -0x10(%rbp), %rax
movl $0x2, 0xd8(%rax)
jmp 0x33da5
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb0(%rax), %xmm1
callq 0x3c500
testb $0x1, %al
jne 0x33b76
jmp 0x33b7b
jmp 0x33d88
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
divsd 0x31791(%rip), %xmm0    # 0x65320
movq -0x10(%rbp), %rax
movsd %xmm0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xb0(%rax)
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0xc0(%rcx), %rax
jl 0x33be8
movq -0x10(%rbp), %rax
movq $0x3, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
movsd 0x31704(%rip), %xmm1    # 0x65300
callq 0x3c480
testb $0x1, %al
jne 0x33c07
jmp 0x33c27
movq -0x10(%rbp), %rax
movq $0x4, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
divsd 0x316e5(%rip), %xmm0    # 0x65320
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rdx
movq %rax, %r8
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41b10
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rsi
subq $0x1, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x42370
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rdx
movq %rax, %r8
movsd -0x20(%rbp), %xmm0
movl $0x1, %ecx
movq %rcx, %rsi
callq 0x41fe0
movq -0x10(%rbp), %rax
movl $0x3, 0xd8(%rax)
jmp 0x33da5
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd 0xb0(%rax), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0x33d2f
jmp 0x33d66
movq -0x10(%rbp), %rax
movsd 0xa8(%rax), %xmm0
divsd 0x315dd(%rip), %xmm0    # 0x65320
movq -0x10(%rbp), %rax
movsd %xmm0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0xb0(%rax)
jmp 0x33d83
movq -0x10(%rbp), %rax
movq $0x1, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
jmp 0x33bb0
movq -0x10(%rbp), %rax
movq $0x1, 0xd0(%rax)
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x33dd7
movb $0x1, -0x29(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x108(%rax), %rax
movq %rcx, (%rax)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movsd %xmm0, (%rax)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)