// File: /workspace/github_cpp_makefile_star2_O3/Pyboon[P]sage/sage.cpp
// Function: Sage::getAntennaResponse(double, double, int)
MatrixX2cd Sage::getAntennaResponse(double theta, double phi, const int k){
    int theta_index = (int)((theta+90)/180 * 90);
    int phi_index = (int)((phi+180)/360 * 180);
    // k == 1 : tx antenna response 
    if(k==1){
        MatrixX2cd response(config.Tx, 2);
        for(int i = 0; i < config.Tx; ++i){
            response(i, 1) = TxArrayEphi[i](phi_index, theta_index);
            response(i, 0) = TxArrayEtheta[i](phi_index, theta_index);
        }
        return response;

    } else if(k ==2){ // k ==2 : rx antenna response
        MatrixX2cd response(config.Rx, 2);
        for(int i = 0; i < config.Rx; ++i){
            response(i, 1) = RxArrayEphi[i](phi_index, theta_index);
            response(i, 0) = RxArrayEtheta[i](phi_index, theta_index);
        }
        return response;
    } else {
        cerr<<"parameters error"<<endl;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movsd 0x167b4(%rip), %xmm2    # 0x1c1b0
addsd %xmm2, %xmm0
movsd 0x167b0(%rip), %xmm3    # 0x1c1b8
divsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %ebp
movq %rdi, %rbx
addsd %xmm3, %xmm1
divsd 0x1679d(%rip), %xmm1    # 0x1c1c0
mulsd %xmm3, %xmm1
cvttsd2si %xmm1, %r15d
cmpl $0x2, %edx
je 0x5b3d
cmpl $0x1, %edx
jne 0x5c90
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movslq 0xc(%r14), %rdx
testq %rdx, %rdx
js 0x5c71
leaq (%rdx,%rdx), %rsi
movl $0x2, %ecx
movq %rbx, %rdi
callq 0x65de
cmpl $0x0, 0xc(%r14)
jle 0x5c2d
movl %ebp, %eax
orl %r15d, %eax
js 0x5c3b
movslq %r15d, %rax
movslq %ebp, %rcx
movl $0x10, %edx
xorl %esi, %esi
movq %rax, %rdi
shlq $0x4, %rdi
xorl %r8d, %r8d
movq 0x160(%r14), %r10
movq -0x8(%r10,%rdx), %r9
cmpq %rax, %r9
jle 0x5c3b
cmpq %rcx, (%r10,%rdx)
jle 0x5c3b
movq 0x8(%rbx), %r11
cmpq %r8, %r11
jle 0x5c52
imulq %rcx, %r9
shlq $0x4, %r9
addq -0x10(%r10,%rdx), %r9
shlq $0x4, %r11
addq (%rbx), %r11
movups (%rdi,%r9), %xmm0
movups %xmm0, (%rsi,%r11)
movq 0x178(%r14), %r10
movq -0x8(%r10,%rdx), %r9
cmpq %rax, %r9
jle 0x5c3b
cmpq %rcx, (%r10,%rdx)
jle 0x5c3b
cmpq %r8, 0x8(%rbx)
jle 0x5c52
imulq %rcx, %r9
shlq $0x4, %r9
addq -0x10(%r10,%rdx), %r9
movq (%rbx), %r10
movupd (%rdi,%r9), %xmm0
movupd %xmm0, (%r10,%rsi)
incq %r8
movslq 0xc(%r14), %r9
addq $0x18, %rdx
addq $0x10, %rsi
cmpq %r9, %r8
jl 0x5a91
jmp 0x5c2d
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movslq 0x8(%r14), %rdx
testq %rdx, %rdx
js 0x5c71
leaq (%rdx,%rdx), %rsi
movl $0x2, %ecx
movq %rbx, %rdi
callq 0x65de
cmpl $0x0, 0x8(%r14)
jle 0x5c2d
movl %ebp, %eax
orl %r15d, %eax
js 0x5c3b
movslq %r15d, %rax
movslq %ebp, %rcx
movl $0x10, %edx
xorl %esi, %esi
movq %rax, %rdi
shlq $0x4, %rdi
xorl %r8d, %r8d
movq 0x190(%r14), %r10
movq -0x8(%r10,%rdx), %r9
cmpq %rax, %r9
jle 0x5c3b
cmpq %rcx, (%r10,%rdx)
jle 0x5c3b
movq 0x8(%rbx), %r11
cmpq %r8, %r11
jle 0x5c52
imulq %rcx, %r9
shlq $0x4, %r9
addq -0x10(%r10,%rdx), %r9
shlq $0x4, %r11
addq (%rbx), %r11
movupd (%rdi,%r9), %xmm0
movupd %xmm0, (%rsi,%r11)
movq 0x1a8(%r14), %r10
movq -0x8(%r10,%rdx), %r9
cmpq %rax, %r9
jle 0x5c3b
cmpq %rcx, (%r10,%rdx)
jle 0x5c3b
cmpq %r8, 0x8(%rbx)
jle 0x5c52
imulq %rcx, %r9
shlq $0x4, %r9
addq -0x10(%r10,%rdx), %r9
movq (%rbx), %r10
movupd (%rdi,%r9), %xmm0
movupd %xmm0, (%r10,%rsi)
incq %r8
movslq 0x8(%r14), %r9
addq $0x18, %rdx
addq $0x10, %rsi
cmpq %r9, %r8
jl 0x5b90
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16dc5(%rip), %rdi     # 0x1ca07
leaq 0x16df3(%rip), %rsi     # 0x1ca3c
leaq 0x16e0f(%rip), %rcx     # 0x1ca5f
jmp 0x5c67
leaq 0x16dae(%rip), %rdi     # 0x1ca07
leaq 0x16ddc(%rip), %rsi     # 0x1ca3c
leaq 0x16f39(%rip), %rcx     # 0x1cba0
movl $0x16d, %edx            # imm = 0x16D
callq 0x31b0
leaq 0x16a3a(%rip), %rdi     # 0x1c6b2
leaq 0x16bc2(%rip), %rsi     # 0x1c841
leaq 0x16e85(%rip), %rcx     # 0x1cb0b
movl $0x11d, %edx            # imm = 0x11D
callq 0x31b0
callq 0x34f2
jmp 0x5c97
movq %rax, %r14
movq (%rbx), %rdi
callq 0x3310
movq %r14, %rdi
callq 0x3450