// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_external.c
// Function: cram_expand_method
cram_method_details *cram_expand_method(uint8_t *data, int32_t size,
                                        enum cram_block_method comp) {
    cram_method_details *cm = calloc(1, sizeof(*cm));
    if (!cm)
        return NULL;

    const char *xz_header = "\xFD""7zXZ"; // including nul

    if (comp == CRAM_COMP_UNKNOWN) {
        // Auto-detect
        if (size > 1 && data[0] == 0x1f && data[1] == 0x8b)
            comp = CRAM_COMP_GZIP;
        else if (size > 3 && data[1] == 'B' && data[2] == 'Z'
                 && data[3] == 'h')
            comp = CRAM_COMP_BZIP2;
        else if (size > 6 && memcmp(xz_header, data, 6) == 0)
            comp = CRAM_COMP_LZMA;
        else
            comp = CRAM_COMP_UNKNOWN;
    }
    cm->method = comp;

    // Interrogate the compressed data stream to fill out additional fields.
    switch (comp) {
    case CRAM_COMP_GZIP:
        if (size > 8) {
            if (data[8] == 4)
                cm->level = 1;
            else if (data[8] == 2)
                cm->level = 9;
            else
                cm->level = 5;
        }
        break;

    case CRAM_COMP_BZIP2:
        if (size > 3 && data[3] >= '1' && data[3] <= '9')
            cm->level = data[3]-'0';
        break;

    case CRAM_COMP_RANS4x8:
        cm->Nway = 4;
        if (size > 0 && data[0] == 1)
            cm->order = 1;
        else
            cm->order = 0;
        break;

    case CRAM_COMP_RANSNx16:
        if (size > 0) {
            cm->order  = data[0] & 1;
            cm->Nway   = data[0] & RANS_ORDER_X32    ? 32 : 4;
            cm->rle    = data[0] & RANS_ORDER_RLE    ?  1 : 0;
            cm->pack   = data[0] & RANS_ORDER_PACK   ?  1 : 0;
            cm->cat    = data[0] & RANS_ORDER_CAT    ?  1 : 0;
            cm->stripe = data[0] & RANS_ORDER_STRIPE ?  1 : 0;
            cm->nosz   = data[0] & RANS_ORDER_NOSZ   ?  1 : 0;
        }
        break;

    case CRAM_COMP_ARITH:
        if (size > 0) {
            // Not in a public header, but the same transforms as rANSNx16
            cm->order  = data[0] & 3;
            cm->rle    = data[0] & RANS_ORDER_RLE    ?  1 : 0;
            cm->pack   = data[0] & RANS_ORDER_PACK   ?  1 : 0;
            cm->cat    = data[0] & RANS_ORDER_CAT    ?  1 : 0;
            cm->stripe = data[0] & RANS_ORDER_STRIPE ?  1 : 0;
            cm->nosz   = data[0] & RANS_ORDER_NOSZ   ?  1 : 0;
            cm->ext    = data[0] & 4 /*external*/    ?  1 : 0;
        }
        break;

    case CRAM_COMP_TOK3:
        if (size > 8) {
            if (data[8] == 1)
                cm->level = 11;
            else if (data[8] == 0)
                cm->level = 1;
        }
        break;

    default:
        break;
    }

    return cm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x16060
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xc4209
movq $0x0, -0x8(%rbp)
jmp 0xc4597
leaq 0x7736d(%rip), %rax     # 0x13b57d
movq %rax, -0x28(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0xc42b1
cmpl $0x1, -0x14(%rbp)
jle 0xc4248
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1f, %eax
jne 0xc4248
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x8b, %eax
jne 0xc4248
movl $0x1, -0x18(%rbp)
jmp 0xc42af
cmpl $0x3, -0x14(%rbp)
jle 0xc427e
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x42, %eax
jne 0xc427e
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x5a, %eax
jne 0xc427e
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x68, %eax
jne 0xc427e
movl $0x2, -0x18(%rbp)
jmp 0xc42ad
cmpl $0x6, -0x14(%rbp)
jle 0xc42a4
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x6, %edx
callq 0x16020
cmpl $0x0, %eax
jne 0xc42a4
movl $0x3, -0x18(%rbp)
jmp 0xc42ab
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
jmp 0xc42ad
jmp 0xc42af
jmp 0xc42b1
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x7, %eax
ja 0xc458d
movq -0x30(%rbp), %rax
leaq 0x771ef(%rip), %rcx     # 0x13b4c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x8, -0x14(%rbp)
jle 0xc432b
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x4, %eax
jne 0xc4302
movq -0x20(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0xc4329
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x2, %eax
jne 0xc431c
movq -0x20(%rbp), %rax
movl $0x9, 0x4(%rax)
jmp 0xc4327
movq -0x20(%rbp), %rax
movl $0x5, 0x4(%rax)
jmp 0xc4329
jmp 0xc432b
jmp 0xc458f
cmpl $0x3, -0x14(%rbp)
jle 0xc4362
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x31, %eax
jl 0xc4362
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x39, %eax
jg 0xc4362
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %ecx
subl $0x30, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0xc458f
movq -0x20(%rbp), %rax
movl $0x4, 0x20(%rax)
cmpl $0x0, -0x14(%rbp)
jle 0xc4391
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0xc4391
movq -0x20(%rbp), %rax
movl $0x1, 0x8(%rax)
jmp 0xc439c
movq -0x20(%rbp), %rax
movl $0x0, 0x8(%rax)
jmp 0xc458f
cmpl $0x0, -0x14(%rbp)
jle 0xc4476
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
andl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x4, %edx
movl $0x4, %ecx
movl $0x20, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x40, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x80, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x20, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x8, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x10, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0xc458f
cmpl $0x0, -0x14(%rbp)
jle 0xc454d
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
andl $0x3, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x40, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x80, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x20, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x8, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x10, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x4, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
jmp 0xc458f
cmpl $0x8, -0x14(%rbp)
jle 0xc458b
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x1, %eax
jne 0xc456f
movq -0x20(%rbp), %rax
movl $0xb, 0x4(%rax)
jmp 0xc4589
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0xc4587
movq -0x20(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0xc4589
jmp 0xc458b
jmp 0xc458f
jmp 0xc458f
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)