#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 137
#define EACCES 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;
  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    $0x9,%eax
ja     122e <print_errno_name+0x11e>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1243 <print_errno_name+0x133>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe32(%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    $0x9,%eax
ja     1146 <print_errno_name+0x26>
lea    0xecc(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0xee4(%rip),%rdi
jmp    11aa <print_errno_name+0x8a>
lea    0xf21(%rip),%rsi
mov    %rcx,%rdi
xor    %eax,%eax
jmp    1030 <fprintf@plt>
lea    0xeea(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xedf(%rip),%rdi
jmp    11c0 <print_errno_name+0xa0>
lea    0xeb1(%rip),%rdi
jmp    11c0 <print_errno_name+0xa0>
lea    0xed4(%rip),%rdi
jmp    11c0 <print_errno_name+0xa0>
lea    0xeb2(%rip),%rdi
jmp    11c0 <print_errno_name+0xa0>
lea    0xed0(%rip),%rdi
jmp    11aa <print_errno_name+0x8a>
lea    0xe9a(%rip),%rdi
jmp    11aa <print_errno_name+0x8a>
lea    0xe8b(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
lea    0xea1(%rip),%rdi
mov    $0x6,%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 = [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 %36 [
i32 128, label %6
i32 131, label %9
i32 137, label %12
i32 135, label %15
i32 133, label %18
i32 129, label %21
i32 130, label %24
i32 132, label %27
i32 136, label %30
i32 134, label %33
]
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 %40
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 %40
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 %40
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 %40
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 %40
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 %40
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 %40
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 %40
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 %40
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 %40
36: ; preds = %2
%37 = load i32*, i32** %3
%38 = load i32, i32* %4
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %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 = [11 x i8] c"UNKNOWN %d\00"
define void @print_errno_name(i32* nocapture %0, i32 %1) {
switch i32 %1, label %23 [
i32 128, label %3
i32 131, label %5
i32 137, label %7
i32 135, label %9
i32 133, label %11
i32 129, label %13
i32 130, label %15
i32 132, label %17
i32 136, label %19
i32 134, label %21
]
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 %25
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 %25
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 %25
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 %25
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 %25
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 %25
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 %25
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 %25
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 %25
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 %25
23: ; preds = %2
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %1)
br label %25
25: ; preds = %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3
ret void
}