#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 /*<<< orphan*/ printf(char *, ...);
int printErrorMessage(char **args, int code) {
  switch (code) {
  case EACCES:
    printf("Permission DENIED: %s\n", args[0]);
    break;
  case ENOENT:
    printf("Command not found: %s\n", args[0]);
    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    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x80,%eax
je     1162 <printErrorMessage+0x52>
jmp    1135 <printErrorMessage+0x25>
mov    -0x18(%rbp),%eax
sub    $0x81,%eax
jne    117c <printErrorMessage+0x6c>
jmp    1148 <printErrorMessage+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a2 <printErrorMessage+0x92>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a2 <printErrorMessage+0x92>
mov    -0x14(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printErrorMessage>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x81,%esi
je     112d <printErrorMessage+0x1d>
cmp    $0x80,%esi
jne    1136 <printErrorMessage+0x26>
lea    0xeec(%rip),%rdi
jmp    114b <printErrorMessage+0x3b>
lea    0xecc(%rip),%rdi
jmp    114b <printErrorMessage+0x3b>
lea    0xef1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
mov    (%rbx),%rsi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Permission DENIED: %s\0A\00"
@.str.1 = [23 x i8] c"Command not found: %s\0A\00"
@.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 i32 @printErrorMessage(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %17 [
i32 129, label %7
i32 128, label %12
]
7: ; preds = %2
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %24
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %24
17: ; preds = %2
%18 = load i32, i32* %5
%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*** %4
%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, %12, %7
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [23 x i8] c"Permission DENIED: %s\0A\00"
@.str.1 = [23 x i8] c"Command not found: %s\0A\00"
@.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 i32 @printErrorMessage(i8** nocapture %0, i32 %1) {
switch i32 %1, label %4 [
i32 129, label %6
i32 128, label %3
]
3: ; preds = %2
br label %6
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %6
6: ; preds = %2, %4, %3
%7 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %2 ]
%8 = load i8*, i8** %0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %7, i8* %8)
ret i32 undef
}