#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 EACCES 132
#define ELOOP 131
#define EMFILE 130
#define ENAMETOOLONG 129
#define EOVERFLOW 128
int errno;
char *getFileErrMsg() {
  static char *out;
  switch (errno) {
  case EACCES:
    out = "can't open %s: access denied\n";
    break;
  case EMFILE:
    out = "can't open %s: too much file already opened\n";
    break;
  case EOVERFLOW:
    out = "can't open %s: file too large\n";
    break;
  case ELOOP:
    out = "can't correctly find %s: there are loops in the path\n";
    break;
  case ENAMETOOLONG:
    out = "can't open %s:a component in the path is too long\n";
    break;
  default:
    out = "unknown error while opening %s : errno(%d)\n";
  }
  return out;
}


x86 assembly (clang, -O0):
<getFileErrMsg>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ed5(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x8(%rbp)
sub    $0x4,%eax
ja     1192 <getFileErrMsg+0x92>
mov    -0x8(%rbp),%rax
lea    0xed6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeda(%rip),%rax
mov    %rax,0x2ee7(%rip)
jmp    11a0 <getFileErrMsg+0xa0>
lea    0xee5(%rip),%rax
mov    %rax,0x2ed4(%rip)
jmp    11a0 <getFileErrMsg+0xa0>
lea    0xeff(%rip),%rax
mov    %rax,0x2ec1(%rip)
jmp    11a0 <getFileErrMsg+0xa0>
lea    0xf0b(%rip),%rax
mov    %rax,0x2eae(%rip)
jmp    11a0 <getFileErrMsg+0xa0>
lea    0xf2e(%rip),%rax
mov    %rax,0x2e9b(%rip)
jmp    11a0 <getFileErrMsg+0xa0>
lea    0xf4e(%rip),%rax
mov    %rax,0x2e88(%rip)
mov    0x2e81(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileErrMsg>:
mov    0x2ed9(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
cmp    $0x4,%eax
ja     1122 <getFileErrMsg+0x22>
cltq
lea    0xfe6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xfaa(%rip),%rax
ret

LLVM IR (-O0):
@getFileErrMsg.out = internal global i8* null
@errno = global i32 0
@.str = [30 x i8] c"can't open %s: access denied\0A\00"
@.str.1 = [45 x i8] c"can't open %s: too much file already opened\0A\00"
@.str.2 = [31 x i8] c"can't open %s: file too large\0A\00"
@.str.3 = [54 x i8] c"can't correctly find %s: there are loops in the path\0A\00"
@.str.4 = [51 x i8] c"can't open %s:a component in the path is too long\0A\00"
@.str.5 = [44 x i8] c"unknown error while opening %s : errno(%d)\0A\00"
define i8* @getFileErrMsg() {
%1 = load i32, i32* @errno
switch i32 %1, label %7 [
i32 132, label %2
i32 130, label %3
i32 128, label %4
i32 131, label %5
i32 129, label %6
]
2: ; preds = %0
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8** @getFileErrMsg.out
br label %8
3: ; preds = %0
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8** @getFileErrMsg.out
br label %8
4: ; preds = %0
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8** @getFileErrMsg.out
br label %8
5: ; preds = %0
store i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i8** @getFileErrMsg.out
br label %8
6: ; preds = %0
store i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8** @getFileErrMsg.out
br label %8
7: ; preds = %0
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8** @getFileErrMsg.out
br label %8
8: ; preds = %7, %6, %5, %4, %3, %2
%9 = load i8*, i8** @getFileErrMsg.out
ret i8* %9
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [30 x i8] c"can't open %s: access denied\0A\00"
@.str.1 = [45 x i8] c"can't open %s: too much file already opened\0A\00"
@.str.2 = [31 x i8] c"can't open %s: file too large\0A\00"
@.str.3 = [54 x i8] c"can't correctly find %s: there are loops in the path\0A\00"
@.str.4 = [51 x i8] c"can't open %s:a component in the path is too long\0A\00"
@.str.5 = [44 x i8] c"unknown error while opening %s : errno(%d)\0A\00"
@reltable.getFileErrMsg = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.getFileErrMsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([51 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.getFileErrMsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.1 to i64), i64 ptrtoint ([5 x i32]* @reltable.getFileErrMsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([54 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.getFileErrMsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str to i64), i64 ptrtoint ([5 x i32]* @reltable.getFileErrMsg to i64)) to i32)]
define i8* @getFileErrMsg() {
%1 = load i32, i32* @errno
%2 = add i32 %1, -128
%3 = icmp ult i32 %2, 5
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.getFileErrMsg to i8*), i64 %6)
br label %8
8: ; preds = %0, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), %0 ]
ret i8* %9
}