#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 */
char *calloc(int, int);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
char *errMessage(const short ftag, const char *fpath) {
  char *res;
  if (fpath != NULL)
    res = calloc(0x7F + strlen(fpath), sizeof(char));
  else
    res = calloc(0x7F, sizeof(char));
  switch (ftag) {
  case 0x05:
    strcat(res, "ERROR: Unable to create standard key file in current "
                "directory, try again as superuser!");
    break;
  case 0x04:
    strcat(res, "ERROR: Unable to create key file '");
    strcat(res, fpath);
    strcat(res, "' in current directory, try again as superuser!");
    break;
  case 0x03:
    strcat(res, "ERROR: Key file '");
    strcat(res, fpath);
    strcat(res, "' does not exist or is not accessible!");
    break;
  case 0x02:
    strcat(res, "ERROR: Unable to create output file '");
    strcat(res, fpath);
    strcat(res, "', try again as superuser!");
    break;
  case 0x01:
    strcat(res, "ERROR: Input file '");
    strcat(res, fpath);
    strcat(res, "' does not exist or is not accessible!");
    break;
  }
  return res;
}


x86 assembly (clang, -O0):
<errMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116f <errMessage+0x3f>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
add    $0x7f,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
jmp    1182 <errMessage+0x52>
mov    $0x7f,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movswl -0x2(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     1284 <errMessage+0x154>
mov    -0x20(%rbp),%rax
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1050 <strcat@plt>
jmp    1284 <errMessage+0x154>
mov    -0x18(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <strcat@plt>
jmp    1284 <errMessage+0x154>
mov    -0x18(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <strcat@plt>
jmp    1284 <errMessage+0x154>
mov    -0x18(%rbp),%rdi
lea    0xec8(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xed1(%rip),%rsi
call   1050 <strcat@plt>
jmp    1284 <errMessage+0x154>
mov    -0x18(%rbp),%rdi
lea    0xed7(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errMessage>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
test   %rsi,%rsi
je     114b <errMessage+0x1b>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x7f(%rax),%edi
jmp    1150 <errMessage+0x20>
mov    $0x7f,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
movswl %bp,%ecx
add    $0xffffffff,%ecx
cmp    $0x4,%ecx
ja     11dc <errMessage+0xac>
lea    0xf20(%rip),%rbp
lea    0xef6(%rip),%rsi
lea    0xe97(%rip),%rax
lea    0xe7c(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf3d(%rip),%rbp
lea    0xf9e(%rip),%rsi
jmp    11bb <errMessage+0x8b>
lea    0xf7a(%rip),%rbp
lea    0xf4d(%rip),%rsi
jmp    11bb <errMessage+0x8b>
lea    0xf1d(%rip),%rbp
lea    0xf04(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %rbp,%rax
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [88 x i8] c"ERROR: Unable to create standard key file in current directory, try again as superuser!\00"
@.str.1 = [35 x i8] c"ERROR: Unable to create key file '\00"
@.str.2 = [48 x i8] c"' in current directory, try again as superuser!\00"
@.str.3 = [18 x i8] c"ERROR: Key file '\00"
@.str.4 = [39 x i8] c"' does not exist or is not accessible!\00"
@.str.5 = [38 x i8] c"ERROR: Unable to create output file '\00"
@.str.6 = [27 x i8] c"', try again as superuser!\00"
@.str.7 = [20 x i8] c"ERROR: Input file '\00"
define i8* @errMessage(i16 signext %0, i8* %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i8*
store i16 %0, i16* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 127, %10
%12 = call i8* @calloc(i32 %11, i32 1)
store i8* %12, i8** %5
br label %15
13: ; preds = %2
%14 = call i8* @calloc(i32 127, i32 1)
store i8* %14, i8** %5
br label %15
15: ; preds = %13, %8
%16 = load i16, i16* %3
%17 = sext i16 %16 to i32
switch i32 %17, label %53 [
i32 5, label %18
i32 4, label %21
i32 3, label %29
i32 2, label %37
i32 1, label %45
]
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0))
br label %53
21: ; preds = %15
%22 = load i8*, i8** %5
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8*, i8** %5
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = load i8*, i8** %5
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %53
29: ; preds = %15
%30 = load i8*, i8** %5
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%32 = load i8*, i8** %5
%33 = load i8*, i8** %4
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = load i8*, i8** %5
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %53
37: ; preds = %15
%38 = load i8*, i8** %5
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%40 = load i8*, i8** %5
%41 = load i8*, i8** %4
%42 = call i32 @strcat(i8* %40, i8* %41)
%43 = load i8*, i8** %5
%44 = call i32 @strcat(i8* %43, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %53
45: ; preds = %15
%46 = load i8*, i8** %5
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%48 = load i8*, i8** %5
%49 = load i8*, i8** %4
%50 = call i32 @strcat(i8* %48, i8* %49)
%51 = load i8*, i8** %5
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %53
53: ; preds = %15, %45, %37, %29, %21, %18
%54 = load i8*, i8** %5
ret i8* %54
}

LLVM IR (-O2):
@.str = [88 x i8] c"ERROR: Unable to create standard key file in current directory, try again as superuser!\00"
@.str.1 = [35 x i8] c"ERROR: Unable to create key file '\00"
@.str.2 = [48 x i8] c"' in current directory, try again as superuser!\00"
@.str.3 = [18 x i8] c"ERROR: Key file '\00"
@.str.4 = [39 x i8] c"' does not exist or is not accessible!\00"
@.str.5 = [38 x i8] c"ERROR: Unable to create output file '\00"
@.str.6 = [27 x i8] c"', try again as superuser!\00"
@.str.7 = [20 x i8] c"ERROR: Input file '\00"
define i8* @errMessage(i16 signext %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
%6 = add nsw i32 %5, 127
%7 = tail call i8* @calloc(i32 %6, i32 1)
br label %10
8: ; preds = %2
%9 = tail call dereferenceable_or_null(127) i8* @calloc(i32 127, i32 1)
br label %10
10: ; preds = %8, %4
%11 = phi i8* [ %7, %4 ], [ %9, %8 ]
%12 = sext i16 %0 to i32
switch i32 %12, label %24 [
i32 5, label %21
i32 4, label %16
i32 3, label %13
i32 2, label %14
i32 1, label %15
]
13: ; preds = %10
br label %16
14: ; preds = %10
br label %16
15: ; preds = %10
br label %16
16: ; preds = %10, %15, %14, %13
%17 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), %14 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), %15 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), %10 ]
%18 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), %13 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), %10 ]
%19 = tail call i32 @strcat(i8* %11, i8* %17)
%20 = tail call i32 @strcat(i8* %11, i8* %1)
br label %21
21: ; preds = %16, %10
%22 = phi i8* [ getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0), %10 ], [ %18, %16 ]
%23 = tail call i32 @strcat(i8* %11, i8* %22)
br label %24
24: ; preds = %21, %10
ret i8* %11
}