// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/bam.c
// Function: swap_endian_data
static void swap_endian_data(const bam1_core_t *c, int data_len, uint8_t *data)
{
	uint8_t *s;
	uint32_t i, *cigar = (uint32_t*)(data + c->l_qname);
	s = data + c->n_cigar*4 + c->l_qname + c->l_qseq + (c->l_qseq + 1)/2;
	for (i = 0; i < c->n_cigar; ++i) bam_swap_endian_4p(&cigar[i]);
	while (s < data + data_len) {
		uint8_t type;
		s += 2; // skip key
		type = toupper(*s); ++s; // skip type
		if (type == 'C' || type == 'A') ++s;
		else if (type == 'S') { bam_swap_endian_2p(s); s += 2; }
		else if (type == 'I' || type == 'F') { bam_swap_endian_4p(s); s += 4; }
		else if (type == 'D') { bam_swap_endian_8p(s); s += 8; }
		else if (type == 'Z' || type == 'H') { while (*s) ++s; ++s; }
		else if (type == 'B') {
			int32_t n, Bsize = bam_aux_type2size(*s);
			memcpy(&n, s + 1, 4);
			if (1 == Bsize) {
			} else if (2 == Bsize) {
				for (i = 0; i < n; i += 2)
					bam_swap_endian_2p(s + 5 + i);
			} else if (4 == Bsize) {
				for (i = 0; i < n; i += 4)
					bam_swap_endian_4p(s + 5 + i);
			}
			bam_swap_endian_4p(s+1); 
		}
	}
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x18, %rcx
andq $0xff, %rcx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x30, %rcx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x18, %rcx
andq $0xff, %rcx
movslq %ecx, %rcx
addq %rcx, %rax
movq 0x40(%rsp), %rcx
movslq 0x10(%rcx), %rcx
addq %rcx, %rax
movq %rax, (%rsp)
movq 0x40(%rsp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq (%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x30, %rcx
cmpl %ecx, %eax
jae 0x3661be
movq 0x18(%rsp), %rdi
movl 0x24(%rsp), %eax
shlq $0x2, %rax
addq %rax, %rdi
callq 0x365aa0
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x366187
jmp 0x3661c0
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movslq 0x3c(%rsp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x3663cf
movq 0x28(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movzbl (%rax), %edi
callq 0x19dd0
movb %al, 0x17(%rsp)
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
movzbl 0x17(%rsp), %eax
cmpl $0x43, %eax
je 0x36621c
movzbl 0x17(%rsp), %eax
cmpl $0x41, %eax
jne 0x36622f
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x3663ca
movzbl 0x17(%rsp), %eax
cmpl $0x53, %eax
jne 0x366256
movq 0x28(%rsp), %rdi
callq 0x367b20
movq 0x28(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x28(%rsp)
jmp 0x3663c8
movzbl 0x17(%rsp), %eax
cmpl $0x49, %eax
je 0x36626a
movzbl 0x17(%rsp), %eax
cmpl $0x46, %eax
jne 0x366287
movq 0x28(%rsp), %rdi
callq 0x365aa0
movq 0x28(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
jmp 0x3663c6
movzbl 0x17(%rsp), %eax
cmpl $0x44, %eax
jne 0x3662ae
movq 0x28(%rsp), %rdi
callq 0x367b50
movq 0x28(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x28(%rsp)
jmp 0x3663c4
movzbl 0x17(%rsp), %eax
cmpl $0x5a, %eax
je 0x3662c2
movzbl 0x17(%rsp), %eax
cmpl $0x48, %eax
jne 0x3662f1
jmp 0x3662c4
movq 0x28(%rsp), %rax
cmpb $0x0, (%rax)
je 0x3662de
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x3662c4
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x3663c2
movzbl 0x17(%rsp), %eax
cmpl $0x42, %eax
jne 0x3663c0
movq 0x28(%rsp), %rax
movzbl (%rax), %edi
callq 0x367b80
movl %eax, 0xc(%rsp)
movq 0x28(%rsp), %rax
movl 0x1(%rax), %eax
movl %eax, 0x10(%rsp)
movl $0x1, %eax
cmpl 0xc(%rsp), %eax
jne 0x36632c
jmp 0x3663b2
movl $0x2, %eax
cmpl 0xc(%rsp), %eax
jne 0x36636d
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x10(%rsp), %eax
jae 0x36636b
movq 0x28(%rsp), %rdi
addq $0x5, %rdi
movl 0x24(%rsp), %eax
addq %rax, %rdi
callq 0x367b20
movl 0x24(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x24(%rsp)
jmp 0x36633f
jmp 0x3663b0
movl $0x4, %eax
cmpl 0xc(%rsp), %eax
jne 0x3663ae
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x10(%rsp), %eax
jae 0x3663ac
movq 0x28(%rsp), %rdi
addq $0x5, %rdi
movl 0x24(%rsp), %eax
addq %rax, %rdi
callq 0x365aa0
movl 0x24(%rsp), %eax
addl $0x4, %eax
movl %eax, 0x24(%rsp)
jmp 0x366380
jmp 0x3663ae
jmp 0x3663b0
jmp 0x3663b2
movq 0x28(%rsp), %rdi
addq $0x1, %rdi
callq 0x365aa0
jmp 0x3663c2
jmp 0x3663c4
jmp 0x3663c6
jmp 0x3663c8
jmp 0x3663ca
jmp 0x3661c0
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)