// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movsd %xmm0, -0x30(%rbp)
testl %edi, %edi
je 0x523ad
movslq (%rcx), %r13
testq %r13, %r13
jle 0x524d6
movq %rdx, %r15
movl %edi, %r12d
movq 0x8(%rcx), %rbx
movq %rbx, -0x40(%rbp)
xorl %r14d, %r14d
cmpl %r12d, (%rbx)
jne 0x52399
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x52360
movsd 0x90(%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r15, %rsi
callq 0x8330
addsd -0x38(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
ja 0x52399
movq 0x98(%rbx), %rdi
testq %rdi, %rdi
je 0x524ea
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 0x524d8
incq %r14
addq $0x2b8, %rbx            # imm = 0x2B8
decq %r13
jne 0x5232e
jmp 0x524d6
movq %rcx, -0x30(%rbp)
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
callq 0x85c0
leaq 0x2312e(%rip), %rsi     # 0x754f5
movq %rbx, %rdi
callq 0x89c0
testq %rax, %rax
je 0x52400
xorl %r15d, %r15d
leaq 0x23117(%rip), %rbx     # 0x754f5
leaq 0x1(%r15), %r14
movq %rax, -0x50(%rbp,%r15,8)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x89c0
testq %rax, %rax
je 0x52403
testq %r15, %r15
movq %r14, %r15
je 0x523de
jmp 0x52403
xorl %r14d, %r14d
testl %r14d, %r14d
je 0x524d6
movq -0x30(%rbp), %rax
movslq (%rax), %r13
testq %r13, %r13
jle 0x52496
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movl %r14d, %ecx
movq %rax, %r14
movq -0x50(%rbp), %rsi
movq %rcx, -0x58(%rbp)
leaq -0x1(%rcx), %r15
xorl %eax, %eax
movq %r14, -0x60(%rbp)
movq %rsi, -0x40(%rbp)
movq %rax, -0x38(%rbp)
imulq $0x2b8, %rax, %rbx      # imm = 0x2B8
leaq (%r14,%rbx), %r12
addq $0x4, %r12
movq %r12, %rdi
callq 0x8160
testq %rax, %rax
je 0x52486
addq %r14, %rbx
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x524d8
movq -0x48(%rbp,%r14,8), %rsi
movq %r12, %rdi
callq 0x8160
incq %r14
testq %rax, %rax
jne 0x52462
cmpq -0x58(%rbp), %r14
movq -0x60(%rbp), %r14
jae 0x524d8
movq -0x38(%rbp), %rax
incq %rax
cmpq %r13, %rax
movq -0x40(%rbp), %rsi
jne 0x5243c
testl %r13d, %r13d
jle 0x524d6
movq -0x30(%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 0x524fa
addq $0x2b8, %r12            # imm = 0x2B8
decq %r13
jne 0x524b4
jmp 0x524d8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x78, %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 0x524d8
movq %r12, %rbx
jmp 0x524d8