// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movl %esi, %r13d
movq %rdi, %rbx
leaq 0x1746b(%rip), %rsi     # 0x1d6b0
leaq 0x48(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x3b5e
leaq 0x48(%rsp), %rdi
callq 0x547e
leaq 0x48(%rsp), %rdi
callq 0x3100
movl %r13d, 0x150(%rbx)
movl %r12d, 0x154(%rbx)
movl %r15d, 0xc(%rbx)
movl %ebp, 0x8(%rbx)
movl 0xa0(%rsp), %edx
movl %edx, 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 0x17108(%rip), %xmm1    # 0x1d3d0
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 %edx, %r15d
movl %r15d, 0x14(%rbx)
movsd 0x170db(%rip), %xmm3    # 0x1d3d8
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 0x1708b(%rip), %xmm0    # 0x1d3e0
callq 0x3050
movsd %xmm0, 0xd8(%rbx)
movaps 0x170a7(%rip), %xmm0    # 0x1d410
movups %xmm0, 0x110(%rbx)
movaps 0x170a9(%rip), %xmm0    # 0x1d420
movups %xmm0, 0x100(%rbx)
movups %xmm0, 0xf0(%rbx)
movups %xmm0, 0xe0(%rbx)
movaps 0x15c8d(%rip), %xmm0    # 0x1c020
movups %xmm0, 0x120(%rbx)
movl $0x1, 0x130(%rbx)
leaq 0x17314(%rip), %rsi     # 0x1d6bf
leaq 0x28(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x3b5e
leaq 0x28(%rsp), %rdi
callq 0x547e
leaq 0x28(%rsp), %rdi
callq 0x3100
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x63f1
jmp 0x63f8
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3100
jmp 0x63fb
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3430
nop