#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 EBADF 138
#define EDOM 137
#define EILSEQ 136
#define EINVAL 135
#define EISCONN 134
#define EMFILE 133
#define ENOENT 132
#define EPERM 131
#define ERANGE 130
#define EROFS 129
#define ESPIPE 128
char *strerror(int num) {
  char *error;
  switch (num) {
  case 0:
    error = "Success";
    break;
  case EDOM:
    error = "Domain error";
    break;
  case ERANGE:
    error = "Range error";
    break;
  case EILSEQ:
    error = "Illegal sequence";
    break;
  case ENOENT:
    error = "No such file or directory";
    break;
  case ESPIPE:
    error = "Invalid seek";
    break;
  case EROFS:
    error = "Read-only file system";
    break;
  case EINVAL:
  case EBADF:
  case EPERM:
  case EMFILE:
  case EISCONN:
  default:
    error = "";
    break;
  }
  return error;
}


x86 assembly (clang, -O0):
<strerror>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     11c8 <strerror+0xc8>
jmp    111a <strerror+0x1a>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
je     1218 <strerror+0x118>
jmp    112d <strerror+0x2d>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
je     1228 <strerror+0x128>
jmp    1140 <strerror+0x40>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
je     11e8 <strerror+0xe8>
jmp    1153 <strerror+0x53>
mov    -0x14(%rbp),%eax
sub    $0x83,%eax
je     1238 <strerror+0x138>
jmp    1166 <strerror+0x66>
mov    -0x14(%rbp),%eax
sub    $0x84,%eax
je     1208 <strerror+0x108>
jmp    1179 <strerror+0x79>
mov    -0x14(%rbp),%eax
add    $0xffffff7b,%eax
sub    $0x3,%eax
jb     1238 <strerror+0x138>
jmp    118f <strerror+0x8f>
mov    -0x14(%rbp),%eax
sub    $0x88,%eax
je     11f8 <strerror+0xf8>
jmp    11a2 <strerror+0xa2>
mov    -0x14(%rbp),%eax
sub    $0x89,%eax
je     11d8 <strerror+0xd8>
jmp    11b5 <strerror+0xb5>
mov    -0x14(%rbp),%eax
sub    $0x8a,%eax
je     1238 <strerror+0x138>
jmp    123d <strerror+0x13d>
lea    0xe31(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
lea    0xe29(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
lea    0xe26(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
lea    0xe22(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
lea    0xe23(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
lea    0xe2d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
lea    0xe2a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1248 <strerror+0x148>
jmp    123d <strerror+0x13d>
lea    0xded(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strerror>:
lea    -0x80(%rdi),%eax
cmp    $0x9,%eax
ja     1120 <strerror+0x20>
lea    0xef1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf55(%rip),%rax
ret
test   %edi,%edi
jne    112c <strerror+0x2c>
lea    0xefd(%rip),%rax
ret
lea    0xf26(%rip),%rax
ret
lea    0xf46(%rip),%rax
ret
lea    0xefa(%rip),%rax
ret
lea    0xf0f(%rip),%rax
ret
lea    0xef6(%rip),%rax
ret
lea    0xed5(%rip),%rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Success\00"
@.str.1 = [13 x i8] c"Domain error\00"
@.str.2 = [12 x i8] c"Range error\00"
@.str.3 = [17 x i8] c"Illegal sequence\00"
@.str.4 = [26 x i8] c"No such file or directory\00"
@.str.5 = [13 x i8] c"Invalid seek\00"
@.str.6 = [22 x i8] c"Read-only file system\00"
@.str.7 = [1 x i8] zeroinitializer
define i8* @strerror(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %13 [
i32 0, label %5
i32 137, label %6
i32 130, label %7
i32 136, label %8
i32 132, label %9
i32 128, label %10
i32 129, label %11
i32 135, label %12
i32 138, label %12
i32 131, label %12
i32 133, label %12
i32 134, label %12
]
5: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %3
br label %14
6: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %14
7: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %14
8: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %14
9: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %14
10: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %14
11: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %14
12: ; preds = %1, %1, %1, %1, %1
br label %13
13: ; preds = %1, %12
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %14
14: ; preds = %13, %11, %10, %9, %8, %7, %6, %5
%15 = load i8*, i8** %3
ret i8* %15
}

LLVM IR (-O2):
@.str = [8 x i8] c"Success\00"
@.str.1 = [13 x i8] c"Domain error\00"
@.str.2 = [12 x i8] c"Range error\00"
@.str.3 = [17 x i8] c"Illegal sequence\00"
@.str.4 = [26 x i8] c"No such file or directory\00"
@.str.5 = [13 x i8] c"Invalid seek\00"
@.str.6 = [22 x i8] c"Read-only file system\00"
@.str.7 = [1 x i8] zeroinitializer
define i8* @strerror(i32 %0) {
switch i32 %0, label %8 [
i32 0, label %9
i32 137, label %2
i32 130, label %3
i32 136, label %4
i32 132, label %5
i32 128, label %6
i32 129, label %7
]
2: ; preds = %1
br label %9
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %8, %7, %6, %5, %4, %3, %2
%10 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %10
}