// File: /workspace/github_c_makefile_star2_O3/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 0x11585
movq %rax, %r14
movl $0x3, %edi
callq 0x40f0
testl %eax, %eax
je 0x7e330
xorl %edi, %edi
movl %eax, %esi
callq 0x7e55c
movl %eax, %ebx
callq 0x4050
movl %ebx, (%rax)
jmp 0x7e3b2
callq 0x4490
movq %rax, 0x38dfc(%rip)     # 0xb7138
testq %rax, %rax
je 0x7e3a2
leaq 0x342(%rip), %rdx       # 0x7e68a
movq %rax, %rdi
movl $0x3, %esi
xorl %eax, %eax
callq 0x42b0
movl %eax, %ebp
movq 0x38dd8(%rip), %rdi     # 0xb7138
leaq 0x32f(%rip), %rdx       # 0x7e696
movl $0x4, %esi
xorl %eax, %eax
callq 0x42b0
movl %eax, %r15d
orl %ebp, %r15d
movq 0x38db8(%rip), %rdi     # 0xb7138
movl $0x1, %esi
movl $0x3, %edx
xorl %eax, %eax
callq 0x42b0
orl %r15d, %eax
je 0x7e3c2
movq 0x38d9b(%rip), %rdi     # 0xb7138
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 0x22e97(%rip), %rdi     # 0xa1260
callq 0x4600
testq %rax, %rax
je 0x7e412
movq %rax, %rdi
callq 0x4930
movq %rax, %r12
movq %rax, 0x38d5b(%rip)     # 0xb7140
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, %r15
movq %rax, 0x38d4a(%rip)     # 0xb7148
testq %r12, %r12
setne %al
testq %r15, %r15
setne %cl
testb %cl, %al
je 0x7e4b5
leaq 0x22e59(%rip), %rdi     # 0xa1272
callq 0x4600
testq %rax, %rax
je 0x7e440
leaq 0x22e73(%rip), %rsi     # 0xa129d
movq %rax, %rdi
callq 0x46c0
testl %eax, %eax
jne 0x7e440
movl $0x1, 0x38d10(%rip)     # 0xb7150
movl $0x9, %edi
callq 0x43a0
movq %rax, %r15
movq 0x8(%rax), %rcx
leaq 0x38cc8(%rip), %rdi     # 0xb7120
leaq 0x22e55(%rip), %rsi     # 0xa12b4
xorl %ebp, %ebp
movq %r14, %rdx
xorl %eax, %eax
callq 0x9ab7
leaq 0x171f1(%rip), %rax     # 0x95663
movq %rax, 0x10(%rbx)
leaq 0x225(%rip), %rax       # 0x7e6a2
movq %rax, 0x18(%rbx)
movq 0x40(%r15), %r14
movq (%r14), %rdi
testq %rdi, %rdi
je 0x7e3b7
addq $0x8, %r14
leaq 0x374bc(%rip), %rbx     # 0xb5958
movq %rbx, %rsi
callq 0xf7a2
movq (%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x7e49c
jmp 0x7e3b7
callq 0x4050
movq %rax, %rbx
movl (%rax), %ebp
movq %r12, %rdi
callq 0x45c0
testq %r15, %r15
je 0x7e4d4
movq %r15, %rdi
callq 0x45c0
movq 0x38c5d(%rip), %rdi     # 0xb7138
callq 0x4910
callq 0x41a0
movl %ebp, (%rbx)
jmp 0x7e3b2