// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: check_big_ref
static void check_big_ref(int parse_header)
{
    static const char sam_text[] = "data:,"
        "@HD\tVN:1.4\n"
        "@SQ\tSN:large#1\tLN:5000000000\n"
        "@SQ\tSN:small#1\tLN:100\n"
        "@SQ\tSN:large#2\tLN:4611686018427387904\n"
        "@SQ\tSN:small#2\tLN:1\n"
        "r1\t0\tlarge#1\t4999999000\t50\t8M\t*\t0\t0\tACGTACGT\tabcdefgh\n"
        "r2\t0\tsmall#1\t1\t50\t8M\t*\t0\t0\tACGTACGT\tabcdefgh\n"
        "r3\t0\tlarge#2\t4611686018427387000\t50\t8M\t*\t0\t0\tACGTACGT\tabcdefgh\n"
        "p1\t99\tlarge#2\t1\t50\t8M\t=\t4611686018427387895\t4611686018427387903\tACGTACGT\tabcdefgh\n"
        "p1\t147\tlarge#2\t4611686018427387895\t50\t8M\t=\t1\t-4611686018427387903\tACGTACGT\tabcdefgh\n"
        "r4\t0\tsmall#2\t2\t50\t8M\t*\t0\t0\tACGTACGT\tabcdefgh\n";
    const hts_pos_t expected_lengths[] = {
        5000000000LL, 100LL, 4611686018427387904LL, 1LL
    };
    const int expected_tids[] = {
        0, 1, 2, 2, 2, 3
    };
    const int expected_mtid[] = {
        -1, -1, -1, 2, 2, -1
    };
    const hts_pos_t expected_positions[] = {
        4999999000LL - 1, 1LL - 1, 4611686018427387000LL - 1, 1LL - 1,
        4611686018427387895LL - 1, 2LL - 1
    };
    const hts_pos_t expected_mpos[] = {
        -1, -1, -1, 4611686018427387895LL - 1, 1LL - 1, -1
    };
    samFile *in = NULL, *out = NULL;
    sam_hdr_t *header = NULL, *dup_header = NULL;
    bam1_t *aln = bam_init1();
    const int num_refs = sizeof(expected_lengths) / sizeof(expected_lengths[0]);
    const int num_align = sizeof(expected_tids) / sizeof(expected_tids[0]);
    const char *outfname = "test/sam_big_ref.tmp.sam_";
    int i, r;
    char buffer[sizeof(sam_text) + 1024];
    FILE *inf = NULL;
    size_t bytes;

    if (!aln) {
        fail("Out of memory");
        goto cleanup;
    }

    in = sam_open(sam_text, "r");
    if (!in) {
        fail("Opening SAM file");
        goto cleanup;
    }
    out = sam_open(outfname, "w");
    if (!out) {
        fail("Opening output SAM file \"%s\"", outfname);
        goto cleanup;
    }
    header = sam_hdr_read(in);
    if (!header) {
        fail("Reading SAM header");
        goto cleanup;
    }
    if (parse_header) {
        // This will force the header to be parsed
        if (sam_hdr_count_lines(header, "SQ") != num_refs) {
            fail("Wrong number of SQ lines in header");
            goto cleanup;
        }
    }
    if (check_ref_lengths(header, expected_lengths, num_refs, "header") < 0)
        goto cleanup;

    dup_header = sam_hdr_dup(header);
    if (!dup_header) {
        fail("Failed to duplicate header");
    }

    if (check_ref_lengths(dup_header, expected_lengths,
                          num_refs, "duplicate header") < 0)
        goto cleanup;

    if (sam_hdr_count_lines(dup_header, "SQ") != num_refs) {
        fail("Wrong number of SQ lines in duplicate header");
        goto cleanup;
    }

    if (check_ref_lengths(dup_header, expected_lengths,
                          num_refs, "parsed duplicate header") < 0)
        goto cleanup;

    if (sam_hdr_write(out, header) < 0) {
        fail("Failed to write SAM header");
        goto cleanup;
    }
    i = 0;
    while ((r = sam_read1(in, header, aln)) >= 0) {
        if (i >= num_align) {
            fail("Too many alignment records.\n");
            goto cleanup;
        }
        if (aln->core.tid != expected_tids[i]) {
            fail("Wrong tid for record %d : expected %d got %d\n",
                 i, expected_tids[i], aln->core.tid);
            goto cleanup;
        }
        if (aln->core.mtid != expected_mtid[i]) {
            fail("Wrong mate tid for record %d : expected %d got %d\n",
                 i, expected_mtid[i], aln->core.mtid);
            goto cleanup;
        }
        if (aln->core.pos != expected_positions[i]) {
            fail("Wrong position for record %d : "
                 "expected %"PRIhts_pos" got %"PRIhts_pos"\n",
                 i, expected_positions[i], aln->core.pos);
        }
        if (aln->core.mpos != expected_mpos[i]) {
            fail("Wrong mate position for record %d : "
                 "expected %"PRIhts_pos" got %"PRIhts_pos"\n",
                 i, expected_mpos[i], aln->core.mpos);
        }
        if (sam_write1(out, header, aln) < 0) {
            fail("Failed to write alignment record %d\n", i);
            goto cleanup;
        }
        i++;
    }
    if (r < -1) {
        fail("Error reading SAM alignment\n");
        goto cleanup;
    }
    if (i < num_align) {
        fail("Not enough alignment records\n");
        goto cleanup;
    }
    r = sam_close(in); in = NULL;
    if (r < 0) {
        fail("sam_close(in)");
        goto cleanup;
    }
    r = sam_close(out); out = NULL;
    if (r < 0) {
        fail("sam_close(out)");
        goto cleanup;
    }

    inf = fopen(outfname, "r");
    if (!inf) {
        fail("Opening \"%s\"", outfname);
        goto cleanup;
    }
    bytes = fread(buffer, 1, sizeof(buffer), inf);
    if (bytes != sizeof(sam_text) - 7
        || memcmp(buffer, sam_text + 6, bytes - 7) != 0) {
        fail("Output file does not match original version");
        fprintf(stderr,
                "---------- Expected:\n%.*s\n"
                "++++++++++ Got:\n%.*s\n"
                "====================\n",
                (int) sizeof(sam_text) - 7, sam_text + 6,
                (int) bytes, buffer);
        goto cleanup;
    }

 cleanup:
    bam_destroy1(aln);
    sam_hdr_destroy(header);
    sam_hdr_destroy(dup_header);
    if (in) sam_close(in);
    if (out) sam_close(out);
    if (inf) fclose(inf);
    unlink(outfname);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x720, %rsp            # imm = 0x720
movl %edi, -0x4(%rbp)
movq 0xe9a9b(%rip), %rax     # 0xf3300
movq %rax, -0x30(%rbp)
movq 0xe9a98(%rip), %rax     # 0xf3308
movq %rax, -0x28(%rbp)
movq 0xe9a95(%rip), %rax     # 0xf3310
movq %rax, -0x20(%rbp)
movq 0xe9a92(%rip), %rax     # 0xf3318
movq %rax, -0x18(%rbp)
movq 0xe6c6f(%rip), %rax     # 0xf0500
movq %rax, -0x50(%rbp)
movq 0xe6c6c(%rip), %rax     # 0xf0508
movq %rax, -0x48(%rbp)
movq 0xe6c69(%rip), %rax     # 0xf0510
movq %rax, -0x40(%rbp)
movq 0xe6c6e(%rip), %rax     # 0xf0520
movq %rax, -0x70(%rbp)
movq 0xe6c6b(%rip), %rax     # 0xf0528
movq %rax, -0x68(%rbp)
movq 0xe6c68(%rip), %rax     # 0xf0530
movq %rax, -0x60(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x4240
movabsq $0x12a05ee17, %rax      # imm = 0x12A05EE17
movq %rax, -0xa0(%rbp)
movabsq $0x3ffffffffffffc77, %rax # imm = 0x3FFFFFFFFFFFFC77
movq %rax, -0x90(%rbp)
movabsq $0x3ffffffffffffff6, %rax # imm = 0x3FFFFFFFFFFFFFF6
movq %rax, -0x80(%rbp)
movq $0x1, -0x78(%rbp)
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x4240
movq $-0x1, -0xd0(%rbp)
movq $-0x1, -0xc8(%rbp)
movq $-0x1, -0xc0(%rbp)
movabsq $0x3ffffffffffffff6, %rax # imm = 0x3FFFFFFFFFFFFFF6
movq %rax, -0xb8(%rbp)
movq $-0x1, -0xa8(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xf0(%rbp)
callq 0x37e90
movq %rax, -0xf8(%rbp)
movl $0x4, -0xfc(%rbp)
movl $0x6, -0x100(%rbp)
leaq 0xe8a8d(%rip), %rax     # 0xf2447
movq %rax, -0x108(%rbp)
movq $0x0, -0x718(%rbp)
cmpq $0x0, -0xf8(%rbp)
jne 0x99e9
leaq 0xe8a84(%rip), %rdi     # 0xf2461
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
leaq 0xe6910(%rip), %rdi     # 0xf0300
leaq 0xee081(%rip), %rsi     # 0xf7a78
callq 0x232d0
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
jne 0x9a20
leaq 0xe8a5b(%rip), %rdi     # 0xf246f
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0x108(%rbp), %rdi
leaq 0xed2c0(%rip), %rsi     # 0xf6cee
callq 0x232d0
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
jne 0x9a5e
movq -0x108(%rbp), %rsi
leaq 0xe8a2e(%rip), %rdi     # 0xf2480
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xd8(%rbp), %rdi
callq 0x3c9b0
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0xe8(%rbp)
jne 0x9a8e
leaq 0xe8a1b(%rip), %rdi     # 0xf249d
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
cmpl $0x0, -0x4(%rbp)
je 0x9ac1
movq -0xe8(%rbp), %rdi
leaq 0xe7ca0(%rip), %rsi     # 0xf1742
callq 0x18290
cmpl $0x4, %eax
je 0x9abf
leaq 0xe89fd(%rip), %rdi     # 0xf24b0
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
jmp 0x9ac1
movq -0xe8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x4, %edx
leaq 0xed0f0(%rip), %rcx     # 0xf6bc8
callq 0xe600
cmpl $0x0, %eax
jge 0x9ae7
jmp 0x9ef2
movq -0xe8(%rbp), %rdi
callq 0x37140
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xf0(%rbp)
jne 0x9b12
leaq 0xe89c8(%rip), %rdi     # 0xf24d3
movb $0x0, %al
callq 0x5b50
movq -0xf0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x4, %edx
leaq 0xe89f9(%rip), %rcx     # 0xf2522
callq 0xe600
cmpl $0x0, %eax
jge 0x9b38
jmp 0x9ef2
movq -0xf0(%rbp), %rdi
leaq 0xe7bfc(%rip), %rsi     # 0xf1742
callq 0x18290
cmpl $0x4, %eax
je 0x9b63
leaq 0xe8997(%rip), %rdi     # 0xf24ee
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xf0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x4, %edx
leaq 0xe89a1(%rip), %rcx     # 0xf251b
callq 0xe600
cmpl $0x0, %eax
jge 0x9b89
jmp 0x9ef2
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x3d9c0
cmpl $0x0, %eax
jge 0x9bb4
leaq 0xe898b(%rip), %rdi     # 0xf2533
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movl $0x0, -0x10c(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xf8(%rbp), %rdx
callq 0x41af0
movl %eax, -0x110(%rbp)
cmpl $0x0, %eax
jl 0x9d6b
cmpl $0x6, -0x10c(%rbp)
jl 0x9c03
leaq 0xe8957(%rip), %rdi     # 0xf254e
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %eax
movslq -0x10c(%rbp), %rcx
cmpl -0x50(%rbp,%rcx,4), %eax
je 0x9c48
movl -0x10c(%rbp), %esi
movslq -0x10c(%rbp), %rax
movl -0x50(%rbp,%rax,4), %edx
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
leaq 0xe892f(%rip), %rdi     # 0xf256b
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xf8(%rbp), %rax
movl 0x1c(%rax), %eax
movslq -0x10c(%rbp), %rcx
cmpl -0x70(%rbp,%rcx,4), %eax
je 0x9c8d
movl -0x10c(%rbp), %esi
movslq -0x10c(%rbp), %rax
movl -0x70(%rbp,%rax,4), %edx
movq -0xf8(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0xe8918(%rip), %rdi     # 0xf2599
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xf8(%rbp), %rax
movq (%rax), %rax
movslq -0x10c(%rbp), %rcx
cmpq -0xa0(%rbp,%rcx,8), %rax
je 0x9cd5
movl -0x10c(%rbp), %esi
movslq -0x10c(%rbp), %rax
movq -0xa0(%rbp,%rax,8), %rdx
movq -0xf8(%rbp), %rax
movq (%rax), %rcx
leaq 0xe88fe(%rip), %rdi     # 0xf25cc
movb $0x0, %al
callq 0x5b50
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x10c(%rbp), %rcx
cmpq -0xd0(%rbp,%rcx,8), %rax
je 0x9d1f
movl -0x10c(%rbp), %esi
movslq -0x10c(%rbp), %rax
movq -0xd0(%rbp,%rax,8), %rdx
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rcx
leaq 0xe88e9(%rip), %rdi     # 0xf2601
movb $0x0, %al
callq 0x5b50
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xf8(%rbp), %rdx
callq 0x448b0
cmpl $0x0, %eax
jge 0x9d57
movl -0x10c(%rbp), %esi
leaq 0xe88f0(%rip), %rdi     # 0xf263b
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0x9bbe
cmpl $-0x1, -0x110(%rbp)
jge 0x9d87
leaq 0xe88e5(%rip), %rdi     # 0xf2660
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
cmpl $0x6, -0x10c(%rbp)
jge 0x9da3
leaq 0xe88e6(%rip), %rdi     # 0xf267d
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xd8(%rbp), %rdi
callq 0x253f0
movl %eax, -0x110(%rbp)
movq $0x0, -0xd8(%rbp)
cmpl $0x0, -0x110(%rbp)
jge 0x9ddc
leaq 0xe88cb(%rip), %rdi     # 0xf269b
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0xe0(%rbp), %rdi
callq 0x253f0
movl %eax, -0x110(%rbp)
movq $0x0, -0xe0(%rbp)
cmpl $0x0, -0x110(%rbp)
jge 0x9e15
leaq 0xe88a0(%rip), %rdi     # 0xf26a9
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
movq -0x108(%rbp), %rdi
leaq 0xedc55(%rip), %rsi     # 0xf7a78
callq 0x4590
movq %rax, -0x718(%rbp)
cmpq $0x0, -0x718(%rbp)
jne 0x9e53
movq -0x108(%rbp), %rsi
leaq 0xe8871(%rip), %rdi     # 0xf26b8
movb $0x0, %al
callq 0x5b50
jmp 0x9ef2
leaq -0x710(%rbp), %rdi
movq -0x718(%rbp), %rcx
movl $0x1, %esi
movl $0x5f4, %edx            # imm = 0x5F4
callq 0x4770
movq %rax, -0x720(%rbp)
cmpq $0x1ed, -0x720(%rbp) # imm = 0x1ED
jne 0x9ea7
leaq -0x710(%rbp), %rdi
movq -0x720(%rbp), %rdx
subq $0x7, %rdx
leaq 0xe6469(%rip), %rsi     # 0xf0306
callq 0x41b0
cmpl $0x0, %eax
je 0x9ef0
leaq 0xe8817(%rip), %rdi     # 0xf26c5
movb $0x0, %al
callq 0x5b50
movq 0x107124(%rip), %rax    # 0x110fe0
movq (%rax), %rdi
movq -0x720(%rbp), %rax
movl %eax, %r8d
leaq -0x710(%rbp), %r9
leaq 0xe7bdb(%rip), %rsi     # 0xf1ab2
movl $0x1ed, %edx            # imm = 0x1ED
leaq 0xe641d(%rip), %rcx     # 0xf0300
addq $0x6, %rcx
movb $0x0, %al
callq 0x46d0
jmp 0x9ef2
jmp 0x9ef2
movq -0xf8(%rbp), %rdi
callq 0x380d0
movq -0xe8(%rbp), %rdi
callq 0x36f50
movq -0xf0(%rbp), %rdi
callq 0x36f50
cmpq $0x0, -0xd8(%rbp)
je 0x9f2c
movq -0xd8(%rbp), %rdi
callq 0x253f0
cmpq $0x0, -0xe0(%rbp)
je 0x9f42
movq -0xe0(%rbp), %rdi
callq 0x253f0
cmpq $0x0, -0x718(%rbp)
je 0x9f58
movq -0x718(%rbp), %rdi
callq 0x4490
movq -0x108(%rbp), %rdi
callq 0x41e0
addq $0x720, %rsp            # imm = 0x720
popq %rbp
retq
nopl (%rax)