// File: /workspace/github_cpp_makefile_star2_O3/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, 0xc(%rsp)
movl %r8d, 0x8(%rsp)
movq %rcx, %r15
movq %rdx, 0x18(%rsp)
movq %rsi, %r14
movq %rdi, %rbp
movq 0x118(%rsp), %rbx
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdi
callq 0x25055
movq %r15, 0x10(%rsp)
movq $0x0, (%r15)
leaq 0x90(%rsp), %rdi
movl $0x3, %edx
xorl %esi, %esi
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x251ec
leaq 0x20(%rsp), %r13
movl $0x3, %ecx
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %r8
movl $0x1, %r9d
callq 0x2541c
leaq 0x60(%rsp), %r15
movl $0x3, %edx
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x251ec
leaq 0x1(%r14), %r12
movq %r13, %rdi
movq %r12, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x256d1
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x25326
testq %r14, %r14
jle 0x1cbf7
xorl %r13d, %r13d
movq 0x58(%rsp), %rax
movq 0x8(%rax,%r13,8), %r15
addq $0x8, %r15
movq 0x38(%rbp), %rax
movq (%rax,%r13,8), %r12
movl $0x1, %edi
movq %r14, %rsi
callq 0x2897c
movl $0x1, %esi
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rdx
movq %rax, %r8
callq 0x2860a
incq %r13
cmpq %r13, %r14
jne 0x1cbb4
leaq 0x60(%rsp), %rbp
movq 0x28(%rbp), %r15
addq $0x8, %r15
movq 0x18(%rsp), %r13
movq 0x28(%r13), %r12
movl $0x1, %edi
movq %r14, %rsi
callq 0x2897c
movl $0x1, %esi
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rdx
movq %rax, %r8
callq 0x2860a
movzbl 0x110(%rsp), %eax
movzbl 0x8(%rsp), %r8d
movzbl 0xc(%rsp), %r9d
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
pushq %rbx
leaq 0x98(%rsp), %r10
pushq %r10
pushq $0x0
pushq %rax
callq 0x1ccb8
addq $0x20, %rsp
movq 0x28(%r13), %r15
movq 0x28(%rbp), %r12
addq $0x8, %r12
decq %r14
xorl %edi, %edi
movq %r14, %rsi
callq 0x2897c
movl $0x1, %esi
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rdx
movq %rax, %r8
callq 0x2860a
movq %rbx, %rdi
callq 0x24ff2
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq