// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
leal -0x1(%rbx), %eax
cmpl $0x24, %eax
ja 0x645d6
pushq $0x16
popq %rbp
leaq 0x1e456(%rip), %rcx     # 0x82a1c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x59
jmp 0x646ad
leal -0x37(%rbx), %eax
cmpl $0x12, %eax
ja 0x6461d
leaq 0x1e4cb(%rip), %rcx     # 0x82ab0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rsp, %rdx
movl $0x200019, %esi         # imm = 0x200019
xorl %eax, %eax
callq 0x4290
testl %eax, %eax
je 0x64651
pushq $0x67
jmp 0x646ad
pushq $0xd
jmp 0x646ad
movl %ebp, %eax
jmp 0x646ae
pushq $0x2
jmp 0x646ad
cmpl $0x2f, %ebx
jne 0x64629
pushq $0x28
jmp 0x646ad
movl %ebx, %edi
callq 0x4720
leaq 0x1e780(%rip), %rsi     # 0x82db7
leaq 0x1e60c(%rip), %rdx     # 0x82c4a
pushq $0x1
popq %rdi
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x110c6
pushq $0x5
jmp 0x646ad
movl (%rsp), %eax
jmp 0x646ae
movq %rsp, %rdx
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x4290
movl %eax, %ecx
pushq $0x5
popq %rax
testl %ecx, %ecx
jne 0x646ae
movl (%rsp), %ecx
cmpl $0x1f4, %ecx            # imm = 0x1F4
jl 0x646b5
addl $0xfffffe0b, %ecx       # imm = 0xFFFFFE0B
cmpl $0x4, %ecx
jae 0x646ae
movl %ecx, %eax
leaq 0x1e4b3(%rip), %rcx     # 0x82b40
jmp 0x646d5
pushq $0x1d
jmp 0x646ad
pushq $0x6e
jmp 0x646ad
pushq $0x26
jmp 0x646ad
pushq $0x20
jmp 0x646ad
pushq $0xc
jmp 0x646ad
pushq $0x1c
jmp 0x646ad
pushq $0x1b
jmp 0x646ad
pushq $0x11
popq %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
xorl %eax, %eax
cmpl $0x190, %ecx            # imm = 0x190
jl 0x646ae
addl $0xfffffe6f, %ecx       # imm = 0xFFFFFE6F
movl %ebp, %eax
cmpl $0xa, %ecx
jae 0x646ae
movl %ecx, %eax
leaq 0x1e427(%rip), %rcx     # 0x82afc
movl (%rcx,%rax,4), %eax
jmp 0x646ae