// File: /workspace/github_cpp_makefile_star2_O1/Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::ConfigInit(int, int, int, int, int, int, double, double, double)
void IsiSage::ConfigInit(int spot, int cycle_idx, int Tx, int Rx, int pn_code, int cyc_num, 
double fc, double bd, double cycle_rate){
    Util::log("config init...");
    this->spot = spot;
    this->cycle_idx = cycle_idx;
    // to be modified config
    config.Tx = Tx;
    config.Rx = Rx;
    config.cycle_num = cyc_num;
    config.PN_CODE = pn_code;
    config.fc = fc;
    config.bandwidth = bd;
    config.cycle_rate = cycle_rate;
    config.is_pg = true;
    // fixed config
    config.sample_codes = config.PN_CODE * 2;
    config.lambda = SPEED_OF_LIGHT / config.fc;    
    config.subchannel_num = config.Tx * config.Rx;
    config.subchannel_withPG_num = config.Tx * (config.Rx + 1);
    // souder 的采样原理设置了一个保护间隔
    config.channel_num = config.Tx * (config.Rx + 1) * config.cycle_num;
    // 此处的T为chip rate 就是一个码片的时间，一个PN序列有PN_CODE长度的码片
    config.T = 1 / config.bandwidth;
    // 收端一个天线阵列的扫描时间，即接收一个PN序列的时间，但是由于需要满足采样定理，因此为2倍的PN序列长度
    // 以下有关时间的都以码片为单位
    config.Tsc = config.sample_codes;
    config.switch_interval = config.Tsc;
    config.Tr = config.Tsc + config.switch_interval;
    config.Tt = config.Tr * (config.Rx + 1);
    config.Tcy = (int)(1/config.cycle_rate/config.T);
    config.cycle_interval = 1/config.cycle_rate;
    config.max_doppler = ceil(config.cycle_rate / 2);
    config.max_phi_rx = 180;
    config.min_phi_rx = -180;
    config.max_theta_rx = 75;
    config.min_theta_rx = -75;
    config.max_phi_tx = 75;
    config.min_phi_tx = -75;
    config.max_theta_tx = 75;
    config.min_theta_tx = -75;
    config.doppler_step = 1; // hz
    config.angle_step = 2; // degree
    config.delay_step = 1; // one T period 
    Util::log("config init done");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movsd %xmm2, 0x20(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x10(%rsp)
movl %r9d, %r14d
movl %r8d, %ebp
movl %ecx, %r15d
movl %edx, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x16c10(%rip), %rsi     # 0x1d670
leaq 0x16c17(%rip), %rdx     # 0x1d67e
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x43da
movq %r12, %rdi
callq 0x60e8
movl 0xa0(%rsp), %r12d
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x6a9b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32b0
movl 0x8(%rsp), %eax
movl %eax, 0x150(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x154(%rbx)
movl %r15d, 0xc(%rbx)
movl %ebp, 0x8(%rbx)
movl %r12d, 0x10(%rbx)
movl %r14d, 0x18(%rbx)
movsd 0x10(%rsp), %xmm3
movsd %xmm3, 0x88(%rbx)
movsd 0x18(%rsp), %xmm2
movsd %xmm2, 0x98(%rbx)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0xd0(%rbx)
movb $0x1, 0x40(%rbx)
leal (%r14,%r14), %eax
movl %eax, 0x1c(%rbx)
movsd 0x168cd(%rip), %xmm1    # 0x1d3c8
divsd %xmm3, %xmm1
movsd %xmm1, 0x90(%rbx)
movl %ebp, %ecx
imull %r15d, %ecx
movl %ecx, 0xa0(%rbx)
incl %ebp
imull %ebp, %r15d
movl %r15d, 0xa4(%rbx)
imull %r12d, %r15d
movl %r15d, 0x14(%rbx)
movsd 0x168a0(%rip), %xmm3    # 0x1d3d0
movapd %xmm3, %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, 0xa8(%rbx)
movl %eax, 0xb0(%rbx)
movl %eax, 0xc0(%rbx)
shll $0x2, %r14d
movl %r14d, 0xb8(%rbx)
imull %ebp, %r14d
movl %r14d, 0xb4(%rbx)
divsd %xmm0, %xmm3
movapd %xmm3, %xmm2
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %eax
movl %eax, 0xbc(%rbx)
movsd %xmm3, 0xc8(%rbx)
mulsd 0x16850(%rip), %xmm0    # 0x1d3d8
callq 0x3060
movsd %xmm0, 0xd8(%rbx)
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
movq %rax, 0x118(%rbx)
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
movq %rax, 0x110(%rbx)
movabsq $0x4052c00000000000, %rax # imm = 0x4052C00000000000
movq %rax, 0x108(%rbx)
movabsq $-0x3fad400000000000, %rcx # imm = 0xC052C00000000000
movq %rcx, 0x100(%rbx)
movq %rax, 0xf8(%rbx)
movq %rcx, 0xf0(%rbx)
movq %rax, 0xe8(%rbx)
movq %rcx, 0xe0(%rbx)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x120(%rbx)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x128(%rbx)
movl $0x1, 0x130(%rbx)
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x16a4e(%rip), %rsi     # 0x1d67f
leaq 0x16a57(%rip), %rdx     # 0x1d68f
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x43da
movq %rbx, %rdi
callq 0x60e8
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x6c64
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
jmp 0x6c85
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x6c96
movq (%r13), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x3460