// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/rANS_static4x16pr.c
// Function: rans_enc_func
static inline
unsigned char *(*rans_enc_func(int do_simd, int order))
    (unsigned char *in,
     unsigned int in_size,
     unsigned char *out,
     unsigned int *out_size) {

    if (!do_simd) { // SIMD disabled
        return order & 1
            ? rans_compress_O1_4x16
            : rans_compress_O0_4x16;
    }

#ifdef NO_THREADS
    htscodecs_tls_cpu_init();
#else
    int err = pthread_once(&rans_cpu_once, htscodecs_tls_cpu_init);
    if (err != 0) {
        fprintf(stderr, "Initialising TLS data failed: pthread_once: %s\n",
                strerror(err));
        fprintf(stderr, "Using scalar code only\n");
    }
#endif

    int have_e_sse4_1  = have_sse4_1;
    int have_e_avx2    = have_avx2;
    int have_e_avx512f = have_avx512f;

    if (!(rans_cpu & RANS_CPU_ENC_AVX512)) have_e_avx512f = 0;
    if (!(rans_cpu & RANS_CPU_ENC_AVX2))   have_e_avx2    = 0;
    if (!(rans_cpu & RANS_CPU_ENC_SSE4))   have_e_sse4_1  = 0;

    if (order & 1) {
        // With simulated gathers, the AVX512 is now slower than AVX2, so
        // we avoid using it unless asking for the real avx512 gather.
        // Note for testing we do -c 0x0404 to enable AVX512 and disable AVX2.
        // We then need to call the avx512 func regardless.
        int use_gather;
#ifdef USE_GATHER
        use_gather = 1;
#else
        use_gather = !have_e_avx2;
#endif

#if defined(HAVE_AVX512)
        if (have_e_avx512f && (!is_amd || !have_e_avx2) && use_gather)
            return rans_compress_O1_32x16_avx512;
#endif
#if defined(HAVE_AVX2)
        if (have_e_avx2)
            return rans_compress_O1_32x16_avx2;
#endif
#if defined(HAVE_SSE4_1) && defined(HAVE_SSSE3) && defined(HAVE_POPCNT)
        if (have_e_sse4_1)
            return rans_compress_O1_32x16;
#endif
        return rans_compress_O1_32x16;
    } else {
#if defined(HAVE_AVX512)
        if (have_e_avx512f && (!is_amd || !have_e_avx2))
            return rans_compress_O0_32x16_avx512;
#endif
#if defined(HAVE_AVX2)
        if (have_e_avx2)
            return rans_compress_O0_32x16_avx2;
#endif
#if defined(HAVE_SSE4_1) && defined(HAVE_SSSE3) && defined(HAVE_POPCNT)
        if (have_e_sse4_1)
            return rans_compress_O0_32x16;
#endif
        return rans_compress_O0_32x16;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x916b8
movl -0x10(%rbp), %edx
andl $0x1, %edx
leaq -0x3261(%rip), %rax     # 0x8e440
leaq 0x1868(%rip), %rcx      # 0x92f10
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x9183e
leaq 0x811e5(%rip), %rdi     # 0x1128a4
leaq -0x14d6(%rip), %rsi     # 0x901f0
callq 0x4460
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x91717
movq 0x7b905(%rip), %rax     # 0x10cfe0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %edi
callq 0x4130
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0x64e1e(%rip), %rsi     # 0xf6516
movb $0x0, %al
callq 0x46d0
movq 0x7b8da(%rip), %rax     # 0x10cfe0
movq (%rax), %rdi
leaq 0x64e36(%rip), %rsi     # 0xf6546
movb $0x0, %al
callq 0x46d0
movl 0x8117b(%rip), %eax     # 0x112898
movl %eax, -0x18(%rbp)
movl 0x81176(%rip), %eax     # 0x11289c
movl %eax, -0x1c(%rbp)
movl 0x81171(%rip), %eax     # 0x1128a0
movl %eax, -0x20(%rbp)
movl 0x7c498(%rip), %eax     # 0x10dbd0
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x91747
movl $0x0, -0x20(%rbp)
movl 0x7c483(%rip), %eax     # 0x10dbd0
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x9175c
movl $0x0, -0x1c(%rbp)
movl 0x7c46e(%rip), %eax     # 0x10dbd0
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x91771
movl $0x0, -0x18(%rbp)
movl -0x10(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x917eb
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x917b8
cmpl $0x0, 0x810f2(%rip)     # 0x11288c
je 0x917a2
cmpl $0x0, -0x1c(%rbp)
jne 0x917b8
cmpl $0x0, -0x24(%rbp)
je 0x917b8
leaq 0x19311(%rip), %rax     # 0xaaac0
movq %rax, -0x8(%rbp)
jmp 0x9183e
cmpl $0x0, -0x1c(%rbp)
je 0x917cb
leaq 0xb14b(%rip), %rax      # 0x9c910
movq %rax, -0x8(%rbp)
jmp 0x9183e
cmpl $0x0, -0x18(%rbp)
je 0x917de
leaq 0x2f338(%rip), %rax     # 0xc0b10
movq %rax, -0x8(%rbp)
jmp 0x9183e
leaq 0x2f32b(%rip), %rax     # 0xc0b10
movq %rax, -0x8(%rbp)
jmp 0x9183e
cmpl $0x0, -0x20(%rbp)
je 0x9180d
cmpl $0x0, 0x81094(%rip)     # 0x11288c
je 0x91800
cmpl $0x0, -0x1c(%rbp)
jne 0x9180d
leaq 0x15c39(%rip), %rax     # 0xa7440
movq %rax, -0x8(%rbp)
jmp 0x9183e
cmpl $0x0, -0x1c(%rbp)
je 0x91820
leaq 0x3d06(%rip), %rax      # 0x95520
movq %rax, -0x8(%rbp)
jmp 0x9183e
cmpl $0x0, -0x18(%rbp)
je 0x91833
leaq 0x2cd13(%rip), %rax     # 0xbe540
movq %rax, -0x8(%rbp)
jmp 0x9183e
leaq 0x2cd06(%rip), %rax     # 0xbe540
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)