// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/bamlite.c
// Function: bam_read1
int bam_read1(bamFile fp, bam1_t *b)
{
    bam1_core_t *c = &b->core;
    int32_t block_len, ret, i;
    uint32_t x[8];

    if ((ret = bam_read(fp, &block_len, 4)) != 4) {
        if (ret == 0) return -1; // normal end-of-file
        else return -2; // truncated
    }
    if (bam_read(fp, x, sizeof(bam1_core_t)) != sizeof(bam1_core_t)) return -3;
    if (bam_is_be) {
        bam_swap_endian_4p(&block_len);
        for (i = 0; i < 8; ++i) bam_swap_endian_4p(x + i);
    }
    c->tid = x[0]; c->pos = x[1];
    c->bin = x[2]>>16; c->qual = x[2]>>8&0xff; c->l_qname = x[2]&0xff;
    c->flag = x[3]>>16; c->n_cigar = x[3]&0xffff;
    c->l_qseq = x[4];
    c->mtid = x[5]; c->mpos = x[6]; c->isize = x[7];
    b->data_len = block_len - sizeof(bam1_core_t);
    if (b->m_data < b->data_len) {
        b->m_data = b->data_len;
        kroundup32(b->m_data);
        b->data = (uint8_t*)realloc(b->data, b->m_data);
    }
    if (bam_read(fp, b->data, b->data_len) != b->data_len) return -4;
    b->l_aux = b->data_len - c->n_cigar * 4 - c->l_qname - c->l_qseq - (c->l_qseq+1)/2;
    if (bam_is_be) swap_endian_data(c, b->data_len, b->data);
    return 4 + block_len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x24(%rbp), %rsi
movl $0x4, %edx
callq 0x38a0
movl %eax, -0x28(%rbp)
cmpl $0x4, %eax
je 0x39c0
cmpl $0x0, -0x28(%rbp)
jne 0x39b4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3cc4
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3cc4
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
callq 0x38a0
cltq
cmpq $0x20, %rax
je 0x39e6
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x3cc4
cmpl $0x0, 0x363c7(%rip)     # 0x39db4
je 0x3a26
leaq -0x24(%rbp), %rdi
callq 0x3940
movl $0x0, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jge 0x3a24
leaq -0x50(%rbp), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0x3940
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x39ff
jmp 0x3a26
movl -0x50(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x48(%rbp), %ecx
shrl $0x10, %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x8(%rax), %rcx
andq $0xffff, %rdx           # imm = 0xFFFF
andq $-0x10000, %rcx         # imm = 0xFFFF0000
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x48(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x8(%rax), %rcx
andq $0xff, %rdx
shlq $0x10, %rdx
andq $-0xff0001, %rcx        # imm = 0xFF00FFFF
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x48(%rbp), %ecx
andl $0xff, %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x8(%rax), %rcx
andq $0xff, %rdx
shlq $0x18, %rdx
movabsq $-0xff000001, %rsi      # imm = 0xFFFFFFFF00FFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x44(%rbp), %ecx
shrl $0x10, %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x8(%rax), %rcx
andq $0xffff, %rdx           # imm = 0xFFFF
shlq $0x20, %rdx
movabsq $-0xffff00000001, %rsi  # imm = 0xFFFF0000FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x44(%rbp), %ecx
andl $0xffff, %ecx           # imm = 0xFFFF
movq -0x20(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x8(%rax), %rcx
andq $0xffff, %rdx           # imm = 0xFFFF
shlq $0x30, %rdx
movabsq $0xffffffffffff, %rsi   # imm = 0xFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x40(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x3c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x38(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
movslq -0x24(%rbp), %rax
subq $0x20, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x3c22
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
sarl %ecx
movq -0x18(%rbp), %rax
orl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
sarl $0x2, %ecx
movq -0x18(%rbp), %rax
orl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
sarl $0x4, %ecx
movq -0x18(%rbp), %rax
orl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
sarl $0x8, %ecx
movq -0x18(%rbp), %rax
orl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
sarl $0x10, %ecx
movq -0x18(%rbp), %rax
orl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x28(%rax), %rsi
callq 0x23a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x24(%rax), %edx
callq 0x38a0
movq -0x18(%rbp), %rcx
cmpl 0x24(%rcx), %eax
je 0x3c4c
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x3cc4
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x30, %rax
shll $0x2, %eax
subl %eax, %ecx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x18, %rax
andq $0xff, %rax
subl %eax, %ecx
movq -0x20(%rbp), %rax
subl 0x10(%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x20(%rax)
cmpl $0x0, 0x36113(%rip)     # 0x39db4
je 0x3cbb
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdx
callq 0x3cd0
movl -0x24(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)