// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: read_data_block
static int read_data_block(const char *in_name, samFile *fp_in,
                           const char *out_name, samFile *fp_out,
                           sam_hdr_t *header, bam1_t *recs, size_t max_recs,
                           uint8_t *buffer, size_t bufsz, size_t *nrecs_out) {
    size_t buff_used = 0, nrecs;
    uint32_t new_m_data;
    int ret = -1, res = -1;

    for (nrecs = 0; nrecs < max_recs; nrecs++) {
        bam_set_mempolicy(&recs[nrecs],
                          BAM_USER_OWNS_STRUCT|BAM_USER_OWNS_DATA);

        recs[nrecs].data = &buffer[buff_used];
        recs[nrecs].m_data = bufsz - buff_used;

        res = sam_read1(fp_in, header, &recs[nrecs]);
        if (res < 0) break; // EOF or error

        if (fp_out) {
            if (sam_write1(fp_out, header, &recs[nrecs]) < 0) {
                nrecs++; // To return correct count
                fail("sam_write1() to \"%s\"", out_name);
                goto out;
            }
        }

        if ((bam_get_mempolicy(&recs[nrecs]) & BAM_USER_OWNS_DATA) == 0) {
            continue;  // Data not put in buffer
        }

        new_m_data = ((uint32_t) recs[nrecs].l_data + 7) & (~7U);
        if (new_m_data < recs[nrecs].m_data) recs[nrecs].m_data = new_m_data;

        buff_used += recs[nrecs].m_data;
    }
    if (res < -1) {
        fail("sam_read1() from \"%s\" failed", in_name);
    } else {
        ret = 0;
    }

 out:
    *nrecs_out = nrecs;
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq 0x10(%rbp), %rax
jae 0xeba5
movq -0x30(%rbp), %rdi
imulq $0x50, -0x40(%rbp), %rax
addq %rax, %rdi
movl $0x3, %esi
callq 0xebe0
movq 0x18(%rbp), %rcx
addq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
imulq $0x50, -0x40(%rbp), %rdx
addq %rdx, %rax
movq %rcx, 0x38(%rax)
movq 0x20(%rbp), %rax
subq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
imulq $0x50, -0x40(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x44(%rax)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
imulq $0x50, -0x40(%rbp), %rax
addq %rax, %rdx
callq 0x41af0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0xeada
jmp 0xeba5
cmpq $0x0, -0x20(%rbp)
je 0xeb24
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
imulq $0x50, -0x40(%rbp), %rax
addq %rax, %rdx
callq 0x448b0
cmpl $0x0, %eax
jge 0xeb22
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rsi
leaq 0xe3ed4(%rip), %rdi     # 0xf29ea
movb $0x0, %al
callq 0x5b50
jmp 0xebc8
jmp 0xeb24
movq -0x30(%rbp), %rdi
imulq $0x50, -0x40(%rbp), %rax
addq %rax, %rdi
callq 0xec10
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xeb3f
jmp 0xeb94
movq -0x30(%rbp), %rax
imulq $0x50, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x40(%rax), %eax
addl $0x7, %eax
andl $-0x8, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x30(%rbp), %rcx
imulq $0x50, -0x40(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x44(%rcx), %eax
jae 0xeb7d
movl -0x44(%rbp), %ecx
movq -0x30(%rbp), %rax
imulq $0x50, -0x40(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x44(%rax)
movq -0x30(%rbp), %rax
imulq $0x50, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x44(%rax), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xea5e
cmpl $-0x1, -0x4c(%rbp)
jge 0xebbf
movq -0x8(%rbp), %rsi
leaq 0xe3e49(%rip), %rdi     # 0xf29ff
movb $0x0, %al
callq 0x5b50
jmp 0xebc6
movl $0x0, -0x48(%rbp)
jmp 0xebc8
movq -0x40(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x48(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)