// File: 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
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rsi, %rdx
movq %rdx, -0x290(%rbp)
movq %rdi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq 0x5084f(%rip), %rsi     # 0x6fcae
leaq -0x30(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x21ac0
movq -0x280(%rbp), %rdi
callq 0x13b80
jmp 0x1f47d
leaq -0x30(%rbp), %rdi
callq 0x9470
movq -0x290(%rbp), %rsi
leaq -0x240(%rbp), %rdi
movl $0x4, %edx
callq 0x9f50
movq -0x240(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x240(%rbp,%rax), %rdi
callq 0x9310
movb %al, -0x291(%rbp)
jmp 0x1f4be
movb -0x291(%rbp), %al
testb $0x1, %al
jne 0x1f4ca
jmp 0x1f51b
movq 0x95b1f(%rip), %rdi     # 0xb4ff0
leaq 0x507ed(%rip), %rsi     # 0x6fcc5
callq 0x9790
jmp 0x1f4df
callq 0x93b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x9470
jmp 0x1f964
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x9b80
jmp 0x1f964
movq -0x288(%rbp), %rsi
addq $0x150, %rsi            # imm = 0x150
leaq -0x240(%rbp), %rdi
movl $0x4, %edx
callq 0x9a30
jmp 0x1f53c
movq -0x288(%rbp), %rsi
addq $0x154, %rsi            # imm = 0x154
leaq -0x240(%rbp), %rdi
movl $0x4, %edx
callq 0x9a30
jmp 0x1f55d
movq -0x288(%rbp), %rsi
addq $0x15c, %rsi            # imm = 0x15C
leaq -0x240(%rbp), %rdi
movl $0x4, %edx
callq 0x9a30
jmp 0x1f57e
movq -0x288(%rbp), %rsi
addq $0x158, %rsi            # imm = 0x158
leaq -0x240(%rbp), %rdi
movl $0x4, %edx
callq 0x9a30
jmp 0x1f59f
movl $0x0, -0x244(%rbp)
movq -0x288(%rbp), %rcx
movl -0x244(%rbp), %eax
cmpl 0x15c(%rcx), %eax
jge 0x1f94f
movq -0x288(%rbp), %rdi
addq $0x1c0, %rdi            # imm = 0x1C0
movslq -0x244(%rbp), %rsi
callq 0x14090
movq %rax, -0x2a0(%rbp)
jmp 0x1f5e5
movq -0x2a0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x248(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movl $0x4, %edx
callq 0x9a30
jmp 0x1f60e
movq -0x288(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x244(%rbp), %rsi
callq 0x14140
movq %rax, -0x2a8(%rbp)
jmp 0x1f631
movq -0x2a8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x250(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f65e
movq -0x288(%rbp), %rdi
addq $0x200, %rdi            # imm = 0x200
movslq -0x244(%rbp), %rsi
callq 0x14140
movq %rax, -0x2b0(%rbp)
jmp 0x1f681
movq -0x288(%rbp), %rdi
movq -0x2b0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x258(%rbp)
addq $0x210, %rdi            # imm = 0x210
movslq -0x244(%rbp), %rsi
callq 0x14140
movq %rax, -0x2b8(%rbp)
jmp 0x1f6b7
movq -0x2b8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x260(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x258(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f6e4
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f6fe
movq -0x288(%rbp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movslq -0x244(%rbp), %rsi
callq 0x14140
movq %rax, -0x2c0(%rbp)
jmp 0x1f721
movq -0x288(%rbp), %rdi
movq -0x2c0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x258(%rbp)
addq $0x1f0, %rdi            # imm = 0x1F0
movslq -0x244(%rbp), %rsi
callq 0x14140
movq %rax, -0x2c8(%rbp)
jmp 0x1f757
movq -0x2c8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x260(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x258(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f784
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f79e
movq -0x288(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movslq -0x244(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x13c40
movq %rax, -0x2d0(%rbp)
jmp 0x1f7c5
movq -0x2d0(%rbp), %rdi
callq 0x20b40
movsd %xmm0, -0x2d8(%rbp)
jmp 0x1f7db
movq -0x288(%rbp), %rdi
movsd -0x2d8(%rbp), %xmm0
movsd %xmm0, -0x268(%rbp)
addq $0x220, %rdi            # imm = 0x220
movslq -0x244(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x13c40
movq %rax, -0x2e0(%rbp)
jmp 0x1f812
movq -0x2e0(%rbp), %rdi
callq 0x21bd0
movsd %xmm0, -0x2e8(%rbp)
jmp 0x1f828
movsd -0x2e8(%rbp), %xmm0
movsd %xmm0, -0x270(%rbp)
movl $0x0, -0x274(%rbp)
cmpl $0x4, -0x274(%rbp)
jge 0x1f939
movq -0x288(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movslq -0x274(%rbp), %rsi
movslq -0x244(%rbp), %rdx
callq 0x13c40
movq %rax, -0x2f0(%rbp)
jmp 0x1f879
movq -0x2f0(%rbp), %rdi
callq 0x20b40
movsd %xmm0, -0x2f8(%rbp)
jmp 0x1f88f
movsd -0x2f8(%rbp), %xmm0
movsd %xmm0, -0x268(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f8b9
movq -0x288(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movslq -0x274(%rbp), %rsi
movslq -0x244(%rbp), %rdx
callq 0x13c40
movq %rax, -0x300(%rbp)
jmp 0x1f8e3
movq -0x300(%rbp), %rdi
callq 0x21bd0
movsd %xmm0, -0x308(%rbp)
jmp 0x1f8f9
movsd -0x308(%rbp), %xmm0
movsd %xmm0, -0x270(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movl $0x8, %edx
callq 0x9a30
jmp 0x1f923
jmp 0x1f925
movl -0x274(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x274(%rbp)
jmp 0x1f842
jmp 0x1f93b
movl -0x244(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x244(%rbp)
jmp 0x1f5a9
leaq -0x240(%rbp), %rdi
callq 0x9b80
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x9dc0
nopl (%rax)