#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 EAGAIN 133
#define EDEADLK 132
#define EINTR 131
#define EINVAL 130
#define ENOENT 129
#define ENOSYS 128
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void print_error() {
  switch (errno) {
  case EAGAIN:
    fprintf(stderr, "EAGAIN\n");
    break;
  case EINTR:
    fprintf(stderr, "EINTR\n");
    break;
  case EINVAL:
    fprintf(stderr, "EINVAL\n");
    break;
  case ENOSYS:
    fprintf(stderr, "ENOSYS\n");
    break;
  case ENOENT:
    fprintf(stderr, "ENOENT\n");
    break;
  case EDEADLK:
    fprintf(stderr, "EDEADLK\n");
    break;
  default:
    fprintf(stderr, "Unknown error\n");
    break;
  }
}


x86 assembly (clang, -O0):
<print_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x8(%rbp)
sub    $0x5,%eax
ja     11e3 <print_error+0xd3>
mov    -0x8(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <print_error+0xe8>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <print_error+0xe8>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <print_error+0xe8>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <print_error+0xe8>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <print_error+0xe8>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <print_error+0xe8>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_error>:
mov    0x2ec1(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
cmp    $0x5,%eax
ja     1133 <print_error+0x23>
cltq
lea    0xf16(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    113a <print_error+0x2a>
lea    0xef6(%rip),%rsi
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@errno = global i32 0
@stderr = global i32 0
@.str = [8 x i8] c"EAGAIN\0A\00"
@.str.1 = [7 x i8] c"EINTR\0A\00"
@.str.2 = [8 x i8] c"EINVAL\0A\00"
@.str.3 = [8 x i8] c"ENOSYS\0A\00"
@.str.4 = [8 x i8] c"ENOENT\0A\00"
@.str.5 = [9 x i8] c"EDEADLK\0A\00"
@.str.6 = [15 x i8] c"Unknown error\0A\00"
define void @print_error() {
%1 = load i32, i32* @errno
switch i32 %1, label %20 [
i32 133, label %2
i32 131, label %5
i32 130, label %8
i32 128, label %11
i32 129, label %14
i32 132, label %17
]
2: ; preds = %0
%3 = load i32, i32* @stderr
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %23
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %23
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %23
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %23
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %23
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %23
20: ; preds = %0
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %23
23: ; preds = %20, %17, %14, %11, %8, %5, %2
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@stderr = global i32 0
@.str = [8 x i8] c"EAGAIN\0A\00"
@.str.1 = [7 x i8] c"EINTR\0A\00"
@.str.2 = [8 x i8] c"EINVAL\0A\00"
@.str.3 = [8 x i8] c"ENOSYS\0A\00"
@.str.4 = [8 x i8] c"ENOENT\0A\00"
@.str.5 = [9 x i8] c"EDEADLK\0A\00"
@.str.6 = [15 x i8] c"Unknown error\0A\00"
@reltable.print_error = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.print_error to i64)) to i32)]
define void @print_error() {
%1 = load i32, i32* @errno
%2 = add i32 %1, -128
%3 = icmp ult i32 %2, 6
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 ([6 x i32]* @reltable.print_error to i8*), i64 %6)
br label %8
8: ; preds = %0, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), %0 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* %9)
ret void
}