// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/sam.c
// Function: swap_data
static void swap_data(const bam1_core_t *c, int l_data, uint8_t *data, int is_host)
{
    uint8_t *s;
    uint32_t *cigar = (uint32_t*)(data + c->l_qname);
    uint32_t i, n;
    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) ed_swap_4p(&cigar[i]);
    while (s < data + l_data) {
        int size;
        s += 2; // skip key
        size = aux_type2size(*s); ++s; // skip type
        switch (size) {
        case 1: ++s; break;
        case 2: ed_swap_2p(s); s += 2; break;
        case 4: ed_swap_4p(s); s += 4; break;
        case 8: ed_swap_8p(s); s += 8; break;
        case 'Z':
        case 'H':
            while (*s) ++s;
            ++s;
            break;
        case 'B':
            size = aux_type2size(*s); ++s;
            if (is_host) memcpy(&n, s, 4), ed_swap_4p(s);
            else ed_swap_4p(s), memcpy(&n, s, 4);
            s += 4;
            switch (size) {
            case 1: s += n; break;
            case 2: for (i = 0; i < n; ++i, s += 2) ed_swap_2p(s); break;
            case 4: for (i = 0; i < n; ++i, s += 4) ed_swap_4p(s); break;
            case 8: for (i = 0; i < n; ++i, s += 8) ed_swap_8p(s); break;
            }
            break;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r14
movq 0x8(%rdi), %r11
movl %r11d, %r8d
shrl $0x18, %r8d
leaq (%rdx,%r8), %r10
movq %r11, %rax
shrq $0x30, %rax
leaq (%rdx,%rax,4), %rcx
movslq 0x10(%rdi), %r9
leal 0x1(%r9), %eax
pushq $0x2
popq %rbp
cltd
idivl %ebp
cltq
xorl %edx, %edx
shrq $0x30, %r11
cmpq %r11, %rdx
jae 0x61ca7
movl (%r10,%rdx,4), %r11d
bswapl %r11d
movl %r11d, (%r10,%rdx,4)
incq %rdx
movq 0x8(%rdi), %r11
jmp 0x61c8a
addq %r8, %rcx
addq %r9, %rcx
addq %rax, %rcx
movslq %esi, %rax
addq %rax, %r14
leaq 0x274a7(%rip), %r15     # 0x89164
leaq 0x27480(%rip), %r12     # 0x89144
cmpq %r14, %rcx
jae 0x61de1
movq %rcx, %r13
movzbl 0x2(%rcx), %edi
callq 0x642f6
leaq 0x3(%r13), %rcx
movzbl %al, %eax
leal -0x1(%rax), %edx
cmpl $0x7, %edx
ja 0x61cfa
movslq (%r12,%rdx,4), %rax
addq %r12, %rax
jmpq *%rax
addq $0x4, %r13
movq %r13, %rcx
jmp 0x61cc4
cmpl $0x42, %eax
je 0x61d58
cmpl $0x5a, %eax
je 0x61d44
movq %rcx, %rdx
cmpl $0x48, %eax
jne 0x61cc4
jmp 0x61d47
movl 0x3(%r13), %eax
bswapl %eax
movl %eax, 0x3(%r13)
addq $0x7, %r13
movq %r13, %rcx
jmp 0x61cc4
movq 0x3(%r13), %rax
bswapq %rax
movq %rax, 0x3(%r13)
addq $0xb, %r13
movq %r13, %rcx
jmp 0x61cc4
rolw $0x8, 0x3(%r13)
addq $0x5, %r13
movq %r13, %rcx
jmp 0x61cc4
movq %rcx, %rdx
leaq 0x1(%rdx), %rcx
cmpb $0x0, (%rdx)
movq %rcx, %rdx
jne 0x61d47
jmp 0x61cc4
movzbl 0x3(%r13), %edi
callq 0x642f6
testl %ebx, %ebx
je 0x61d70
movl 0x4(%r13), %edx
movl %edx, %ecx
bswapl %ecx
jmp 0x61d78
movl 0x4(%r13), %ecx
bswapl %ecx
movl %ecx, %edx
movl %ecx, 0x4(%r13)
movq %r13, %rcx
addq $0x8, %rcx
movzbl %al, %eax
decl %eax
cmpl $0x7, %eax
ja 0x61cc4
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl %edx, %eax
addq %rax, %rcx
jmp 0x61cc4
movl (%rcx), %eax
bswapl %eax
movl %eax, (%rcx)
addq $0x4, %rcx
subl $0x1, %edx
jae 0x61da4
jmp 0x61cc4
movq (%rcx), %rax
bswapq %rax
movq %rax, (%rcx)
addq $0x8, %rcx
subl $0x1, %edx
jae 0x61db8
jmp 0x61cc4
rolw $0x8, (%rcx)
addq $0x2, %rcx
subl $0x1, %edx
jae 0x61dcf
jmp 0x61cc4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq