// File: /workspace/github_cpp_makefile_star2_O2/Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::SaveResult(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void IsiSage::SaveResult(const string save_path){
    Util::log("Saving Sage Result at " + save_path);
    ofstream f_result(save_path, ios::binary);
    if(!f_result){
        cerr<<"sage result save Error!!!";
        abort();
    }
    //save sage metainfo 
    f_result.write((char*)&spot, sizeof(int));
    f_result.write((char*)&cycle_idx, sizeof(int));
    f_result.write((char*)&max_path_num, sizeof(int));
    f_result.write((char*)&max_iter_num, sizeof(int));
    // save sage result data
    for(int iL = 0; iL < max_path_num; ++iL){
        //save tau of the iL path
        int tau = result.tau(iL);
        f_result.write((char*)&tau, sizeof(int));
        //save doppler of the iL path
        double doppler = result.doppler(iL);
        f_result.write((char*)&doppler, sizeof(double));
        //save AOA of the iL path
        double theta = result.theta_rx(iL);
        double phi = result.phi_rx(iL);
        f_result.write((char*)&theta, sizeof(double));
        f_result.write((char*)&phi, sizeof(double));
        //save AoD of the iL path
        theta = result.theta_tx(iL);
        phi = result.phi_tx(iL);
        f_result.write((char*)&theta, sizeof(double));
        f_result.write((char*)&phi, sizeof(double));
        //save alpha of the iL path
        double alpha_real = result.alpha(0, iL).real();
        double alpha_imag = result.alpha(0, iL).imag();
        for(int i = 0; i < 4; ++i){
            alpha_real = result.alpha(i, iL).real();
            f_result.write((char*)&alpha_real, sizeof(double));
            alpha_imag = result.alpha(i, iL).imag();
            f_result.write((char*)&alpha_imag, sizeof(double));
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x13336(%rip), %rsi     # 0x1d8ae
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xb1af
movq %r15, %rdi
callq 0x547e
leaq 0x68(%rsp), %rdi
callq 0x3100
leaq 0x88(%rsp), %r15
pushq $0x4
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3490
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xa8(%rsp,%rax)
jne 0xa82c
leaq 0x150(%rbx), %rsi
leaq 0x88(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x3310
leaq 0x154(%rbx), %rsi
leaq 0x88(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x3310
leaq 0x15c(%rbx), %rsi
leaq 0x88(%rsp), %rdi
pushq $0x4
popq %rdx
movq %rsi, 0x58(%rsp)
callq 0x3310
leaq 0x158(%rbx), %rsi
leaq 0x88(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x3310
leaq 0x1c0(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x1d0(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x200(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x210(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x1e0(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x1f0(%rbx), %rax
movq %rax, 0x28(%rsp)
addq $0x220, %rbx            # imm = 0x220
xorl %r12d, %r12d
leaq 0x88(%rsp), %r13
pushq $0x8
popq %rbp
leaq 0x18(%rsp), %r15
movq 0x58(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %r12
jge 0xa80d
movq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x5618
movl (%rax), %eax
movl %eax, 0x14(%rsp)
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x3310
movq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
movq %rbp, %rdx
callq 0x3310
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x3310
movq %r13, %rdi
movq %rsp, %rsi
movq %rbp, %rdx
callq 0x3310
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x3310
movq %r13, %rdi
movq %rsp, %rsi
movq %rbp, %rdx
callq 0x3310
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x54d6
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x54d6
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0xa805
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x54d6
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
movq %rbp, %rdx
callq 0x3310
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x54d6
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x3310
incq %r14
jmp 0xa7ab
incq %r12
jmp 0xa688
leaq 0x88(%rsp), %rdi
callq 0x3370
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2f7bd(%rip), %rdi     # 0x39ff0
leaq 0x1308b(%rip), %rsi     # 0x1d8c5
callq 0x3250
callq 0x3160
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3100
jmp 0xa871
jmp 0xa861
jmp 0xa861
jmp 0xa861
jmp 0xa861
jmp 0xa861
jmp 0xa861
jmp 0xa861
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x3370
movq %rbx, %rdi
callq 0x3430
nop