// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movsd 0x17187(%rip), %xmm2    # 0x1c188
addsd %xmm2, %xmm0
movsd 0x17183(%rip), %xmm3    # 0x1c190
divsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %ebx
addsd %xmm3, %xmm1
divsd 0x17173(%rip), %xmm1    # 0x1c198
mulsd %xmm3, %xmm1
cvttsd2si %xmm1, %ebp
cmpl $0x2, %edx
movq %rsi, (%rsp)
jne 0x50df
leaq 0x8(%r15), %rsi
leaq 0x10(%rsp), %rdx
movl $0x2, (%rdx)
movq %rdi, %r14
movq %rsi, 0x8(%rsp)
callq 0x5562
movslq %ebp, %r12
movslq %ebx, %r13
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %rbp
jge 0x5189
movq 0x190(%r15), %rdi
addq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x54d6
movq %rax, %r15
movq %r14, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rdx
callq 0x5596
movupd (%r15), %xmm0
movupd %xmm0, (%rax)
movq (%rsp), %rax
movq 0x1a8(%rax), %rdi
addq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x54d6
movq %rax, %r15
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x5596
movupd (%r15), %xmm0
movupd %xmm0, (%rax)
incq %rbp
addq $0x18, %rbx
movq (%rsp), %r15
jmp 0x5060
cmpl $0x1, %edx
jne 0x519b
leaq 0xc(%r15), %rsi
leaq 0x14(%rsp), %rdx
movl $0x2, (%rdx)
movq %rdi, %r14
movq %rsi, 0x8(%rsp)
callq 0x5562
movslq %ebp, %r12
movslq %ebx, %r13
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %rbp
jge 0x5189
movq 0x160(%r15), %rdi
addq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x54d6
movq %rax, %r15
movq %r14, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rdx
callq 0x5596
movupd (%r15), %xmm0
movupd %xmm0, (%rax)
movq (%rsp), %rax
movq 0x178(%rax), %rdi
addq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x54d6
movq %rax, %r15
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x5596
movupd (%r15), %xmm0
movupd %xmm0, (%rax)
incq %rbp
addq $0x18, %rbx
movq (%rsp), %r15
jmp 0x510e
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34e4e(%rip), %rdi     # 0x39ff0
leaq 0x17116(%rip), %rsi     # 0x1c2bf
callq 0x3250
movq %rax, %rdi
callq 0x3110
jmp 0x51b8
movq %rax, %rbx
movq %r14, %rdi
callq 0x56d8
movq %rbx, %rdi
callq 0x3430
nop