// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::readerp(char const*, bamboo::erp_t*)
extern int readerp(const char *file, erp_t *erp)
{
    FILE *fp;
    erpd_t *erp_data;
    double v[14]={0};
    char buff[256];
    
    trace(3,"readerp: file=%s\n",file);
    
    if (!(fp=fopen(file,"r"))) {
        trace(2,"erp file open error: file=%s\n",file);
        return 0;
    }
    while (fgets(buff,sizeof(buff),fp)) {
        if (sscanf(buff,"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
                   v,v+1,v+2,v+3,v+4,v+5,v+6,v+7,v+8,v+9,v+10,v+11,v+12,v+13)<5) {
            continue;
        }
        if (erp->n>=erp->nmax) {
            erp->nmax=erp->nmax<=0?128:erp->nmax*2;
            erp_data=(erpd_t *)realloc(erp->data,sizeof(erpd_t)*erp->nmax);
            if (!erp_data) {
                free(erp->data); erp->data=NULL; erp->n=erp->nmax=0;
                fclose(fp);
                return 0;
            }
            erp->data=erp_data;
        }
        erp->data[erp->n].mjd=v[0];
        erp->data[erp->n].xp=v[1]*1E-6*AS2R;
        erp->data[erp->n].yp=v[2]*1E-6*AS2R;
        erp->data[erp->n].ut1_utc=v[3]*1E-7;
        erp->data[erp->n].lod=v[4]*1E-7;
        erp->data[erp->n].xpr=v[12]*1E-6*AS2R;
        erp->data[erp->n++].ypr=v[13]*1E-6*AS2R;
    }
    fclose(fp);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x40(%rbp)
movapd %xmm0, -0x50(%rbp)
movapd %xmm0, -0x60(%rbp)
movapd %xmm0, -0x70(%rbp)
movapd %xmm0, -0x80(%rbp)
movapd %xmm0, -0x90(%rbp)
movapd %xmm0, -0xa0(%rbp)
leaq 0x2341b(%rip), %rsi     # 0x7536c
callq 0x8770
testq %rax, %rax
je 0x52104
movq %rax, %r14
leaq -0x1a0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rax, %rdx
callq 0x89e0
movl $0x1, %r15d
testq %rax, %rax
je 0x5211d
leaq 0x23156(%rip), %r12     # 0x750e2
leaq -0x1a0(%rbp), %r13
leaq -0xa0(%rbp), %r15
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
leaq -0x98(%rbp), %rcx
leaq -0x90(%rbp), %r8
leaq -0x88(%rbp), %r9
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x40(%rbp), %r10
pushq %r10
leaq -0x48(%rbp), %r10
pushq %r10
leaq -0x50(%rbp), %r10
pushq %r10
leaq -0x58(%rbp), %r10
pushq %r10
leaq -0x60(%rbp), %r10
pushq %r10
leaq -0x68(%rbp), %r10
pushq %r10
leaq -0x70(%rbp), %r10
pushq %r10
leaq -0x78(%rbp), %r10
pushq %r10
leaq -0x80(%rbp), %r10
pushq %r10
callq 0x8610
addq $0x50, %rsp
cmpl $0x5, %eax
jl 0x520e3
movl (%rbx), %ecx
movl 0x4(%rbx), %edx
movq 0x8(%rbx), %rax
cmpl %edx, %ecx
jl 0x52040
leal (%rdx,%rdx), %ecx
testl %edx, %edx
movl $0x80, %edx
cmovlel %edx, %ecx
movl %ecx, 0x4(%rbx)
imulq $0x38, %rcx, %rsi
movq %rax, %rdi
callq 0x8a70
testq %rax, %rax
je 0x52109
movq %rax, 0x8(%rbx)
movl (%rbx), %ecx
movsd -0xa0(%rbp), %xmm0
movslq %ecx, %rcx
imulq $0x38, %rcx, %rdx
movsd %xmm0, (%rax,%rdx)
movsd -0x98(%rbp), %xmm0
movsd 0x1abdc(%rip), %xmm1    # 0x6cc40
mulsd %xmm1, %xmm0
movsd 0x22bb8(%rip), %xmm2    # 0x74c28
mulsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rax,%rdx)
movsd -0x90(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rax,%rdx)
movsd -0x88(%rbp), %xmm0
movsd 0x22be8(%rip), %xmm3    # 0x74c88
mulsd %xmm3, %xmm0
movsd %xmm0, 0x28(%rax,%rdx)
movsd -0x80(%rbp), %xmm0
mulsd %xmm3, %xmm0
movsd %xmm0, 0x30(%rax,%rdx)
movsd -0x40(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x18(%rax,%rdx)
movsd -0x38(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
incl %ecx
movl %ecx, (%rbx)
movsd %xmm0, 0x20(%rax,%rdx)
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89e0
testq %rax, %rax
jne 0x51f9a
movl $0x1, %r15d
jmp 0x5211d
xorl %r15d, %r15d
jmp 0x52125
movq 0x8(%rbx), %rdi
callq 0x87a0
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x8630
movl %r15d, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq