#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
#define E2BIG 141
#define EACCES 140
#define EAGAIN 139
#define EBADF 138
#define EBUSY 137
#define EFAULT 136
#define EINVAL 135
#define EMFILE 134
#define ENODEV 133
#define ENOENT 132
#define ENOSPC 131
#define EOPNOTSUPP 130
#define EOVERFLOW 129
#define EPERM 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void print_errno_name(FILE *fff, int e) {
  switch (e) {
  case EPERM:
    fprintf(fff, "EPERM");
    break;
  case ENOENT:
    fprintf(fff, "ENOENT");
    break;
  case E2BIG:
    fprintf(fff, "E2BIG");
    break;
  case EBADF:
    fprintf(fff, "EBADF");
    break;
  case EINVAL:
    fprintf(fff, "EINVAL");
    break;
  case EOPNOTSUPP:
    fprintf(fff, "EOPNOTSUPP");
    break;
  case ENODEV:
    fprintf(fff, "ENODEV");
    break;
  case ENOSPC:
    fprintf(fff, "ENOSPC");
    break;
  case EMFILE:
    fprintf(fff, "EMFILE");
    break;
  case EACCES:
    fprintf(fff, "EACCES");
    break;
  case EBUSY:
    fprintf(fff, "EBUSY");
    break;
  case EAGAIN:
    fprintf(fff, "EAGAIN");
    break;
  case EOVERFLOW:
    fprintf(fff, "EOVERFLOW");
    break;
  case EFAULT:
    fprintf(fff, "EFAULT");
    break;
  default:
    fprintf(fff, "UNKNOWN %d", e);
    break;
  }
}


x86 assembly (clang, -O0):
<print_errno_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xd,%eax
ja     128a <print_errno_name+0x17a>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xee5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xed4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129f <print_errno_name+0x18f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_errno_name>:
mov    %esi,%edx
mov    %rdi,%rcx
lea    -0x80(%rdx),%eax
cmp    $0xd,%eax
ja     1149 <print_errno_name+0x29>
lea    0xecc(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0xef4(%rip),%rdi
jmp    11f4 <print_errno_name+0xd4>
lea    0xf4d(%rip),%rsi
mov    %rcx,%rdi
xor    %eax,%eax
jmp    1030 <fprintf@plt>
lea    0xf2b(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xee1(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xedd(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xea8(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xec4(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xec9(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xea0(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xedc(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xebc(%rip),%rdi
jmp    11f4 <print_errno_name+0xd4>
lea    0xe7f(%rip),%rdi
jmp    11f4 <print_errno_name+0xd4>
lea    0xeb0(%rip),%rdi
jmp    11de <print_errno_name+0xbe>
lea    0xe9a(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xe51(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"EPERM\00"
@.str.1 = [7 x i8] c"ENOENT\00"
@.str.2 = [6 x i8] c"E2BIG\00"
@.str.3 = [6 x i8] c"EBADF\00"
@.str.4 = [7 x i8] c"EINVAL\00"
@.str.5 = [11 x i8] c"EOPNOTSUPP\00"
@.str.6 = [7 x i8] c"ENODEV\00"
@.str.7 = [7 x i8] c"ENOSPC\00"
@.str.8 = [7 x i8] c"EMFILE\00"
@.str.9 = [7 x i8] c"EACCES\00"
@.str.10 = [6 x i8] c"EBUSY\00"
@.str.11 = [7 x i8] c"EAGAIN\00"
@.str.12 = [10 x i8] c"EOVERFLOW\00"
@.str.13 = [7 x i8] c"EFAULT\00"
@.str.14 = [11 x i8] c"UNKNOWN %d\00"
define void @print_errno_name(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %48 [
i32 128, label %6
i32 132, label %9
i32 141, label %12
i32 138, label %15
i32 135, label %18
i32 130, label %21
i32 133, label %24
i32 131, label %27
i32 134, label %30
i32 140, label %33
i32 137, label %36
i32 139, label %39
i32 129, label %42
i32 136, label %45
]
6: ; preds = %2
%7 = load i32*, i32** %3
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %52
9: ; preds = %2
%10 = load i32*, i32** %3
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %52
12: ; preds = %2
%13 = load i32*, i32** %3
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %52
15: ; preds = %2
%16 = load i32*, i32** %3
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %52
18: ; preds = %2
%19 = load i32*, i32** %3
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %52
21: ; preds = %2
%22 = load i32*, i32** %3
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %52
24: ; preds = %2
%25 = load i32*, i32** %3
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %52
27: ; preds = %2
%28 = load i32*, i32** %3
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %52
30: ; preds = %2
%31 = load i32*, i32** %3
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %52
33: ; preds = %2
%34 = load i32*, i32** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %52
36: ; preds = %2
%37 = load i32*, i32** %3
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %52
39: ; preds = %2
%40 = load i32*, i32** %3
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %52
42: ; preds = %2
%43 = load i32*, i32** %3
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0))
br label %52
45: ; preds = %2
%46 = load i32*, i32** %3
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
br label %52
48: ; preds = %2
%49 = load i32*, i32** %3
%50 = load i32, i32* %4
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"EPERM\00"
@.str.1 = [7 x i8] c"ENOENT\00"
@.str.2 = [6 x i8] c"E2BIG\00"
@.str.3 = [6 x i8] c"EBADF\00"
@.str.4 = [7 x i8] c"EINVAL\00"
@.str.5 = [11 x i8] c"EOPNOTSUPP\00"
@.str.6 = [7 x i8] c"ENODEV\00"
@.str.7 = [7 x i8] c"ENOSPC\00"
@.str.8 = [7 x i8] c"EMFILE\00"
@.str.9 = [7 x i8] c"EACCES\00"
@.str.10 = [6 x i8] c"EBUSY\00"
@.str.11 = [7 x i8] c"EAGAIN\00"
@.str.12 = [10 x i8] c"EOVERFLOW\00"
@.str.13 = [7 x i8] c"EFAULT\00"
@.str.14 = [11 x i8] c"UNKNOWN %d\00"
define void @print_errno_name(i32* nocapture %0, i32 %1) {
switch i32 %1, label %31 [
i32 128, label %3
i32 132, label %5
i32 141, label %7
i32 138, label %9
i32 135, label %11
i32 130, label %13
i32 133, label %15
i32 131, label %17
i32 134, label %19
i32 140, label %21
i32 137, label %23
i32 139, label %25
i32 129, label %27
i32 136, label %29
]
3: ; preds = %2
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %33
5: ; preds = %2
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
7: ; preds = %2
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %33
9: ; preds = %2
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %33
11: ; preds = %2
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
13: ; preds = %2
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i64 10, i64 1, i32* %0)
br label %33
15: ; preds = %2
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
17: ; preds = %2
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
19: ; preds = %2
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
21: ; preds = %2
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
23: ; preds = %2
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %33
25: ; preds = %2
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
27: ; preds = %2
%28 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i64 9, i64 1, i32* %0)
br label %33
29: ; preds = %2
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
31: ; preds = %2
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32 %1)
br label %33
33: ; preds = %31, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3
ret void
}