// File: /workspace/github_cpp_makefile_star2_O1/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 0x229c3(%rip), %rsi     # 0x750fd
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x8610
movsbl (%r14), %edi
callq 0x8bf0
movb %al, (%r14)
incq %r14
testb %al, %al
jne 0x52747
leaq 0x22c2b(%rip), %rsi     # 0x7538c
movq %rbx, %rdi
callq 0x8780
testq %rax, %rax
je 0x5291d
movq %rax, %r14
leaq -0x1e0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rax, %rdx
callq 0x89f0
testq %rax, %rax
je 0x52911
leaq -0x98(%rbp), %r13
leaq -0x90(%rbp), %rbx
leaq -0x2e0(%rbp), %r12
cmpw $0x2424, -0x1e0(%rbp)   # imm = 0x2424
je 0x5282a
leaq -0x1e0(%rbp), %rdi
callq 0x8290
cmpq $0x1, %rax
jbe 0x5282a
leaq -0x1de(%rbp), %rdi
leaq 0x2292b(%rip), %rsi     # 0x750fd
leaq -0xc0(%rbp), %rdx
xorl %eax, %eax
callq 0x8610
testl %eax, %eax
jle 0x5282a
movq %rbx, %r15
movq %r13, %rbx
leaq -0xc0(%rbp), %r13
movsbl (%r13), %edi
callq 0x8bf0
movb %al, (%r13)
incq %r13
testb %al, %al
jne 0x527f1
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8890
testl %eax, %eax
movq %rbx, %r13
movq %r15, %rbx
leaq -0x88(%rbp), %r15
je 0x5284c
leaq -0x1e0(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x89f0
testq %rax, %rax
jne 0x527a7
jmp 0x52911
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 0x89f0
testq %rax, %rax
je 0x5282a
cmpw $0x2424, -0x2e0(%rbp)   # imm = 0x2424
je 0x5285a
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x22886(%rip), %rsi     # 0x7510e
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 0x5285a
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 0x528db
movq -0x30(%rbp), %rax
incq %rax
addq $0x8, %rdx
cmpq $0x6, %rax
jne 0x52852
movl $0x1, %ebx
jmp 0x52913
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x8630
jmp 0x5291f
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq