// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: test_mempolicy
static void test_mempolicy(void)
{
    size_t bufsz = MAX_RECS * REC_LENGTH, nrecs = 0, i;
    bam1_t *recs = calloc(MAX_RECS, sizeof(bam1_t));
    uint8_t *buffer = malloc(bufsz);
    const char *fname = "test/sam_alignment.tmp.sam";
    const char *bam_name = "test/sam_alignment.tmp.bam";
    const char *cram_name = "test/sam_alignment.tmp.cram";
    const char tag_text[] =
        "lengthy text ... lengthy text ... lengthy text ... lengthy text ... "
        "lengthy text ... lengthy text ... lengthy text ... lengthy text ... "
        "lengthy text ... lengthy text ... lengthy text ... lengthy text ... "
        "lengthy text ... lengthy text ... lengthy text ... lengthy text ... "
        "lengthy text ... lengthy text ... lengthy text ... lengthy text ... ";
    int res = 0;
    samFile *fp = NULL, *bam_fp = NULL, *cram_fp = NULL;
    htsFormat cram_fmt;
    sam_hdr_t *header = NULL;

    if (!recs || !buffer) {
        fail("Allocating buffer");
        goto cleanup;
    }

    memset(&cram_fmt, 0, sizeof(cram_fmt));

    // Make test file
    if (generator(fname) < 0)
        goto cleanup;

    // Open and read header
    fp = sam_open(fname, "r");
    if (!fp) {
        fail("sam_open(\"%s\")", fname);
        goto cleanup;
    }

    bam_fp = sam_open(bam_name, "wb");
    if (!fp) {
        fail("sam_open(\"%s\")", bam_name);
        goto cleanup;
    }

    header = sam_hdr_read(fp);
    if (!header) {
        fail("read header from \"%s\"", fname);
        goto cleanup;
    }

    if (sam_hdr_write(bam_fp, header) < 0) {
        fail("sam_hdr_write() to \"%s\"", bam_name);
        goto cleanup;
    }

    if (read_data_block(fname, fp, bam_name, bam_fp, header, recs,
                        MAX_RECS, buffer, bufsz, &nrecs) < 0)
        goto cleanup;

    res = sam_close(bam_fp);
    bam_fp = NULL;
    if (res < 0) {
        fail("sam_close(\"%s\")", bam_name);
        goto cleanup;
    }

    // Add a big tag to some records so they no longer fit in the allocated
    // buffer space.
    for (i = 0; i < MAX_RECS; i += 11) {
        if (bam_aux_update_str(&recs[i], "ZZ",
                               sizeof(tag_text) - 1, tag_text) < 0) {
            fail("bam_aux_update_str()");
            goto cleanup;
        }
    }

    // Delete all the records.  bam_destroy1() should free the data
    // for the ones that were expanded.
    for (i = 0; i < nrecs; i++) {
        bam_destroy1(&recs[i]);
    }

    res = sam_close(fp);
    fp = NULL;
    if (res < 0) {
        fail("sam_close(\"%s\")", fname);
        goto cleanup;
    }

    // Same test but reading BAM, writing CRAM
    nrecs = 0;
    sam_hdr_destroy(header);
    header = NULL;

    bam_fp = sam_open(bam_name, "r");
    if (!bam_fp) {
        fail("sam_open(\"%s\", \"r\")", bam_name);
        goto cleanup;
    }

    if (hts_parse_format(&cram_fmt, "cram,no_ref") < 0) {
        fail("hts_parse_format");
        goto cleanup;
    }
    cram_fp = hts_open_format(cram_name, "wc", &cram_fmt);
    if (!cram_fp) {
        fail("hts_open_format(\"%s\", \"wc\")", cram_name);
        goto cleanup;
    }

    header = sam_hdr_read(bam_fp);
    if (!header) {
        fail("read header from \"%s\"", bam_name);
        goto cleanup;
    }

    if (sam_hdr_write(cram_fp, header) < 0) {
        fail("sam_hdr_write() to \"%s\"", cram_name);
        goto cleanup;
    }

    if (read_data_block(bam_name, bam_fp, cram_name, cram_fp, header, recs,
                        MAX_RECS, buffer, bufsz, &nrecs) < 0)
        goto cleanup;

    res = sam_close(cram_fp);
    cram_fp = NULL;
    if (res < 0) {
        fail("sam_close(\"%s\")", cram_name);
        goto cleanup;
    }

    for (i = 0; i < MAX_RECS; i += 11) {
        if (bam_aux_update_str(&recs[i], "ZZ",
                               sizeof(tag_text) - 1, tag_text) < 0) {
            fail("bam_aux_update_str()");
            goto cleanup;
        }
    }

    for (i = 0; i < nrecs; i++) {
        bam_destroy1(&recs[i]);
    }

    // Now try reading the cram file
    nrecs = 0;
    sam_hdr_destroy(header);
    header = NULL;

    cram_fp = sam_open(cram_name, "r");
    if (!cram_fp) {
        fail("sam_open(\"%s\", \"r\")", cram_name);
        goto cleanup;
    }

    header = sam_hdr_read(cram_fp);
    if (!header) {
        fail("read header from \"%s\"", cram_name);
        goto cleanup;
    }

    if (read_data_block(cram_name, cram_fp, NULL, NULL, header, recs,
                        MAX_RECS, buffer, bufsz, &nrecs) < 0)
        goto cleanup;

    for (i = 0; i < MAX_RECS; i += 11) {
        if (bam_aux_update_str(&recs[i], "ZZ",
                               sizeof(tag_text) - 1, tag_text) < 0) {
            fail("bam_aux_update_str()");
            goto cleanup;
        }
    }

 cleanup:
    sam_hdr_destroy(header);
    if (fp) sam_close(fp);
    if (bam_fp) sam_close(bam_fp);
    if (cram_fp) sam_close(cram_fp);

    for (i = 0; i < nrecs; i++) {
        bam_destroy1(&recs[i]);
    }
    free(buffer);
    free(recs);
    if (cram_fmt.specific) {
        hts_opt_free(cram_fmt.specific);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq $0x249f0, -0x8(%rbp)    # imm = 0x249F0
movq $0x0, -0x10(%rbp)
movl $0x3e8, %edi            # imm = 0x3E8
movl $0x50, %esi
callq 0x42e0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4650
movq %rax, -0x28(%rbp)
leaq 0xe875e(%rip), %rax     # 0xf28b0
movq %rax, -0x30(%rbp)
leaq 0xe73e3(%rip), %rax     # 0xf1540
movq %rax, -0x38(%rbp)
leaq 0xe73fa(%rip), %rax     # 0xf1562
movq %rax, -0x40(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq 0xe91d6(%rip), %rsi     # 0xf3350
movl $0x155, %edx            # imm = 0x155
callq 0x43a0
movl $0x0, -0x1a4(%rbp)
movq $0x0, -0x1b0(%rbp)
movq $0x0, -0x1b8(%rbp)
movq $0x0, -0x1c0(%rbp)
movq $0x0, -0x1e8(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xa1c8
cmpq $0x0, -0x28(%rbp)
jne 0xa1db
leaq 0xe86fc(%rip), %rdi     # 0xf28cb
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
leaq -0x1e0(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x4240
movq -0x30(%rbp), %rdi
callq 0xe7a0
cmpl $0x0, %eax
jge 0xa201
jmp 0xa7a7
movq -0x30(%rbp), %rdi
leaq 0xed86c(%rip), %rsi     # 0xf7a78
callq 0x232d0
movq %rax, -0x1b0(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jne 0xa239
movq -0x30(%rbp), %rsi
leaq 0xe86b0(%rip), %rdi     # 0xf28dd
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x38(%rbp), %rdi
leaq 0xe7317(%rip), %rsi     # 0xf155b
callq 0x232d0
movq %rax, -0x1b8(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jne 0xa271
movq -0x38(%rbp), %rsi
leaq 0xe8678(%rip), %rdi     # 0xf28dd
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x1b0(%rbp), %rdi
callq 0x3c9b0
movq %rax, -0x1e8(%rbp)
cmpq $0x0, -0x1e8(%rbp)
jne 0xa2a5
movq -0x30(%rbp), %rsi
leaq 0xe8653(%rip), %rdi     # 0xf28ec
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x1b8(%rbp), %rdi
movq -0x1e8(%rbp), %rsi
callq 0x3d9c0
cmpl $0x0, %eax
jge 0xa2d4
movq -0x38(%rbp), %rsi
leaq 0xe863a(%rip), %rdi     # 0xf2902
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x30(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x1b8(%rbp), %rcx
movq -0x1e8(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r11
movq -0x8(%rbp), %r10
leaq -0x10(%rbp), %rax
movq $0x3e8, (%rsp)          # imm = 0x3E8
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0xea10
cmpl $0x0, %eax
jge 0xa327
jmp 0xa7a7
movq -0x1b8(%rbp), %rdi
callq 0x253f0
movl %eax, -0x1a4(%rbp)
movq $0x0, -0x1b8(%rbp)
cmpl $0x0, -0x1a4(%rbp)
jge 0xa364
movq -0x38(%rbp), %rsi
leaq 0xe85c2(%rip), %rdi     # 0xf291a
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq $0x0, -0x18(%rbp)
cmpq $0x3e8, -0x18(%rbp)     # imm = 0x3E8
jae 0xa3c2
movq -0x20(%rbp), %rdi
imulq $0x50, -0x18(%rbp), %rax
addq %rax, %rdi
leaq -0x1a0(%rbp), %rcx
leaq 0xe6a43(%rip), %rsi     # 0xf0dd3
movl $0x154, %edx            # imm = 0x154
callq 0x45f60
cmpl $0x0, %eax
jge 0xa3b2
leaq 0xe8584(%rip), %rdi     # 0xf292a
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
jmp 0xa3b4
movq -0x18(%rbp), %rax
addq $0xb, %rax
movq %rax, -0x18(%rbp)
jmp 0xa36c
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xa3f3
movq -0x20(%rbp), %rdi
imulq $0x50, -0x18(%rbp), %rax
addq %rax, %rdi
callq 0x380d0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xa3ca
movq -0x1b0(%rbp), %rdi
callq 0x253f0
movl %eax, -0x1a4(%rbp)
movq $0x0, -0x1b0(%rbp)
cmpl $0x0, -0x1a4(%rbp)
jge 0xa430
movq -0x30(%rbp), %rsi
leaq 0xe84f6(%rip), %rdi     # 0xf291a
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq $0x0, -0x10(%rbp)
movq -0x1e8(%rbp), %rdi
callq 0x36f50
movq $0x0, -0x1e8(%rbp)
movq -0x38(%rbp), %rdi
leaq 0xed61e(%rip), %rsi     # 0xf7a78
callq 0x232d0
movq %rax, -0x1b8(%rbp)
cmpq $0x0, -0x1b8(%rbp)
jne 0xa487
movq -0x38(%rbp), %rsi
leaq 0xe84c4(%rip), %rdi     # 0xf293f
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
leaq -0x1e0(%rbp), %rdi
leaq 0xe84be(%rip), %rsi     # 0xf2953
callq 0x24c40
cmpl $0x0, %eax
jge 0xa4b2
leaq 0xe84b9(%rip), %rdi     # 0xf295f
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x40(%rbp), %rdi
leaq 0xe70c1(%rip), %rsi     # 0xf157e
leaq -0x1e0(%rbp), %rdx
callq 0x223a0
movq %rax, -0x1c0(%rbp)
cmpq $0x0, -0x1c0(%rbp)
jne 0xa4f1
movq -0x40(%rbp), %rsi
leaq 0xe848b(%rip), %rdi     # 0xf2970
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x1b8(%rbp), %rdi
callq 0x3c9b0
movq %rax, -0x1e8(%rbp)
cmpq $0x0, -0x1e8(%rbp)
jne 0xa525
movq -0x38(%rbp), %rsi
leaq 0xe83d3(%rip), %rdi     # 0xf28ec
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x1c0(%rbp), %rdi
movq -0x1e8(%rbp), %rsi
callq 0x3d9c0
cmpl $0x0, %eax
jge 0xa554
movq -0x40(%rbp), %rsi
leaq 0xe83ba(%rip), %rdi     # 0xf2902
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x38(%rbp), %rdi
movq -0x1b8(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x1c0(%rbp), %rcx
movq -0x1e8(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r11
movq -0x8(%rbp), %r10
leaq -0x10(%rbp), %rax
movq $0x3e8, (%rsp)          # imm = 0x3E8
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0xea10
cmpl $0x0, %eax
jge 0xa5a7
jmp 0xa7a7
movq -0x1c0(%rbp), %rdi
callq 0x253f0
movl %eax, -0x1a4(%rbp)
movq $0x0, -0x1c0(%rbp)
cmpl $0x0, -0x1a4(%rbp)
jge 0xa5e4
movq -0x40(%rbp), %rsi
leaq 0xe8342(%rip), %rdi     # 0xf291a
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq $0x0, -0x18(%rbp)
cmpq $0x3e8, -0x18(%rbp)     # imm = 0x3E8
jae 0xa642
movq -0x20(%rbp), %rdi
imulq $0x50, -0x18(%rbp), %rax
addq %rax, %rdi
leaq -0x1a0(%rbp), %rcx
leaq 0xe67c3(%rip), %rsi     # 0xf0dd3
movl $0x154, %edx            # imm = 0x154
callq 0x45f60
cmpl $0x0, %eax
jge 0xa632
leaq 0xe8304(%rip), %rdi     # 0xf292a
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
jmp 0xa634
movq -0x18(%rbp), %rax
addq $0xb, %rax
movq %rax, -0x18(%rbp)
jmp 0xa5ec
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xa673
movq -0x20(%rbp), %rdi
imulq $0x50, -0x18(%rbp), %rax
addq %rax, %rdi
callq 0x380d0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xa64a
movq $0x0, -0x10(%rbp)
movq -0x1e8(%rbp), %rdi
callq 0x36f50
movq $0x0, -0x1e8(%rbp)
movq -0x40(%rbp), %rdi
leaq 0xed3db(%rip), %rsi     # 0xf7a78
callq 0x232d0
movq %rax, -0x1c0(%rbp)
cmpq $0x0, -0x1c0(%rbp)
jne 0xa6ca
movq -0x40(%rbp), %rsi
leaq 0xe8281(%rip), %rdi     # 0xf293f
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x1c0(%rbp), %rdi
callq 0x3c9b0
movq %rax, -0x1e8(%rbp)
cmpq $0x0, -0x1e8(%rbp)
jne 0xa6fe
movq -0x40(%rbp), %rsi
leaq 0xe81fa(%rip), %rdi     # 0xf28ec
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
movq -0x40(%rbp), %rdi
movq -0x1c0(%rbp), %rsi
movq -0x1e8(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r11
movq -0x8(%rbp), %r10
xorl %eax, %eax
movl %eax, %ecx
leaq -0x10(%rbp), %rax
movq %rcx, %rdx
movq $0x3e8, (%rsp)          # imm = 0x3E8
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0xea10
cmpl $0x0, %eax
jge 0xa74a
jmp 0xa7a7
movq $0x0, -0x18(%rbp)
cmpq $0x3e8, -0x18(%rbp)     # imm = 0x3E8
jae 0xa7a5
movq -0x20(%rbp), %rdi
imulq $0x50, -0x18(%rbp), %rax
addq %rax, %rdi
leaq -0x1a0(%rbp), %rcx
leaq 0xe665d(%rip), %rsi     # 0xf0dd3
movl $0x154, %edx            # imm = 0x154
callq 0x45f60
cmpl $0x0, %eax
jge 0xa795
leaq 0xe819e(%rip), %rdi     # 0xf292a
movb $0x0, %al
callq 0x5b50
jmp 0xa7a7
jmp 0xa797
movq -0x18(%rbp), %rax
addq $0xb, %rax
movq %rax, -0x18(%rbp)
jmp 0xa752
jmp 0xa7a7
movq -0x1e8(%rbp), %rdi
callq 0x36f50
cmpq $0x0, -0x1b0(%rbp)
je 0xa7c9
movq -0x1b0(%rbp), %rdi
callq 0x253f0
cmpq $0x0, -0x1b8(%rbp)
je 0xa7df
movq -0x1b8(%rbp), %rdi
callq 0x253f0
cmpq $0x0, -0x1c0(%rbp)
je 0xa7f5
movq -0x1c0(%rbp), %rdi
callq 0x253f0
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xa826
movq -0x20(%rbp), %rdi
imulq $0x50, -0x18(%rbp), %rax
addq %rax, %rdi
callq 0x380d0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xa7fd
movq -0x28(%rbp), %rdi
callq 0x45a0
movq -0x20(%rbp), %rdi
callq 0x45a0
cmpq $0x0, -0x1c8(%rbp)
je 0xa84e
movq -0x1c8(%rbp), %rdi
callq 0x24a30
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw (%rax,%rax)