// File: /workspace/github_c_makefile_star2_O1/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), %r8
movl %r8d, %eax
shrl $0x18, %eax
addq %rdx, %rax
shrq $0x30, %r8
leaq (%rax,%r8,4), %r9
movslq 0x10(%rdi), %r10
addq %r10, %r9
leal 0x1(%r10), %r11d
shrl $0x1f, %r11d
addl %r11d, %r10d
incl %r10d
sarl %r10d
movslq %r10d, %r11
addq %r9, %r11
testq %r8, %r8
je 0x6d726
xorl %r8d, %r8d
movl (%rax,%r8,4), %r9d
bswapl %r9d
movl %r9d, (%rax,%r8,4)
incq %r8
movzwl 0xe(%rdi), %r9d
cmpq %r9, %r8
jb 0x6d70e
movslq %esi, %rax
addq %rax, %rdx
cmpq %rdx, %r11
jae 0x6d95d
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
leaq 0x2ca52(%rip), %rax     # 0x9a194
leaq 0x2ca8b(%rip), %rsi     # 0x9a1d4
leaq 0x2caa4(%rip), %rdi     # 0x9a1f4
leaq 0x2cadd(%rip), %r8      # 0x9a234
leaq 0x2caba(%rip), %r9      # 0x9a218
leaq 0x2ca53(%rip), %r10     # 0x9a1b8
movb 0x2(%r11), %bl
movzbl %bl, %r14d
movb $0x1, %bpl
cmpl $0x59, %r14d
jg 0x6d78e
leal -0x41(%r14), %r15d
cmpl $0x8, %r15d
ja 0x6d7b9
movslq (%rax,%r15,4), %r14
addq %rax, %r14
jmpq *%r14
movl %ebx, %ebp
jmp 0x6d7c6
leal -0x63(%r14), %r15d
cmpl $0x6, %r15d
ja 0x6d7a6
movslq (%r10,%r15,4), %rbx
addq %r10, %rbx
jmpq *%rbx
movb $0x4, %bpl
jmp 0x6d7c6
movl %ebx, %ebp
cmpl $0x5a, %r14d
je 0x6d7c6
cmpl $0x73, %r14d
jne 0x6d7bf
movb $0x2, %bpl
jmp 0x6d7c6
cmpl $0x53, %r14d
je 0x6d7b4
xorl %ebp, %ebp
jmp 0x6d7c6
movb $0x8, %bpl
leaq 0x3(%r11), %rbx
movzbl %bpl, %r14d
cmpl $0x41, %r14d
jg 0x6d7f1
decl %r14d
cmpl $0x7, %r14d
ja 0x6d86f
movslq (%rsi,%r14,4), %r14
addq %rsi, %r14
jmpq *%r14
addq $0x4, %r11
jmp 0x6d833
cmpl $0x42, %r14d
je 0x6d838
cmpl $0x5a, %r14d
je 0x6d85f
movq %rbx, %r11
cmpl $0x48, %r14d
je 0x6d862
jmp 0x6d86f
movl 0x3(%r11), %ebx
bswapl %ebx
movl %ebx, 0x3(%r11)
addq $0x7, %r11
jmp 0x6d833
movq 0x3(%r11), %rbx
bswapq %rbx
movq %rbx, 0x3(%r11)
addq $0xb, %r11
jmp 0x6d833
rolw $0x8, 0x3(%r11)
addq $0x5, %r11
movq %r11, %rbx
jmp 0x6d86f
movb (%rbx), %bpl
movzbl %bpl, %r14d
movb $0x1, %bl
cmpl $0x59, %r14d
jg 0x6d880
leal -0x41(%r14), %r15d
cmpl $0x8, %r15d
ja 0x6d8aa
movslq (%rdi,%r15,4), %r14
addq %rdi, %r14
jmpq *%r14
movl %ebp, %ebx
jmp 0x6d8b6
movq %rbx, %r11
leaq 0x1(%r11), %rbx
cmpb $0x0, (%r11)
movq %rbx, %r11
jne 0x6d862
movq %rbx, %r11
cmpq %rdx, %rbx
jb 0x6d765
jmp 0x6d957
leal -0x63(%r14), %r15d
cmpl $0x6, %r15d
ja 0x6d898
movslq (%r9,%r15,4), %r14
addq %r9, %r14
jmpq *%r14
movb $0x4, %bl
jmp 0x6d8b6
movl %ebp, %ebx
cmpl $0x5a, %r14d
je 0x6d8b6
cmpl $0x73, %r14d
jne 0x6d8b0
movb $0x2, %bl
jmp 0x6d8b6
cmpl $0x53, %r14d
je 0x6d8a6
xorl %ebx, %ebx
jmp 0x6d8b6
movb $0x8, %bl
testl %ecx, %ecx
je 0x6d8c6
movl 0x4(%r11), %ebp
movl %ebp, %r14d
bswapl %r14d
jmp 0x6d8d0
movl 0x4(%r11), %r14d
bswapl %r14d
movl %r14d, %ebp
movl %r14d, 0x4(%r11)
addq $0x8, %r11
movzbl %bl, %ebx
decl %ebx
cmpl $0x7, %ebx
ja 0x6d833
movslq (%r8,%rbx,4), %rbx
addq %r8, %rbx
jmpq *%rbx
movl %ebp, %ebx
addq %rbx, %r11
jmp 0x6d833
movq %r11, %rbx
testl %ebp, %ebp
je 0x6d86f
movl (%rbx), %r11d
bswapl %r11d
movl %r11d, (%rbx)
addq $0x4, %rbx
decl %ebp
jne 0x6d904
jmp 0x6d86f
movq %r11, %rbx
testl %ebp, %ebp
je 0x6d86f
rolw $0x8, (%rbx)
addq $0x2, %rbx
decl %ebp
jne 0x6d925
jmp 0x6d86f
movq %r11, %rbx
testl %ebp, %ebp
je 0x6d86f
movq (%rbx), %r11
bswapq %r11
movq %r11, (%rbx)
addq $0x8, %rbx
decl %ebp
jne 0x6d941
jmp 0x6d86f
popq %rbx
popq %r14
popq %r15
popq %rbp
retq