// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/test_khash.c
// Function: test_str2int
static int test_str2int(size_t max, size_t to_del, int show_stats) {
    const size_t kl = 16;
    size_t mask = max;
    char *keys = make_keys(max, kl);
    uint8_t *flags = NULL;
    khash_t(str2int) *h;
    khint_t i;
    uint32_t r = 0x533d;

    if (!keys) return -1;

    h = kh_init(str2int);
    if (!h) goto memfail;

    // Add some entries
    for (i = 0; i < max; i++) {
        if (add_str2int_entry(h, keys + i * kl, i) != 0)
            goto fail;
    }

    // Check they exist
    for (i = 0; i < max; i++) {
        if (check_str2int_entry(h, keys + i * kl, i, 0) != 0)
            goto fail;
    }

    if (show_stats) {
        printf("Initial fill:\n");
        write_stats_str2int(h);
    }

    // Delete a random selection
    flags = calloc(max, sizeof(*flags));
    if (!flags) {
        perror("");
        goto fail;
    }

    kroundup_size_t(mask);
    --mask;

    // Note that this method may become slow for a high %age removed
    // as it searches for the last available entries.  Despite this, it
    // seems to be acceptable for the number of entries allowed.
    for (i = 0; i < to_del; i++) {
        khint_t victim;
        // LFSR, see http://users.ece.cmu.edu/~koopman/lfsr/index.html
        do {
            r = (r >> 1) ^ ((r & 1) * 0x80000057U);
            victim = (r & mask) - 1;
        } while (victim >= max || flags[victim]);
        if (del_str2int_entry(h, keys + victim * kl) != 0)
            goto fail;
        flags[victim] = 1;
    }

    // Check correct entries are present
    for (i = 0; i < max; i++) {
        if (check_str2int_entry(h, keys + i * kl, i, flags[i]) != 0)
            goto fail;
    }

    if (show_stats) {
        printf("\nAfter deletion:\n");
        write_stats_str2int(h);
    }

    // Re-insert deleted entries
    for (i = 0; i < max; i++) {
        if (flags[i] && add_str2int_entry(h, keys + i * kl, i) != 0)
            goto fail;
    }

    // Ensure they're all back
    for (i = 0; i < max; i++) {
        if (check_str2int_entry(h, keys + i * kl, i, 0) != 0)
            goto fail;
    }

    if (show_stats) {
        printf("\nAfter re-insert:\n");
        write_stats_str2int(h);
    }

    kh_destroy(str2int, h);
    free(keys);
    free(flags);

    return 0;

 memfail:
    perror(NULL);
 fail:
    kh_destroy(str2int, h);
    free(keys);
    free(flags);
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq $0x10, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x10, %esi
callq 0x1280
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x533d, -0x50(%rbp)    # imm = 0x533D
cmpq $0x0, -0x38(%rbp)
jne 0x16e7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1aa2
callq 0x1e30
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x16fc
jmp 0x1a77
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x10(%rbp), %rax
jae 0x173d
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x4c(%rbp), %edx
callq 0x1e50
cmpl $0x0, %eax
je 0x1730
jmp 0x1a80
jmp 0x1732
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1703
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x10(%rbp), %rax
jae 0x1780
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x4c(%rbp), %edx
xorl %ecx, %ecx
callq 0x1ee0
cmpl $0x0, %eax
je 0x1773
jmp 0x1a80
jmp 0x1775
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1744
cmpl $0x0, -0x1c(%rbp)
je 0x179d
leaq 0x2aa0(%rip), %rdi      # 0x422d
movb $0x0, %al
callq 0x1030
movq -0x48(%rbp), %rdi
callq 0x2030
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x1070
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x17c7
leaq 0x29a5(%rip), %rdi      # 0x4162
callq 0x1090
jmp 0x1a80
cmpq $0x0, -0x30(%rbp)
jbe 0x188f
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq %rax
orq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x2, %rax
orq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x4, %rax
orq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x8, %rax
orq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x10, %rax
orq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x20, %rax
orq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
imulq $0x0, -0x30(%rbp), %rdx
addq $0x1, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
cmpq $0x0, %rcx
seta %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rdx
movl $0x3f, %ecx
subq %rdx, %rcx
shrq %cl, %rax
andq $0x1, %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
jmp 0x1891
jmp 0x1891
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x18(%rbp), %rax
jae 0x193c
jmp 0x18b3
movl -0x50(%rbp), %eax
shrl %eax
movl -0x50(%rbp), %ecx
andl $0x1, %ecx
imull $0x80000057, %ecx, %ecx # imm = 0x80000057
xorl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
andq -0x30(%rbp), %rax
subq $0x1, %rax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, %ecx
movb $0x1, %al
cmpq -0x10(%rbp), %rcx
movb %al, -0x55(%rbp)
jae 0x18fb
movq -0x40(%rbp), %rax
movl -0x54(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x18b3
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x54(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x2100
cmpl $0x0, %eax
je 0x1923
jmp 0x1a80
movq -0x40(%rbp), %rax
movl -0x54(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x18a4
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x10(%rbp), %rax
jae 0x1988
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x4c(%rbp), %edx
movq -0x40(%rbp), %rax
movl -0x4c(%rbp), %ecx
movzbl (%rax,%rcx), %ecx
callq 0x1ee0
cmpl $0x0, %eax
je 0x197b
jmp 0x1a80
jmp 0x197d
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1943
cmpl $0x0, -0x1c(%rbp)
je 0x19a5
leaq 0x28a7(%rip), %rdi      # 0x423c
movb $0x0, %al
callq 0x1030
movq -0x48(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x10(%rbp), %rax
jae 0x19f6
movq -0x40(%rbp), %rax
movl -0x4c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x19e9
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x4c(%rbp), %edx
callq 0x1e50
cmpl $0x0, %eax
je 0x19e9
jmp 0x1a80
jmp 0x19eb
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x19ac
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x10(%rbp), %rax
jae 0x1a36
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x4c(%rbp), %edx
xorl %ecx, %ecx
callq 0x1ee0
cmpl $0x0, %eax
je 0x1a29
jmp 0x1a80
jmp 0x1a2b
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x19fd
cmpl $0x0, -0x1c(%rbp)
je 0x1a53
leaq 0x280b(%rip), %rdi      # 0x424e
movb $0x0, %al
callq 0x1030
movq -0x48(%rbp), %rdi
callq 0x2030
movq -0x48(%rbp), %rdi
callq 0x2170
movq -0x38(%rbp), %rdi
callq 0x10e0
movq -0x40(%rbp), %rdi
callq 0x10e0
movl $0x0, -0x4(%rbp)
jmp 0x1aa2
xorl %eax, %eax
movl %eax, %edi
callq 0x1090
movq -0x48(%rbp), %rdi
callq 0x2170
movq -0x38(%rbp), %rdi
callq 0x10e0
movq -0x40(%rbp), %rdi
callq 0x10e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)