// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam2bcf_indel.c
// Function: bcf_call_add_rg
void *bcf_call_add_rg(void *_hash, const char *hdtext, const char *list)
{
	const char *s, *p, *q, *r, *t;
	khash_t(rg) *hash;
	if (list == 0 || hdtext == 0) return _hash;
	if (_hash == 0) _hash = kh_init(rg);
	hash = (khash_t(rg)*)_hash;
	if ((s = strstr(hdtext, "@RG\t")) == 0) return hash;
	do {
		t = strstr(s + 4, "@RG\t"); // the next @RG
		if ((p = strstr(s, "\tID:")) != 0) p += 4;
		if ((q = strstr(s, "\tPL:")) != 0) q += 4;
		if (p && q && (t == 0 || (p < t && q < t))) { // ID and PL are both present
			int lp, lq;
			char *x;
			for (r = p; *r && *r != '\t' && *r != '\n'; ++r); lp = r - p;
			for (r = q; *r && *r != '\t' && *r != '\n'; ++r); lq = r - q;
			x = calloc((lp > lq? lp : lq) + 1, 1);
			for (r = q; *r && *r != '\t' && *r != '\n'; ++r) x[r-q] = *r;
			if (strstr(list, x)) { // insert ID to the hash table
				khint_t k;
				int ret;
				for (r = p; *r && *r != '\t' && *r != '\n'; ++r) x[r-p] = *r;
				x[r-p] = 0;
				k = kh_get(rg, hash, x);
				if (k == kh_end(hash)) k = kh_put(rg, hash, x, &ret);
				else free(x);
			} else free(x);
		}
		s = t;
	} while (s);
	return hash;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x30(%rsp)
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x1354b
movq %rdi, %r14
jmp 0x13b4f
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
testq %rdi, %rdi
jne 0x1356c
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, 0x8(%rsp)
leaq 0x2cf72(%rip), %rsi     # 0x404e5
movq %r14, %rdi
callq 0x3460
testq %rax, %rax
je 0x13b4a
movq %rax, %rdx
movq %rdx, %r14
leaq 0x4(%rdx), %rdi
leaq 0x2cf50(%rip), %rsi     # 0x404e5
callq 0x3460
movq %rax, %r12
movq %r14, %rdi
leaq 0x2cf43(%rip), %rsi     # 0x404ea
callq 0x3460
movq %rax, %r15
leaq 0x4(%rax), %rbp
testq %rax, %rax
setne %bl
movq %rbp, %r13
cmoveq %rax, %r13
movq %r14, %rdi
movq 0x8(%rsp), %r14
leaq 0x2e635(%rip), %rsi     # 0x41c04
callq 0x3460
movq %r12, %rdx
movq %rax, %r12
addq $0x4, %rax
testq %r12, %r12
setne %cl
cmovneq %rax, %r12
andb %bl, %cl
cmpb $0x1, %cl
jne 0x13b3f
testq %rdx, %rdx
je 0x1360e
cmpq %rdx, %rbp
setb %cl
cmpq %rdx, %rax
setb %al
andb %cl, %al
cmpb $0x1, %al
jne 0x13b3f
subl %r13d, %r15d
addl $0x4, %r15d
movl $0x601, %ebx            # imm = 0x601
movzbl (%rbp), %eax
cmpl $0xa, %eax
ja 0x13628
btl %eax, %ebx
jb 0x13630
incq %rbp
incl %r15d
jmp 0x1361a
xorl %eax, %eax
movzbl (%r12,%rax), %ecx
cmpl $0xa, %ecx
ja 0x13641
btl %ecx, %ebx
jb 0x13646
incq %rax
jmp 0x13632
movq %rdx, 0x10(%rsp)
cmpl %eax, %r15d
cmovgl %r15d, %eax
incl %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x3610
movq %rax, %r15
xorl %eax, %eax
movzbl (%r12,%rax), %ecx
cmpl $0xa, %ecx
ja 0x13675
btl %ecx, %ebx
jb 0x1367e
movb %cl, (%r15,%rax)
incq %rax
jmp 0x13666
movq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x3460
testq %rax, %rax
je 0x136e7
xorl %eax, %eax
movq %r15, %rsi
movzbl (%r13,%rax), %ecx
cmpl $0xa, %ecx
ja 0x136a5
btl %ecx, %ebx
jb 0x136ad
movb %cl, (%rsi,%rax)
incq %rax
jmp 0x13695
movb $0x0, (%rsi,%rax)
movl (%r14), %r15d
testl %r15d, %r15d
movq %rsi, 0x20(%rsp)
je 0x136f4
movsbl (%rsi), %ecx
testl %ecx, %ecx
je 0x136fb
movb 0x1(%rsi), %al
testb %al, %al
je 0x136fd
leaq 0x2(%rsi), %rdx
movl %ecx, %edi
shll $0x5, %edi
subl %ecx, %edi
movsbl %al, %ecx
addl %edi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x136d0
jmp 0x136fd
movq %r15, %rdi
callq 0x3350
jmp 0x13b3a
xorl %ebp, %ebp
jmp 0x13789
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r15d
movl %edx, %ebx
leal -0x1(%r15), %edi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
incl %edx
movq 0x10(%r14), %r13
movl %ebx, %ebp
movl %edx, 0x18(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %r12d
leal (,%rbp,2), %r14d
andl $0x1e, %r14d
movl %r12d, %eax
movl %r14d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x1377b
testb $0x1, %al
jne 0x13763
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x35a0
movl 0x18(%rsp), %edx
movq 0x20(%rsp), %rsi
testl %eax, %eax
je 0x1377b
addl %edx, %ebp
cmpl %r15d, %ebp
movl %r15d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebp
cmpl %ebx, %ebp
jne 0x1371c
jmp 0x13792
movl %r14d, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
cmovnel %r15d, %ebp
cmpl %r15d, %ebp
jne 0x139cd
movq 0x8(%rsp), %r14
movl 0x8(%r14), %eax
cmpl 0xc(%r14), %eax
jb 0x1399e
movl 0x4(%r14), %eax
leal (%rax,%rax), %ecx
cmpl %r15d, %ecx
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
addl %r15d, %ecx
movl $0x21, %edx
leaq 0x2e518(%rip), %rdi     # 0x41ce0
leal -0x2(%rdx), %r8d
decl %edx
cmpl %ecx, (%rdi,%r8,4)
ja 0x137c8
movl %edx, %ecx
movl (%rdi,%rcx,4), %ebp
cvtsi2sd %rbp, %xmm0
mulsd 0x2b82a(%rip), %xmm0    # 0x3f010
addsd 0x2b82a(%rip), %xmm0    # 0x3f018
cvttsd2si %xmm0, %r13
cmpl %r13d, %eax
jae 0x1399e
movl %ebp, %eax
shrl $0x4, %eax
leaq 0x4(,%rax,4), %r14
movq %r14, %rdi
callq 0x3240
movq %rax, %r12
movq %rax, %rdi
movl $0xaa, %esi
movq %r14, %rdx
movq 0x8(%rsp), %r14
callq 0x3080
cmpl %ebp, %r15d
jae 0x13846
movq 0x18(%r14), %rdi
leaq (,%rbp,8), %rsi
callq 0x3720
movq %rax, 0x18(%r14)
movl (%r14), %r15d
testl %r15d, %r15d
je 0x1397b
leal -0x1(%rbp), %edi
xorl %r8d, %r8d
movq 0x10(%r14), %r9
movl %r8d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %edx
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %edx, %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0x13955
movq 0x18(%r14), %rsi
movl %r8d, %r10d
movq (%rsi,%r10,8), %r10
btsl %ecx, %edx
movl %edx, (%r9,%rax,4)
movsbl (%r10), %ecx
testl %ecx, %ecx
je 0x138b5
movb 0x1(%r10), %al
testb %al, %al
je 0x138b7
leaq 0x2(%r10), %rdx
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %al, %ecx
addl %esi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x1389e
jmp 0x138b7
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %esi, %eax
movl %esi, %ecx
addl %esi, %ecx
andl $0x1e, %ecx
movl $0x2, %ebx
shll %cl, %ebx
shrl $0x4, %eax
movl (%r12,%rax,4), %r11d
testl %r11d, %ebx
jne 0x1390a
incl %edx
addl %edx, %esi
xorl %eax, %eax
cmpl %ebp, %esi
jb 0x138ed
movl %ebp, %eax
subl %eax, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %r11d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl $0x2, %ebx
shll %cl, %ebx
testl %r11d, %ebx
je 0x138e3
notl %ebx
andl %r11d, %ebx
movl %ebx, (%r12,%rax,4)
movl (%r14), %r15d
movl %esi, %edx
cmpl %r15d, %esi
jae 0x1394d
movl (%r9,%rax,4), %r9d
shrl %cl, %r9d
movq 0x18(%r14), %rsi
testb $0x3, %r9b
jne 0x13951
movq (%rsi,%rdx,8), %r11
movq %r10, (%rsi,%rdx,8)
movl $0x1, %edx
shll %cl, %edx
movq 0x10(%r14), %r9
orl %edx, (%r9,%rax,4)
movq %r11, %r10
jmp 0x1388a
movq 0x18(%r14), %rsi
movq %r10, (%rsi,%rdx,8)
incl %r8d
cmpl %r15d, %r8d
jne 0x13855
cmpl %ebp, %r15d
jbe 0x1397b
movq 0x18(%r14), %rdi
leaq (,%rbp,8), %rsi
callq 0x3720
movq %rax, 0x18(%r14)
movq 0x10(%r14), %rdi
callq 0x3350
movq %r12, 0x10(%r14)
movl %ebp, (%r14)
movl 0x4(%r14), %eax
movl %eax, 0x8(%r14)
movl %r13d, 0xc(%r14)
movq 0x20(%rsp), %rsi
jmp 0x139a1
movl %r15d, %ebp
movsbl (%rsi), %edi
testl %edi, %edi
je 0x139df
movb 0x1(%rsi), %al
testb %al, %al
je 0x139e1
movq %rsi, %rcx
addq $0x2, %rcx
movl %edi, %edx
shll $0x5, %edx
subl %edi, %edx
movsbl %al, %edi
addl %edx, %edi
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x139b6
jmp 0x139e1
movq %rsi, %rdi
callq 0x3350
movq 0x8(%rsp), %r14
jmp 0x13b3a
xorl %edi, %edi
movl %edi, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %r9d
movq 0x10(%r14), %r13
movl %edx, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %eax
leal (%r9,%r9), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x13a0a
movl %r9d, %r12d
jmp 0x13ac2
leal -0x1(%rbp), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %r9d, %r15d
movl %ebp, %r12d
movq %r9, 0x18(%rsp)
movl %edx, 0x2c(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %ebx
leal (%r15,%r15), %r14d
andl $0x1e, %r14d
movl %ebx, %eax
movl %r14d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x13a9d
testb $0x1, %al
jne 0x13a6d
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x35a0
movl 0x2c(%rsp), %edx
movq 0x18(%rsp), %r9
movq 0x20(%rsp), %rsi
testl %eax, %eax
je 0x13a9d
btl %r14d, %ebx
cmovbl %r15d, %r12d
addl %edx, %r15d
cmpl %ebp, %r15d
movl %ebp, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r15d
cmpl %r9d, %r15d
jne 0x13a24
movb $0x1, %al
movl %ebp, %ecx
cmpl %ebp, %r12d
movq 0x8(%rsp), %r14
je 0x13ab3
jmp 0x13ac2
movl %r14d, %ecx
shrl %cl, %ebx
testb $0x2, %bl
sete %al
movl %r12d, %ecx
movl %r15d, %r9d
movq 0x8(%rsp), %r14
cmpl %ebp, %ecx
cmovel %r9d, %ecx
testb %al, %al
cmovnel %r9d, %ecx
movl %ecx, %r12d
movl %r12d, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %edx
leal (%r12,%r12), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
testb $0x2, %dl
jne 0x13b0b
testb $0x1, %dl
movq 0x10(%rsp), %rdx
je 0x13b3f
movq 0x18(%r14), %rdx
movl %r12d, %edi
movq %rsi, (%rdx,%rdi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r14), %rcx
andl %edx, (%rcx,%rax,4)
movq 0x10(%rsp), %rdx
incl 0x4(%r14)
jmp 0x13b3f
movq 0x18(%r14), %rdx
movl %r12d, %edi
movq %rsi, (%rdx,%rdi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r14), %rcx
andl %edx, (%rcx,%rax,4)
movq 0x4(%r14), %xmm0
psubd 0x2b50c(%rip), %xmm0    # 0x3f040
movq %xmm0, 0x4(%r14)
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
jne 0x13587
jmp 0x13b4f
movq 0x8(%rsp), %r14
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq