// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/test_bgzf.c
// Function: main
int main(int argc, char **argv) {
    Files f = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 };
    int retval = EXIT_FAILURE;

    if (argc != 2) {
        fprintf(stderr, "Usage: %s <source file>\n", argv[0]);
        return EXIT_FAILURE;
    }

    if (setup(argv[1], &f) != 0) goto out;

    // Try reading an existing file
    if (test_check_EOF(f.src_bgzf, 1) != 0) goto out;
    if (test_read(&f) != 0) goto out;

    // Try writing some data and reading it back
    if (test_write_read(&f, "wu", USE_BGZF_OPEN, 0, 0) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 0) != 0) goto out;
    if (test_write_read(&f, "w",  USE_BGZF_OPEN, 0, 2) != 0)  goto out;
    if (test_check_EOF(f.tmp_bgzf, 1) != 0) goto out;
    if (test_write_read(&f, "w0", USE_BGZF_OPEN, 0, 2) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 1) != 0) goto out;
    if (test_write_read(&f, "w1", USE_BGZF_DOPEN, 0, 2) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 1) != 0) goto out;
    if (test_write_read(&f, "w9", USE_BGZF_HOPEN, 0, 2) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 1) != 0) goto out;
    if (test_write_read(&f, "wg", USE_BGZF_OPEN, 0, 1) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 0) != 0) goto out;

    // Try writing and reading with threads
    if (test_write_read(&f, "w", USE_BGZF_OPEN, 1, 2) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 1) != 0) goto out;
    if (test_write_read(&f, "w", USE_BGZF_OPEN, 2, 2) != 0) goto out;
    if (test_check_EOF(f.tmp_bgzf, 1) != 0) goto out;

    // Embedded EOF block
    if (test_embed_eof(&f, "w", 0) != 0) goto out;
    if (test_embed_eof(&f, "w", 1) != 0) goto out;
    if (test_embed_eof(&f, "w", 2) != 0) goto out;

    // Index load and dump
    if (test_index_load_dump(&f) != 0) goto out;

    // Index building on the fly and bgzf_useek
    if (test_index_useek_getc(&f, "w", 1000000, 0) != 0) goto out;

    // Index building on the fly and bgzf_useek, with threads
    if (test_index_useek_getc(&f, "w", 1000000, 1) != 0) goto out;
    if (test_index_useek_getc(&f, "w", 1000000, 2) != 0) goto out;

    // bgzf_useek on an uncompressed file
    if (test_index_useek_getc(&f, "wu", 0, 0) != 0) goto out;

    // bgzf_tell and bgzf_seek
    if (test_tell_seek_getc(&f, "w", 0, 0) != 0) goto out;
    if (test_tell_seek_getc(&f, "wu", 0, 0) != 0) goto out;
    if (test_tell_seek_getc(&f, "w", 1000000, 0) != 0) goto out;
    if (test_tell_seek_getc(&f, "wu", 1000000, 0) != 0) goto out;
    if (test_tell_seek_getc(&f, "w", 0, 1) != 0) goto out;
    if (test_tell_seek_getc(&f, "w", 0, 2) != 0) goto out;
    if (test_tell_seek_getc(&f, "wu", 0, 1) != 0) goto out;
    if (test_tell_seek_getc(&f, "wu", 0, 2) != 0) goto out;
    if (test_tell_seek_getc(&f, "w", 1000000, 1) != 0) goto out;
    if (test_tell_seek_getc(&f, "w", 1000000, 2) != 0) goto out;
    if (test_tell_seek_getc(&f, "wu", 1000000, 1) != 0) goto out;
    if (test_tell_seek_getc(&f, "wu", 1000000, 2) != 0) goto out;

    // bgzf_tell and bgzf_read
    if (test_tell_read(&f, "w") != 0) goto out;
    if (test_tell_read(&f, "wu") != 0) goto out;

    // bgzf_useek and bgzf_read_small
    if (test_useek_read_small(&f, "w") != 0) goto out;
    if (test_useek_read_small(&f, "wu") != 0) goto out;

    // getline
    if (test_bgzf_getline(&f, "w", 0) != 0) goto out;
    if (test_bgzf_getline(&f, "w", 1) != 0) goto out;
    if (test_bgzf_getline(&f, "w", 2) != 0) goto out;

    if (test_bgzf_getline_on_truncated_file(&f, "w", 0) != 0) goto out;
    if (test_bgzf_getline_on_truncated_file(&f, "w", 1) != 0) goto out;
    if (test_bgzf_getline_on_truncated_file(&f, "w", 2) != 0) goto out;

    retval = EXIT_SUCCESS;

 out:
    cleanup(&f, retval);
    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x100b8, %rsp          # imm = 0x100B8
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
cmpl $0x2, %edi
jne 0x6b65
movq 0x8(%rsi), %r14
movq %r14, %rdi
callq 0x41c0
movq %rax, %rbx
movq 0xad0b5(%rip), %rdi     # 0xb34f0
callq 0x41c0
movq %rax, %r15
movq 0xad0ae(%rip), %rdi     # 0xb34f8
callq 0x41c0
movq %rax, %r12
movq 0xad0a7(%rip), %rdi     # 0xb3500
callq 0x41c0
addq %rbx, %r15
addq %r12, %r15
addq %rax, %r15
addq $0x8, %r15
movl $0x5, %edi
movq %r15, %rsi
callq 0x42f0
testq %rax, %rax
je 0x6b77
movq %rax, %r13
leaq 0x8ed63(%rip), %rdx     # 0x951ee
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x4800
leaq (%r15,%r13), %rbp
movq 0xad04a(%rip), %r8      # 0xb34f0
leaq 0x8c863(%rip), %rdx     # 0x92d10
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x4800
leaq (,%r15,2), %rdi
addq %r13, %rdi
movq %rdi, 0x8(%rsp)
movq 0xad01c(%rip), %r8      # 0xb34f0
movq 0xad01d(%rip), %r9      # 0xb34f8
leaq 0x8ab73(%rip), %rbx     # 0x91055
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x4800
leaq (%r15,%r15,2), %r12
addq %r13, %r12
movq 0xad000(%rip), %r8      # 0xb3500
movq 0xacfe9(%rip), %r9      # 0xb34f0
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x4800
leaq (,%r15,4), %rbx
addq %r13, %rbx
movq 0xacfd4(%rip), %r8      # 0xb3500
movq 0xacfbd(%rip), %r9      # 0xb34f0
movq 0xacfbe(%rip), %rax     # 0xb34f8
movq %rax, (%rsp)
leaq 0x8ab0e(%rip), %rdx     # 0x91053
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x4800
movq %r13, 0x40(%rsp)
movq %rbp, 0x48(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %r12, 0x38(%rsp)
movq %r12, 0x58(%rsp)
movq %rbx, 0x60(%rsp)
movl $0x61a81, %r14d         # imm = 0x61A81
movl $0x61a81, %edi          # imm = 0x61A81
callq 0x4680
testq %rax, %rax
je 0x6b8d
movq %rbp, %r12
movq %rbx, 0xa0(%rsp)
movq %r13, 0x10(%rsp)
leaq 0x8aab4(%rip), %r15     # 0x9105c
movq %rax, 0x28(%rsp)
movq %rax, %r13
xorl %ebx, %ebx
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4800
addq $-0x8, %r14
incl %ebx
addq $0x8, %r13
cmpq $0x1, %r14
jne 0x65b2
movq 0x28(%rsp), %rbx
movq %rbx, 0x80(%rsp)
movq $0x61a80, 0x88(%rsp) # imm = 0x61A80
leaq 0x8aa6e(%rip), %rsi     # 0x91062
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x8635
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x6673
movq %rax, %r14
leaq 0x8aa4d(%rip), %rsi     # 0x91062
movq %r12, %rdi
callq 0x8635
movq %rax, 0x70(%rsp)
movl $0x1, 0x34(%rsp)
testq %rax, %rax
je 0x667a
movq %rax, %r15
leaq 0x8aa29(%rip), %rsi     # 0x91062
movq 0x8(%rsp), %rdi
callq 0x8635
movq %rax, 0x78(%rsp)
testq %rax, %rax
je 0x667d
movq %rax, %rbp
movl $0x1, 0x34(%rsp)
movq %r12, %rbx
movq %r12, %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
je 0x66c9
movq 0x28(%rsp), %rbx
jmp 0x667f
movl $0x1, %ebp
jmp 0x66a5
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x44a0
testq %r15, %r15
je 0x6694
movq %r15, %rdi
callq 0x44a0
testq %rbp, %rbp
je 0x66a1
movq %rbp, %rdi
callq 0x44a0
movl 0x34(%rsp), %ebp
movq %r13, %rdi
callq 0x45b0
movq %rbx, %rdi
callq 0x45b0
movl %ebp, %eax
addq $0x100b8, %rsp          # imm = 0x100B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, 0x18(%rsp)
movq %r15, 0x20(%rsp)
callq 0x4050
movq %rax, 0x98(%rsp)
movl $0x0, (%rax)
leaq 0x8ebfe(%rip), %rsi     # 0x952eb
leaq 0x8aa61(%rip), %rbp     # 0x91155
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x865e
movq %rax, 0xa8(%rsp)
testq %rax, %rax
movq 0x28(%rsp), %rbx
je 0x6bb7
movq %rax, %r15
movq %r14, 0x8(%rsp)
movl $0x8000, %edx           # imm = 0x8000
movq %r15, %rdi
leaq 0x80b0(%rsp), %rsi
movq %r12, %rcx
movq %rbp, %r8
callq 0x8732
testq %rax, %rax
js 0x6ba5
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x87a4
testq %rax, %rax
js 0x6ba5
movq %rax, %r13
movq %rbp, (%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x80b0(%rsp), %rsi
movq %rax, %rdx
movq %r14, %rcx
movq 0x10(%rsp), %r8
movq %r12, %r9
callq 0x87f7
testl %eax, %eax
jne 0x6ba5
testq %r14, %r14
je 0x67a7
testq %r13, %r13
jne 0x671d
leaq 0x8a9a7(%rip), %rdx     # 0x91155
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x86bf
testl %eax, %eax
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
jne 0x6bb7
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4530
testl %eax, %eax
jne 0x6bc6
leaq 0x8a851(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x6bb7
movq 0x38(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x6e20
testl %eax, %eax
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rbp
jne 0x667f
leaq 0x8dce3(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x667f
movl $0x1, 0x34(%rsp)
movq %r12, %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
jne 0x667f
leaq 0x8a7d3(%rip), %rsi     # 0x91041
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x667f
movl $0x1, 0x34(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
jne 0x6b59
leaq 0x8a794(%rip), %rsi     # 0x91044
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x6b59
movl $0x1, 0x34(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
jne 0x6b59
leaq 0x8a74a(%rip), %rsi     # 0x91047
leaq 0x40(%rsp), %rdi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x6b59
movl $0x1, 0x34(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
jne 0x6b59
leaq 0x8a708(%rip), %rsi     # 0x9104a
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x6b59
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x6e20
testl %eax, %eax
jne 0x6b59
leaq 0x8db90(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
xorl %edx, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x6b59
movl $0x1, 0x34(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
jne 0x6b59
leaq 0x8db43(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x2, %r8d
callq 0x6eb0
testl %eax, %eax
jne 0x6b59
movl $0x1, 0x34(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x6e20
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x70fc
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0x1, %esi
callq 0x70fc
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
movl $0x2, %esi
callq 0x70fc
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
callq 0x73a5
testl %eax, %eax
jne 0x6b59
leaq 0x8daa2(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
xorl %ecx, %ecx
callq 0x751e
testl %eax, %eax
jne 0x6b59
leaq 0x8da82(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x1, %ecx
callq 0x751e
testl %eax, %eax
jne 0x6b59
leaq 0x8da57(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x2, %ecx
callq 0x751e
testl %eax, %eax
jne 0x6b59
leaq 0x8a561(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x751e
testl %eax, %eax
jne 0x6b59
leaq 0x8da1b(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8a52f(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8d9e9(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
xorl %ecx, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8a4fa(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
xorl %ecx, %ecx
callq 0x78ac
testl %eax, %eax
je 0x6bd8
movq 0x10(%rsp), %r13
movq 0x28(%rsp), %rbx
jmp 0x6bb2
movq %rsi, %rdi
callq 0x49e0
movl $0x1, %ebp
jmp 0x66b5
leaq 0x8a4cf(%rip), %rdi     # 0x9104d
callq 0x43c0
movl $0x1, %ebp
xorl %r13d, %r13d
jmp 0x6b9e
leaq 0x8a4b9(%rip), %rdi     # 0x9104d
callq 0x43c0
movl $0x1, %ebp
xorl %ebx, %ebx
jmp 0x66a5
movq %r15, %rdi
callq 0xbb59
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rbp
jmp 0x667f
movq 0x98(%rsp), %rdi
movq %r13, %rsi
callq 0x49fe
jmp 0x6bb7
leaq 0x8d932(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
xorl %edx, %edx
movl $0x1, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8d90a(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8a417(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
xorl %edx, %edx
movl $0x1, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8a3ef(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8d8a2(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x1, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8d877(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x2, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8a381(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x1, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8a356(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x2, %ecx
callq 0x78ac
testl %eax, %eax
jne 0x6b59
leaq 0x8d806(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
callq 0x7ca8
testl %eax, %eax
jne 0x6b59
leaq 0x8a31a(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
callq 0x7ca8
testl %eax, %eax
jne 0x6b59
leaq 0x8d7d4(%rip), %rsi     # 0x94511
leaq 0x40(%rsp), %rdi
callq 0x7eb7
testl %eax, %eax
jne 0x6b59
leaq 0x8a2e8(%rip), %rsi     # 0x9103e
leaq 0x40(%rsp), %rdi
callq 0x7eb7
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x808f
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0x1, %esi
callq 0x808f
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
movl $0x2, %esi
callq 0x808f
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x82a3
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
movl $0x1, 0x34(%rsp)
movl $0x1, %esi
callq 0x82a3
testl %eax, %eax
jne 0x6b59
leaq 0x40(%rsp), %rdi
movl $0x2, %esi
callq 0x82a3
testl %eax, %eax
jne 0x6b59
movq 0x38(%rsp), %rdi
callq 0x41f0
movq 0xa0(%rsp), %rdi
callq 0x41f0
movl $0x0, 0x34(%rsp)
jmp 0x6b59