#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void printStdErrMessage(const char *func, int line, const char *msg, int code) {
  switch (code) {
  case EACCES:
    fprintf(stderr, "Permission DENIED: %s\n", msg);
    break;
  case ENOENT:
    fprintf(stderr, "Command not found: %s\n", msg);
    break;
  default:
    fprintf(stderr, "Something bad happened. Error code %d\n", code);
  }
  fprintf(stderr, "%s %d: %s errno: %d\n", func, line, msg, errno);
}


x86 assembly (clang, -O0):
<printStdErrMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x80,%eax
je     116f <printStdErrMessage+0x5f>
jmp    113c <printStdErrMessage+0x2c>
mov    -0x20(%rbp),%eax
sub    $0x81,%eax
jne    118f <printStdErrMessage+0x7f>
jmp    114f <printStdErrMessage+0x3f>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11a9 <printStdErrMessage+0x99>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11a9 <printStdErrMessage+0x99>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    0x2e14(%rip),%rax
mov    (%rax),%r9d
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printStdErrMessage>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%rbp
mov    0x2ebc(%rip),%rax
cmp    $0x80,%ecx
je     113f <printStdErrMessage+0x2f>
cmp    $0x81,%ecx
jne    1154 <printStdErrMessage+0x44>
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
jmp    1148 <printStdErrMessage+0x38>
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1166 <printStdErrMessage+0x56>
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%r9d
lea    0xed5(%rip),%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %rbx,%r8
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.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 = [21 x i8] c"%s %d: %s errno: %d\0A\00"
@errno = global i32 0
define void @printStdErrMessage(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
switch i32 %9, label %18 [
i32 129, label %10
i32 128, label %14
]
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %7
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %22
14: ; preds = %4
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %7
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %22
18: ; preds = %4
%19 = load i32, i32* @stderr
%20 = load i32, i32* %8
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %18, %14, %10
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = load i8*, i8** %7
%27 = load i32, i32* @errno
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %24, i32 %25, i8* %26, i32 %27)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.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 = [21 x i8] c"%s %d: %s errno: %d\0A\00"
@errno = global i32 0
define void @printStdErrMessage(i8* %0, i32 %1, i8* %2, i32 %3) {
switch i32 %3, label %11 [
i32 129, label %5
i32 128, label %8
]
5: ; preds = %4
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %14
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %14
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %3)
br label %14
14: ; preds = %11, %8, %5
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %1, i8* %2, i32 %16)
ret void
}