// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::searchpcv(int, char const*, bamboo::gtime_t, bamboo::pcvs_t const*)
extern pcv_t *searchpcv(int sat, const char *type, gtime_t time,
                        const pcvs_t *pcvs)
{
    pcv_t *pcv;
    char buff[MAXANT],*types[2],*p;
    int i,j,n=0;
    
    trace(3,"searchpcv: sat=%2d type=%s\n",sat,type);
    
    if (sat) { /* search satellite antenna */
        for (i=0;i<pcvs->n;i++) {
            pcv=pcvs->pcv+i;
            if (pcv->sat!=sat) continue;
            if (pcv->ts.time!=0&&timediff(pcv->ts,time)>0.0) continue;
            if (pcv->te.time!=0&&timediff(pcv->te,time)<0.0) continue;
            return pcv;
        }
    }
    else {
        strcpy(buff,type);
        for (p=strtok(buff," ");p&&n<2;p=strtok(NULL," ")) types[n++]=p;
        if (n<=0) return NULL;
        
        /* search receiver antenna with radome at first */
        for (i=0;i<pcvs->n;i++) {
            pcv=pcvs->pcv+i;
            for (j=0;j<n;j++) if (!strstr(pcv->type,types[j])) break;
            if (j>=n) return pcv;
        }
        /* search receiver antenna without radome */
        for (i=0;i<pcvs->n;i++) {
            pcv=pcvs->pcv+i;
            if (strstr(pcv->type,types[0])!=pcv->type) continue;
            
            trace(2,"pcv without radome is used type=%s\n",type);
            return pcv;
        }
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movsd %xmm0, -0x30(%rbp)
testl %edi, %edi
je 0x5199e
movslq (%r14), %r13
testq %r13, %r13
jle 0x51aa5
movq %rdx, %r15
movl %edi, %r12d
movq 0x8(%r14), %rbx
movq %rbx, -0x40(%rbp)
xorl %r14d, %r14d
cmpl %r12d, (%rbx)
jne 0x5198a
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x51951
movsd 0x90(%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r15, %rsi
callq 0x8330
addsd -0x38(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
ja 0x5198a
movq 0x98(%rbx), %rdi
testq %rdi, %rdi
je 0x51aa7
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r15, %rsi
callq 0x8330
addsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x51ab9
incq %r14
addq $0x2b8, %rbx            # imm = 0x2B8
decq %r13
jne 0x5191f
jmp 0x51aa5
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x85c0
leaq 0x23b1b(%rip), %rsi     # 0x754cf
movq %rbx, %rdi
callq 0x89b0
testq %rax, %rax
je 0x51aa5
leaq -0x48(%rbp), %r15
leaq -0x50(%rbp), %rcx
movb $0x1, %r12b
xorl %edx, %edx
leaq 0x23af6(%rip), %rbx     # 0x754cf
movq %rdx, %r13
movq %rax, (%rcx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x89b0
testq %rax, %rax
je 0x51a02
movl $0x1, %edx
movq %r15, %rcx
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x519d9
movslq (%r14), %rcx
movq %rcx, -0x30(%rbp)
testq %rcx, %rcx
jle 0x51aa5
movq %r14, -0x40(%rbp)
movq 0x8(%r14), %rcx
incq %r13
xorl %r12d, %r12d
movq %rcx, -0x38(%rbp)
imulq $0x2b8, %r12, %rax      # imm = 0x2B8
leaq (%rcx,%rax), %rbx
leaq (%rcx,%rax), %r15
addq $0x4, %r15
xorl %r14d, %r14d
movq -0x50(%rbp,%r14,8), %rsi
movq %r15, %rdi
callq 0x8160
testq %rax, %rax
je 0x51a56
incq %r14
cmpq %r14, %r13
jne 0x51a3a
jmp 0x51aa7
incq %r12
cmpq -0x30(%rbp), %r12
movq -0x38(%rbp), %rcx
jne 0x51a24
cmpl $0x0, -0x30(%rbp)
jle 0x51aa5
movq -0x40(%rbp), %rax
movq 0x8(%rax), %r12
movq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0x8290
movq %rax, %r15
xorl %ebx, %ebx
leaq 0x4(%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x82f0
testl %eax, %eax
je 0x51ac9
addq $0x2b8, %r12            # imm = 0x2B8
decq -0x30(%rbp)
jne 0x51a82
jmp 0x51aa7
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
imulq $0x2b8, %r14, %rax      # imm = 0x2B8
movq -0x40(%rbp), %rbx
addq %rax, %rbx
jmp 0x51aa7
movq %r12, %rbx
jmp 0x51aa7