// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: hfile_plugin_init_libcurl
int PLUGIN_GLOBAL(hfile_plugin_init,_libcurl)(struct hFILE_plugin *self)
{
    static const struct hFILE_scheme_handler handler =
        { hopen_libcurl, hfile_always_remote, "libcurl",
          2000 + 50,
          vhopen_libcurl };

#ifdef ENABLE_PLUGINS
    // Embed version string for examination via strings(1) or what(1)
    static const char id[] =
        "@(#)hfile_libcurl plugin (htslib)\t" HTS_VERSION_TEXT;
    const char *version = strchr(id, '\t')+1;
#else
    const char *version = hts_version();
#endif
    const curl_version_info_data *info;
    const char * const *protocol;
    const char *auth;
    CURLcode err;
    CURLSHcode errsh;

    err = curl_global_init(CURL_GLOBAL_ALL);
    if (err != CURLE_OK) { errno = easy_errno(NULL, err); return -1; }

    curl.share = curl_share_init();
    if (curl.share == NULL) { curl_global_cleanup(); errno = EIO; return -1; }
    errsh = curl_share_setopt(curl.share, CURLSHOPT_LOCKFUNC, share_lock);
    errsh |= curl_share_setopt(curl.share, CURLSHOPT_UNLOCKFUNC, share_unlock);
    errsh |= curl_share_setopt(curl.share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
    if (errsh != 0) {
        curl_share_cleanup(curl.share);
        curl_global_cleanup();
        errno = EIO;
        return -1;
    }

    if ((auth = getenv("HTS_AUTH_LOCATION")) != NULL) {
        curl.auth_path = strdup(auth);
        curl.auth_map = kh_init(auth_map);
        if (!curl.auth_path || !curl.auth_map) {
            int save_errno = errno;
            free(curl.auth_path);
            kh_destroy(auth_map, curl.auth_map);
            curl_share_cleanup(curl.share);
            curl_global_cleanup();
            errno = save_errno;
            return -1;
        }
    }
    if ((auth = getenv("HTS_ALLOW_UNENCRYPTED_AUTHORIZATION_HEADER")) != NULL
        && strcmp(auth, "I understand the risks") == 0) {
        curl.allow_unencrypted_auth_header = 1;
    }

    info = curl_version_info(CURLVERSION_NOW);
    ksprintf(&curl.useragent, "htslib/%s libcurl/%s", version, info->version);

    self->name = "libcurl";
    self->destroy = libcurl_exit;

    for (protocol = info->protocols; *protocol; protocol++)
        hfile_add_scheme_handler(*protocol, &handler);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x117ef
movq %rax, %r14
movl $0x3, %edi
callq 0x40f0
testl %eax, %eax
je 0x80808
xorl %edi, %edi
movl %eax, %esi
callq 0x80a55
movl %eax, %ebx
callq 0x4050
movl %ebx, (%rax)
jmp 0x8088a
callq 0x4490
movq %rax, 0x39924(%rip)     # 0xba138
testq %rax, %rax
je 0x8087a
leaq 0x363(%rip), %rdx       # 0x80b83
movq %rax, %rdi
movl $0x3, %esi
xorl %eax, %eax
callq 0x42b0
movl %eax, %ebp
movq 0x39900(%rip), %rdi     # 0xba138
leaq 0x350(%rip), %rdx       # 0x80b8f
movl $0x4, %esi
xorl %eax, %eax
callq 0x42b0
movl %eax, %r15d
orl %ebp, %r15d
movq 0x398e0(%rip), %rdi     # 0xba138
movl $0x1, %esi
movl $0x3, %edx
xorl %eax, %eax
callq 0x42b0
orl %r15d, %eax
je 0x8089a
movq 0x398c3(%rip), %rdi     # 0xba138
callq 0x4910
callq 0x41a0
callq 0x4050
movl $0x5, (%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2322f(%rip), %rdi     # 0xa3ad0
callq 0x4600
testq %rax, %rax
je 0x808ea
movq %rax, %rdi
callq 0x4930
movq %rax, %r12
movq %rax, 0x39883(%rip)     # 0xba140
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, %r15
movq %rax, 0x39872(%rip)     # 0xba148
testq %r12, %r12
setne %al
testq %r15, %r15
setne %cl
testb %cl, %al
je 0x8098d
leaq 0x231f1(%rip), %rdi     # 0xa3ae2
callq 0x4600
testq %rax, %rax
je 0x80918
leaq 0x2320b(%rip), %rsi     # 0xa3b0d
movq %rax, %rdi
callq 0x46c0
testl %eax, %eax
jne 0x80918
movl $0x1, 0x39838(%rip)     # 0xba150
movl $0x9, %edi
callq 0x43a0
movq %rax, %r15
movq 0x8(%rax), %rcx
leaq 0x397f0(%rip), %rdi     # 0xba120
leaq 0x231ed(%rip), %rsi     # 0xa3b24
xorl %ebp, %ebp
movq %r14, %rdx
xorl %eax, %eax
callq 0x9aab
leaq 0x17cd9(%rip), %rax     # 0x98623
movq %rax, 0x10(%rbx)
leaq 0x246(%rip), %rax       # 0x80b9b
movq %rax, 0x18(%rbx)
movq 0x40(%r15), %r14
movq (%r14), %rdi
testq %rdi, %rdi
je 0x8088f
addq $0x8, %r14
leaq 0x37fe4(%rip), %rbx     # 0xb8958
movq %rbx, %rsi
callq 0xf992
movq (%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x80974
jmp 0x8088f
callq 0x4050
movq %rax, %rbx
movl (%rax), %ebp
movq %r12, %rdi
callq 0x45c0
testq %r15, %r15
je 0x809c7
movq 0x18(%r15), %rdi
callq 0x45c0
movq 0x10(%r15), %rdi
callq 0x45c0
movq 0x20(%r15), %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
movq 0x3976a(%rip), %rdi     # 0xba138
callq 0x4910
callq 0x41a0
movl %ebp, (%rbx)
jmp 0x8088a