#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
#define E2BIG 180
#define EACCES 179
#define EADDRINUSE 178
#define EADDRNOTAVAIL 177
#define EAFNOSUPPORT 176
#define EAGAIN 175
#define EBADF 174
#define EBUSY 173
#define ECHILD 172
#define ECONNREFUSED 171
#define ECONNRESET 170
#define EDEADLK 169
#define EDESTADDRREQ 168
#define EDOM 167
#define EDQUOT 166
#define EEXIST 165
#define EFAULT 164
#define EFBIG 163
#define EINTR 162
#define EINVAL 161
#define EIO 160
#define EISCONN 159
#define EISDIR 158
#define ELOOP 157
#define EMFILE 156
#define EMLINK 155
#define EMSGSIZE 154
#define ENAMETOOLONG 153
#define ENFILE 152
#define ENOBUFS 151
#define ENODEV 150
#define ENOENT 149
#define ENOEXEC 148
#define ENOMEM 147
#define ENOPROTOOPT 146
#define ENOSPC 145
#define ENOTCONN 144
#define ENOTDIR 143
#define ENOTSOCK 142
#define ENOTTY 141
#define ENXIO 140
#define EOPNOTSUPP 139
#define EOVERFLOW 138
#define EPERM 137
#define EPIPE 136
#define EPROTONOSUPPORT 135
#define ERANGE 134
#define EROFS 133
#define ESPIPE 132
#define ESRCH 131
#define ETIMEDOUT 130
#define ETXTBSY 129
#define EXDEV 128
int errno;
int convert_std_errno(int _error_code) {
  switch (_error_code) {
  case EPERM:
    return -1001;
  case ENOENT:
    return -1002;
  case ESRCH:
    return -1003;
  case EINTR:
    return -1004;
  case EIO:
    return -1005;
  case ENXIO:
    return -1006;
  case E2BIG:
    return -1007;
  case ENOEXEC:
    return -1008;
  case EBADF:
    return -1009;
  case ECHILD:
    return -1010;
  case EAGAIN:
    return -1011;
  case ENOMEM:
    return -1012;
  case EACCES:
    return -1013;
  case EFAULT:
    return -1014;
  case EBUSY:
    return -1016;
  case EEXIST:
    return -1017;
  case EXDEV:
    return -1018;
  case ENODEV:
    return -1019;
  case ENOTDIR:
    return -1020;
  case EISDIR:
    return -1021;
  case EINVAL:
    return -1022;
  case ENFILE:
    return -1023;
  case EMFILE:
    return -1024;
  case ENOTTY:
    return -1025;
  case EFBIG:
    return -1027;
  case ENOSPC:
    return -1028;
  case ESPIPE:
    return -1029;
  case EROFS:
    return -1030;
  case EMLINK:
    return -1031;
  case EPIPE:
    return -1032;
  case EDOM:
    return -1033;
  case ERANGE:
    return -1034;
  case EDEADLK:
    return -1205;
  case ETIMEDOUT:
    return -1200;
  case ELOOP:
    return -1102;
  case EAFNOSUPPORT:
    return -1107;
  case ENOBUFS:
    return -1012;
  case EPROTONOSUPPORT:
    return -1103;
  case EADDRINUSE:
    return -1110;
  case ENOTSOCK:
    return -1109;
  case EADDRNOTAVAIL:
    return -1104;
  case ENAMETOOLONG:
    return -1119;
  case ECONNRESET:
    return -1702;
  case EDESTADDRREQ:
    return -1706;
  case EISCONN:
    return -1703;
  case EMSGSIZE:
    return -1705;
  case ENOTCONN:
    return -1704;
  case EOPNOTSUPP:
    return -1204;
  case ECONNREFUSED:
    return -1702;
  case EDQUOT:
    return -1101;
  case ENOPROTOOPT:
    return -1108;
  case EOVERFLOW:
    return -1101;
  case ETXTBSY:
    return -1600;
  default:
    return -errno;
  }
}


x86 assembly (clang, -O0):
<convert_std_errno>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x34,%eax
ja     13ac <convert_std_errno+0x2ac>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xfffffc17,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc16,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc15,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc14,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc13,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc12,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc11,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc10,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0f,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0e,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0d,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0c,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0b,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0a,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc08,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc07,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc06,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc05,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc04,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc03,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc02,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc01,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc00,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbff,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbfd,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbfc,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbfb,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbfa,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbf9,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbf8,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbf7,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbf6,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffb4b,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffb50,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbb2,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbad,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffc0c,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbb1,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbaa,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbab,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbb0,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffba1,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff95a,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff956,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff959,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff957,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff958,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffb4c,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff95a,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbb3,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbac,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffffbb3,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
movl   $0xfffff9c0,-0x4(%rbp)
jmp    13ba <convert_std_errno+0x2ba>
xor    %eax,%eax
mov    0x2c2b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_std_errno>:
add    $0xffffff80,%edi
cmp    $0x35,%edi
jae    1116 <convert_std_errno+0x16>
movslq %edi,%rax
lea    0xeee(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret
mov    0x2ec3(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
ret

LLVM IR (-O0):
@errno = global i32 0
define i32 @convert_std_errno(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %58 [
i32 137, label %5
i32 149, label %6
i32 131, label %7
i32 162, label %8
i32 160, label %9
i32 140, label %10
i32 180, label %11
i32 148, label %12
i32 174, label %13
i32 172, label %14
i32 175, label %15
i32 147, label %16
i32 179, label %17
i32 164, label %18
i32 173, label %19
i32 165, label %20
i32 128, label %21
i32 150, label %22
i32 143, label %23
i32 158, label %24
i32 161, label %25
i32 152, label %26
i32 156, label %27
i32 141, label %28
i32 163, label %29
i32 145, label %30
i32 132, label %31
i32 133, label %32
i32 155, label %33
i32 136, label %34
i32 167, label %35
i32 134, label %36
i32 169, label %37
i32 130, label %38
i32 157, label %39
i32 176, label %40
i32 151, label %41
i32 135, label %42
i32 178, label %43
i32 142, label %44
i32 177, label %45
i32 153, label %46
i32 170, label %47
i32 168, label %48
i32 159, label %49
i32 154, label %50
i32 144, label %51
i32 139, label %52
i32 171, label %53
i32 166, label %54
i32 146, label %55
i32 138, label %56
i32 129, label %57
]
5: ; preds = %1
store i32 -1001, i32* %2
br label %61
6: ; preds = %1
store i32 -1002, i32* %2
br label %61
7: ; preds = %1
store i32 -1003, i32* %2
br label %61
8: ; preds = %1
store i32 -1004, i32* %2
br label %61
9: ; preds = %1
store i32 -1005, i32* %2
br label %61
10: ; preds = %1
store i32 -1006, i32* %2
br label %61
11: ; preds = %1
store i32 -1007, i32* %2
br label %61
12: ; preds = %1
store i32 -1008, i32* %2
br label %61
13: ; preds = %1
store i32 -1009, i32* %2
br label %61
14: ; preds = %1
store i32 -1010, i32* %2
br label %61
15: ; preds = %1
store i32 -1011, i32* %2
br label %61
16: ; preds = %1
store i32 -1012, i32* %2
br label %61
17: ; preds = %1
store i32 -1013, i32* %2
br label %61
18: ; preds = %1
store i32 -1014, i32* %2
br label %61
19: ; preds = %1
store i32 -1016, i32* %2
br label %61
20: ; preds = %1
store i32 -1017, i32* %2
br label %61
21: ; preds = %1
store i32 -1018, i32* %2
br label %61
22: ; preds = %1
store i32 -1019, i32* %2
br label %61
23: ; preds = %1
store i32 -1020, i32* %2
br label %61
24: ; preds = %1
store i32 -1021, i32* %2
br label %61
25: ; preds = %1
store i32 -1022, i32* %2
br label %61
26: ; preds = %1
store i32 -1023, i32* %2
br label %61
27: ; preds = %1
store i32 -1024, i32* %2
br label %61
28: ; preds = %1
store i32 -1025, i32* %2
br label %61
29: ; preds = %1
store i32 -1027, i32* %2
br label %61
30: ; preds = %1
store i32 -1028, i32* %2
br label %61
31: ; preds = %1
store i32 -1029, i32* %2
br label %61
32: ; preds = %1
store i32 -1030, i32* %2
br label %61
33: ; preds = %1
store i32 -1031, i32* %2
br label %61
34: ; preds = %1
store i32 -1032, i32* %2
br label %61
35: ; preds = %1
store i32 -1033, i32* %2
br label %61
36: ; preds = %1
store i32 -1034, i32* %2
br label %61
37: ; preds = %1
store i32 -1205, i32* %2
br label %61
38: ; preds = %1
store i32 -1200, i32* %2
br label %61
39: ; preds = %1
store i32 -1102, i32* %2
br label %61
40: ; preds = %1
store i32 -1107, i32* %2
br label %61
41: ; preds = %1
store i32 -1012, i32* %2
br label %61
42: ; preds = %1
store i32 -1103, i32* %2
br label %61
43: ; preds = %1
store i32 -1110, i32* %2
br label %61
44: ; preds = %1
store i32 -1109, i32* %2
br label %61
45: ; preds = %1
store i32 -1104, i32* %2
br label %61
46: ; preds = %1
store i32 -1119, i32* %2
br label %61
47: ; preds = %1
store i32 -1702, i32* %2
br label %61
48: ; preds = %1
store i32 -1706, i32* %2
br label %61
49: ; preds = %1
store i32 -1703, i32* %2
br label %61
50: ; preds = %1
store i32 -1705, i32* %2
br label %61
51: ; preds = %1
store i32 -1704, i32* %2
br label %61
52: ; preds = %1
store i32 -1204, i32* %2
br label %61
53: ; preds = %1
store i32 -1702, i32* %2
br label %61
54: ; preds = %1
store i32 -1101, i32* %2
br label %61
55: ; preds = %1
store i32 -1108, i32* %2
br label %61
56: ; preds = %1
store i32 -1101, i32* %2
br label %61
57: ; preds = %1
store i32 -1600, i32* %2
br label %61
58: ; preds = %1
%59 = load i32, i32* @errno
%60 = sub nsw i32 0, %59
store i32 %60, i32* %2
br label %61
61: ; preds = %58, %57, %56, %55, %54, %53, %52, %51, %50, %49, %48, %47, %46, %45, %44, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
@errno = global i32 0
@switch.table.convert_std_errno = [53 x i32] [i32 -1018, i32 -1600, i32 -1200, i32 -1003, i32 -1029, i32 -1030, i32 -1034, i32 -1103, i32 -1032, i32 -1001, i32 -1101, i32 -1204, i32 -1006, i32 -1025, i32 -1109, i32 -1020, i32 -1704, i32 -1028, i32 -1108, i32 -1012, i32 -1008, i32 -1002, i32 -1019, i32 -1012, i32 -1023, i32 -1119, i32 -1705, i32 -1031, i32 -1024, i32 -1102, i32 -1021, i32 -1703, i32 -1005, i32 -1022, i32 -1004, i32 -1027, i32 -1014, i32 -1017, i32 -1101, i32 -1033, i32 -1706, i32 -1205, i32 -1702, i32 -1702, i32 -1010, i32 -1016, i32 -1009, i32 -1011, i32 -1107, i32 -1104, i32 -1110, i32 -1013, i32 -1007]
define i32 @convert_std_errno(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 53
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = sub nsw i32 0, %5
br label %11
7: ; preds = %1
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds [53 x i32], [53 x i32]* @switch.table.convert_std_errno, i64 0, i64 %8
%10 = load i32, i32* %9
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ %6, %4 ], [ %10, %7 ]
ret i32 %12
}