// File: /workspace/github_c_makefile_star2_O1/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 $0x10088, %rsp          # imm = 0x10088
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
cmpl $0x2, %edi
jne 0x6c2e
movq 0x8(%rsi), %r12
movq %r12, %rdi
callq 0x41c0
movq %rax, %rbx
movq 0xaf148(%rip), %rdi     # 0xb54f0
callq 0x41c0
movq %rax, %r14
movq 0xaf141(%rip), %rdi     # 0xb54f8
callq 0x41c0
movq %rax, %r15
movq 0xaf13a(%rip), %rdi     # 0xb5500
callq 0x41c0
addq %rbx, %r14
addq %r15, %r14
leaq (%rax,%r14), %r13
addq $0x8, %r13
movl $0x5, %edi
movq %r13, %rsi
callq 0x42f0
testq %rax, %rax
je 0x6c20
movq %rax, %rbx
leaq 0x91e4e(%rip), %rdx     # 0x98247
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rcx
xorl %eax, %eax
callq 0x4800
leaq (%rbx,%r13), %rdi
movq %rdi, 0x68(%rsp)
movq 0xaf0d7(%rip), %r8      # 0xb54f0
leaq 0x8f870(%rip), %rdx     # 0x95c90
movq %r13, %rsi
movq %r12, %rcx
xorl %eax, %eax
callq 0x4800
leaq (%rbx,%r13,2), %r15
movq 0xaf0b8(%rip), %r8      # 0xb54f0
movq 0xaf0b9(%rip), %r9      # 0xb54f8
leaq 0x8dbf3(%rip), %r14     # 0x94039
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x4800
leaq (,%r13,2), %rbp
addq %r13, %rbp
addq %rbx, %rbp
movq 0xaf092(%rip), %r8      # 0xb5500
movq 0xaf07b(%rip), %r9      # 0xb54f0
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x4800
leaq (%rbx,%r13,4), %r14
movq 0xaf06d(%rip), %r8      # 0xb5500
movq 0xaf056(%rip), %r9      # 0xb54f0
movq 0xaf057(%rip), %rax     # 0xb54f8
movq %rax, (%rsp)
leaq 0x8db8b(%rip), %rdx     # 0x94037
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rcx
xorl %eax, %eax
callq 0x4800
movq %rbx, 0x10(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r15, 0x70(%rsp)
movq %r15, 0x20(%rsp)
movq %rbp, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movl $0x61a81, %r12d         # imm = 0x61A81
movl $0x61a81, %edi          # imm = 0x61A81
callq 0x4680
testq %rax, %rax
je 0x6c20
movq %rax, %r15
leaq 0x8db3e(%rip), %rbp     # 0x94040
movq %rax, %r13
xorl %r14d, %r14d
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4800
addq $-0x8, %r12
incl %r14d
addq $0x8, %r13
cmpq $0x1, %r12
jne 0x6508
movq %r15, 0x50(%rsp)
movq $0x61a80, 0x58(%rsp)    # imm = 0x61A80
leaq 0x8db05(%rip), %rsi     # 0x94046
movq %rbx, %rdi
callq 0x859b
movq %rax, 0x38(%rsp)
movl $0x1, %r13d
testq %rax, %rax
je 0x6c4c
leaq 0x8dae2(%rip), %rsi     # 0x94046
movq 0x68(%rsp), %rdi
callq 0x859b
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x6c4c
leaq 0x8dac3(%rip), %rsi     # 0x94046
movq 0x70(%rsp), %rdi
callq 0x859b
movq %rax, 0x48(%rsp)
testq %rax, %rax
je 0x6c4c
movq 0x18(%rsp), %r12
movl $0x1, %r13d
movq %r12, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c4c
callq 0x4050
movq %rax, %rbx
movl $0x0, (%rax)
leaq 0x91d74(%rip), %rsi     # 0x98344
leaq 0x8db62(%rip), %rbp     # 0x94139
movq %r12, %rdi
movq %rbp, %rdx
callq 0x85b7
movq %rax, 0x78(%rsp)
testq %rax, %rax
je 0x6c4c
movq %rax, %r14
movq %rbx, 0x70(%rsp)
movq 0x10(%rsp), %r15
movq 0x38(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x8000, %edx           # imm = 0x8000
movq %r14, %rdi
leaq 0x8080(%rsp), %rsi
movq %r12, %rcx
movq %rbp, %r8
callq 0x868e
testq %rax, %rax
js 0x6c3e
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x8700
testq %rax, %rax
js 0x6c3e
movq %rax, %r13
movq %rbp, (%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x8080(%rsp), %rsi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
movq %r12, %r9
callq 0x8760
testl %eax, %eax
jne 0x6c3e
testq %rbx, %rbx
je 0x668d
testq %r13, %r13
jne 0x6607
leaq 0x8daa5(%rip), %rdx     # 0x94139
leaq 0x78(%rsp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x861b
testl %eax, %eax
movl $0x1, %r13d
movq 0x70(%rsp), %rbx
jne 0x6c4c
movq 0x68(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4530
testl %eax, %eax
jne 0x6cbb
leaq 0x8d94f(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x6d82
testl %eax, %eax
jne 0x6c4c
movq 0x28(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c4c
leaq 0x90e57(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6d82
testl %eax, %eax
jne 0x6c4c
movl $0x1, %r13d
movq %r14, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c4c
leaq 0x8d8dd(%rip), %rsi     # 0x94025
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6d82
testl %eax, %eax
jne 0x6c4c
movl $0x1, %r13d
movq %r14, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c4c
leaq 0x8d8a2(%rip), %rsi     # 0x94028
leaq 0x10(%rsp), %rdi
movl $0x1, %r13d
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6d82
testl %eax, %eax
jne 0x6c4c
movq %r14, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c46
leaq 0x8d864(%rip), %rsi     # 0x9402b
leaq 0x10(%rsp), %rdi
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x6d82
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
movq %r14, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c4c
leaq 0x8d826(%rip), %rsi     # 0x9402e
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x6d82
testl %eax, %eax
jne 0x6c46
movq %r14, %rdi
xorl %esi, %esi
callq 0x6cf2
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x90d1e(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0x6d82
testl %eax, %eax
jne 0x6c4c
movq %r14, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c46
leaq 0x90ce3(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x2, %r8d
callq 0x6d82
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
movq %r14, %rdi
movl $0x1, %esi
callq 0x6cf2
testl %eax, %eax
jne 0x6c46
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x6fd7
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x6fd7
testl %eax, %eax
jne 0x6c46
leaq 0x10(%rsp), %rdi
movl $0x2, %esi
callq 0x6fd7
testl %eax, %eax
jne 0x6c46
leaq 0x10(%rsp), %rdi
callq 0x7282
testl %eax, %eax
jne 0x6c46
leaq 0x90c48(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
xorl %ecx, %ecx
callq 0x7410
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x90c22(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x1, %ecx
callq 0x7410
testl %eax, %eax
jne 0x6c46
leaq 0x90bff(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x2, %ecx
callq 0x7410
testl %eax, %eax
jne 0x6c46
leaq 0x8d69d(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x7410
testl %eax, %eax
jne 0x6c46
leaq 0x90bbf(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x8d663(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x90b85(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
xorl %ecx, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x8d626(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
xorl %ecx, %ecx
callq 0x77d2
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x90b3f(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x90b1f(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x77d2
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x8d5ba(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x8d59a(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x77d2
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x90ab3(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x1, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x90a90(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x2, %ecx
callq 0x77d2
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x8d528(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x1, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x8d505(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
movl $0xf4240, %edx          # imm = 0xF4240
movl $0x2, %ecx
callq 0x77d2
testl %eax, %eax
jne 0x6c46
leaq 0x90a21(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
callq 0x7bee
testl %eax, %eax
jne 0x6c46
leaq 0x8d4c9(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
callq 0x7bee
testl %eax, %eax
jne 0x6c46
leaq 0x909ef(%rip), %rsi     # 0x97561
leaq 0x10(%rsp), %rdi
callq 0x7df7
testl %eax, %eax
jne 0x6c46
leaq 0x8d497(%rip), %rsi     # 0x94022
leaq 0x10(%rsp), %rdi
callq 0x7df7
testl %eax, %eax
jne 0x6c46
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x7fc9
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x7fc9
testl %eax, %eax
jne 0x6c46
leaq 0x10(%rsp), %rdi
movl $0x2, %esi
callq 0x7fc9
testl %eax, %eax
jne 0x6c46
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x81e1
testl %eax, %eax
movl $0x1, %r13d
jne 0x6c4c
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x81e1
testl %eax, %eax
jne 0x6c4c
leaq 0x10(%rsp), %rdi
movl $0x2, %esi
callq 0x81e1
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
jmp 0x6c4c
leaq 0x8d40a(%rip), %rdi     # 0x94031
callq 0x43c0
jmp 0x6c46
movq %rsi, %rdi
callq 0x49e0
movl $0x1, %r13d
jmp 0x6ca6
movq %r14, %rdi
callq 0xbc44
movl $0x1, %r13d
testl %r13d, %r13d
jne 0x6c65
movq 0x28(%rsp), %rdi
callq 0x41f0
movq 0x30(%rsp), %rdi
callq 0x41f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x6c74
callq 0x44a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x6c83
callq 0x44a0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x6c92
callq 0x44a0
movq 0x10(%rsp), %rdi
callq 0x45b0
movq 0x50(%rsp), %rdi
callq 0x45b0
movl %r13d, %eax
addq $0x10088, %rsp          # imm = 0x10088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xae31e(%rip), %rax     # 0xb4fe0
movq %rbx, %rcx
movq (%rax), %rbx
movl (%rcx), %edi
callq 0x4140
leaq 0x8d4e4(%rip), %rsi     # 0x941ba
leaq 0x8d45c(%rip), %rdx     # 0x94139
movq %rbx, %rdi
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x4700
jmp 0x6c4c