// File: 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
subq $0xf0, %rsp
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x10(%rbp)
movl %edi, -0x1c(%rbp)
movq %rsi, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0x1c(%rbp), %edx
movq -0x28(%rbp), %rcx
movl $0x3, %edi
leaq 0x35bde(%rip), %rsi     # 0xc7a5a
movb $0x0, %al
callq 0x8b980
cmpl $0x0, -0x1c(%rbp)
je 0x91fe6
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x91fe1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x9c(%rbp), %rcx
imulq $0x2b8, %rcx, %rcx      # imm = 0x2B8
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
je 0x91ed6
jmp 0x91fcd
movq -0x38(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x91f4b
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rcx
movq %rcx, -0xb8(%rbp)
movq 0x90(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movsd -0xb0(%rbp), %xmm0
movq -0xc8(%rbp), %rsi
movsd -0xc0(%rbp), %xmm1
callq 0x8e8e0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x91f4b
jmp 0x91fcd
movq -0x38(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0x91fc0
movq -0x38(%rbp), %rax
movq 0x98(%rax), %rcx
movq %rcx, -0xd8(%rbp)
movq 0xa0(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
movsd -0xd0(%rbp), %xmm0
movq -0xe8(%rbp), %rsi
movsd -0xe0(%rbp), %xmm1
callq 0x8e8e0
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x91fc0
jmp 0x91fcd
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x921d6
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x91e97
jmp 0x921ce
leaq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x96f0
leaq -0x80(%rbp), %rdi
leaq 0x36185(%rip), %rsi     # 0xc8183
callq 0x9b70
movq %rax, -0x98(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x98(%rbp)
movb %al, -0xe9(%rbp)
je 0x9202c
cmpl $0x2, -0xa4(%rbp)
setl %al
movb %al, -0xe9(%rbp)
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0x92038
jmp 0x92073
movq -0x98(%rbp), %rcx
movl -0xa4(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0xa4(%rbp)
cltq
movq %rcx, -0x90(%rbp,%rax,8)
xorl %eax, %eax
movl %eax, %edi
leaq 0x3611e(%rip), %rsi     # 0xc8183
callq 0x9b70
movq %rax, -0x98(%rbp)
jmp 0x9200a
cmpl $0x0, -0xa4(%rbp)
jg 0x92089
movq $0x0, -0x8(%rbp)
jmp 0x921d6
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x92142
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x9c(%rbp), %rcx
imulq $0x2b8, %rcx, %rcx      # imm = 0x2B8
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jge 0x92111
movq -0x38(%rbp), %rdi
addq $0x4, %rdi
movslq -0xa0(%rbp), %rax
movq -0x90(%rbp,%rax,8), %rsi
callq 0x91b0
cmpq $0x0, %rax
jne 0x920fe
jmp 0x92111
jmp 0x92100
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x920cc
movl -0xa0(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jl 0x9212c
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x921d6
jmp 0x9212e
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x92093
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x921cc
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x9c(%rbp), %rcx
imulq $0x2b8, %rcx, %rcx      # imm = 0x2B8
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
addq $0x4, %rdi
movq -0x90(%rbp), %rsi
callq 0x91b0
movq -0x38(%rbp), %rcx
addq $0x4, %rcx
cmpq %rcx, %rax
je 0x9219a
jmp 0x921bb
movq -0x28(%rbp), %rdx
movl $0x2, %edi
leaq 0x358cc(%rip), %rsi     # 0xc7a76
movb $0x0, %al
callq 0x8b980
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x921d6
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x9214c
jmp 0x921ce
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)