// File: /workspace/github_cpp_makefile_star2_O1/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 0x21e83(%rip), %rsi     # 0x7538c
callq 0x8780
testq %rax, %rax
je 0x53ab8
movq %rax, %r14
leaq -0x1150(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdx
callq 0x89f0
testq %rax, %rax
je 0x53aa9
movq -0x30(%rbp), %rax
leaq 0x170(%rax), %rcx
movq %rcx, -0x150(%rbp)
leaq 0x90(%rax), %rcx
movq %rcx, -0x148(%rbp)
leaq 0x290(%rax), %rcx
movq %rcx, -0x140(%rbp)
leaq 0x178(%rax), %rcx
movq %rcx, -0x138(%rbp)
leaq 0x180(%rax), %rcx
movq %rcx, -0x130(%rbp)
leaq 0x188(%rax), %rcx
movq %rcx, -0x128(%rbp)
leaq 0x190(%rax), %rcx
movq %rcx, -0x120(%rbp)
leaq 0x198(%rax), %rcx
movq %rcx, -0x118(%rbp)
leaq 0x1a0(%rax), %rcx
movq %rcx, -0x110(%rbp)
leaq 0x1a8(%rax), %rcx
movq %rcx, -0x108(%rbp)
leaq 0x98(%rax), %rcx
movq %rcx, -0x100(%rbp)
leaq 0xa0(%rax), %rcx
movq %rcx, -0xf8(%rbp)
addq $0xa8, %rax
movq %rax, -0xf0(%rbp)
movl $0x554e4f49, %r15d      # imm = 0x554E4F49
leaq -0x1150(%rbp), %r13
movq %r14, -0x80(%rbp)
movl -0x1150(%rbp), %eax
xorl %r15d, %eax
movzwl -0x114c(%rbp), %ecx
xorl $0x4354, %ecx           # imm = 0x4354
orl %eax, %ecx
je 0x5365b
movq %r13, %rdi
movl $0x2c, %esi
callq 0x8250
testq %rax, %rax
je 0x53a90
movq %rax, %r12
movb $0x0, (%rax)
movq %r13, %rdi
callq 0x4dc92
testl %eax, %eax
je 0x53a90
movl %eax, %ebx
cmpl $0x21, %eax
jae 0x536f3
xorl %ecx, %ecx
movl %ebx, %eax
jmp 0x5371a
movq -0x150(%rbp), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdx)
movups %xmm0, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, (%rdx)
movq -0x148(%rbp), %r10
movups %xmm0, 0x10(%r10)
movups %xmm0, (%r10)
movq -0x140(%rbp), %r11
movl $0x0, (%r11)
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x21aa1(%rip), %rsi     # 0x75141
movq -0x138(%rbp), %rcx
movq -0x130(%rbp), %r8
movq -0x128(%rbp), %r9
xorl %eax, %eax
pushq %r11
pushq -0xf0(%rbp)
pushq -0xf8(%rbp)
pushq -0x100(%rbp)
pushq %r10
pushq -0x108(%rbp)
pushq -0x110(%rbp)
pushq -0x118(%rbp)
pushq -0x120(%rbp)
callq 0x8610
addq $0x50, %rsp
jmp 0x53a90
cmpl $0x3b, %ebx
ja 0x536ff
leal -0x20(%rbx), %eax
movb $0x1, %cl
jmp 0x5371a
cmpl $0x5f, %ebx
ja 0x53709
leal -0x3b(%rbx), %eax
jmp 0x53718
leal -0xd(%rbx), %ecx
leal -0x5f(%rbx), %eax
cmpl $0x85, %ebx
cmovael %ecx, %eax
xorl %ecx, %ecx
incq %r12
testb %cl, %cl
je 0x53865
movq -0x30(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rdx, %r15
cltq
imulq $0x98, %rax, %r14
leaq (%rcx,%r14), %rdi
addq $-0x98, %rdi
movl $0x98, %edx
xorl %esi, %esi
callq 0x8390
movq 0x48(%r15), %rax
leaq (%rax,%r14), %rdx
addq $-0x94, %rdx
movl %ebx, -0x4(%rdx)
xorl %ecx, %ecx
movq %rcx, -0x98(%rbp)
movq %rcx, -0x38(%rbp)
leaq (%rax,%r14), %rcx
addq $-0x90, %rcx
leaq -0x8c(%rax,%r14), %r8
leaq -0x88(%rax,%r14), %r9
leaq -0x84(%rax,%r14), %rsi
movq %rsi, -0x78(%rbp)
leaq -0x60(%rax,%r14), %rsi
movq %rsi, -0x70(%rbp)
leaq -0x58(%rax,%r14), %rsi
movq %rsi, -0x68(%rbp)
leaq -0x50(%rax,%r14), %rsi
movq %rsi, -0x60(%rbp)
leaq -0x48(%rax,%r14), %rsi
movq %rsi, -0x58(%rbp)
leaq -0x40(%rax,%r14), %rsi
movq %rsi, -0x50(%rbp)
leaq -0x38(%rax,%r14), %rsi
movq %rsi, -0x48(%rbp)
leaq -0x30(%rax,%r14), %rsi
movq %rsi, -0x40(%rbp)
leaq -0x28(%rax,%r14), %r10
leaq -0x20(%rax,%r14), %r11
leaq (%rax,%r14), %rbx
addq $-0x18, %rbx
leaq (%rax,%r14), %r13
addq $-0x10, %r13
leaq (%rax,%r14), %r15
addq $-0x8, %r15
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x21976(%rip), %rsi     # 0x7517b
xorl %eax, %eax
pushq %r15
pushq %r13
pushq %rbx
pushq %r11
pushq %r10
pushq -0x40(%rbp)
pushq -0x48(%rbp)
pushq -0x50(%rbp)
pushq -0x58(%rbp)
pushq -0x60(%rbp)
pushq -0x68(%rbp)
pushq -0x70(%rbp)
leaq -0x98(%rbp), %r10
pushq %r10
leaq -0x38(%rbp), %r10
pushq %r10
pushq -0x78(%rbp)
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 0x53a7f
movl %ebx, %eax
decl %eax
shlq $0x5, %rax
leaq (%rax,%rax,8), %r14
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdi
movq %rax, %r15
addq %r14, %rdi
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x8390
movq 0x40(%r15), %rax
leaq (%rax,%r14), %rdx
addq $0x4, %rdx
movl %ebx, -0x4(%rdx)
xorl %ecx, %ecx
movq %rcx, -0x88(%rbp)
movq %rcx, -0x90(%rbp)
movq %rcx, -0x38(%rbp)
leaq (%rax,%r14), %rcx
addq $0x8, %rcx
leaq 0xc(%rax,%r14), %r8
leaq 0x10(%rax,%r14), %r9
leaq 0x50(%rax,%r14), %rsi
movq %rsi, -0x78(%rbp)
leaq 0x58(%rax,%r14), %rsi
movq %rsi, -0x70(%rbp)
leaq 0x60(%rax,%r14), %rsi
movq %rsi, -0x68(%rbp)
leaq 0x68(%rax,%r14), %rsi
movq %rsi, -0x60(%rbp)
leaq 0x70(%rax,%r14), %rsi
movq %rsi, -0x58(%rbp)
leaq 0x78(%rax,%r14), %rsi
movq %rsi, -0x50(%rbp)
leaq 0x80(%rax,%r14), %rsi
movq %rsi, -0x48(%rbp)
leaq 0x88(%rax,%r14), %rsi
movq %rsi, -0x40(%rbp)
leaq 0x90(%rax,%r14), %rsi
movq %rsi, -0xe8(%rbp)
leaq 0x98(%rax,%r14), %rsi
movq %rsi, -0xe0(%rbp)
leaq 0xa0(%rax,%r14), %rsi
movq %rsi, -0xd8(%rbp)
leaq 0xa8(%rax,%r14), %rsi
movq %rsi, -0xd0(%rbp)
leaq 0xb0(%rax,%r14), %rsi
movq %rsi, -0xc8(%rbp)
leaq 0xb8(%rax,%r14), %rsi
movq %rsi, -0xc0(%rbp)
leaq 0xc0(%rax,%r14), %rsi
movq %rsi, -0xb8(%rbp)
leaq 0xc8(%rax,%r14), %rsi
movq %rsi, -0xb0(%rbp)
leaq 0xd0(%rax,%r14), %rsi
movq %rsi, -0xa8(%rbp)
leaq 0xd8(%rax,%r14), %rsi
movq %rsi, -0xa0(%rbp)
leaq 0xe0(%rax,%r14), %r15
leaq 0xe8(%rax,%r14), %r10
leaq 0xf0(%rax,%r14), %r11
leaq 0x18(%rax,%r14), %r13
leaq (%rax,%r14), %rbx
addq $0x1c, %rbx
movq %r12, %rdi
leaq 0x217ef(%rip), %rsi     # 0x751c2
xorl %eax, %eax
pushq %rbx
pushq %r13
pushq %r11
pushq %r10
pushq %r15
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)
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, %r15d      # imm = 0x554E4F49
leaq -0x1150(%rbp), %r13
movq %r13, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x89f0
testq %rax, %rax
jne 0x53601
movq %r14, %rdi
callq 0x8630
movl $0x1, %eax
jmp 0x53aba
xorl %eax, %eax
addq $0x1128, %rsp           # imm = 0x1128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq