// File: /workspace/github_c_makefile_star2_O0/DReichLab[P]adna/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->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 (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);
	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 0x4fb0
movl %eax, -0x28(%rbp)
cmpl $0x4, %eax
je 0xd0e0
cmpl $0x0, -0x28(%rbp)
jne 0xd0d4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd3a5
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xd3a5
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
callq 0x4fb0
cmpq $0x20, %rax
je 0xd104
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0xd3a5
movq -0x10(%rbp), %rax
movl (%rax), %eax
shll $0xc, %eax
sarl $0x1e, %eax
cmpl $0x0, %eax
je 0xd14c
leaq -0x24(%rbp), %rdi
callq 0xcb00
movl $0x0, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jge 0xd14a
leaq -0x50(%rbp), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0xcb00
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xd125
jmp 0xd14c
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
movl 0x24(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0xd344
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 0x22f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x20(%rax), %rdx
callq 0x4fb0
movq -0x18(%rbp), %rcx
movslq 0x20(%rcx), %rcx
cmpq %rcx, %rax
je 0xd373
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xd3a5
movq -0x10(%rbp), %rax
movl (%rax), %eax
shll $0xc, %eax
sarl $0x1e, %eax
cmpl $0x0, %eax
je 0xd39c
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x20(%rax), %esi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdx
callq 0xd3b0
movl -0x24(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop