#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 143
#define EACCES 142
#define EFAULT 141
#define EINVAL 140
#define EIO 139
#define EISDIR 138
#define ELIBBAD 137
#define ELOOP 136
#define ENAMETOOLONG 135
#define ENFILE 134
#define ENOENT 133
#define ENOEXEC 132
#define ENOMEM 131
#define ENOTDIR 130
#define EPERM 129
#define ETXTBSY 128
char *strerror(int);
char *get_exec_error_msg(int RC, char *filename) {
  switch (RC) {
  case EACCES: {
    return "EACCES Permission denied";
  }
  case EPERM: {
    return "EPERM Not super-user";
  }
  case E2BIG: {
    return "E2BIG Arg list too long";
  }
  case ENOEXEC: {
    return "ENOEXEC Exec format error";
  }
  case EFAULT: {
    return "EFAULT Bad address";
  }
  case ENAMETOOLONG: {
    return "ENAMETOOLONG path name is too long     ";
  }
  case ENOENT: {
    return "ENOENT No such file or directory";
  }
  case ENOMEM: {
    return "ENOMEM Not enough core";
  }
  case ENOTDIR: {
    return "ENOTDIR Not a directory";
  }
  case ELOOP: {
    return "ELOOP Too many symbolic links";
  }
  case ETXTBSY: {
    return "ETXTBSY Text file busy";
  }
  case EIO: {
    return "EIO I/O error";
  }
  case ENFILE: {
    return "ENFILE Too many open files in system";
  }
  case EINVAL: {
    return "EINVAL Invalid argument";
  }
  case EISDIR: {
    return "EISDIR Is a directory";
  }
  case ELIBBAD: {
    return "ELIBBAD Accessing a corrupted shared lib";
  }
  default: {
    if (RC != 0) {
      return strerror(RC);
    }
  }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_exec_error_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xf,%eax
ja     1248 <get_exec_error_msg+0x138>
mov    -0x20(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xefa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xeff(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf11(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf14(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf3d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf44(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf4c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf5a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf5f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf74(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf7c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
lea    0xf82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
cmpl   $0x0,-0xc(%rbp)
je     1263 <get_exec_error_msg+0x153>
mov    -0xc(%rbp),%edi
call   1030 <strerror@plt>
mov    %rax,-0x8(%rbp)
jmp    1270 <get_exec_error_msg+0x160>
jmp    1268 <get_exec_error_msg+0x158>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_exec_error_msg>:
cmp    $0x8f,%edi
ja     1134 <get_exec_error_msg+0x24>
lea    0x1121(%rip),%rax
mov    %edi,%ecx
lea    0xed8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
xor    %eax,%eax
ret
jmp    1030 <strerror@plt>
lea    0x1209(%rip),%rax
ret
lea    0x1111(%rip),%rax
ret
lea    0x11c3(%rip),%rax
ret
lea    0x11a4(%rip),%rax
ret
lea    0x1126(%rip),%rax
ret
lea    0x1173(%rip),%rax
ret
lea    0x11fe(%rip),%rax
ret
lea    0x113b(%rip),%rax
ret
lea    0x11ab(%rip),%rax
ret
lea    0x1239(%rip),%rax
ret
lea    0x121b(%rip),%rax
ret
lea    0x11c8(%rip),%rax
ret
lea    0x11f3(%rip),%rax
ret
lea    0x10f8(%rip),%rax
ret
lea    0x10be(%rip),%rax
ret

LLVM IR (-O0):
@.str = [25 x i8] c"EACCES Permission denied\00"
@.str.1 = [21 x i8] c"EPERM Not super-user\00"
@.str.2 = [24 x i8] c"E2BIG Arg list too long\00"
@.str.3 = [26 x i8] c"ENOEXEC Exec format error\00"
@.str.4 = [19 x i8] c"EFAULT Bad address\00"
@.str.5 = [40 x i8] c"ENAMETOOLONG path name is too long \00"
@.str.6 = [33 x i8] c"ENOENT No such file or directory\00"
@.str.7 = [23 x i8] c"ENOMEM Not enough core\00"
@.str.8 = [24 x i8] c"ENOTDIR Not a directory\00"
@.str.9 = [30 x i8] c"ELOOP Too many symbolic links\00"
@.str.10 = [23 x i8] c"ETXTBSY Text file busy\00"
@.str.11 = [14 x i8] c"EIO I/O error\00"
@.str.12 = [37 x i8] c"ENFILE Too many open files in system\00"
@.str.13 = [24 x i8] c"EINVAL Invalid argument\00"
@.str.14 = [22 x i8] c"EISDIR Is a directory\00"
@.str.15 = [41 x i8] c"ELIBBAD Accessing a corrupted shared lib\00"
define i8* @get_exec_error_msg(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i32, i32* %4
switch i32 %6, label %23 [
i32 142, label %7
i32 129, label %8
i32 143, label %9
i32 132, label %10
i32 141, label %11
i32 135, label %12
i32 133, label %13
i32 131, label %14
i32 130, label %15
i32 136, label %16
i32 128, label %17
i32 139, label %18
i32 134, label %19
i32 140, label %20
i32 138, label %21
i32 137, label %22
]
7: ; preds = %2
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %3
br label %31
8: ; preds = %2
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %31
9: ; preds = %2
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %31
10: ; preds = %2
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %31
11: ; preds = %2
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %31
12: ; preds = %2
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %31
13: ; preds = %2
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %31
14: ; preds = %2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %31
15: ; preds = %2
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %31
16: ; preds = %2
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %31
17: ; preds = %2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %31
18: ; preds = %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %31
19: ; preds = %2
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %31
20: ; preds = %2
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %31
21: ; preds = %2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), i8** %3
br label %31
22: ; preds = %2
store i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i8** %3
br label %31
23: ; preds = %2
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %4
%28 = call i8* @strerror(i32 %27)
store i8* %28, i8** %3
br label %31
29: ; preds = %23
br label %30
30: ; preds = %29
store i8* null, i8** %3
br label %31
31: ; preds = %30, %26, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%32 = load i8*, i8** %3
ret i8* %32
}

LLVM IR (-O2):
@.str = [25 x i8] c"EACCES Permission denied\00"
@.str.1 = [21 x i8] c"EPERM Not super-user\00"
@.str.2 = [24 x i8] c"E2BIG Arg list too long\00"
@.str.3 = [26 x i8] c"ENOEXEC Exec format error\00"
@.str.4 = [19 x i8] c"EFAULT Bad address\00"
@.str.5 = [40 x i8] c"ENAMETOOLONG path name is too long \00"
@.str.6 = [33 x i8] c"ENOENT No such file or directory\00"
@.str.7 = [23 x i8] c"ENOMEM Not enough core\00"
@.str.8 = [24 x i8] c"ENOTDIR Not a directory\00"
@.str.9 = [30 x i8] c"ELOOP Too many symbolic links\00"
@.str.10 = [23 x i8] c"ETXTBSY Text file busy\00"
@.str.11 = [14 x i8] c"EIO I/O error\00"
@.str.12 = [37 x i8] c"ENFILE Too many open files in system\00"
@.str.13 = [24 x i8] c"EINVAL Invalid argument\00"
@.str.14 = [22 x i8] c"EISDIR Is a directory\00"
@.str.15 = [41 x i8] c"ELIBBAD Accessing a corrupted shared lib\00"
define i8* @get_exec_error_msg(i32 %0, i8* nocapture readnone %1) {
switch i32 %0, label %18 [
i32 142, label %21
i32 129, label %3
i32 143, label %4
i32 132, label %5
i32 141, label %6
i32 135, label %7
i32 133, label %8
i32 131, label %9
i32 130, label %10
i32 136, label %11
i32 128, label %12
i32 139, label %13
i32 134, label %14
i32 140, label %15
i32 138, label %16
i32 137, label %17
i32 0, label %20
]
3: ; preds = %2
br label %21
4: ; preds = %2
br label %21
5: ; preds = %2
br label %21
6: ; preds = %2
br label %21
7: ; preds = %2
br label %21
8: ; preds = %2
br label %21
9: ; preds = %2
br label %21
10: ; preds = %2
br label %21
11: ; preds = %2
br label %21
12: ; preds = %2
br label %21
13: ; preds = %2
br label %21
14: ; preds = %2
br label %21
15: ; preds = %2
br label %21
16: ; preds = %2
br label %21
17: ; preds = %2
br label %21
18: ; preds = %2
%19 = tail call i8* @strerror(i32 %0)
br label %21
20: ; preds = %2
br label %21
21: ; preds = %2, %20, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%22 = phi i8* [ %19, %18 ], [ null, %20 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), %17 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), %16 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), %15 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), %14 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), %13 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), %10 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %22
}