// File: /workspace/github_c_makefile_star2_O2/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 0xf698
movq %rax, %r14
pushq $0x3
popq %rdi
callq 0x40f0
testl %eax, %eax
je 0x643a7
xorl %edi, %edi
movl %eax, %esi
callq 0x645af
movl %eax, %ebx
callq 0x4050
movl %ebx, (%rax)
jmp 0x64423
callq 0x4490
movq %rax, 0x3ad85(%rip)     # 0x9f138
testq %rax, %rax
je 0x64413
leaq 0x31b(%rip), %rdx       # 0x646da
pushq $0x3
popq %rbp
movq %rax, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x42b0
movl %eax, %r15d
movq 0x3ad60(%rip), %rdi     # 0x9f138
leaq 0x307(%rip), %rdx       # 0x646e6
pushq $0x4
popq %rsi
xorl %eax, %eax
callq 0x42b0
movl %eax, %r12d
orl %r15d, %r12d
movq 0x3ad42(%rip), %rdi     # 0x9f138
pushq $0x1
popq %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x42b0
orl %r12d, %eax
je 0x64431
movq 0x3ad2a(%rip), %rdi     # 0x9f138
callq 0x4910
callq 0x41a0
callq 0x4050
movl $0x5, (%rax)
pushq $-0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e718(%rip), %rdi     # 0x82b50
callq 0x4600
testq %rax, %rax
je 0x6447d
movq %rax, %rdi
callq 0x4930
movq %rax, %r15
movq %rax, 0x3acec(%rip)     # 0x9f140
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x4300
movq %rax, %r12
movq %rax, 0x3acdf(%rip)     # 0x9f148
testq %r15, %r15
setne %al
testq %r12, %r12
setne %cl
testb %cl, %al
je 0x6450f
leaq 0x1e6de(%rip), %rdi     # 0x82b62
callq 0x4600
testq %rax, %rax
je 0x644ab
leaq 0x1e6f8(%rip), %rsi     # 0x82b8d
movq %rax, %rdi
callq 0x46c0
testl %eax, %eax
jne 0x644ab
movl $0x1, 0x3aca5(%rip)     # 0x9f150
pushq $0x9
popq %rdi
callq 0x43a0
movq %rax, %r15
movq 0x8(%rax), %rcx
leaq 0x3ac5f(%rip), %rdi     # 0x9f120
leaq 0x1e6dc(%rip), %rsi     # 0x82ba4
xorl %ebp, %ebp
movq %r14, %rdx
xorl %eax, %eax
callq 0x8c78
leaq 0x13138(%rip), %rax     # 0x77613
movq %rax, 0x10(%rbx)
leaq 0x23a(%rip), %rax       # 0x64720
movq %rax, 0x18(%rbx)
movq 0x40(%r15), %r14
leaq 0x39463(%rip), %rbx     # 0x9d958
movq (%r14), %rdi
testq %rdi, %rdi
je 0x64426
movq %rbx, %rsi
callq 0xdb74
addq $0x8, %r14
jmp 0x644f5
callq 0x4050
movq %rax, %rbx
movl (%rax), %ebp
movq %r15, %rdi
callq 0x45c0
movq %r12, %rdi
callq 0x646f2
movq 0x3ac08(%rip), %rdi     # 0x9f138
callq 0x4910
callq 0x41a0
movl %ebp, (%rbx)
jmp 0x64423