#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__ ECHILD;
scalar_t__ ENOEXEC;
scalar_t__ errno;
int /*<<< orphan*/ printf(char *);
void handle_errors() {
  if (errno == EACCES)
    printf("error: permission is denied for file\n");
  else if (errno == ENOEXEC)
    printf("error: file header is not recognised\n");
  else if (errno == ECHILD)
    printf("error: process specified by pid does not exist\n");
}


x86 assembly (clang, -O0):
<handle_errors>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%rax
mov    0x2ebb(%rip),%rcx
cmp    (%rcx),%rax
jne    113f <handle_errors+0x2f>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
jmp    119a <handle_errors+0x8a>
mov    0x2e8a(%rip),%rax
mov    (%rax),%rax
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%rax
jne    116a <handle_errors+0x5a>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <handle_errors+0x85>
mov    0x2e5f(%rip),%rax
mov    (%rax),%rax
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%rax
jne    1190 <handle_errors+0x80>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <handle_errors+0x85>
jmp    119a <handle_errors+0x8a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_errors>:
mov    0x2eb9(%rip),%rax
mov    (%rax),%rax
mov    0x2ebf(%rip),%rcx
cmp    (%rcx),%rax
jne    1132 <handle_errors+0x22>
lea    0xf27(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2eaf(%rip),%rcx
cmp    (%rcx),%rax
jne    114a <handle_errors+0x3a>
lea    0xeea(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%rax
jne    1162 <handle_errors+0x52>
lea    0xea3(%rip),%rdi
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
@errno = global i64 0
@EACCES = global i64 0
@.str = [38 x i8] c"error: permission is denied for file\0A\00"
@ENOEXEC = global i64 0
@.str.1 = [38 x i8] c"error: file header is not recognised\0A\00"
@ECHILD = global i64 0
@.str.2 = [48 x i8] c"error: process specified by pid does not exist\0A\00"
define void @handle_errors() {
%1 = load i64, i64* @errno
%2 = load i64, i64* @EACCES
%3 = icmp eq i64 %1, %2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %20
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @ENOEXEC
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %19
12: ; preds = %6
%13 = load i64, i64* @errno
%14 = load i64, i64* @ECHILD
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
br label %19
19: ; preds = %18, %10
br label %20
20: ; preds = %19, %4
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EACCES = global i64 0
@ENOEXEC = global i64 0
@ECHILD = global i64 0
@str = [47 x i8] c"error: process specified by pid does not exist\00"
@str.3 = [37 x i8] c"error: file header is not recognised\00"
@str.4 = [37 x i8] c"error: permission is denied for file\00"
define void @handle_errors() {
%1 = load i64, i64* @errno
%2 = load i64, i64* @EACCES
%3 = icmp eq i64 %1, %2
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = load i64, i64* @ENOEXEC
%6 = icmp eq i64 %1, %5
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = load i64, i64* @ECHILD
%9 = icmp eq i64 %1, %8
br i1 %9, label %10, label %13
10: ; preds = %7, %4, %0
%11 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0), %7 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %10, %7
ret void
}