// File: /workspace/github_c_makefile_star2_O1/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 %rdi, %r13
movq %rdx, 0x30(%rsp)
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x135f7
movq %rsi, %r14
testq %r13, %r13
jne 0x131f7
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %r13
leaq 0x2c2af(%rip), %rsi     # 0x3f4ad
movq %r14, %rdi
callq 0x3460
testq %rax, %rax
je 0x135f7
movq %rax, %r14
leaq 0x2c294(%rip), %r12     # 0x3f4ad
movq %r13, 0x8(%rsp)
leaq 0x4(%r14), %rdi
movq %r12, %rsi
callq 0x3460
movq %rax, %rbx
movq %r14, %rdi
leaq 0x2c27b(%rip), %rsi     # 0x3f4b2
callq 0x3460
movq %rax, %r15
addq $0x4, %rax
testq %r15, %r15
setne %bpl
cmovneq %rax, %r15
movq %r14, %rdi
movq %rbx, %r14
leaq 0x2d949(%rip), %rsi     # 0x40ba4
callq 0x3460
leaq 0x4(%rax), %rbx
testq %rax, %rax
setne %cl
cmoveq %rax, %rbx
andb %bpl, %cl
cmpb $0x1, %cl
jne 0x13483
testq %r14, %r14
je 0x13296
cmpq %r14, %r15
setb %al
cmpq %r14, %rbx
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x13483
xorl %eax, %eax
movl $0x601, %ebp            # imm = 0x601
movzbl (%r15,%rax), %ecx
cmpl $0xa, %ecx
ja 0x132ac
btl %ecx, %ebp
jb 0x132b1
incq %rax
jmp 0x1329d
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
cmpl $0xa, %edx
ja 0x132c1
btl %edx, %ebp
jb 0x132c6
incq %rcx
jmp 0x132b3
cmpl %ecx, %eax
cmovgl %eax, %ecx
incl %ecx
movslq %ecx, %rdi
movl $0x1, %esi
callq 0x3610
movq %rax, %rsi
xorl %eax, %eax
movzbl (%rbx,%rax), %ecx
cmpl $0xa, %ecx
ja 0x132ed
btl %ecx, %ebp
jb 0x132f5
movb %cl, (%rsi,%rax)
incq %rax
jmp 0x132df
movq 0x30(%rsp), %rdi
movq %rsi, %rbx
callq 0x3460
testq %rax, %rax
je 0x13363
xorl %eax, %eax
movq %rbx, %rsi
movzbl (%r15,%rax), %ecx
cmpl $0xa, %ecx
ja 0x1331b
btl %ecx, %ebp
jb 0x13323
movb %cl, (%rsi,%rax)
incq %rax
jmp 0x1330c
movb $0x0, (%rsi,%rax)
movl (%r13), %r9d
testl %r9d, %r9d
movq %rsi, 0x20(%rsp)
je 0x1336b
movsbl (%rsi), %ecx
testl %ecx, %ecx
movq %r14, 0x10(%rsp)
je 0x13372
movb 0x1(%rsi), %al
testb %al, %al
je 0x13374
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 0x1334c
jmp 0x13374
movq %rbx, %rdi
jmp 0x1347e
xorl %ebx, %ebx
jmp 0x13419
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r9d
movl %edx, %r14d
leal -0x1(%r9), %edi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
incl %edx
movq 0x10(%r13), %rbp
movl %r14d, %ebx
movl %edx, 0x18(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rbp,%rax,4), %r15d
leal (%rbx,%rbx), %r13d
andl $0x1e, %r13d
movl %r15d, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x133fa
testb $0x1, %al
jne 0x133de
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r9, %r12
callq 0x35a0
movl 0x18(%rsp), %edx
movq %r12, %r9
movq 0x20(%rsp), %rsi
testl %eax, %eax
je 0x133fa
addl %edx, %ebx
cmpl %r9d, %ebx
movl %r9d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebx
cmpl %r14d, %ebx
jne 0x13395
movl %r9d, %ebx
jmp 0x13408
movl %r13d, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
cmovnel %r9d, %ebx
movq 0x8(%rsp), %r13
leaq 0x2c099(%rip), %r12     # 0x3f4ad
movq 0x10(%rsp), %r14
cmpl %r9d, %ebx
jne 0x1347b
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jb 0x1344b
movl 0x4(%r13), %eax
addl %eax, %eax
cmpl %r9d, %eax
movl $0x0, %esi
sbbl %esi, %esi
orl $0x1, %esi
addl %r9d, %esi
movq %r13, %rdi
callq 0x15411
movq 0x20(%rsp), %rsi
movl (%r13), %ebx
movsbl (%rsi), %edi
testl %edi, %edi
je 0x13491
movb 0x1(%rsi), %al
testb %al, %al
je 0x13493
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 0x13464
jmp 0x13493
movq %rsi, %rdi
callq 0x3350
testq %r14, %r14
jne 0x1321e
jmp 0x135f7
xorl %edi, %edi
movl %edi, %eax
xorl %edx, %edx
divl %ebx
movl %edx, %r10d
movq 0x10(%r13), %r9
movl %edx, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %eax
leal (%r10,%r10), %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x1357c
leal -0x1(%rbx), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %r10d, %r15d
movl %ebx, %r12d
movq %r14, 0x10(%rsp)
movq %r9, 0x18(%rsp)
movl %edx, 0x2c(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %ebp
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %ebp, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x1354e
testb $0x1, %al
jne 0x13529
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r10, %r14
callq 0x35a0
movl 0x2c(%rsp), %edx
movq %r14, %r10
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %rsi
testl %eax, %eax
je 0x1354e
btl %r13d, %ebp
cmovbl %r15d, %r12d
addl %edx, %r15d
cmpl %ebx, %r15d
movl %ebx, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r15d
movl %r12d, %eax
cmpl %r10d, %r15d
jne 0x134d6
jmp 0x13550
movl %ebx, %eax
movl %eax, %r10d
cmpl %ebx, %eax
movq 0x8(%rsp), %r13
jne 0x1357c
movl %r15d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %eax
leal (%r15,%r15), %ecx
shrl %cl, %eax
cmpl %ebx, %r12d
cmovel %r15d, %r12d
testb $0x2, %al
cmovel %r15d, %r12d
movl %r12d, %r10d
movl %r10d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %edx
leal (%r10,%r10), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
testb $0x2, %dl
jne 0x135c8
testb $0x1, %dl
leaq 0x2bf0f(%rip), %r12     # 0x3f4ad
je 0x13483
movq 0x18(%r13), %rdx
movl %r10d, %edi
movq %rsi, (%rdx,%rdi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r13), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%r13)
jmp 0x13483
movq 0x18(%r13), %rdx
movl %r10d, %edi
movq %rsi, (%rdx,%rdi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r13), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%r13)
incl 0x8(%r13)
leaq 0x2bebb(%rip), %r12     # 0x3f4ad
jmp 0x13483
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq