// File: DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::read_leaps_usno(_IO_FILE*)
static int read_leaps_usno(FILE *fp)
{
    static const char *months[]={
        "JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"
    };
    double jd,tai_utc;
    char buff[256],month[32],ls[MAXLEAPS][7]={{0}};
    int i,j,y,m,d,n=0;
    
    rewind(fp);
    
    while (fgets(buff,sizeof(buff),fp)&&n<MAXLEAPS) {
        if (sscanf(buff,"%d %s %d =JD %lf TAI-UTC= %lf",&y,month,&d,&jd,
                   &tai_utc)<5) continue;
        if (y<1980) continue;
        for (m=1;m<=12;m++) if (!strcmp(months[m-1],month)) break;
        if (m>=13) continue;
        ls[n][0]=y;
        ls[n][1]=m;
        ls[n][2]=d;
        ls[n++][6]=(char)(19.0-tai_utc);
    }
    for (i=0;i<n;i++) for (j=0;j<7;j++) {
        leaps[i][j]=ls[n-i-1][j];
    }
    return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
leaq -0x300(%rbp), %rdi
xorl %esi, %esi
movl $0x1c0, %edx            # imm = 0x1C0
callq 0x93d0
movl $0x0, -0x318(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9110
leaq -0x120(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x9ba0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x319(%rbp)
je 0x8ed6b
cmpl $0x40, -0x318(%rbp)
setl %al
movb %al, -0x319(%rbp)
movb -0x319(%rbp), %al
testb $0x1, %al
jne 0x8ed7a
jmp 0x8eec4
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rcx
leaq 0x3936b(%rip), %rsi     # 0xc80fa
leaq -0x30c(%rbp), %rdx
leaq -0x314(%rbp), %r8
leaq -0x10(%rbp), %r9
leaq -0x18(%rbp), %rax
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9750
cmpl $0x5, %eax
jge 0x8edba
jmp 0x8ed35
cmpl $0x7bc, -0x30c(%rbp)    # imm = 0x7BC
jge 0x8edcb
jmp 0x8ed35
movl $0x1, -0x310(%rbp)
cmpl $0xc, -0x310(%rbp)
jg 0x8ee1b
movl -0x310(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x69ddf(%rip), %rax     # 0xf8bd0
movq (%rax,%rcx,8), %rdi
leaq -0x140(%rbp), %rsi
callq 0x9a60
cmpl $0x0, %eax
jne 0x8ee08
jmp 0x8ee1b
jmp 0x8ee0a
movl -0x310(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x310(%rbp)
jmp 0x8edd5
cmpl $0xd, -0x310(%rbp)
jl 0x8ee29
jmp 0x8ed35
movb -0x30c(%rbp), %cl
movslq -0x318(%rbp), %rdx
movq %rdx, %rax
shlq $0x3, %rax
subq %rdx, %rax
movb %cl, -0x300(%rbp,%rax)
movb -0x310(%rbp), %cl
movslq -0x318(%rbp), %rdx
movq %rdx, %rax
shlq $0x3, %rax
subq %rdx, %rax
movb %cl, -0x2ff(%rbp,%rax)
movb -0x314(%rbp), %cl
movslq -0x318(%rbp), %rdx
movq %rdx, %rax
shlq $0x3, %rax
subq %rdx, %rax
movb %cl, -0x2fe(%rbp,%rax)
movsd -0x18(%rbp), %xmm1
movsd 0x2df78(%rip), %xmm0    # 0xbce08
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, %cl
movl -0x318(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x318(%rbp)
movslq %eax, %rdx
leaq -0x300(%rbp), %rax
imulq $0x7, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x6(%rax)
jmp 0x8ed35
movl $0x0, -0x304(%rbp)
movl -0x304(%rbp), %eax
cmpl -0x318(%rbp), %eax
jge 0x8ef6f
movl $0x0, -0x308(%rbp)
cmpl $0x7, -0x308(%rbp)
jge 0x8ef59
movl -0x318(%rbp), %ecx
movl -0x304(%rbp), %eax
notl %eax
addl %ecx, %eax
movslq %eax, %rcx
movq %rcx, %rax
shlq $0x3, %rax
subq %rcx, %rax
leaq -0x300(%rbp,%rax), %rcx
movslq -0x308(%rbp), %rax
movsbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
movslq -0x304(%rbp), %rcx
leaq 0x69cfb(%rip), %rax     # 0xf8c30
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq -0x308(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x308(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x308(%rbp)
jmp 0x8eeea
jmp 0x8ef5b
movl -0x304(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x304(%rbp)
jmp 0x8eece
movl -0x318(%rbp), %eax
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
nop