// File: /workspace/github_c_makefile_star2_O3/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:
movq 0x8(%rdi), %r9
movl %r9d, %r8d
shrl $0x18, %r8d
addq %rdx, %r8
shrq $0x30, %r9
leaq (%r8,%r9,4), %r10
movslq 0x10(%rdi), %rax
addq %rax, %r10
leal 0x1(%rax), %r11d
shrl $0x1f, %r11d
addl %r11d, %eax
incl %eax
sarl %eax
cltq
addq %r10, %rax
testq %r9, %r9
je 0x6d6d7
xorl %r9d, %r9d
movl (%r8,%r9,4), %r10d
bswapl %r10d
movl %r10d, (%r8,%r9,4)
incq %r9
movzwl 0xe(%rdi), %r10d
cmpq %r10, %r9
jb 0x6d6bf
movslq %esi, %rsi
addq %rsi, %rdx
cmpq %rdx, %rax
jae 0x6d8ba
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
leaq 0x2ccd1(%rip), %rsi     # 0x9a3c4
leaq 0x2cd0a(%rip), %rdi     # 0x9a404
leaq 0x2cd43(%rip), %r8      # 0x9a444
leaq 0x2cd20(%rip), %r9      # 0x9a428
leaq 0x2ccd9(%rip), %r10     # 0x9a3e8
movzbl 0x2(%rax), %r11d
cmpl $0x59, %r11d
jg 0x6d72c
leal -0x41(%r11), %ebx
cmpl $0x8, %ebx
ja 0x6d794
movslq (%rsi,%rbx,4), %rbx
addq %rsi, %rbx
jmpq *%rbx
leal -0x63(%r11), %ebx
cmpl $0x6, %ebx
ja 0x6d756
movslq (%r10,%rbx,4), %r11
addq %r10, %r11
jmpq *%r11
movl 0x3(%rax), %r11d
bswapl %r11d
movl %r11d, 0x3(%rax)
addq $0x7, %rax
jmp 0x6d7af
addq $0x4, %rax
jmp 0x6d7af
cmpl $0x5a, %r11d
je 0x6d76d
cmpl $0x73, %r11d
jne 0x6d79a
rolw $0x8, 0x3(%rax)
addq $0x5, %rax
jmp 0x6d7af
leaq 0x3(%rax), %rbx
cmpl $0x42, %r11d
je 0x6d7bd
cmpl $0x5a, %r11d
je 0x6d786
movq %rbx, %rax
cmpl $0x48, %r11d
jne 0x6d7af
leaq 0x1(%rbx), %rax
cmpb $0x0, (%rbx)
movq %rax, %rbx
jne 0x6d786
jmp 0x6d7af
cmpl $0x53, %r11d
je 0x6d762
addq $0x3, %rax
jmp 0x6d7af
movq 0x3(%rax), %r11
bswapq %r11
movq %r11, 0x3(%rax)
addq $0xb, %rax
cmpq %rdx, %rax
jb 0x6d70f
jmp 0x6d8b4
movb (%rbx), %r11b
movzbl %r11b, %r14d
movb $0x1, %bl
cmpl $0x59, %r14d
jg 0x6d7e5
leal -0x41(%r14), %r15d
cmpl $0x8, %r15d
ja 0x6d810
movslq (%rdi,%r15,4), %r14
addq %rdi, %r14
jmpq *%r14
movl %r11d, %ebx
jmp 0x6d81c
leal -0x63(%r14), %r15d
cmpl $0x6, %r15d
ja 0x6d7fd
movslq (%r9,%r15,4), %r11
addq %r9, %r11
jmpq *%r11
movb $0x4, %bl
jmp 0x6d81c
movl %r11d, %ebx
cmpl $0x5a, %r14d
je 0x6d81c
cmpl $0x73, %r14d
jne 0x6d816
movb $0x2, %bl
jmp 0x6d81c
cmpl $0x53, %r14d
je 0x6d80c
xorl %ebx, %ebx
jmp 0x6d81c
movb $0x8, %bl
testl %ecx, %ecx
je 0x6d82b
movl 0x4(%rax), %r11d
movl %r11d, %ebp
bswapl %ebp
jmp 0x6d833
movl 0x4(%rax), %ebp
bswapl %ebp
movl %ebp, %r11d
movl %ebp, 0x4(%rax)
addq $0x8, %rax
movzbl %bl, %ebx
decl %ebx
cmpl $0x7, %ebx
ja 0x6d7af
movslq (%r8,%rbx,4), %rbx
addq %r8, %rbx
jmpq *%rbx
movl %r11d, %r11d
addq %r11, %rax
jmp 0x6d7af
testl %r11d, %r11d
je 0x6d7af
movl (%rax), %ebx
bswapl %ebx
movl %ebx, (%rax)
addq $0x4, %rax
decl %r11d
jne 0x6d865
jmp 0x6d7af
testl %r11d, %r11d
je 0x6d7af
rolw $0x8, (%rax)
addq $0x2, %rax
decl %r11d
jne 0x6d882
jmp 0x6d7af
testl %r11d, %r11d
je 0x6d7af
movq (%rax), %rbx
bswapq %rbx
movq %rbx, (%rax)
addq $0x8, %rax
decl %r11d
jne 0x6d89d
jmp 0x6d7af
popq %rbx
popq %r14
popq %r15
popq %rbp
retq