// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam.c
// Function: bam_format1_core
char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of)
{
	uint8_t *s = bam1_seq(b), *t = bam1_qual(b);
	int i;
	const bam1_core_t *c = &b->core;
	kstring_t str;
	str.l = str.m = 0; str.s = 0;

	ksprintf(&str, "%s\t", bam1_qname(b));
	if (of == BAM_OFDEC) ksprintf(&str, "%d\t", c->flag);
	else if (of == BAM_OFHEX) ksprintf(&str, "0x%x\t", c->flag);
	else { // BAM_OFSTR
		for (i = 0; i < 16; ++i)
			if ((c->flag & 1<<i) && bam_flag2char_table[i])
				kputc(bam_flag2char_table[i], &str);
		kputc('\t', &str);
	}
	if (c->tid < 0) kputs("*\t", &str);
	else ksprintf(&str, "%s\t", header->target_name[c->tid]);
	ksprintf(&str, "%d\t%d\t", c->pos + 1, c->qual);
	if (c->n_cigar == 0) kputc('*', &str);
	else {
		for (i = 0; i < c->n_cigar; ++i)
			ksprintf(&str, "%d%c", bam1_cigar(b)[i]>>BAM_CIGAR_SHIFT, "MIDNSHP"[bam1_cigar(b)[i]&BAM_CIGAR_MASK]);
	}
	kputc('\t', &str);
	if (c->mtid < 0) kputs("*\t", &str);
	else if (c->mtid == c->tid) kputs("=\t", &str);
	else ksprintf(&str, "%s\t", header->target_name[c->mtid]);
	ksprintf(&str, "%d\t%d\t", c->mpos + 1, c->isize);
	if (c->l_qseq) {
		for (i = 0; i < c->l_qseq; ++i) kputc(bam_nt16_rev_table[bam1_seqi(s, i)], &str);
		kputc('\t', &str);
		if (t[0] == 0xff) kputc('*', &str);
		else for (i = 0; i < c->l_qseq; ++i) kputc(t[i] + 33, &str);
	} else ksprintf(&str, "*\t*");
	s = bam1_aux(b);
	while (s < b->data + b->data_len) {
		uint8_t type, key[2];
		key[0] = s[0]; key[1] = s[1];
		s += 2; type = *s; ++s;
		ksprintf(&str, "\t%c%c:", key[0], key[1]);
		if (type == 'A') { ksprintf(&str, "A:%c", *s); ++s; }
		else if (type == 'C') { ksprintf(&str, "i:%u", *s); ++s; }
		else if (type == 'c') { ksprintf(&str, "i:%d", *s); ++s; }
		else if (type == 'S') { ksprintf(&str, "i:%u", *(uint16_t*)s); s += 2; }
		else if (type == 's') { ksprintf(&str, "i:%d", *(int16_t*)s); s += 2; }
		else if (type == 'I') { ksprintf(&str, "i:%u", *(uint32_t*)s); s += 4; }
		else if (type == 'i') { ksprintf(&str, "i:%d", *(int32_t*)s); s += 4; }
		else if (type == 'f') { ksprintf(&str, "f:%g", *(float*)s); s += 4; }
		else if (type == 'd') { ksprintf(&str, "d:%lg", *(double*)s); s += 8; }
		else if (type == 'Z' || type == 'H') { ksprintf(&str, "%c:", type); while (*s) kputc(*s++, &str); ++s; }
	}
	return str.s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
movq 0x30(%rsi), %rdx
movq 0x8(%rsi), %r15
movl 0x10(%rsi), %eax
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x14d4d(%rip), %rsi     # 0x271b7
movq %rdx, 0x30(%rsp)
xorl %eax, %eax
callq 0x10a44
testl %ebp, %ebp
je 0x1248c
cmpl $0x1, %ebp
jne 0x124a6
movzwl 0xc(%rbx), %edx
leaq 0x13fd2(%rip), %rsi     # 0x2645c
jmp 0x12497
movzwl 0xc(%rbx), %edx
leaq 0x127b5(%rip), %rsi     # 0x24c4c
movq %rsp, %rdi
xorl %eax, %eax
callq 0x10a44
jmp 0x125c3
xorl %r12d, %r12d
movl 0xc(%rbx), %eax
btl %r12d, %eax
jae 0x1253e
movq 0x1d713(%rip), %rax     # 0x2fbd0
movb (%rax,%r12), %bpl
testb %bpl, %bpl
je 0x1253e
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x1251c
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb %bpl, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r12
cmpq $0x10, %r12
jne 0x124a9
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x125a1
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb $0x9, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movslq (%rbx), %rax
testq %rax, %rax
js 0x125eb
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%rax,8), %rdx
leaq 0x14bd8(%rip), %rsi     # 0x271b7
movq %rsp, %rdi
xorl %eax, %eax
callq 0x10a44
jmp 0x12667
movq (%rsp), %rax
addq $0x3, %rax
cmpq 0x8(%rsp), %rax
jb 0x12642
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movw $0x92a, (%rcx,%rax)     # imm = 0x92A
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x2(%rax), %rdx
movq %rdx, (%rsp)
movb $0x0, 0x2(%rcx,%rax)
movl 0x4(%rbx), %edx
incl %edx
movzbl 0xa(%rbx), %ecx
leaq 0x125d2(%rip), %rsi     # 0x24c49
movq %rsp, %rdi
xorl %eax, %eax
callq 0x10a44
cmpw $0x0, 0xe(%rbx)
jne 0x12702
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x126de
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb $0x2a, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
jmp 0x12760
movabsq $0x1000000000000, %rcx  # imm = 0x1000000000000
movq 0x8(%rbx), %rax
cmpq %rcx, %rax
jb 0x12760
leaq 0x13d4b(%rip), %rbp     # 0x26467
leaq 0x13d3f(%rip), %r12     # 0x26462
movq %rsp, %r13
xorl %r14d, %r14d
shrl $0x18, %eax
addq 0x30(%rbx), %rax
movl (%rax,%r14,4), %eax
movl %eax, %edx
shrl $0x4, %edx
andl $0xf, %eax
movsbl (%rax,%rbp), %ecx
movq %r13, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x10a44
incq %r14
movq 0x8(%rbx), %rax
movq %rax, %rcx
shrq $0x30, %rcx
cmpq %rcx, %r14
jb 0x12729
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x127b6
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb $0x9, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movslq 0x14(%rbx), %rax
testq %rax, %rax
js 0x12851
cmpl (%rbx), %eax
jne 0x128cf
movq (%rsp), %rax
addq $0x3, %rax
cmpq 0x8(%rsp), %rax
jb 0x12840
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movw $0x93d, (%rcx,%rax)     # imm = 0x93D
jmp 0x128b7
movq (%rsp), %rax
addq $0x3, %rax
cmpq 0x8(%rsp), %rax
jb 0x128a8
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movw $0x92a, (%rcx,%rax)     # imm = 0x92A
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x2(%rax), %rdx
movq %rdx, (%rsp)
movb $0x0, 0x2(%rcx,%rax)
jmp 0x128ed
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%rax,8), %rdx
leaq 0x148d4(%rip), %rsi     # 0x271b7
movq %rsp, %rdi
xorl %eax, %eax
callq 0x10a44
movl 0x18(%rbx), %edx
movl 0x1c(%rbx), %ecx
incl %edx
leaq 0x1234d(%rip), %rsi     # 0x24c49
movq %rsp, %rdi
xorl %eax, %eax
callq 0x10a44
cmpl $0x0, 0x10(%rbx)
je 0x12b24
movq 0x28(%rsp), %rdx
leal 0x1(%rdx), %eax
shrl $0x1f, %eax
movq %r15, %rcx
shrq $0x30, %rcx
shrl $0x18, %r15d
addl %edx, %eax
incl %eax
movq 0x30(%rsp), %rdx
leaq (%rdx,%rcx,4), %rcx
addq %rcx, %r15
sarl %eax
cltq
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x10(%rbx)
jle 0x129fb
xorl %ebp, %ebp
leaq 0x1d58e(%rip), %r12     # 0x2fee0
xorl %r13d, %r13d
movl %r13d, %eax
shrl %eax
movzbl (%r15,%rax), %eax
movl %ebp, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %eax
movq (%r12), %rcx
andl $0xf, %eax
movb (%rcx,%rax), %r14b
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x129c9
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb %r14b, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incl %r13d
addl $0x4, %ebp
cmpl 0x10(%rbx), %r13d
jl 0x12955
addq 0x20(%rsp), %r15
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x12a56
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb $0x9, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
cmpb $-0x1, (%r15)
je 0x12b37
cmpl $0x0, 0x10(%rbx)
jle 0x12baf
xorl %r14d, %r14d
movb (%r15,%r14), %bpl
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x12ae9
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
addb $0x21, %bpl
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb %bpl, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
incq %r14
movslq 0x10(%rbx), %rax
cmpq %rax, %r14
jl 0x12a8f
jmp 0x12baf
leaq 0x13944(%rip), %rsi     # 0x2646f
movq %rsp, %rdi
xorl %eax, %eax
callq 0x10a44
jmp 0x12baf
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x12b8d
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb $0x2a, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x8(%rbx), %rax
movq 0x30(%rbx), %rcx
movq %rax, %rdx
shrq $0x30, %rdx
leaq (%rcx,%rdx,4), %rdx
shrl $0x18, %eax
movslq 0x10(%rbx), %rsi
addq %rsi, %rax
addq %rdx, %rax
leal 0x1(%rsi), %edx
shrl $0x1f, %edx
addl %esi, %edx
incl %edx
sarl %edx
movslq %edx, %r13
addq %rax, %r13
movslq 0x24(%rbx), %rax
addq %rcx, %rax
cmpq %rax, %r13
jae 0x12e00
leaq 0x1387b(%rip), %r14     # 0x26473
movq %rsp, %r15
movzbl (%r13), %edx
movzbl 0x1(%r13), %ecx
movzbl 0x2(%r13), %ebp
leaq 0x3(%r13), %r12
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x10a44
cmpl $0x59, %ebp
jle 0x12c4c
leal -0x63(%rbp), %eax
cmpl $0x6, %eax
ja 0x12c7c
leaq 0x13791(%rip), %rcx     # 0x263c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x1383d(%rip), %rsi     # 0x26484
jmp 0x12d8a
leal -0x41(%rbp), %eax
cmpl $0x8, %eax
ja 0x12d46
leaq 0x1373d(%rip), %rcx     # 0x2639c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x13803(%rip), %rsi     # 0x2647a
jmp 0x12d8a
cmpl $0x5a, %ebp
je 0x12c9e
cmpl $0x73, %ebp
jne 0x12dec
movswl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x137eb(%rip), %rsi     # 0x26484
jmp 0x12d5e
movq %r15, %rdi
leaq 0x137ce(%rip), %rsi     # 0x26476
movl %ebp, %edx
xorl %eax, %eax
callq 0x10a44
movb (%r12), %bpl
testb %bpl, %bpl
je 0x12d3e
movq (%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jb 0x12d14
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x3610
movq %rax, 0x10(%rsp)
incq %r12
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movb %bpl, (%rcx,%rax)
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx,%rax)
jmp 0x12cb1
incq %r12
jmp 0x12dec
cmpl $0x53, %ebp
jne 0x12dec
movzwl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x13721(%rip), %rsi     # 0x2647f
xorl %eax, %eax
callq 0x10a44
addq $0x5, %r13
jmp 0x12de9
movl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x13706(%rip), %rsi     # 0x2647f
jmp 0x12da5
movzbl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x136f5(%rip), %rsi     # 0x2647f
xorl %eax, %eax
callq 0x10a44
addq $0x4, %r13
jmp 0x12de9
movl 0x3(%r13), %edx
movq %r15, %rdi
leaq 0x136df(%rip), %rsi     # 0x26484
xorl %eax, %eax
callq 0x10a44
jmp 0x12de5
movsd 0x3(%r13), %xmm0
movq %r15, %rdi
leaq 0x136d0(%rip), %rsi     # 0x2648e
movb $0x1, %al
callq 0x10a44
addq $0xb, %r13
jmp 0x12de9
xorps %xmm0, %xmm0
cvtss2sd 0x3(%r13), %xmm0
movq %r15, %rdi
leaq 0x136ab(%rip), %rsi     # 0x26489
movb $0x1, %al
callq 0x10a44
addq $0x7, %r13
movq %r13, %r12
movslq 0x24(%rbx), %rax
addq 0x30(%rbx), %rax
movq %r12, %r13
cmpq %rax, %r12
jb 0x12bfb
movq 0x10(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq