// File: /workspace/github_cpp_makefile_star2_O3/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 0x16cc0(%rip), %rsi     # 0x1d700
leaq 0x16cc7(%rip), %rdx     # 0x1d70e
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x43cc
movq %r12, %rdi
callq 0x60be
movl 0xa0(%rsp), %r12d
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x6a7b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32a0
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 0x1690d(%rip), %xmm1    # 0x1d3e8
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 0x168e0(%rip), %xmm3    # 0x1d3f0
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 0x16890(%rip), %xmm0    # 0x1d3f8
callq 0x3060
movsd %xmm0, 0xd8(%rbx)
movaps 0x168b4(%rip), %xmm0    # 0x1d430
movups %xmm0, 0x110(%rbx)
movaps 0x168b6(%rip), %xmm0    # 0x1d440
movups %xmm0, 0x100(%rbx)
movups %xmm0, 0xf0(%rbx)
movups %xmm0, 0xe0(%rbx)
movaps 0x1547a(%rip), %xmm0    # 0x1c020
movups %xmm0, 0x120(%rbx)
movl $0x1, 0x130(%rbx)
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x16b48(%rip), %rsi     # 0x1d70f
leaq 0x16b51(%rip), %rdx     # 0x1d71f
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x43cc
movq %rbx, %rdi
callq 0x60be
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x6bfa
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32a0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
jmp 0x6c1b
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x6c2c
movq (%r13), %rsi
incq %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3450