// File: /workspace/github_cpp_makefile_star2_O3/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, -0x40(%rbp)
movq %rsi, %rax
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq -0xe0(%rbp), %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0x233d0(%rip), %rsi     # 0x750dd
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x8610
movsbl (%r14), %edi
callq 0x8be0
movb %al, (%r14)
incq %r14
testb %al, %al
jne 0x51d1a
leaq 0x23638(%rip), %rsi     # 0x7536c
movq %rbx, %rdi
callq 0x8770
testq %rax, %rax
je 0x51ef0
movq %rax, %r14
leaq -0x1e0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rax, %rdx
callq 0x89e0
testq %rax, %rax
je 0x51ee4
leaq -0x98(%rbp), %r13
leaq -0x90(%rbp), %rbx
leaq -0x2e0(%rbp), %r12
cmpw $0x2424, -0x1e0(%rbp)   # imm = 0x2424
je 0x51dfd
leaq -0x1e0(%rbp), %rdi
callq 0x8290
cmpq $0x1, %rax
jbe 0x51dfd
leaq -0x1de(%rbp), %rdi
leaq 0x23338(%rip), %rsi     # 0x750dd
leaq -0xc0(%rbp), %rdx
xorl %eax, %eax
callq 0x8610
testl %eax, %eax
jle 0x51dfd
movq %rbx, %r15
movq %r13, %rbx
leaq -0xc0(%rbp), %r13
movsbl (%r13), %edi
callq 0x8be0
movb %al, (%r13)
incq %r13
testb %al, %al
jne 0x51dc4
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8880
testl %eax, %eax
movq %rbx, %r13
movq %r15, %rbx
leaq -0x88(%rbp), %r15
je 0x51e1f
leaq -0x1e0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89e0
testq %rax, %rax
jne 0x51d7a
jmp 0x51ee4
movq -0x40(%rbp), %rdx
xorl %eax, %eax
movq %rax, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %r12, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89e0
testq %rax, %rax
je 0x51dfd
cmpw $0x2424, -0x2e0(%rbp)   # imm = 0x2424
je 0x51e2d
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x23293(%rip), %rsi     # 0x750ee
leaq -0xa0(%rbp), %rdx
movq %r13, %rcx
movq %rbx, %r8
movq %r15, %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 0x8610
addq $0x40, %rsp
cmpl $0xb, %eax
jl 0x51e2d
movq -0x38(%rbp), %rdx
movq %rdx, %rax
xorl %ecx, %ecx
movsd -0xa0(%rbp,%rcx,8), %xmm0
movsd %xmm0, (%rax)
incq %rcx
addq $0x30, %rax
cmpq $0xb, %rcx
jne 0x51eae
movq -0x30(%rbp), %rax
incq %rax
addq $0x8, %rdx
cmpq $0x6, %rax
jne 0x51e25
movl $0x1, %ebx
jmp 0x51ee6
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x8630
jmp 0x51ef2
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq