// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::readblq(char const*, char const*, double*)
extern int readblq(const char *file, const char *sta, double *odisp)
{
    FILE *fp;
    char buff[256],staname[32]="",name[32],*p;
    
    /* station name to upper case */
    sscanf(sta,"%16s",staname);
    for (p=staname;(*p=(char)toupper((int)(*p)));p++) ;
    
    if (!(fp=fopen(file,"r"))) {
        trace(2,"blq file open error: file=%s\n",file);
        return 0;
    }
    while (fgets(buff,sizeof(buff),fp)) {
        if (!strncmp(buff,"$$",2)||strlen(buff)<2) continue;
        
        if (sscanf(buff+2,"%16s",name)<1) continue;
        for (p=name;(*p=(char)toupper((int)(*p)));p++) ;
        if (strcmp(name,staname)) continue;
        
        /* read blq record */
        if (readblqrecord(fp,odisp)) {
            fclose(fp);
            return 1;
        }
    }
    fclose(fp);
    trace(2,"no otl parameters: sta=%s file=%s\n",sta,file);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdx, -0x30(%rbp)
movq %rsi, %rax
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq -0xe0(%rbp), %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0x21a4f(%rip), %rsi     # 0x6b0f3
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x8600
movsbl (%r14), %edi
callq 0x8be0
movb %al, (%r14)
incq %r14
testb %al, %al
jne 0x496b1
leaq 0x21cb7(%rip), %rsi     # 0x6b382
movq %rbx, %rdi
callq 0x8750
testq %rax, %rax
je 0x49869
movq %rax, %r14
leaq -0x98(%rbp), %rbx
leaq -0x90(%rbp), %r15
leaq -0x2e0(%rbp), %r13
leaq -0x1e0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89d0
testq %rax, %rax
je 0x4985d
cmpw $0x2424, -0x1e0(%rbp)   # imm = 0x2424
je 0x496f4
leaq -0x1e0(%rbp), %rdi
callq 0x8290
cmpq $0x2, %rax
jb 0x496f4
leaq -0x1de(%rbp), %rdi
leaq 0x219b7(%rip), %rsi     # 0x6b0f3
leaq -0xc0(%rbp), %rdx
xorl %eax, %eax
callq 0x8600
testl %eax, %eax
jle 0x496f4
movq %r15, %r12
movq %rbx, %r15
leaq -0xc0(%rbp), %rbx
movsbl (%rbx), %edi
callq 0x8be0
movb %al, (%rbx)
incq %rbx
testb %al, %al
jne 0x4975b
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8890
testl %eax, %eax
movq %r15, %rbx
movq %r12, %r15
leaq -0x88(%rbp), %r12
jne 0x496f4
movq -0x30(%rbp), %rdx
xorl %eax, %eax
movq %rax, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89d0
testq %rax, %rax
je 0x496f4
cmpw $0x2424, -0x2e0(%rbp)   # imm = 0x2424
je 0x497a2
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x21930(%rip), %rsi     # 0x6b104
leaq -0xa0(%rbp), %rdx
movq %rbx, %rcx
movq %r15, %r8
movq %r12, %r9
xorl %eax, %eax
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 0x8600
addq $0x40, %rsp
cmpl $0xb, %eax
jl 0x497a2
movq -0x40(%rbp), %rdx
movq %rdx, %rax
xorl %ecx, %ecx
cmpq $0xb, %rcx
je 0x49843
movsd -0xa0(%rbp,%rcx,8), %xmm0
movsd %xmm0, (%rax)
incq %rcx
addq $0x30, %rax
jmp 0x49827
movq -0x38(%rbp), %rax
incq %rax
addq $0x8, %rdx
cmpq $0x6, %rax
jne 0x4979a
pushq $0x1
popq %rbx
jmp 0x4985f
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x8620
jmp 0x4986b
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq