// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_stats.c
// Function: cram_stats_add
int cram_stats_add(cram_stats *st, int64_t val) {
    st->nsamp++;

    //assert(val >= 0);

    if (val < MAX_STAT_VAL && val >= 0) {
        st->freqs[val]++;
    } else {
        khint_t k;
        int r;

        if (!st->h) {
            st->h = kh_init(m_i2i);
            if (!st->h)
                return -1;
        }

        k = kh_put(m_i2i, st->h, val, &r);
        if (r == 0)
            kh_val(st->h, k)++;
        else if (r != -1)
            kh_val(st->h, k) = 1;
        else
            return -1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
incl 0x1008(%rdi)
cmpq $0x3ff, %rsi            # imm = 0x3FF
ja 0x589e4
incl (%rbx,%r14,4)
jmp 0x58ba4
cmpq $0x0, 0x1000(%rbx)
jne 0x58a0d
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, 0x1000(%rbx)
testq %rax, %rax
je 0x58bb5
movq 0x1000(%rbx), %r15
movl 0x8(%r15), %eax
cmpl 0xc(%r15), %eax
jb 0x58a41
movl (%r15), %esi
movl 0x4(%r15), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x58a2f
decl %esi
jmp 0x58a31
incl %esi
movq %r15, %rdi
callq 0x5909a
testl %eax, %eax
js 0x58acc
movl (%r15), %eax
leal -0x1(%rax), %r9d
movq %r14, %rdx
shrq $0x21, %rdx
movl %r14d, %ecx
shll $0xb, %ecx
xorl %ecx, %edx
xorl %r14d, %edx
andl %r9d, %edx
movq 0x10(%r15), %rsi
movl %edx, %ecx
shrl $0x4, %ecx
movl (%rsi,%rcx,4), %edi
leal (%rdx,%rdx), %ecx
shrl %cl, %edi
testb $0x2, %dil
jne 0x58aff
movl $0x1, %r10d
movl %edx, %r8d
movl %eax, %edi
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%rsi,%rcx,4), %r11d
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %r11d, %ebp
shrl %cl, %ebp
testb $0x2, %bpl
jne 0x58ad9
testb $0x1, %bpl
jne 0x58ab2
movq 0x18(%r15), %r12
movl %r8d, %r13d
cmpq %r14, (%r12,%r13,8)
je 0x58ad9
btl %ecx, %r11d
cmovbl %r8d, %edi
addl %r10d, %r8d
andl %r9d, %r8d
incl %r10d
movl %edi, %ecx
cmpl %edx, %r8d
jne 0x58a83
jmp 0x58adb
movl (%r15), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x58b75
movl %eax, %ecx
movl %ecx, %edx
cmpl %eax, %ecx
jne 0x58aff
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%rsi,%rcx,4), %edx
leal (%r8,%r8), %ecx
shrl %cl, %edx
cmpl %eax, %edi
cmovel %r8d, %edi
testb $0x2, %dl
cmovel %r8d, %edi
movl %edi, %edx
movl %edx, %edi
shrl $0x4, %edi
movl (%rsi,%rdi,4), %r8d
leal (%rdx,%rdx), %ecx
andl $0x1e, %ecx
movl %r8d, %r9d
shrl %cl, %r9d
testb $0x2, %r9b
jne 0x58b4b
xorl %eax, %eax
testb $0x1, %r9b
je 0x58b75
movq 0x18(%r15), %rax
movl %edx, %r9d
movl $0x3, %r10d
shll %cl, %r10d
movq %r14, (%rax,%r9,8)
notl %r10d
andl %r10d, %r8d
movl %r8d, (%rsi,%rdi,4)
incl 0x4(%r15)
movl $0x2, %eax
jmp 0x58b75
movq 0x18(%r15), %rax
movl $0x3, %r9d
shll %cl, %r9d
movl %edx, %ecx
movq %r14, (%rax,%rcx,8)
notl %r9d
andl %r9d, %r8d
movl %r8d, (%rsi,%rdi,4)
incl 0x4(%r15)
incl 0x8(%r15)
movl $0x1, %eax
cmpl $-0x1, %eax
je 0x58ba6
testl %eax, %eax
jne 0x58b90
movq 0x1000(%rbx), %rax
movq 0x20(%rax), %rax
movl %edx, %ecx
incl (%rax,%rcx,4)
jmp 0x58ba4
movq 0x1000(%rbx), %rax
movq 0x20(%rax), %rax
movl %edx, %ecx
movl $0x1, (%rax,%rcx,4)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x58ba6