// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
callq 0x18120
movq %rax, -0x18(%rbp)
movl $0x3, %edi
callq 0x40d0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xcea7d
movl -0x34(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0xced50
movl %eax, -0x40(%rbp)
callq 0x4050
movl -0x40(%rbp), %ecx
movl %ecx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcec93
callq 0x4480
movq %rax, 0x43e3f(%rip)     # 0x1128c8
cmpq $0x0, 0x43e37(%rip)     # 0x1128c8
jne 0xceaaf
callq 0x4180
callq 0x4050
movl $0x5, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcec93
movq 0x43e12(%rip), %rdi     # 0x1128c8
movl $0x3, %esi
leaq 0x40e(%rip), %rdx       # 0xceed0
movb $0x0, %al
callq 0x42a0
movl %eax, -0x38(%rbp)
movq 0x43df5(%rip), %rdi     # 0x1128c8
movl $0x4, %esi
leaq 0x421(%rip), %rdx       # 0xcef00
movb $0x0, %al
callq 0x42a0
orl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movq 0x43dd5(%rip), %rdi     # 0x1128c8
movl $0x1, %esi
movl $0x3, %edx
movb $0x0, %al
callq 0x42a0
orl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0xceb38
movq 0x43db1(%rip), %rdi     # 0x1128c8
callq 0x4900
callq 0x4180
callq 0x4050
movl $0x5, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcec93
leaq 0x289fd(%rip), %rdi     # 0xf753c
callq 0x45e0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xcebd3
movq -0x30(%rbp), %rdi
callq 0x4920
movq %rax, 0x43d6e(%rip)     # 0x1128d0
callq 0xcef30
movq %rax, 0x43d6a(%rip)     # 0x1128d8
cmpq $0x0, 0x43d5a(%rip)     # 0x1128d0
je 0xceb82
cmpq $0x0, 0x43d58(%rip)     # 0x1128d8
jne 0xcebd1
callq 0x4050
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq 0x43d3d(%rip), %rdi     # 0x1128d0
callq 0x45a0
movq 0x43d39(%rip), %rdi     # 0x1128d8
callq 0xcef50
movq 0x43d1d(%rip), %rdi     # 0x1128c8
callq 0x4900
callq 0x4180
movl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
callq 0x4050
movl -0x44(%rbp), %ecx
movl %ecx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcec93
jmp 0xcebd3
leaq 0x28974(%rip), %rdi     # 0xf754e
callq 0x45e0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xcec08
movq -0x30(%rbp), %rdi
leaq 0x28985(%rip), %rsi     # 0xf7579
callq 0x4690
cmpl $0x0, %eax
jne 0xcec08
movl $0x1, 0x43cd8(%rip)     # 0x1128e0
movl $0x9, %edi
callq 0x4390
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x43c87(%rip), %rdi     # 0x1128b0
leaq 0x28960(%rip), %rsi     # 0xf7590
movb $0x0, %al
callq 0xb040
movq -0x10(%rbp), %rax
leaq 0x20bf1(%rip), %rcx     # 0xef833
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
leaq 0x34f(%rip), %rcx       # 0xcefa0
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0xcec8c
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x3e0bf(%rip), %rsi     # 0x10cd38
callq 0x14e80
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0xcec61
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)