// File: DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::readantex(char const*, bamboo::pcvs_t*)
static int readantex(const char *file, pcvs_t *pcvs)
{
    FILE *fp;
    static const pcv_t pcv0={0};
    pcv_t pcv;
    double neu[3];
    int i,f,freq=0,state=0,freqs[]={1,2,5,6,7,8,0};
    char buff[256];
    
    trace(3,"readantex: file=%s\n",file);
    
    if (!(fp=fopen(file,"r"))) {
        trace(2,"antex pcv file open error: %s\n",file);
        return 0;
    }
    while (fgets(buff,sizeof(buff),fp)) {
        
        if (strlen(buff)<60||strstr(buff+60,"COMMENT")) continue;
        
        if (strstr(buff+60,"START OF ANTENNA")) {
            pcv=pcv0;
            state=1;
        }
        if (strstr(buff+60,"END OF ANTENNA")) {
            addpcv(&pcv,pcvs);
            state=0;
        }
        if (!state) continue;
        
        if (strstr(buff+60,"TYPE / SERIAL NO")) {
            strncpy(pcv.type,buff   ,20); pcv.type[20]='\0';
            strncpy(pcv.code,buff+20,20); pcv.code[20]='\0';
            if (!strncmp(pcv.code+3,"        ",8)) {
                pcv.sat=satid2no(pcv.code);
            }
        }
        else if (strstr(buff+60,"VALID FROM")) {
            if (!str2time(buff,0,43,&pcv.ts)) continue;
        }
        else if (strstr(buff+60,"VALID UNTIL")) {
            if (!str2time(buff,0,43,&pcv.te)) continue;
        }
        else if (strstr(buff+60,"START OF FREQUENCY")) {
            if (sscanf(buff+4,"%d",&f)<1) continue;
            for (i=0;i<NFREQ;i++) if (freqs[i]==f) break;
            if (i<NFREQ) freq=i+1;
        }
        else if (strstr(buff+60,"END OF FREQUENCY")) {
            freq=0;
        }
        else if (strstr(buff+60,"NORTH / EAST / UP")) {
            if (freq<1||NFREQ<freq) continue;
            if (decodef(buff,3,neu)<3) continue;
            pcv.off[freq-1][0]=neu[pcv.sat?0:1]; /* x or e */
            pcv.off[freq-1][1]=neu[pcv.sat?1:0]; /* y or n */
            pcv.off[freq-1][2]=neu[2];           /* z or u */
        }
        else if (strstr(buff,"NOAZI")) {
            if (freq<1||NFREQ<freq) continue;
            if ((i=decodef(buff+8,19,pcv.var[freq-1]))<=0) continue;
            for (;i<19;i++) pcv.var[freq-1][i]=pcv.var[freq-1][i-1];
        }
    }
    fclose(fp);
    
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x2fc(%rbp)
movl $0x0, -0x300(%rbp)
movq 0x36d32(%rip), %rax     # 0xc82e0
movq %rax, -0x320(%rbp)
movq 0x36d2c(%rip), %rax     # 0xc82e8
movq %rax, -0x318(%rbp)
movq 0x36d26(%rip), %rax     # 0xc82f0
movq %rax, -0x310(%rbp)
movl 0x36d21(%rip), %eax     # 0xc82f8
movl %eax, -0x308(%rbp)
movq -0x10(%rbp), %rdx
movl $0x3, %edi
leaq 0x36b2b(%rip), %rsi     # 0xc8118
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rdi
leaq 0x368a0(%rip), %rsi     # 0xc7e9f
callq 0x98d0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x91631
movq -0x10(%rbp), %rdx
movl $0x2, %edi
leaq 0x36b0e(%rip), %rsi     # 0xc812c
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x4(%rbp)
jmp 0x91b55
jmp 0x91633
leaq -0x420(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x9ba0
cmpq $0x0, %rax
je 0x91b45
leaq -0x420(%rbp), %rdi
callq 0x92e0
cmpq $0x3c, %rax
jb 0x91681
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x2c283(%rip), %rsi     # 0xbd8f9
callq 0x91b0
cmpq $0x0, %rax
je 0x91683
jmp 0x91633
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x36ab6(%rip), %rsi     # 0xc814b
callq 0x91b0
cmpq $0x0, %rax
je 0x916c2
leaq -0x2d8(%rbp), %rdi
leaq 0x35612(%rip), %rsi     # 0xc6cc0
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x9610
movl $0x1, -0x300(%rbp)
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x36a88(%rip), %rsi     # 0xc815c
callq 0x91b0
cmpq $0x0, %rax
je 0x916f9
movq -0x18(%rbp), %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x997e0
movl $0x0, -0x300(%rbp)
cmpl $0x0, -0x300(%rbp)
jne 0x91707
jmp 0x91633
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x36a52(%rip), %rsi     # 0xc816b
callq 0x91b0
cmpq $0x0, %rax
je 0x917b2
leaq -0x2d8(%rbp), %rdi
addq $0x4, %rdi
leaq -0x420(%rbp), %rsi
movl $0x14, %edx
callq 0x93b0
movb $0x0, -0x2c0(%rbp)
leaq -0x2d8(%rbp), %rdi
addq $0x44, %rdi
leaq -0x420(%rbp), %rsi
addq $0x14, %rsi
movl $0x14, %edx
callq 0x93b0
movb $0x0, -0x280(%rbp)
leaq -0x2d8(%rbp), %rdi
addq $0x44, %rdi
addq $0x3, %rdi
leaq 0x369f4(%rip), %rsi     # 0xc817c
movl $0x8, %edx
callq 0x9360
cmpl $0x0, %eax
jne 0x917ad
leaq -0x2d8(%rbp), %rdi
addq $0x44, %rdi
callq 0x8b510
movl %eax, -0x2d8(%rbp)
jmp 0x91b40
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x369c1(%rip), %rsi     # 0xc8185
callq 0x91b0
cmpq $0x0, %rax
je 0x917ff
leaq -0x420(%rbp), %rdi
leaq -0x2d8(%rbp), %rcx
addq $0x88, %rcx
xorl %esi, %esi
movl $0x2b, %edx
callq 0x8dfc0
cmpl $0x0, %eax
jne 0x917fa
jmp 0x91633
jmp 0x91b3e
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x3697f(%rip), %rsi     # 0xc8190
callq 0x91b0
cmpq $0x0, %rax
je 0x9184c
leaq -0x420(%rbp), %rdi
leaq -0x2d8(%rbp), %rcx
addq $0x98, %rcx
xorl %esi, %esi
movl $0x2b, %edx
callq 0x8dfc0
cmpl $0x0, %eax
jne 0x91847
jmp 0x91633
jmp 0x91b3c
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x3693e(%rip), %rsi     # 0xc819c
callq 0x91b0
cmpq $0x0, %rax
je 0x918f2
leaq -0x420(%rbp), %rdi
addq $0x4, %rdi
leaq 0x3767b(%rip), %rsi     # 0xc8efa
leaq -0x2f8(%rbp), %rdx
movb $0x0, %al
callq 0x9750
cmpl $0x1, %eax
jge 0x91897
jmp 0x91633
movl $0x0, -0x2f4(%rbp)
cmpl $0x3, -0x2f4(%rbp)
jge 0x918d5
movslq -0x2f4(%rbp), %rax
movl -0x320(%rbp,%rax,4), %eax
cmpl -0x2f8(%rbp), %eax
jne 0x918c2
jmp 0x918d5
jmp 0x918c4
movl -0x2f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2f4(%rbp)
jmp 0x918a1
cmpl $0x3, -0x2f4(%rbp)
jge 0x918ed
movl -0x2f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2fc(%rbp)
jmp 0x91b3a
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x368ab(%rip), %rsi     # 0xc81af
callq 0x91b0
cmpq $0x0, %rax
je 0x9191e
movl $0x0, -0x2fc(%rbp)
jmp 0x91b38
leaq -0x420(%rbp), %rdi
addq $0x3c, %rdi
leaq 0x36890(%rip), %rsi     # 0xc81c0
callq 0x91b0
cmpq $0x0, %rax
je 0x91a33
cmpl $0x1, -0x2fc(%rbp)
jl 0x91955
movl $0x3, %eax
cmpl -0x2fc(%rbp), %eax
jge 0x9195a
jmp 0x91633
leaq -0x420(%rbp), %rdi
leaq -0x2f0(%rbp), %rdx
movl $0x3, %esi
callq 0x998c0
cmpl $0x3, %eax
jge 0x9197c
jmp 0x91633
movl -0x2d8(%rbp), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
cltq
movsd -0x2f0(%rbp,%rax,8), %xmm0
leaq -0x2d8(%rbp), %rax
addq $0xa8, %rax
movl -0x2fc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movl -0x2d8(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
cltq
movsd -0x2f0(%rbp,%rax,8), %xmm0
leaq -0x2d8(%rbp), %rax
addq $0xa8, %rax
movl -0x2fc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movsd -0x2e0(%rbp), %xmm0
leaq -0x2d8(%rbp), %rax
addq $0xa8, %rax
movl -0x2fc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
jmp 0x91b36
leaq -0x420(%rbp), %rdi
leaq 0x36791(%rip), %rsi     # 0xc81d2
callq 0x91b0
cmpq $0x0, %rax
je 0x91b34
cmpl $0x1, -0x2fc(%rbp)
jl 0x91a66
movl $0x3, %eax
cmpl -0x2fc(%rbp), %eax
jge 0x91a6b
jmp 0x91633
leaq -0x420(%rbp), %rdi
addq $0x8, %rdi
leaq -0x2d8(%rbp), %rdx
addq $0xf0, %rdx
movl -0x2fc(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x98, %rax, %rax
addq %rax, %rdx
movl $0x13, %esi
callq 0x998c0
movl %eax, -0x2f4(%rbp)
cmpl $0x0, %eax
jg 0x91ab3
jmp 0x91633
jmp 0x91ab5
cmpl $0x13, -0x2f4(%rbp)
jge 0x91b32
leaq -0x2d8(%rbp), %rax
addq $0xf0, %rax
movl -0x2fc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movl -0x2f4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
leaq -0x2d8(%rbp), %rax
addq $0xf0, %rax
movl -0x2fc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movslq -0x2f4(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2f4(%rbp)
jmp 0x91ab5
jmp 0x91b34
jmp 0x91b36
jmp 0x91b38
jmp 0x91b3a
jmp 0x91b3c
jmp 0x91b3e
jmp 0x91b40
jmp 0x91633
movq -0x20(%rbp), %rdi
callq 0x9770
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
nopw %cs:(%rax,%rax)