// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::savenav(char const*, bamboo::nav_t const*)
extern int savenav(const char *file, const nav_t *nav)
{
    FILE *fp;
    int i;
    char id[32];
    
    trace(3,"savenav: file=%s\n",file);
    
    if (!(fp=fopen(file,"w"))) return 0;
    
    for (i=0;i<MAXRTKSAT;i++) {
        if (nav->eph[i].ttr.time==0) continue;
        satno2id(nav->eph[i].sat,id);
        fprintf(fp,"%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
                   "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
                   "%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n",
                id,nav->eph[i].iode,nav->eph[i].iodc,nav->eph[i].sva ,
                nav->eph[i].svh ,(int)nav->eph[i].toe.time,
                (int)nav->eph[i].toc.time,(int)nav->eph[i].ttr.time,
                nav->eph[i].A   ,nav->eph[i].e  ,nav->eph[i].i0  ,nav->eph[i].OMG0,
                nav->eph[i].omg ,nav->eph[i].M0 ,nav->eph[i].deln,nav->eph[i].OMGd,
                nav->eph[i].idot,nav->eph[i].crc,nav->eph[i].crs ,nav->eph[i].cuc ,
                nav->eph[i].cus ,nav->eph[i].cic,nav->eph[i].cis ,nav->eph[i].toes,
                nav->eph[i].fit ,nav->eph[i].f0 ,nav->eph[i].f1  ,nav->eph[i].f2  ,
                nav->eph[i].tgd[0],nav->eph[i].code,nav->eph[i].flag);
    }
    for (i=0;i<MAXPRNGLO;i++) {
        if (nav->geph[i].tof.time==0) continue;
        satno2id(nav->geph[i].sat,id);
        fprintf(fp,"%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
                   "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n",
                id,nav->geph[i].iode,nav->geph[i].frq,nav->geph[i].svh,
                nav->geph[i].sva,nav->geph[i].age,(int)nav->geph[i].toe.time,
                (int)nav->geph[i].tof.time,
                nav->geph[i].pos[0],nav->geph[i].pos[1],nav->geph[i].pos[2],
                nav->geph[i].vel[0],nav->geph[i].vel[1],nav->geph[i].vel[2],
                nav->geph[i].acc[0],nav->geph[i].acc[1],nav->geph[i].acc[2],
                nav->geph[i].taun,nav->geph[i].gamn,nav->geph[i].dtaun);
    }
    fprintf(fp,"IONUTC,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
               "%.14E,%.14E,%.14E,%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);
    
    fclose(fp);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
leaq 0x23a56(%rip), %rsi     # 0x76aa8
callq 0x8770
testq %rax, %rax
je 0x5330f
movq %rax, %rbx
xorl %r13d, %r13d
leaq -0x50(%rbp), %r15
leaq 0x221a3(%rip), %r12     # 0x75214
movq 0x40(%r14), %rax
cmpq $0x0, 0x40(%rax,%r13)
je 0x53199
movl (%rax,%r13), %edi
movq %r15, %rsi
callq 0x4d442
movq 0x40(%r14), %r10
movl 0x4(%r10,%r13), %ecx
movl 0x8(%r10,%r13), %r8d
movl 0xc(%r10,%r13), %r9d
movl 0x10(%r10,%r13), %eax
movl 0x20(%r10,%r13), %edx
movl 0x30(%r10,%r13), %esi
movl 0x40(%r10,%r13), %edi
movsd 0x50(%r10,%r13), %xmm0
movsd 0x58(%r10,%r13), %xmm1
movsd 0x60(%r10,%r13), %xmm2
movsd 0x68(%r10,%r13), %xmm3
movsd 0x70(%r10,%r13), %xmm4
movsd 0x78(%r10,%r13), %xmm5
movsd 0x80(%r10,%r13), %xmm6
movsd 0x88(%r10,%r13), %xmm7
movups 0x90(%r10,%r13), %xmm8
movups 0xa0(%r10,%r13), %xmm9
movups 0xb0(%r10,%r13), %xmm10
movups 0xc0(%r10,%r13), %xmm11
movups 0xd0(%r10,%r13), %xmm12
movups 0xe0(%r10,%r13), %xmm13
movsd 0xf0(%r10,%r13), %xmm14
movl 0x18(%r10,%r13), %r11d
movl 0x1c(%r10,%r13), %r10d
movl %r10d, 0x90(%rsp)
movl %r11d, 0x88(%rsp)
movsd %xmm14, 0x80(%rsp)
movups %xmm13, 0x70(%rsp)
movups %xmm12, 0x60(%rsp)
movups %xmm11, 0x50(%rsp)
movups %xmm10, 0x40(%rsp)
movups %xmm9, 0x30(%rsp)
movups %xmm8, 0x20(%rsp)
movl %edi, 0x18(%rsp)
movl %esi, 0x10(%rsp)
movl %edx, 0x8(%rsp)
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movb $0x8, %al
callq 0x88c0
addq $0x120, %r13            # imm = 0x120
cmpq $0xae60, %r13           # imm = 0xAE60
jne 0x53071
xorl %r13d, %r13d
leaq -0x50(%rbp), %r15
leaq 0x220f6(%rip), %r12     # 0x752b1
movq 0x48(%r14), %rax
cmpq $0x0, 0x28(%rax,%r13)
je 0x53271
movl (%rax,%r13), %edi
movq %r15, %rsi
callq 0x4d442
movq 0x48(%r14), %rax
movl 0x4(%rax,%r13), %ecx
movl 0x8(%rax,%r13), %r8d
movl 0xc(%rax,%r13), %r9d
movl 0x10(%rax,%r13), %edx
movl 0x14(%rax,%r13), %esi
movl 0x18(%rax,%r13), %edi
movl 0x28(%rax,%r13), %r10d
movsd 0x38(%rax,%r13), %xmm0
movsd 0x40(%rax,%r13), %xmm1
movsd 0x48(%rax,%r13), %xmm2
movsd 0x50(%rax,%r13), %xmm3
movsd 0x58(%rax,%r13), %xmm4
movsd 0x60(%rax,%r13), %xmm5
movsd 0x68(%rax,%r13), %xmm6
movsd 0x70(%rax,%r13), %xmm7
movups 0x78(%rax,%r13), %xmm8
movups 0x88(%rax,%r13), %xmm9
movups %xmm9, 0x30(%rsp)
movups %xmm8, 0x20(%rsp)
movl %r10d, 0x18(%rsp)
movl %edi, 0x10(%rsp)
movl %esi, 0x8(%rsp)
movl %edx, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movb $0x8, %al
callq 0x88c0
addq $0x98, %r13
cmpq $0x1008, %r13           # imm = 0x1008
jne 0x531bb
movsd 0x170(%r14), %xmm0
movsd 0x178(%r14), %xmm1
movsd 0x180(%r14), %xmm2
movsd 0x188(%r14), %xmm3
movsd 0x190(%r14), %xmm4
movsd 0x198(%r14), %xmm5
movsd 0x1a0(%r14), %xmm6
movsd 0x1a8(%r14), %xmm7
movups 0x90(%r14), %xmm8
movups 0xa0(%r14), %xmm9
movl 0x290(%r14), %edx
movups %xmm9, 0x10(%rsp)
movups %xmm8, (%rsp)
leaq 0x2201c(%rip), %rsi     # 0x75312
movq %rbx, %rdi
movb $0x8, %al
callq 0x88c0
movq %rbx, %rdi
callq 0x8630
movl $0x1, %eax
jmp 0x53311
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq