// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_init_tables
static void cram_init_tables(cram_fd *fd) {
    int i;

    memset(fd->L1, 4, 256);
    fd->L1['A'] = 0; fd->L1['a'] = 0;
    fd->L1['C'] = 1; fd->L1['c'] = 1;
    fd->L1['G'] = 2; fd->L1['g'] = 2;
    fd->L1['T'] = 3; fd->L1['t'] = 3;

    memset(fd->L2, 5, 256);
    fd->L2['A'] = 0; fd->L2['a'] = 0;
    fd->L2['C'] = 1; fd->L2['c'] = 1;
    fd->L2['G'] = 2; fd->L2['g'] = 2;
    fd->L2['T'] = 3; fd->L2['t'] = 3;
    fd->L2['N'] = 4; fd->L2['n'] = 4;

    if (CRAM_MAJOR_VERS(fd->version) == 1) {
        for (i = 0; i < 0x200; i++) {
            int f = 0;

            if (i & CRAM_FPAIRED)      f |= BAM_FPAIRED;
            if (i & CRAM_FPROPER_PAIR) f |= BAM_FPROPER_PAIR;
            if (i & CRAM_FUNMAP)       f |= BAM_FUNMAP;
            if (i & CRAM_FREVERSE)     f |= BAM_FREVERSE;
            if (i & CRAM_FREAD1)       f |= BAM_FREAD1;
            if (i & CRAM_FREAD2)       f |= BAM_FREAD2;
            if (i & CRAM_FSECONDARY)   f |= BAM_FSECONDARY;
            if (i & CRAM_FQCFAIL)      f |= BAM_FQCFAIL;
            if (i & CRAM_FDUP)         f |= BAM_FDUP;

            fd->bam_flag_swap[i]  = f;
        }

        for (i = 0; i < 0x1000; i++) {
            int g = 0;

            if (i & BAM_FPAIRED)           g |= CRAM_FPAIRED;
            if (i & BAM_FPROPER_PAIR)  g |= CRAM_FPROPER_PAIR;
            if (i & BAM_FUNMAP)        g |= CRAM_FUNMAP;
            if (i & BAM_FREVERSE)      g |= CRAM_FREVERSE;
            if (i & BAM_FREAD1)        g |= CRAM_FREAD1;
            if (i & BAM_FREAD2)        g |= CRAM_FREAD2;
            if (i & BAM_FSECONDARY)    g |= CRAM_FSECONDARY;
            if (i & BAM_FQCFAIL)       g |= CRAM_FQCFAIL;
            if (i & BAM_FDUP)          g |= CRAM_FDUP;

            fd->cram_flag_swap[i] = g;
        }
    } else {
        /* NOP */
        for (i = 0; i < 0x1000; i++)
            fd->bam_flag_swap[i] = i;
        for (i = 0; i < 0x1000; i++)
            fd->cram_flag_swap[i] = i;
    }

    memset(fd->cram_sub_matrix, 4, 32*32);
    for (i = 0; i < 32; i++) {
        fd->cram_sub_matrix[i]['A'&0x1f]=0;
        fd->cram_sub_matrix[i]['C'&0x1f]=1;
        fd->cram_sub_matrix[i]['G'&0x1f]=2;
        fd->cram_sub_matrix[i]['T'&0x1f]=3;
        fd->cram_sub_matrix[i]['N'&0x1f]=4;
    }
    for (i = 0; i < 20; i+=4) {
        int j;
        for (j = 0; j < 20; j++) {
            fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][j]=3;
            fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][j]=3;
            fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][j]=3;
            fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][j]=3;
        }
        fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][CRAM_SUBST_MATRIX[i+0]&0x1f]=0;
        fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][CRAM_SUBST_MATRIX[i+1]&0x1f]=1;
        fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][CRAM_SUBST_MATRIX[i+2]&0x1f]=2;
        fd->cram_sub_matrix["ACGTN"[i>>2]&0x1f][CRAM_SUBST_MATRIX[i+3]&0x1f]=3;
    }

    cram_init_varint(&fd->vv, CRAM_MAJOR_VERS(fd->version));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
addq $0x8270, %rdi           # imm = 0x8270
pushq $0x4
popq %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4260
xorl %r14d, %r14d
movb %r14b, 0x82b1(%rbx)
movb %r14b, 0x82d1(%rbx)
movb $0x1, %bpl
movb %bpl, 0x82b3(%rbx)
movb %bpl, 0x82d3(%rbx)
movb $0x2, %r15b
movb %r15b, 0x82b7(%rbx)
movb %r15b, 0x82d7(%rbx)
movb $0x3, %r12b
movb %r12b, 0x82c4(%rbx)
movb %r12b, 0x82e4(%rbx)
leaq 0x8370(%rbx), %rdi
pushq $0x5
popq %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4260
movb %r14b, 0x83b1(%rbx)
movb %r14b, 0x83d1(%rbx)
movb %bpl, 0x83b3(%rbx)
movb %bpl, 0x83d3(%rbx)
movb %r15b, 0x83b7(%rbx)
movb %r15b, 0x83d7(%rbx)
movb %r12b, 0x83c4(%rbx)
movb %r12b, 0x83e4(%rbx)
movb $0x4, %al
movb %al, 0x83be(%rbx)
movb %al, 0x83de(%rbx)
movl 0xc(%rbx), %ebp
movl %ebp, %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x100, %eax            # imm = 0x100
jne 0x44a67
movl $0x100, %eax            # imm = 0x100
movl $0x400, %ecx            # imm = 0x400
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq $0x200, %r9             # imm = 0x200
je 0x44a81
xorl %r10d, %r10d
cmpq $0x100, %r9             # imm = 0x100
setae %r10b
movl %r9d, %r11d
shrl $0x6, %r11d
andl $0x2, %r11d
orl %r10d, %r11d
movl %r9d, %r10d
shrl $0x4, %r10d
andl $0x4, %r10d
orl %r11d, %r10d
movl %r9d, %r11d
shrl %r11d
andl $0x10, %r11d
orl %r10d, %r11d
movl %r14d, %r10d
andl $0x40, %r10d
orl %r11d, %r10d
movl %edx, %r11d
andl $0x80, %r11d
orl %r10d, %r11d
movl %esi, %r10d
andl %eax, %r10d
orl %r11d, %r10d
movl %edi, %r11d
andl $0x200, %r11d           # imm = 0x200
movl %r8d, %r15d
andl %ecx, %r15d
orl %r11d, %r15d
orl %r10d, %r15d
movl %r15d, 0x270(%rbx,%r9,4)
incq %r9
addl %ecx, %r8d
addl %eax, %edi
addl $0x40, %esi
addl $0x10, %edx
addl $0x4, %r14d
jmp 0x449ce
xorl %eax, %eax
cmpq $0x1000, %rax           # imm = 0x1000
je 0x44b42
movl %eax, 0x270(%rbx,%rax,4)
incq %rax
jmp 0x44a69
xorl %eax, %eax
movl $0xf0f, %ecx            # imm = 0xF0F
movl $0x3333, %edx           # imm = 0x3333
xorl %esi, %esi
cmpq $0x1000, %rsi           # imm = 0x1000
je 0x44b58
movl %esi, %edi
andl $0x7, %edi
rolw $0x8, %di
movl %edi, %r8d
shrl $0x4, %r8d
andl %ecx, %r8d
andl %ecx, %edi
shll $0x4, %edi
orl %r8d, %edi
movl %edi, %r8d
andl %edx, %r8d
shrl $0x2, %edi
andl %edx, %edi
leal (%rdi,%r8,4), %edi
movl %edi, %r8d
andl $0x5540, %r8d           # imm = 0x5540
shrl %edi
andl $0x5500, %edi           # imm = 0x5500
leal (%rdi,%r8,2), %edi
shrl $0x7, %edi
movl %eax, %r8d
andl $0x20, %r8d
movl %esi, %r9d
shrl $0x2, %r9d
andl $0x10, %r9d
orl %r8d, %r9d
movl %esi, %r8d
shrl $0x4, %r8d
andl $0x8, %r8d
orl %r9d, %r8d
movl %esi, %r9d
shrl $0x6, %r9d
andl $0x4, %r9d
orl %r8d, %r9d
movl %esi, %r8d
shrl $0x8, %r8d
andl $0x2, %r8d
orl %r9d, %r8d
movl %esi, %r9d
shrl $0xa, %r9d
andl $0x1, %r9d
orl %r8d, %r9d
orl %edi, %r9d
movl %r9d, 0x4270(%rbx,%rsi,4)
incq %rsi
addl $0x2, %eax
jmp 0x44a8f
xorl %eax, %eax
cmpq $0x1000, %rax           # imm = 0x1000
je 0x44b58
movl %eax, 0x4270(%rbx,%rax,4)
incq %rax
jmp 0x44b44
leaq 0x8470(%rbx), %r14
pushq $0x4
popq %rsi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
callq 0x4260
xorl %eax, %eax
cmpq $0x400, %rax            # imm = 0x400
je 0x44ba7
movb $0x0, 0x8471(%rbx,%rax)
movb $0x1, 0x8473(%rbx,%rax)
movb $0x2, 0x8477(%rbx,%rax)
movb $0x3, 0x8484(%rbx,%rax)
movb $0x4, 0x847e(%rbx,%rax)
addq $0x20, %rax
jmp 0x44b71
xorl %eax, %eax
leaq 0x371bd(%rip), %rcx     # 0x7bd6d
pushq $-0x14
popq %rdx
leaq 0x37028(%rip), %rsi     # 0x7bbe2
cmpq $0x13, %rax
ja 0x44c32
movq %rax, %rdi
shrq $0x2, %rdi
movzbl (%rdi,%rcx), %edi
andl $0x1f, %edi
movl %edi, %r8d
shll $0x5, %r8d
addq %r14, %r8
movq %rdx, %r9
testq %r9, %r9
je 0x44beb
movb $0x3, 0x14(%r8,%r9)
incq %r9
jmp 0x44bdb
movzbl (%rax,%rsi), %r8d
andl $0x1f, %r8d
shll $0x5, %edi
addq %r14, %rdi
movb $0x0, (%r8,%rdi)
movzbl 0x1(%rax,%rsi), %r8d
andl $0x1f, %r8d
movb $0x1, (%r8,%rdi)
movzbl 0x2(%rax,%rsi), %r8d
andl $0x1f, %r8d
movb $0x2, (%r8,%rdi)
movzbl 0x3(%rax,%rsi), %r8d
andl $0x1f, %r8d
movb $0x3, (%r8,%rdi)
addq $0x4, %rax
jmp 0x44bba
cmpl $0x400, %ebp            # imm = 0x400
leaq 0x1ce0(%rip), %rax      # 0x4691f
leaq 0x20e4(%rip), %rdx      # 0x46d2a
cmovlq %rdx, %rax
movq %rax, 0x10(%rsp)
leaq 0x1d06(%rip), %rax      # 0x4695c
cmovlq %rdx, %rax
movq %rax, 0x8(%rsp)
leaq 0x1d4a(%rip), %rax      # 0x469b0
leaq 0x21ae(%rip), %rdi      # 0x46e1b
cmovlq %rdi, %rax
movq %rax, (%rsp)
leaq 0x1d6f(%rip), %rsi      # 0x469eb
cmovlq %rdi, %rsi
leaq 0x1dbc(%rip), %rdi      # 0x46a43
leaq 0x237f(%rip), %r9       # 0x4700d
cmovlq %r9, %rdi
leaq 0x1daf(%rip), %r8       # 0x46a48
cmovlq %r9, %r8
leaq 0x1da9(%rip), %r9       # 0x46a4d
leaq 0x2369(%rip), %r11      # 0x47014
cmovlq %r11, %r9
leaq 0x1d9c(%rip), %r10      # 0x46a52
cmovlq %r11, %r10
leaq 0x1d96(%rip), %r11      # 0x46a57
leaq -0x5d3e(%rip), %r15     # 0x3ef8a
cmovlq %r15, %r11
leaq 0x1dcb(%rip), %r14      # 0x46a9e
cmovlq %r15, %r14
leaq 0x1e07(%rip), %r15      # 0x46ae5
leaq -0x5cd3(%rip), %r12     # 0x3f012
cmovlq %r12, %r15
leaq 0x1e3d(%rip), %r13      # 0x46b2d
cmovlq %r12, %r13
leaq 0x1e7a(%rip), %r12      # 0x46b75
leaq 0x231a(%rip), %rbp      # 0x4701c
cmovgeq %r12, %rbp
leaq 0x1e7d(%rip), %r12      # 0x46b8a
leaq -0x67e1(%rip), %rax     # 0x3e533
cmovlq %rax, %r12
leaq 0x1ef0(%rip), %rcx      # 0x46c0f
cmovlq %rax, %rcx
leaq 0x1f7c(%rip), %rdx      # 0x46ca6
leaq -0x60d9(%rip), %rax     # 0x3ec58
cmovgeq %rdx, %rax
movq 0x10(%rsp), %rdx
movq %rdx, 0x89a8(%rbx)
movq 0x8(%rsp), %rdx
movq %rdx, 0x89b0(%rbx)
movq (%rsp), %rdx
movq %rdx, 0x89b8(%rbx)
movq %rsi, 0x89c0(%rbx)
movq %rdi, 0x89c8(%rbx)
movq %r8, 0x89d0(%rbx)
movq %r9, 0x89d8(%rbx)
movq %r10, 0x89e0(%rbx)
movq %r11, 0x89e8(%rbx)
movq %r14, 0x89f0(%rbx)
movq %r15, 0x89f8(%rbx)
movq %r13, 0x8a00(%rbx)
movq %rbp, 0x8a08(%rbx)
movq %r12, 0x8990(%rbx)
movq %rcx, 0x8998(%rbx)
movq %rax, 0x89a0(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq