// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/sam.c
// Function: bam_read1
int bam_read1(BGZF *fp, bam1_t *b)
{
    bam1_core_t *c = &b->core;
    int32_t block_len, ret, i;
    uint32_t x[8];
    if ((ret = bgzf_read(fp, &block_len, 4)) != 4) {
        if (ret == 0) return -1; // normal end-of-file
        else return -2; // truncated
    }
    if (bgzf_read(fp, x, 32) != 32) return -3;
    if (fp->is_be) {
        ed_swap_4p(&block_len);
        for (i = 0; i < 8; ++i) ed_swap_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->l_data = block_len - 32;
    if (b->l_data < 0 || c->l_qseq < 0 || c->l_qname < 1) return -4;
    if ((char *)bam_get_aux(b) - (char *)b->data > b->l_data)
        return -4;
    if (b->m_data < b->l_data) {
        b->m_data = b->l_data;
        kroundup32(b->m_data);
        b->data = (uint8_t*)realloc(b->data, b->m_data);
        if (!b->data)
            return -4;
    }
    if (bgzf_read(fp, b->data, b->l_data) != b->l_data) return -4;
    //b->l_aux = b->l_data - c->n_cigar * 4 - c->l_qname - c->l_qseq - (c->l_qseq+1)/2;
    if (fp->is_be) swap_data(c, b->l_data, b->data, 0);
    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 0x9c7b0
movl %eax, -0x28(%rbp)
cmpl $0x4, %eax
je 0xa61e0
cmpl $0x0, -0x28(%rbp)
jne 0xa61d4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa656b
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xa656b
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
callq 0x9c7b0
cmpq $0x20, %rax
je 0xa6204
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0xa656b
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x12, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0xa624c
leaq -0x24(%rbp), %rdi
callq 0xa5b00
movl $0x0, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jge 0xa624a
leaq -0x50(%rbp), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0xa5b00
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa6225
jmp 0xa624c
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)
movl -0x24(%rbp), %ecx
subl $0x20, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jl 0xa63b0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jl 0xa63b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x18, %rax
andq $0xff, %rax
cmpl $0x1, %eax
jge 0xa63bc
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xa656b
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x30, %rcx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x18, %rcx
andq $0xff, %rcx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movl 0x10(%rcx), %ecx
addl $0x1, %ecx
sarl %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movslq 0x10(%rcx), %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq %rcx, %rax
movq -0x18(%rbp), %rcx
movslq 0x20(%rcx), %rcx
cmpq %rcx, %rax
jle 0xa6433
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xa656b
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0xa6508
movq -0x18(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
sarl %ecx
movq -0x18(%rbp), %rax
orl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
sarl $0x2, %ecx
movq -0x18(%rbp), %rax
orl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
sarl $0x4, %ecx
movq -0x18(%rbp), %rax
orl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
sarl $0x8, %ecx
movq -0x18(%rbp), %rax
orl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
sarl $0x10, %ecx
movq -0x18(%rbp), %rax
orl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x24(%rax), %rsi
callq 0x6c80
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0xa6506
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xa656b
jmp 0xa6508
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x20(%rax), %rdx
callq 0x9c7b0
movq -0x18(%rbp), %rcx
movslq 0x20(%rcx), %rcx
cmpq %rcx, %rax
je 0xa6537
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xa656b
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x12, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0xa6562
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x20(%rax), %esi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdx
xorl %ecx, %ecx
callq 0xa6580
movl -0x24(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)