// File: 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 $0x208, %rsp            # imm = 0x208
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x93d0
movq -0x38(%rbp), %rdx
movl $0x3, %edi
leaq 0x352de(%rip), %rsi     # 0xc7b2d
movb $0x0, %al
callq 0x8b980
movq -0x38(%rbp), %rdi
leaq 0x3563e(%rip), %rsi     # 0xc7e9f
callq 0x98d0
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x92893
movq -0x38(%rbp), %rdx
movl $0x2, %edi
leaq 0x352bf(%rip), %rsi     # 0xc7b3f
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x2c(%rbp)
jmp 0x92bdb
jmp 0x92895
leaq -0x1c0(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x9ba0
cmpq $0x0, %rax
je 0x92bcb
leaq -0x1c0(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
addq $0x8, %rcx
leaq -0xc0(%rbp), %r8
addq $0x10, %r8
leaq -0xc0(%rbp), %r9
addq $0x18, %r9
leaq -0xc0(%rbp), %rax
addq $0x20, %rax
leaq -0xc0(%rbp), %rsi
addq $0x28, %rsi
movq %rsi, -0x1d0(%rbp)
leaq -0xc0(%rbp), %r13
addq $0x30, %r13
leaq -0xc0(%rbp), %r12
addq $0x38, %r12
leaq -0xc0(%rbp), %r15
addq $0x40, %r15
leaq -0xc0(%rbp), %r14
addq $0x48, %r14
leaq -0xc0(%rbp), %rbx
addq $0x50, %rbx
leaq -0xc0(%rbp), %r11
addq $0x58, %r11
leaq -0xc0(%rbp), %r10
addq $0x60, %r10
leaq -0xc0(%rbp), %rsi
addq $0x68, %rsi
movq %rsi, -0x1c8(%rbp)
leaq 0x351f7(%rip), %rsi     # 0xc7b5d
movq %rax, (%rsp)
movq -0x1d0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x1c8(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movb $0x0, %al
callq 0x9750
cmpl $0x5, %eax
jge 0x929b6
jmp 0x92895
movq -0x40(%rbp), %rax
movl (%rax), %eax
movq -0x40(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jl 0x92a6f
movq -0x40(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jg 0x929e0
movl $0x80, %eax
movl %eax, -0x1d4(%rbp)
jmp 0x929ef
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
movl %eax, -0x1d4(%rbp)
movl -0x1d4(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rax
movslq 0x4(%rax), %rax
imulq $0x38, %rax, %rsi
callq 0x9c30
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x92a63
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x9900
movq -0x40(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x40(%rbp), %rax
movl $0x0, (%rax)
movq -0x48(%rbp), %rdi
callq 0x9770
movl $0x0, -0x2c(%rbp)
jmp 0x92bdb
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movsd -0xc0(%rbp), %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd 0x2c337(%rip), %xmm0    # 0xbedd0
mulsd -0xb8(%rbp), %xmm0
movsd 0x3498f(%rip), %xmm1    # 0xc7438
mulsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movsd 0x2c300(%rip), %xmm0    # 0xbedd0
mulsd -0xb0(%rbp), %xmm0
movsd 0x34958(%rip), %xmm1    # 0xc7438
mulsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movsd 0x349c1(%rip), %xmm0    # 0xc74c8
mulsd -0xa8(%rbp), %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movsd 0x34996(%rip), %xmm0    # 0xc74c8
mulsd -0xa0(%rbp), %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movsd 0x2c273(%rip), %xmm0    # 0xbedd0
mulsd -0x60(%rbp), %xmm0
movsd 0x348ce(%rip), %xmm1    # 0xc7438
mulsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movsd 0x2c23f(%rip), %xmm0    # 0xbedd0
mulsd -0x58(%rbp), %xmm0
movsd 0x3489a(%rip), %xmm1    # 0xc7438
mulsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rdx
movl (%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, (%rdx)
movslq %ecx, %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
jmp 0x92895
movq -0x48(%rbp), %rdi
callq 0x9770
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq