#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 EACCES 129
#define ENOENT 128
int errno;
int /*<<< orphan*/ printf(char *, ...);
void printErrorMessage(char **args, int code) {
  switch (code) {
  case EACCES:
    printf("Permission DENIED: %s\n", args[0]);
    break;
  case ENOENT:
    printf("Command not found: %s, errno = %d\n", args[0], errno);
    break;
  default:
    printf("Something bad happened. Error code %d\n", code);
    printf("You tried to run: %s\n", args[0]);
  }
}


x86 assembly (clang, -O0):
<printErrorMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x80,%eax
je     1162 <printErrorMessage+0x52>
jmp    1135 <printErrorMessage+0x25>
mov    -0x10(%rbp),%eax
sub    $0x81,%eax
jne    1185 <printErrorMessage+0x75>
jmp    1148 <printErrorMessage+0x38>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <printErrorMessage+0x9b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <printErrorMessage+0x9b>
mov    -0xc(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printErrorMessage>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x80,%esi
je     1130 <printErrorMessage+0x20>
cmp    $0x81,%esi
jne    114b <printErrorMessage+0x3b>
mov    (%rbx),%rsi
lea    0xed2(%rip),%rdi
jmp    1163 <printErrorMessage+0x53>
mov    (%rbx),%rsi
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
lea    0xed4(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rsi
lea    0xefe(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Permission DENIED: %s\0A\00"
@.str.1 = [35 x i8] c"Command not found: %s, errno = %d\0A\00"
@errno = global i32 0
@.str.2 = [39 x i8] c"Something bad happened. Error code %d\0A\00"
@.str.3 = [22 x i8] c"You tried to run: %s\0A\00"
define void @printErrorMessage(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %17 [
i32 129, label %6
i32 128, label %11
]
6: ; preds = %2
%7 = load i8**, i8*** %3
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %24
11: ; preds = %2
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i32, i32* @errno
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32 %15)
br label %24
17: ; preds = %2
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i8**, i8*** %3
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %17, %11, %6
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Permission DENIED: %s\0A\00"
@.str.1 = [35 x i8] c"Command not found: %s, errno = %d\0A\00"
@errno = global i32 0
@.str.2 = [39 x i8] c"Something bad happened. Error code %d\0A\00"
@.str.3 = [22 x i8] c"You tried to run: %s\0A\00"
define void @printErrorMessage(i8** nocapture %0, i32 %1) {
switch i32 %1, label %10 [
i32 129, label %3
i32 128, label %6
]
3: ; preds = %2
%4 = load i8*, i8** %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %14
6: ; preds = %2
%7 = load i8*, i8** %0
%8 = load i32, i32* @errno
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %8)
br label %14
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %1)
%12 = load i8*, i8** %0
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %10, %6, %3
ret void
}