// File: /workspace/github_cpp_makefile_star2_O1/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 0x16776(%rip), %xmm2    # 0x1c190
addsd %xmm2, %xmm0
movsd 0x16772(%rip), %xmm3    # 0x1c198
divsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %ebp
movq %rdi, %rbx
addsd %xmm3, %xmm1
divsd 0x1675f(%rip), %xmm1    # 0x1c1a0
mulsd %xmm3, %xmm1
cvttsd2si %xmm1, %r15d
cmpl $0x2, %edx
je 0x5b5b
cmpl $0x1, %edx
jne 0x5cae
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movslq 0xc(%r14), %rdx
testq %rdx, %rdx
js 0x5c8f
leaq (%rdx,%rdx), %rsi
movl $0x2, %ecx
movq %rbx, %rdi
callq 0x65fa
cmpl $0x0, 0xc(%r14)
jle 0x5c4b
movl %ebp, %eax
orl %r15d, %eax
js 0x5c59
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 0x5c59
cmpq %rcx, (%r10,%rdx)
jle 0x5c59
movq 0x8(%rbx), %r11
cmpq %r8, %r11
jle 0x5c70
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 0x5c59
cmpq %rcx, (%r10,%rdx)
jle 0x5c59
cmpq %r8, 0x8(%rbx)
jle 0x5c70
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 0x5aaf
jmp 0x5c4b
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movslq 0x8(%r14), %rdx
testq %rdx, %rdx
js 0x5c8f
leaq (%rdx,%rdx), %rsi
movl $0x2, %ecx
movq %rbx, %rdi
callq 0x65fa
cmpl $0x0, 0x8(%r14)
jle 0x5c4b
movl %ebp, %eax
orl %r15d, %eax
js 0x5c59
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 0x5c59
cmpq %rcx, (%r10,%rdx)
jle 0x5c59
movq 0x8(%rbx), %r11
cmpq %r8, %r11
jle 0x5c70
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 0x5c59
cmpq %rcx, (%r10,%rdx)
jle 0x5c59
cmpq %r8, 0x8(%rbx)
jle 0x5c70
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 0x5bae
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16d87(%rip), %rdi     # 0x1c9e7
leaq 0x16db5(%rip), %rsi     # 0x1ca1c
leaq 0x16dd1(%rip), %rcx     # 0x1ca3f
jmp 0x5c85
leaq 0x16d70(%rip), %rdi     # 0x1c9e7
leaq 0x16d9e(%rip), %rsi     # 0x1ca1c
leaq 0x16efb(%rip), %rcx     # 0x1cb80
movl $0x16d, %edx            # imm = 0x16D
callq 0x31b0
leaq 0x169fc(%rip), %rdi     # 0x1c692
leaq 0x16b84(%rip), %rsi     # 0x1c821
leaq 0x16e47(%rip), %rcx     # 0x1caeb
movl $0x11d, %edx            # imm = 0x11D
callq 0x31b0
callq 0x3502
jmp 0x5cb5
movq %rax, %r14
movq (%rbx), %rdi
callq 0x3320
movq %r14, %rdi
callq 0x3460