// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
leaq 0x21024(%rip), %rsi     # 0x6b382
callq 0x8750
testq %rax, %rax
je 0x4a8de
movq %rax, %r13
leaq 0x170(%rbx), %r15
movq %rbx, %rax
addq $0x90, %rbx
leaq 0x290(%rax), %rcx
movq %rcx, -0x150(%rbp)
leaq 0x178(%rax), %rcx
movq %rcx, -0x148(%rbp)
leaq 0x180(%rax), %rcx
movq %rcx, -0x140(%rbp)
leaq 0x188(%rax), %rcx
movq %rcx, -0x138(%rbp)
leaq 0x190(%rax), %rcx
movq %rcx, -0x130(%rbp)
leaq 0x198(%rax), %rcx
movq %rcx, -0x128(%rbp)
leaq 0x1a0(%rax), %rcx
movq %rcx, -0x120(%rbp)
leaq 0x1a8(%rax), %rcx
movq %rcx, -0x118(%rbp)
leaq 0x98(%rax), %rcx
movq %rcx, -0x110(%rbp)
leaq 0xa0(%rax), %rcx
movq %rcx, -0x108(%rbp)
movq %rax, -0x40(%rbp)
addq $0xa8, %rax
movq %rax, -0x100(%rbp)
leaq -0x1150(%rbp), %r14
movq %r13, -0x90(%rbp)
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r13, %rdx
callq 0x89d0
testq %rax, %rax
je 0x4a8d1
movq %r14, %rdi
leaq 0x20ce2(%rip), %rsi     # 0x6b130
pushq $0x6
popq %rdx
callq 0x8640
testl %eax, %eax
je 0x4a5fd
movq %r14, %rdi
pushq $0x2c
popq %rsi
callq 0x8250
testq %rax, %rax
je 0x4a42b
movb $0x0, (%rax)
movq %r14, %rdi
movq %rax, -0x48(%rbp)
callq 0x453cc
testl %eax, %eax
je 0x4a42b
movl %eax, %r12d
movl %eax, %edi
leaq -0x2c(%rbp), %rsi
callq 0x45362
cmpl $0x4, %eax
jne 0x4a68f
movq -0x40(%rbp), %rcx
movq 0x48(%rcx), %rax
movq %rcx, %r14
movslq -0x2c(%rbp), %rcx
imulq $0x98, %rcx, %r13
leaq (%rax,%r13), %rdi
addq $-0x98, %rdi
movl $0x98, %edx
xorl %esi, %esi
callq 0x8390
movq 0x48(%r14), %rax
movl %r12d, -0x98(%rax,%r13)
movslq -0x2c(%rbp), %rcx
imulq $0x98, %rcx, %rsi
leaq (%rax,%rsi), %rdx
addq $-0x94, %rdx
leaq -0x90(%rax,%rsi), %rcx
leaq -0x8c(%rax,%rsi), %r8
leaq -0x88(%rax,%rsi), %r9
leaq -0x84(%rax,%rsi), %r12
leaq -0x60(%rax,%rsi), %rdi
movq %rdi, -0x88(%rbp)
leaq -0x58(%rax,%rsi), %rdi
movq %rdi, -0x80(%rbp)
leaq -0x50(%rax,%rsi), %rdi
movq %rdi, -0x78(%rbp)
leaq -0x48(%rax,%rsi), %rdi
movq %rdi, -0x70(%rbp)
leaq -0x40(%rax,%rsi), %rdi
movq %rdi, -0x68(%rbp)
leaq -0x38(%rax,%rsi), %rdi
movq %rdi, -0x60(%rbp)
leaq -0x30(%rax,%rsi), %rdi
movq %rdi, -0x58(%rbp)
leaq -0x28(%rax,%rsi), %rdi
movq %rdi, -0x50(%rbp)
leaq -0x20(%rax,%rsi), %r11
leaq (%rax,%rsi), %r14
addq $-0x18, %r14
leaq (%rax,%rsi), %r13
addq $-0x10, %r13
leaq (%rax,%rsi), %r10
addq $-0x8, %r10
andq $0x0, -0xa8(%rbp)
andq $0x0, -0x38(%rbp)
movq -0x48(%rbp), %rdi
incq %rdi
subq $0x8, %rsp
leaq 0x20be3(%rip), %rsi     # 0x6b171
xorl %eax, %eax
pushq %r10
pushq %r13
pushq %r14
pushq %r11
pushq -0x50(%rbp)
pushq -0x58(%rbp)
pushq -0x60(%rbp)
pushq -0x68(%rbp)
pushq -0x70(%rbp)
pushq -0x78(%rbp)
pushq -0x80(%rbp)
pushq -0x88(%rbp)
leaq -0xa8(%rbp), %r10
pushq %r10
leaq -0x38(%rbp), %r10
pushq %r10
pushq %r12
callq 0x8600
addq $0x80, %rsp
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x48(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x98, %rdx, %rdx
movq %rax, -0x80(%rcx,%rdx)
movq -0xa8(%rbp), %rax
movq %rax, -0x70(%rcx,%rdx)
jmp 0x4a8be
xorl %eax, %eax
cmpq $0x8, %rax
je 0x4a60f
andq $0x0, (%r15,%rax,8)
incq %rax
jmp 0x4a5ff
xorl %eax, %eax
cmpq $0x4, %rax
je 0x4a621
andq $0x0, (%rbx,%rax,8)
incq %rax
jmp 0x4a611
movq -0x150(%rbp), %r10
andl $0x0, (%r10)
subq $0x8, %rsp
movq %r14, %rdi
leaq 0x20afd(%rip), %rsi     # 0x6b137
movq %r15, %rdx
movq -0x148(%rbp), %rcx
movq -0x140(%rbp), %r8
movq -0x138(%rbp), %r9
xorl %eax, %eax
pushq %r10
pushq -0x100(%rbp)
pushq -0x108(%rbp)
pushq -0x110(%rbp)
pushq %rbx
pushq -0x118(%rbp)
pushq -0x120(%rbp)
pushq -0x128(%rbp)
pushq -0x130(%rbp)
callq 0x8600
addq $0x50, %rsp
jmp 0x4a42b
movl %r12d, %eax
decl %eax
imulq $0x120, %rax, %r13      # imm = 0x120
movq -0x40(%rbp), %rax
movq 0x40(%rax), %rdi
movq %rax, %r14
addq %r13, %rdi
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x8390
movq 0x40(%r14), %rax
leaq (%rax,%r13), %rdx
addq $0x4, %rdx
movl %r12d, -0x4(%rdx)
andq $0x0, -0x98(%rbp)
andq $0x0, -0xa0(%rbp)
andq $0x0, -0x38(%rbp)
movq -0x48(%rbp), %rdi
incq %rdi
leaq (%rax,%r13), %rcx
addq $0x8, %rcx
leaq 0xc(%rax,%r13), %r8
leaq 0x10(%rax,%r13), %r9
leaq 0x50(%rax,%r13), %r12
leaq 0x58(%rax,%r13), %rsi
movq %rsi, -0x48(%rbp)
leaq 0x60(%rax,%r13), %rsi
movq %rsi, -0x88(%rbp)
leaq 0x68(%rax,%r13), %rsi
movq %rsi, -0x80(%rbp)
leaq 0x70(%rax,%r13), %rsi
movq %rsi, -0x78(%rbp)
leaq 0x78(%rax,%r13), %rsi
movq %rsi, -0x70(%rbp)
leaq 0x80(%rax,%r13), %rsi
movq %rsi, -0x68(%rbp)
leaq 0x88(%rax,%r13), %rsi
movq %rsi, -0x60(%rbp)
leaq 0x90(%rax,%r13), %rsi
movq %rsi, -0x58(%rbp)
leaq 0x98(%rax,%r13), %rsi
movq %rsi, -0x50(%rbp)
leaq 0xa0(%rax,%r13), %rsi
movq %rsi, -0xf8(%rbp)
leaq 0xa8(%rax,%r13), %rsi
movq %rsi, -0xf0(%rbp)
leaq 0xb0(%rax,%r13), %rsi
movq %rsi, -0xe8(%rbp)
leaq 0xb8(%rax,%r13), %rsi
movq %rsi, -0xe0(%rbp)
leaq 0xc0(%rax,%r13), %rsi
movq %rsi, -0xd8(%rbp)
leaq 0xc8(%rax,%r13), %rsi
movq %rsi, -0xd0(%rbp)
leaq 0xd0(%rax,%r13), %rsi
movq %rsi, -0xc8(%rbp)
leaq 0xd8(%rax,%r13), %rsi
movq %rsi, -0xc0(%rbp)
leaq 0xe0(%rax,%r13), %rsi
movq %rsi, -0xb8(%rbp)
leaq 0xe8(%rax,%r13), %rsi
movq %rsi, -0xb0(%rbp)
leaq 0xf0(%rax,%r13), %r14
leaq (%rax,%r13), %r10
addq $0x18, %r10
leaq (%rax,%r13), %r11
addq $0x1c, %r11
leaq 0x209ab(%rip), %rsi     # 0x6b1b8
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r14
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 -0xf0(%rbp)
pushq -0xf8(%rbp)
pushq -0x50(%rbp)
pushq -0x58(%rbp)
pushq -0x60(%rbp)
pushq -0x68(%rbp)
pushq -0x70(%rbp)
pushq -0x78(%rbp)
pushq -0x80(%rbp)
pushq -0x88(%rbp)
pushq -0x48(%rbp)
pushq %r12
leaq -0x98(%rbp), %r10
pushq %r10
leaq -0xa0(%rbp), %r10
pushq %r10
leaq -0x38(%rbp), %r10
pushq %r10
callq 0x8600
addq $0xd0, %rsp
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq %rax, 0x20(%rcx,%r13)
movq -0xa0(%rbp), %rax
movq %rax, 0x30(%rcx,%r13)
movq -0x98(%rbp), %rax
movq %rax, 0x40(%rcx,%r13)
movq -0x90(%rbp), %r13
leaq -0x1150(%rbp), %r14
jmp 0x4a42b
movq %r13, %rdi
callq 0x8620
pushq $0x1
popq %rax
jmp 0x4a8e0
xorl %eax, %eax
addq $0x1128, %rsp           # imm = 0x1128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq