// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/bam_index.c
// Function: insert_offset2
static inline void insert_offset2(bam_lidx_t *index2, bam1_t *b, uint64_t offset)
{
	int i, beg, end;
	beg = b->core.pos >> BAM_LIDX_SHIFT;
	end = (bam_calend(&b->core, bam1_cigar(b)) - 1) >> BAM_LIDX_SHIFT;
	if (index2->m < end + 1) {
		int old_m = index2->m;
		index2->m = end + 1;
		kroundup32(index2->m);
		index2->offset = (uint64_t*)realloc(index2->offset, index2->m * 8);
		memset(index2->offset + old_m, 0, 8 * (index2->m - old_m));
	}
	if (beg == end) {
		if (index2->offset[beg] == 0) index2->offset[beg] = offset;
	} else {
		for (i = beg; i <= end; ++i)
			if (index2->offset[i] == 0) index2->offset[i] = offset;
	}
	index2->n = end + 1;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x18(%rsp), %rax
movl 0x4(%rax), %eax
sarl $0xe, %eax
movl %eax, 0x8(%rsp)
movq 0x18(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rsi
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
shrq $0x18, %rax
andq $0xff, %rax
cltq
addq %rax, %rsi
callq 0x468fb0
subl $0x1, %eax
shrl $0xe, %eax
movl %eax, 0x4(%rsp)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
movl 0x4(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x471be5
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, (%rsp)
movl 0x4(%rsp), %ecx
addl $0x1, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
sarl %ecx
movq 0x20(%rsp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
sarl $0x2, %ecx
movq 0x20(%rsp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
sarl $0x4, %ecx
movq 0x20(%rsp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
sarl $0x8, %ecx
movq 0x20(%rsp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
sarl $0x10, %ecx
movq 0x20(%rsp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
shll $0x3, %eax
movslq %eax, %rsi
callq 0x340d0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
movslq (%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
subl (%rsp), %eax
shll $0x3, %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x2f4c0
movl 0x8(%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0x471c1d
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x471c1b
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x471c6c
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x4(%rsp), %eax
jg 0x471c6a
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0xc(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x471c5b
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0xc(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x471c5d
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x471c25
jmp 0x471c6c
movl 0x4(%rsp), %ecx
addl $0x1, %ecx
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
addq $0x28, %rsp
retq
nop