// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: easy_errno
static int easy_errno(CURL *easy, CURLcode err)
{
    long lval;

    switch (err) {
    case CURLE_OK:
        return 0;

    case CURLE_UNSUPPORTED_PROTOCOL:
    case CURLE_URL_MALFORMAT:
        return EINVAL;

#if LIBCURL_VERSION_NUM >= 0x071505
    case CURLE_NOT_BUILT_IN:
        return ENOSYS;
#endif

    case CURLE_COULDNT_RESOLVE_PROXY:
    case CURLE_COULDNT_RESOLVE_HOST:
    case CURLE_FTP_CANT_GET_HOST:
        return EDESTADDRREQ; // Lookup failure

    case CURLE_COULDNT_CONNECT:
    case CURLE_SEND_ERROR:
    case CURLE_RECV_ERROR:
        if (curl_easy_getinfo(easy, CURLINFO_OS_ERRNO, &lval) == CURLE_OK)
            return lval;
        else
            return ECONNABORTED;

    case CURLE_REMOTE_ACCESS_DENIED:
    case CURLE_LOGIN_DENIED:
    case CURLE_TFTP_PERM:
        return EACCES;

    case CURLE_PARTIAL_FILE:
        return EPIPE;

    case CURLE_HTTP_RETURNED_ERROR:
        if (curl_easy_getinfo(easy, CURLINFO_RESPONSE_CODE, &lval) == CURLE_OK)
            return http_status_errno(lval);
        else
            return EIO;

    case CURLE_OUT_OF_MEMORY:
        return ENOMEM;

    case CURLE_OPERATION_TIMEDOUT:
        return ETIMEDOUT;

    case CURLE_RANGE_ERROR:
        return ESPIPE;

    case CURLE_SSL_CONNECT_ERROR:
        // TODO return SSL error buffer messages
        return ECONNABORTED;

    case CURLE_FILE_COULDNT_READ_FILE:
    case CURLE_TFTP_NOTFOUND:
        return ENOENT;

    case CURLE_TOO_MANY_REDIRECTS:
        return ELOOP;

    case CURLE_FILESIZE_EXCEEDED:
        return EFBIG;

    case CURLE_REMOTE_DISK_FULL:
        return ENOSPC;

    case CURLE_REMOTE_FILE_EXISTS:
        return EEXIST;

    default:
        hts_log_error("Libcurl reported error %d (%s)", (int) err,
                      curl_easy_strerror(err));
        return EIO;
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
leal -0x1(%rbx), %eax
cmpl $0x24, %eax
ja 0x80a7e
leaq 0x22f31(%rip), %rcx     # 0xa399c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x59, %eax
jmp 0x80b7d
leal -0x37(%rbx), %eax
cmpl $0x12, %eax
ja 0x80add
leaq 0x22fa3(%rip), %rcx     # 0xa3a30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%rsp), %rdx
movl $0x200019, %esi         # imm = 0x200019
xorl %eax, %eax
callq 0x4290
movl %eax, %ecx
movl $0x67, %eax
testl %ecx, %ecx
jne 0x80b7d
movl 0x8(%rsp), %eax
jmp 0x80b7d
movl $0xd, %eax
jmp 0x80b7d
movl $0x16, %eax
jmp 0x80b7d
movl $0x2, %eax
jmp 0x80b7d
cmpl $0x2f, %ebx
jne 0x80aec
movl $0x28, %eax
jmp 0x80b7d
movl %ebx, %edi
callq 0x4720
leaq 0x2323d(%rip), %rsi     # 0xa3d37
leaq 0x230c9(%rip), %rdx     # 0xa3bca
movl $0x1, %edi
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x14378
movl $0x5, %eax
jmp 0x80b7d
movl $0xc, %eax
jmp 0x80b7d
movl $0x26, %eax
jmp 0x80b7d
movl $0x67, %eax
jmp 0x80b7d
movl $0x20, %eax
jmp 0x80b7d
movl $0x1d, %eax
jmp 0x80b7d
leaq 0x8(%rsp), %rdx
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x4290
movl %eax, %ecx
movl $0x5, %eax
testl %ecx, %ecx
jne 0x80b7d
movl 0x8(%rsp), %edi
callq 0x8391e
jmp 0x80b7d
movl $0x6e, %eax
jmp 0x80b7d
movl $0x1c, %eax
jmp 0x80b7d
movl $0x1b, %eax
jmp 0x80b7d
movl $0x11, %eax
addq $0x10, %rsp
popq %rbx
retq