// File: /workspace/github_cpp_makefile_star2_O1/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 0x22a0e(%rip), %rsi     # 0x7538c
callq 0x8780
testq %rax, %rax
je 0x52b2e
movq %rax, %r14
leaq -0x1a0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rax, %rdx
callq 0x89f0
movl $0x1, %r15d
testq %rax, %rax
je 0x52b47
leaq 0x22749(%rip), %r12     # 0x75102
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 0x52b0d
movl 0x4(%rbx), %eax
cmpl %eax, (%rbx)
jl 0x52a66
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x80, %eax
cmovlel %eax, %ecx
movl %ecx, 0x4(%rbx)
movq 0x8(%rbx), %rdi
imulq $0x38, %rcx, %rsi
callq 0x8a80
testq %rax, %rax
je 0x52b33
movq %rax, 0x8(%rbx)
movsd -0xa0(%rbp), %xmm0
movq 0x8(%rbx), %rax
movslq (%rbx), %rdx
imulq $0x38, %rdx, %rcx
movsd %xmm0, (%rax,%rcx)
movsd -0x98(%rbp), %xmm0
movsd 0x1a1b2(%rip), %xmm1    # 0x6cc40
mulsd %xmm1, %xmm0
movsd 0x221ae(%rip), %xmm2    # 0x74c48
mulsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rax,%rcx)
movsd -0x90(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rax,%rcx)
movsd -0x88(%rbp), %xmm0
movsd 0x221de(%rip), %xmm3    # 0x74ca8
mulsd %xmm3, %xmm0
movsd %xmm0, 0x28(%rax,%rcx)
movsd -0x80(%rbp), %xmm0
mulsd %xmm3, %xmm0
movsd %xmm0, 0x30(%rax,%rcx)
movsd -0x40(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x18(%rax,%rcx)
movsd -0x38(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
incl %edx
movl %edx, (%rbx)
movsd %xmm0, 0x20(%rax,%rcx)
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89f0
testq %rax, %rax
jne 0x529c7
movl $0x1, %r15d
jmp 0x52b47
xorl %r15d, %r15d
jmp 0x52b4f
movq 0x8(%rbx), %rdi
callq 0x87b0
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