// File: Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::SignalConstruct(int)
RowVectorXcd IsiSage::SignalConstruct(const int iL){
    MatrixX2cd C2 = getAntennaResponse(result.theta_rx(iL), result.phi_rx(iL), 2);
    MatrixX2cd C1 = getAntennaResponse(result.theta_tx(iL), result.phi_tx(iL), 1);
    RowVectorXcd signal(config.subchannel_num * config.cycle_num);
    complex<double> temp = 0;
    for(int i_cyc = 0; i_cyc < config.cycle_num; ++i_cyc){
        for(int i_tx = 0; i_tx < config.Tx; ++i_tx){
            for(int i_rx = 0; i_rx < config.Rx; ++i_rx){
                double t = (i_cyc * config.Tcy + i_tx * config.Tt + i_rx * config.Tr) * config.T; 
                temp.real(cos(2*PI* result.doppler(iL) *t));
                temp.imag(sin(2*PI* result.doppler(iL) *t));
                complex<double> pattern_signal = 0;
                for(int p1 = 0; p1 < 2; ++p1){
                    for(int p2 = 0; p2 < 2; ++p2){
                        pattern_signal += result.alpha(2*p1+p2,iL) * C2(i_rx, p1) * C1(i_tx, p2);
                    }
                }
                signal(i_cyc*config.subchannel_num+i_tx*config.Rx+i_rx) = temp * pattern_signal;
            }
        }
    }
    return signal;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
addq $0x200, %rdi            # imm = 0x200
movslq -0x14(%rbp), %rsi
callq 0x14140
movq -0xd0(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
addq $0x210, %rdi            # imm = 0x210
movslq -0x14(%rbp), %rsi
callq 0x14140
movsd -0xd8(%rbp), %xmm0
movq -0xd0(%rbp), %rsi
movsd (%rax), %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0x28(%rbp), %rdi
movl $0x2, %edx
callq *%rax
movq -0xd0(%rbp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0xc8(%rbp)
jmp 0x1c54a
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xf8(%rbp)
addq $0x1f0, %rdi            # imm = 0x1F0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0xf0(%rbp)
jmp 0x1c57d
movsd -0xf8(%rbp), %xmm0
movq -0xd0(%rbp), %rsi
movq -0xf0(%rbp), %rax
movsd (%rax), %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0x38(%rbp), %rdi
movl $0x1, %edx
callq *%rax
jmp 0x1c5ab
movq -0xe8(%rbp), %rdi
movq -0xd0(%rbp), %rax
movb $0x0, -0x45(%rbp)
movl 0x10(%rax), %ecx
movl 0xa0(%rax), %eax
imull %ecx, %eax
movl %eax, -0x4c(%rbp)
leaq -0x4c(%rbp), %rsi
callq 0x21590
jmp 0x1c5d7
leaq -0x60(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x14330
jmp 0x1c5e8
movl $0x0, -0x64(%rbp)
movq -0xd0(%rbp), %rcx
movl -0x64(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0x1c996
movl $0x0, -0x68(%rbp)
movq -0xd0(%rbp), %rcx
movl -0x68(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0x1c986
movl $0x0, -0x6c(%rbp)
movq -0xd0(%rbp), %rcx
movl -0x6c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x1c976
movq -0xd0(%rbp), %rdi
movl -0x64(%rbp), %eax
movl 0xbc(%rdi), %ecx
imull %ecx, %eax
movl -0x68(%rbp), %ecx
movl 0xb4(%rdi), %edx
imull %edx, %ecx
addl %ecx, %eax
movl -0x6c(%rbp), %ecx
movl 0xb8(%rdi), %edx
imull %edx, %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xa8(%rdi), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x100(%rbp)
jmp 0x1c693
movq -0x100(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x531ca(%rip), %xmm1    # 0x6f870
mulsd %xmm1, %xmm0
movsd -0x78(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x9e90
leaq -0x60(%rbp), %rdi
callq 0x13d00
jmp 0x1c6c3
movq -0xd0(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x108(%rbp)
jmp 0x1c6e3
movq -0x108(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x5317a(%rip), %xmm1    # 0x6f870
mulsd %xmm1, %xmm0
movsd -0x78(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x9180
leaq -0x60(%rbp), %rdi
callq 0x13d20
jmp 0x1c713
leaq -0x88(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x14330
jmp 0x1c727
movl $0x0, -0x8c(%rbp)
cmpl $0x2, -0x8c(%rbp)
jge 0x1c8cf
movl $0x0, -0x90(%rbp)
cmpl $0x2, -0x90(%rbp)
jge 0x1c8b9
movq -0xd0(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movl -0x8c(%rbp), %eax
movl -0x90(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movslq %eax, %rsi
movslq -0x14(%rbp), %rdx
callq 0x13c40
movq %rax, -0x110(%rbp)
jmp 0x1c78b
movslq -0x6c(%rbp), %rsi
movslq -0x8c(%rbp), %rdx
leaq -0x28(%rbp), %rdi
callq 0x13e50
movq %rax, -0x118(%rbp)
jmp 0x1c7a8
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdi
callq 0x20310
movsd %xmm1, -0x128(%rbp)
movsd %xmm0, -0x120(%rbp)
jmp 0x1c7cd
movsd -0x128(%rbp), %xmm0
movsd -0x120(%rbp), %xmm1
movsd %xmm1, -0xb0(%rbp)
movsd %xmm0, -0xa8(%rbp)
movslq -0x68(%rbp), %rsi
movslq -0x90(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x13e50
movq %rax, -0x130(%rbp)
jmp 0x1c80a
movq -0x130(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x20310
movsd %xmm1, -0x140(%rbp)
movsd %xmm0, -0x138(%rbp)
jmp 0x1c82f
movsd -0x140(%rbp), %xmm0
movsd -0x138(%rbp), %xmm1
movsd %xmm1, -0xa0(%rbp)
movsd %xmm0, -0x98(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x203e0
jmp 0x1c864
jmp 0x1c866
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x1c748
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c9d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c9ce
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x20040
jmp 0x1c9ce
jmp 0x1c8bb
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x1c731
leaq -0x60(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x20310
movsd %xmm1, -0x150(%rbp)
movsd %xmm0, -0x148(%rbp)
jmp 0x1c8f1
movq -0xe8(%rbp), %rdi
movq -0xd0(%rbp), %rcx
movsd -0x150(%rbp), %xmm0
movsd -0x148(%rbp), %xmm1
movsd %xmm1, -0xc0(%rbp)
movsd %xmm0, -0xb8(%rbp)
movl -0x64(%rbp), %eax
movl 0x8(%rcx), %edx
movl 0xa0(%rcx), %ecx
imull %ecx, %eax
movl -0x68(%rbp), %ecx
imull %edx, %ecx
addl %ecx, %eax
movl -0x6c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x215f0
movq %rax, -0x158(%rbp)
jmp 0x1c94c
movq -0x158(%rbp), %rax
movq -0xc0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xb8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1c623
jmp 0x1c978
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1c609
jmp 0x1c988
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x1c5ef
movb $0x1, -0x45(%rbp)
testb $0x1, -0x45(%rbp)
jne 0x1c9ac
movq -0xe8(%rbp), %rdi
callq 0x20040
leaq -0x38(%rbp), %rdi
callq 0x13f10
leaq -0x28(%rbp), %rdi
callq 0x13f10
movq -0xe0(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x13f10
leaq -0x28(%rbp), %rdi
callq 0x13f10
movq -0x40(%rbp), %rdi
callq 0x9dc0
nopl (%rax)