#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 138
#define EACCES 137
#define EAGAIN 136
#define EBADF 135
#define EBUSY 134
#define EINVAL 133
#define EMFILE 132
#define ENOENT 131
#define ENOSPC 130
#define EOPNOTSUPP 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 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;
  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    $0xa,%eax
ja     1245 <print_errno_name+0x135>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xec8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125a <print_errno_name+0x14a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe26(%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    $0xa,%eax
ja     1149 <print_errno_name+0x29>
lea    0xecc(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0xee8(%rip),%rdi
jmp    11cc <print_errno_name+0xac>
lea    0xf29(%rip),%rsi
mov    %rcx,%rdi
xor    %eax,%eax
jmp    1030 <fprintf@plt>
lea    0xeeb(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xee0(%rip),%rdi
jmp    11b6 <print_errno_name+0x96>
lea    0xeb2(%rip),%rdi
jmp    11b6 <print_errno_name+0x96>
lea    0xed5(%rip),%rdi
jmp    11b6 <print_errno_name+0x96>
lea    0xeb3(%rip),%rdi
jmp    11b6 <print_errno_name+0x96>
lea    0xed1(%rip),%rdi
jmp    11cc <print_errno_name+0xac>
lea    0xe9b(%rip),%rdi
jmp    11cc <print_errno_name+0xac>
lea    0xec5(%rip),%rdi
jmp    11b6 <print_errno_name+0x96>
lea    0xeaf(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xe6d(%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"ENOSPC\00"
@.str.7 = [7 x i8] c"EMFILE\00"
@.str.8 = [7 x i8] c"EACCES\00"
@.str.9 = [6 x i8] c"EBUSY\00"
@.str.10 = [7 x i8] c"EAGAIN\00"
@.str.11 = [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 %39 [
i32 128, label %6
i32 131, label %9
i32 138, label %12
i32 135, label %15
i32 133, label %18
i32 129, label %21
i32 130, label %24
i32 132, label %27
i32 137, label %30
i32 134, label %33
i32 136, label %36
]
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 %43
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 %43
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 %43
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 %43
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 %43
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 %43
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 %43
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 %43
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 %43
33: ; preds = %2
%34 = load i32*, i32** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %43
36: ; preds = %2
%37 = load i32*, i32** %3
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %43
39: ; preds = %2
%40 = load i32*, i32** %3
%41 = load i32, i32* %4
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %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"ENOSPC\00"
@.str.7 = [7 x i8] c"EMFILE\00"
@.str.8 = [7 x i8] c"EACCES\00"
@.str.9 = [6 x i8] c"EBUSY\00"
@.str.10 = [7 x i8] c"EAGAIN\00"
@.str.11 = [11 x i8] c"UNKNOWN %d\00"
define void @print_errno_name(i32* nocapture %0, i32 %1) {
switch i32 %1, label %25 [
i32 128, label %3
i32 131, label %5
i32 138, label %7
i32 135, label %9
i32 133, label %11
i32 129, label %13
i32 130, label %15
i32 132, label %17
i32 137, label %19
i32 134, label %21
i32 136, label %23
]
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 %27
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 %27
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 %27
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 %27
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 %27
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 %27
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 %27
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 %27
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 %27
21: ; preds = %2
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %27
23: ; preds = %2
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %27
25: ; preds = %2
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %1)
br label %27
27: ; preds = %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3
ret void
}