#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 */
scalar_t__ EACCES;
scalar_t__ EBADF;
scalar_t__ EBUSY;
scalar_t__ EPERM;
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, ...);
void errno_print() {
  if (errno == EBUSY) {
    printf("Error: device or resource busy.\n");
  } else if (errno == EPERM) {
    printf("Error: operation not permitted.\n");
  } else if (errno == EACCES) {
    printf("Error: permission denied.\n");
  } else if (errno == EBADF) {
    printf("Error: bad file descriptor.\n");
  } else {
    printf("Unknown error occured (%i).\n", errno);
  }
}


x86 assembly (clang, -O0):
<errno_print>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ebd(%rip),%rax
mov    (%rax),%rax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%rax
jne    1141 <errno_print+0x31>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ef <errno_print+0xdf>
mov    0x2e90(%rip),%rax
mov    (%rax),%rax
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%rax
jne    116e <errno_print+0x5e>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <errno_print+0xda>
mov    0x2e63(%rip),%rax
mov    (%rax),%rax
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%rax
jne    119b <errno_print+0x8b>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <errno_print+0xd5>
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%rax
jne    11c8 <errno_print+0xb8>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <errno_print+0xd0>
mov    0x2e09(%rip),%rax
mov    (%rax),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <errno_print+0xd5>
jmp    11ea <errno_print+0xda>
jmp    11ef <errno_print+0xdf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<errno_print>:
mov    0x2eb1(%rip),%rax
mov    (%rax),%rsi
mov    0x2e97(%rip),%rax
cmp    (%rax),%rsi
jne    1142 <errno_print+0x22>
lea    0xf36(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2e6f(%rip),%rax
cmp    (%rax),%rsi
jne    115a <errno_print+0x3a>
lea    0xefe(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2e87(%rip),%rax
cmp    (%rax),%rsi
jne    1172 <errno_print+0x52>
lea    0xecc(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2e57(%rip),%rax
cmp    (%rax),%rsi
jne    118a <errno_print+0x6a>
lea    0xe98(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@errno = global i64 0
@EBUSY = global i64 0
@.str = [33 x i8] c"Error: device or resource busy.\0A\00"
@EPERM = global i64 0
@.str.1 = [33 x i8] c"Error: operation not permitted.\0A\00"
@EACCES = global i64 0
@.str.2 = [27 x i8] c"Error: permission denied.\0A\00"
@EBADF = global i64 0
@.str.3 = [29 x i8] c"Error: bad file descriptor.\0A\00"
@.str.4 = [29 x i8] c"Unknown error occured (%i).\0A\00"
define void @errno_print() {
%1 = load i64, i64* @errno
%2 = load i64, i64* @EBUSY
%3 = icmp eq i64 %1, %2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %30
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @EPERM
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %29
12: ; preds = %6
%13 = load i64, i64* @errno
%14 = load i64, i64* @EACCES
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %28
18: ; preds = %12
%19 = load i64, i64* @errno
%20 = load i64, i64* @EBADF
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %27
24: ; preds = %18
%25 = load i64, i64* @errno
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i64 %25)
br label %27
27: ; preds = %24, %22
br label %28
28: ; preds = %27, %16
br label %29
29: ; preds = %28, %10
br label %30
30: ; preds = %29, %4
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EBUSY = global i64 0
@EPERM = global i64 0
@EACCES = global i64 0
@EBADF = global i64 0
@.str.4 = [29 x i8] c"Unknown error occured (%i).\0A\00"
@str = [28 x i8] c"Error: bad file descriptor.\00"
@str.5 = [26 x i8] c"Error: permission denied.\00"
@str.6 = [32 x i8] c"Error: operation not permitted.\00"
@str.7 = [32 x i8] c"Error: device or resource busy.\00"
define void @errno_print() {
%1 = load i64, i64* @errno
%2 = load i64, i64* @EBUSY
%3 = icmp eq i64 %1, %2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
br label %23
6: ; preds = %0
%7 = load i64, i64* @EPERM
%8 = icmp eq i64 %1, %7
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0))
br label %23
11: ; preds = %6
%12 = load i64, i64* @EACCES
%13 = icmp eq i64 %1, %12
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0))
br label %23
16: ; preds = %11
%17 = load i64, i64* @EBADF
%18 = icmp eq i64 %1, %17
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %23
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i64 %1)
br label %23
23: ; preds = %9, %19, %21, %14, %4
ret void
}