// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::readnav(char const*, bamboo::nav_t*)
extern int readnav(const char *file, nav_t *nav)
{
    FILE *fp;
    eph_t eph0={0};
    geph_t geph0={0};
    char buff[4096],*p;
    long toe_time,tof_time,toc_time,ttr_time;
    int i,sat,prn;
    
    trace(3,"loadnav: file=%s\n",file);
    
    if (!(fp=fopen(file,"r"))) return 0;
    
    while (fgets(buff,sizeof(buff),fp)) {
        if (!strncmp(buff,"IONUTC",6)) {
            for (i=0;i<8;i++) nav->ion_gps[i]=0.0;
            for (i=0;i<4;i++) nav->utc_gps[i]=0.0;
            nav->leaps=0;
            sscanf(buff,"IONUTC,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d",
                   &nav->ion_gps[0],&nav->ion_gps[1],&nav->ion_gps[2],&nav->ion_gps[3],
                   &nav->ion_gps[4],&nav->ion_gps[5],&nav->ion_gps[6],&nav->ion_gps[7],
                   &nav->utc_gps[0],&nav->utc_gps[1],&nav->utc_gps[2],&nav->utc_gps[3],
                   &nav->leaps);
            continue;   
        }
        if ((p=strchr(buff,','))) *p='\0'; else continue;
        if (!(sat=satid2no(buff))) continue;
        if (satsys(sat,&prn)==SYS_GLO) {
            nav->geph[prn-1]=geph0;
            nav->geph[prn-1].sat=sat;
            toe_time=tof_time=0;
            sscanf(p+1,"%d,%d,%d,%d,%d,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
                        "%lf,%lf,%lf,%lf",
                   &nav->geph[prn-1].iode,&nav->geph[prn-1].frq,&nav->geph[prn-1].svh,
                   &nav->geph[prn-1].sva,&nav->geph[prn-1].age,
                   &toe_time,&tof_time,
                   &nav->geph[prn-1].pos[0],&nav->geph[prn-1].pos[1],&nav->geph[prn-1].pos[2],
                   &nav->geph[prn-1].vel[0],&nav->geph[prn-1].vel[1],&nav->geph[prn-1].vel[2],
                   &nav->geph[prn-1].acc[0],&nav->geph[prn-1].acc[1],&nav->geph[prn-1].acc[2],
                   &nav->geph[prn-1].taun  ,&nav->geph[prn-1].gamn  ,&nav->geph[prn-1].dtaun);
            nav->geph[prn-1].toe.time=toe_time;
            nav->geph[prn-1].tof.time=tof_time;
        }
        else {
            nav->eph[sat-1]=eph0;
            nav->eph[sat-1].sat=sat;
            toe_time=toc_time=ttr_time=0;
            sscanf(p+1,"%d,%d,%d,%d,%ld,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
                        "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d,%d",
                   &nav->eph[sat-1].iode,&nav->eph[sat-1].iodc,&nav->eph[sat-1].sva ,
                   &nav->eph[sat-1].svh ,
                   &toe_time,&toc_time,&ttr_time,
                   &nav->eph[sat-1].A   ,&nav->eph[sat-1].e   ,&nav->eph[sat-1].i0  ,
                   &nav->eph[sat-1].OMG0,&nav->eph[sat-1].omg ,&nav->eph[sat-1].M0  ,
                   &nav->eph[sat-1].deln,&nav->eph[sat-1].OMGd,&nav->eph[sat-1].idot,
                   &nav->eph[sat-1].crc ,&nav->eph[sat-1].crs ,&nav->eph[sat-1].cuc ,
                   &nav->eph[sat-1].cus ,&nav->eph[sat-1].cic ,&nav->eph[sat-1].cis ,
                   &nav->eph[sat-1].toes,&nav->eph[sat-1].fit ,&nav->eph[sat-1].f0  ,
                   &nav->eph[sat-1].f1  ,&nav->eph[sat-1].f2  ,&nav->eph[sat-1].tgd[0],
                   &nav->eph[sat-1].code, &nav->eph[sat-1].flag);
            nav->eph[sat-1].toe.time=toe_time;
            nav->eph[sat-1].toc.time=toc_time;
            nav->eph[sat-1].ttr.time=ttr_time;
        }
    }
    fclose(fp);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1128, %rsp           # imm = 0x1128
movq %rsi, -0x30(%rbp)
leaq 0x228d6(%rip), %rsi     # 0x7536c
callq 0x8770
testq %rax, %rax
je 0x53020
movq %rax, %r14
leaq -0x1150(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdx
callq 0x89e0
testq %rax, %rax
je 0x53011
movq -0x30(%rbp), %rax
leaq 0x170(%rax), %rcx
movq %rcx, -0xf0(%rbp)
leaq 0x90(%rax), %rcx
movq %rcx, -0x150(%rbp)
leaq 0x290(%rax), %rcx
movq %rcx, -0x148(%rbp)
leaq 0x178(%rax), %rcx
movq %rcx, -0x140(%rbp)
leaq 0x180(%rax), %rcx
movq %rcx, -0x138(%rbp)
leaq 0x188(%rax), %rcx
movq %rcx, -0x130(%rbp)
leaq 0x190(%rax), %rcx
movq %rcx, -0x128(%rbp)
leaq 0x198(%rax), %rcx
movq %rcx, -0x120(%rbp)
leaq 0x1a0(%rax), %rcx
movq %rcx, -0x118(%rbp)
leaq 0x1a8(%rax), %rcx
movq %rcx, -0x110(%rbp)
leaq 0x98(%rax), %rcx
movq %rcx, -0x108(%rbp)
leaq 0xa0(%rax), %rcx
movq %rcx, -0x100(%rbp)
addq $0xa8, %rax
movq %rax, -0xf8(%rbp)
movl $0x554e4f49, %r13d      # imm = 0x554E4F49
leaq -0x1150(%rbp), %rbx
movq %r14, -0x80(%rbp)
movl -0x1150(%rbp), %eax
xorl %r13d, %eax
movzwl -0x114c(%rbp), %ecx
xorl $0x4354, %ecx           # imm = 0x4354
orl %eax, %ecx
je 0x52d30
movq %rbx, %rdi
movl $0x2c, %esi
callq 0x8250
testq %rax, %rax
je 0x52ff8
movq %rax, %r12
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x4d35a
testl %eax, %eax
je 0x52ff8
movl %eax, %r15d
leal -0x21(%r15), %eax
cmpl $0x1a, %eax
ja 0x52dc8
movl %r15d, %eax
addl $-0x20, %eax
movq -0x30(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rdx, %rbx
imulq $0x98, %rax, %r14
leaq (%rcx,%r14), %rdi
addq $-0x98, %rdi
movl $0x98, %edx
xorl %esi, %esi
callq 0x8390
movq 0x48(%rbx), %rax
leaq (%rax,%r14), %rdx
addq $-0x94, %rdx
movl %r15d, -0x4(%rdx)
xorl %ecx, %ecx
movq %rcx, -0x98(%rbp)
movq %rcx, -0x38(%rbp)
incq %r12
leaq (%rax,%r14), %rcx
addq $-0x90, %rcx
leaq -0x8c(%rax,%r14), %r8
leaq -0x88(%rax,%r14), %r9
leaq -0x84(%rax,%r14), %r15
leaq -0x60(%rax,%r14), %rsi
movq %rsi, -0x78(%rbp)
leaq -0x58(%rax,%r14), %rsi
movq %rsi, -0x70(%rbp)
leaq -0x50(%rax,%r14), %rsi
movq %rsi, -0x68(%rbp)
leaq -0x48(%rax,%r14), %rsi
movq %rsi, -0x60(%rbp)
leaq -0x40(%rax,%r14), %rsi
movq %rsi, -0x58(%rbp)
leaq -0x38(%rax,%r14), %rsi
movq %rsi, -0x50(%rbp)
leaq -0x30(%rax,%r14), %rsi
movq %rsi, -0x48(%rbp)
leaq -0x28(%rax,%r14), %rsi
movq %rsi, -0x40(%rbp)
leaq -0x20(%rax,%r14), %r13
leaq (%rax,%r14), %rbx
addq $-0x18, %rbx
leaq (%rax,%r14), %r10
addq $-0x10, %r10
leaq (%rax,%r14), %r11
addq $-0x8, %r11
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x2248b(%rip), %rsi     # 0x7515b
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %rbx
pushq %r13
pushq -0x40(%rbp)
pushq -0x48(%rbp)
pushq -0x50(%rbp)
pushq -0x58(%rbp)
pushq -0x60(%rbp)
pushq -0x68(%rbp)
pushq -0x70(%rbp)
pushq -0x78(%rbp)
leaq -0x98(%rbp), %r10
pushq %r10
leaq -0x38(%rbp), %r10
pushq %r10
pushq %r15
callq 0x8610
addq $0x80, %rsp
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
movq %rax, -0x80(%rcx,%r14)
movq -0x98(%rbp), %rax
movq %rax, -0x70(%rcx,%r14)
jmp 0x52fe7
xorps %xmm0, %xmm0
movq -0xf0(%rbp), %rdx
movups %xmm0, 0x30(%rdx)
movups %xmm0, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, (%rdx)
movq -0x150(%rbp), %r10
movups %xmm0, 0x10(%r10)
movups %xmm0, (%r10)
movq -0x148(%rbp), %r11
movl $0x0, (%r11)
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0x223ac(%rip), %rsi     # 0x75121
movq -0x140(%rbp), %rcx
movq -0x138(%rbp), %r8
movq -0x130(%rbp), %r9
xorl %eax, %eax
pushq %r11
pushq -0xf8(%rbp)
pushq -0x100(%rbp)
pushq -0x108(%rbp)
pushq %r10
pushq -0x110(%rbp)
pushq -0x118(%rbp)
pushq -0x120(%rbp)
pushq -0x128(%rbp)
callq 0x8610
addq $0x50, %rsp
jmp 0x52ff8
movl %r15d, %eax
decl %eax
shlq $0x5, %rax
leaq (%rax,%rax,8), %r14
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdi
movq %rax, %rbx
addq %r14, %rdi
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x8390
movq 0x40(%rbx), %rax
leaq (%rax,%r14), %rdx
addq $0x4, %rdx
movl %r15d, -0x4(%rdx)
xorl %ecx, %ecx
movq %rcx, -0x88(%rbp)
movq %rcx, -0x90(%rbp)
movq %rcx, -0x38(%rbp)
incq %r12
leaq (%rax,%r14), %rcx
addq $0x8, %rcx
leaq 0xc(%rax,%r14), %r8
leaq 0x10(%rax,%r14), %r9
leaq 0x50(%rax,%r14), %r15
leaq 0x58(%rax,%r14), %rsi
movq %rsi, -0x78(%rbp)
leaq 0x60(%rax,%r14), %rsi
movq %rsi, -0x70(%rbp)
leaq 0x68(%rax,%r14), %rsi
movq %rsi, -0x68(%rbp)
leaq 0x70(%rax,%r14), %rsi
movq %rsi, -0x60(%rbp)
leaq 0x78(%rax,%r14), %rsi
movq %rsi, -0x58(%rbp)
leaq 0x80(%rax,%r14), %rsi
movq %rsi, -0x50(%rbp)
leaq 0x88(%rax,%r14), %rsi
movq %rsi, -0x48(%rbp)
leaq 0x90(%rax,%r14), %rsi
movq %rsi, -0x40(%rbp)
leaq 0x98(%rax,%r14), %rsi
movq %rsi, -0xe8(%rbp)
leaq 0xa0(%rax,%r14), %rsi
movq %rsi, -0xe0(%rbp)
leaq 0xa8(%rax,%r14), %rsi
movq %rsi, -0xd8(%rbp)
leaq 0xb0(%rax,%r14), %rsi
movq %rsi, -0xd0(%rbp)
leaq 0xb8(%rax,%r14), %rsi
movq %rsi, -0xc8(%rbp)
leaq 0xc0(%rax,%r14), %rsi
movq %rsi, -0xc0(%rbp)
leaq 0xc8(%rax,%r14), %rsi
movq %rsi, -0xb8(%rbp)
leaq 0xd0(%rax,%r14), %rsi
movq %rsi, -0xb0(%rbp)
leaq 0xd8(%rax,%r14), %rsi
movq %rsi, -0xa8(%rbp)
leaq 0xe0(%rax,%r14), %rsi
movq %rsi, -0xa0(%rbp)
leaq 0xe8(%rax,%r14), %rbx
leaq 0xf0(%rax,%r14), %r10
leaq 0x18(%rax,%r14), %r13
leaq (%rax,%r14), %r11
addq $0x1c, %r11
movq %r12, %rdi
leaq 0x22267(%rip), %rsi     # 0x751a2
xorl %eax, %eax
pushq %r11
pushq %r13
pushq %r10
pushq %rbx
pushq -0xa0(%rbp)
pushq -0xa8(%rbp)
pushq -0xb0(%rbp)
pushq -0xb8(%rbp)
pushq -0xc0(%rbp)
pushq -0xc8(%rbp)
pushq -0xd0(%rbp)
pushq -0xd8(%rbp)
pushq -0xe0(%rbp)
pushq -0xe8(%rbp)
pushq -0x40(%rbp)
pushq -0x48(%rbp)
pushq -0x50(%rbp)
pushq -0x58(%rbp)
pushq -0x60(%rbp)
pushq -0x68(%rbp)
pushq -0x70(%rbp)
pushq -0x78(%rbp)
pushq %r15
leaq -0x88(%rbp), %r10
pushq %r10
leaq -0x90(%rbp), %r10
pushq %r10
leaq -0x38(%rbp), %r10
pushq %r10
callq 0x8610
addq $0xd0, %rsp
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq %rax, 0x20(%rcx,%r14)
movq -0x90(%rbp), %rax
movq %rax, 0x30(%rcx,%r14)
movq -0x88(%rbp), %rax
movq %rax, 0x40(%rcx,%r14)
movq -0x80(%rbp), %r14
movl $0x554e4f49, %r13d      # imm = 0x554E4F49
leaq -0x1150(%rbp), %rbx
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x89e0
testq %rax, %rax
jne 0x52b8e
movq %r14, %rdi
callq 0x8630
movl $0x1, %eax
jmp 0x53022
xorl %eax, %eax
addq $0x1128, %rsp           # imm = 0x1128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq