// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/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 0x115bd
movl (%r10,%rdx,4), %r11d
bswapl %r11d
movl %r11d, (%r10,%rdx,4)
incq %rdx
movq 0x8(%rdi), %r11
jmp 0x115a0
addq %r8, %rcx
addq %r9, %rcx
addq %rax, %rcx
movslq %esi, %rax
addq %rax, %r14
leaq 0x32b61(%rip), %r15     # 0x44134
leaq 0x32b3a(%rip), %r12     # 0x44114
cmpq %r14, %rcx
jae 0x116f7
movq %rcx, %r13
movzbl 0x2(%rcx), %edi
callq 0x13ab9
leaq 0x3(%r13), %rcx
movzbl %al, %eax
leal -0x1(%rax), %edx
cmpl $0x7, %edx
ja 0x11610
movslq (%r12,%rdx,4), %rax
addq %r12, %rax
jmpq *%rax
addq $0x4, %r13
movq %r13, %rcx
jmp 0x115da
cmpl $0x42, %eax
je 0x1166e
cmpl $0x5a, %eax
je 0x1165a
movq %rcx, %rdx
cmpl $0x48, %eax
jne 0x115da
jmp 0x1165d
movl 0x3(%r13), %eax
bswapl %eax
movl %eax, 0x3(%r13)
addq $0x7, %r13
movq %r13, %rcx
jmp 0x115da
movq 0x3(%r13), %rax
bswapq %rax
movq %rax, 0x3(%r13)
addq $0xb, %r13
movq %r13, %rcx
jmp 0x115da
rolw $0x8, 0x3(%r13)
addq $0x5, %r13
movq %r13, %rcx
jmp 0x115da
movq %rcx, %rdx
leaq 0x1(%rdx), %rcx
cmpb $0x0, (%rdx)
movq %rcx, %rdx
jne 0x1165d
jmp 0x115da
movzbl 0x3(%r13), %edi
callq 0x13ab9
testl %ebx, %ebx
je 0x11686
movl 0x4(%r13), %edx
movl %edx, %ecx
bswapl %ecx
jmp 0x1168e
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 0x115da
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl %edx, %eax
addq %rax, %rcx
jmp 0x115da
movl (%rcx), %eax
bswapl %eax
movl %eax, (%rcx)
addq $0x4, %rcx
subl $0x1, %edx
jae 0x116ba
jmp 0x115da
movq (%rcx), %rax
bswapq %rax
movq %rax, (%rcx)
addq $0x8, %rcx
subl $0x1, %edx
jae 0x116ce
jmp 0x115da
rolw $0x8, (%rcx)
addq $0x2, %rcx
subl $0x1, %edx
jae 0x116e5
jmp 0x115da
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq