// File: /workspace/github_cpp_makefile_star2_O2/mouda[P]LTE_random_access-simulate/alglibinternal.cpp
// Function: alglib_impl::rmatrixtrsafesolve(alglib_impl::ae_matrix*, long, alglib_impl::ae_vector*, double*, bool, bool, bool, alglib_impl::ae_state*)
void rmatrixtrsafesolve(/* Real    */ ae_matrix* a,
     ae_int_t n,
     /* Real    */ ae_vector* x,
     double* s,
     ae_bool isupper,
     ae_bool istrans,
     ae_bool isunit,
     ae_state *_state)
{
    ae_frame _frame_block;
    ae_bool normin;
    ae_vector cnorm;
    ae_matrix a1;
    ae_vector x1;
    ae_int_t i;

    ae_frame_make(_state, &_frame_block);
    *s = 0;
    ae_vector_init(&cnorm, 0, DT_REAL, _state, ae_true);
    ae_matrix_init(&a1, 0, 0, DT_REAL, _state, ae_true);
    ae_vector_init(&x1, 0, DT_REAL, _state, ae_true);

    
    /*
     * From 0-based to 1-based
     */
    normin = ae_false;
    ae_matrix_set_length(&a1, n+1, n+1, _state);
    ae_vector_set_length(&x1, n+1, _state);
    for(i=1; i<=n; i++)
    {
        ae_v_move(&a1.ptr.pp_double[i][1], 1, &a->ptr.pp_double[i-1][0], 1, ae_v_len(1,n));
    }
    ae_v_move(&x1.ptr.p_double[1], 1, &x->ptr.p_double[0], 1, ae_v_len(1,n));
    
    /*
     * Solve 1-based
     */
    safesolvetriangular(&a1, n, &x1, s, isupper, istrans, isunit, normin, &cnorm, _state);
    
    /*
     * From 1-based to 0-based
     */
    ae_v_move(&x->ptr.p_double[0], 1, &x1.ptr.p_double[1], 1, ae_v_len(0,n-1));
    ae_frame_leave(_state);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r9d, 0x4(%rsp)
movl %r8d, (%rsp)
movq %rcx, %r15
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
movq 0x118(%rsp), %r14
leaq 0xc0(%rsp), %rsi
movq %r14, %rdi
callq 0x23815
movq %r15, 0x8(%rsp)
andq $0x0, (%r15)
xorl %r12d, %r12d
leaq 0x90(%rsp), %rdi
pushq $0x3
popq %r13
pushq $0x1
popq %r15
xorl %esi, %esi
movq %r13, %rdx
movq %r14, %rcx
movl %r15d, %r8d
callq 0x239a5
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
movq %r14, %r8
movl %r15d, %r9d
callq 0x23baa
leaq 0x20(%rsp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r14, %rcx
movl %r15d, %r8d
callq 0x239a5
leaq 0x1(%rbx), %r15
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x23e0a
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x23add
testq %rbx, %rbx
movl $0x0, %r14d
movq %rbx, %rbp
cmovgq %rbx, %r14
pushq $0x1
popq %r13
cmpq %r12, %r14
je 0x1b7b0
movq 0x88(%rsp), %rax
movq 0x8(%rax,%r12,8), %rbx
addq $0x8, %rbx
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax,%r12,8), %r15
movq %r13, %rdi
movq %rbp, %rsi
callq 0x26b4d
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0x2675e
incq %r12
jmp 0x1b769
leaq 0x20(%rsp), %rax
movq 0x28(%rax), %rbx
addq $0x8, %rbx
movq 0x10(%rsp), %r13
movq 0x28(%r13), %r15
pushq $0x1
popq %r14
movq %r14, %rdi
movq %rbp, %r12
movq %rbp, %rsi
callq 0x26b4d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r14, %rcx
movq %r14, %rbp
movq %rax, %r8
callq 0x2675e
movzbl 0x110(%rsp), %eax
movzbl (%rsp), %r8d
movzbl 0x4(%rsp), %r9d
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
leaq 0x20(%rsp), %r15
movq %r15, %rdx
movq 0x8(%rsp), %rcx
movq 0x118(%rsp), %r14
pushq %r14
leaq 0x98(%rsp), %r10
pushq %r10
pushq $0x0
pushq %rax
callq 0x1b87e
addq $0x20, %rsp
movq 0x28(%r13), %rbx
movq 0x28(%r15), %r15
addq $0x8, %r15
decq %r12
xorl %edi, %edi
movq %r12, %rsi
callq 0x26b4d
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %rax, %r8
callq 0x2675e
movq %r14, %rdi
callq 0x237b6
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq