#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 */
int /*<<< orphan*/ App_Exit();
int /*<<< orphan*/ printf(char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void Port_Puts(int Type, char *Location, char *Message) {
  char Temp[32];
  switch (Type) {
  case 0:
  case 1:
    strcpy(Temp, "FATAL ERROR!");
    break;
  case 2:
    strcpy(Temp, "Warning:");
    break;
  case 3:
    strcpy(Temp, "I");
    break;
  case 4:
    printf("Debug - %s: %s\n", Location, Message);
    return;
  default:
    Temp[0] = 0;
    break;
  }
  printf("%s - [%s]: %s\n", Temp, Location, Message);
  if (Type == 0)
    App_Exit();
  return;
}


x86 assembly (clang, -O0):
<Port_Puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x4,%rax
ja     11c2 <Port_Puts+0x92>
mov    -0x48(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x40(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c6 <Port_Puts+0x96>
lea    -0x40(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c6 <Port_Puts+0x96>
lea    -0x40(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c6 <Port_Puts+0x96>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f6 <Port_Puts+0xc6>
movb   $0x0,-0x40(%rbp)
lea    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11f1 <Port_Puts+0xc1>
mov    $0x0,%al
call   1040 <App_Exit@plt>
jmp    11f6 <Port_Puts+0xc6>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Port_Puts>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
cmp    $0x4,%edi
ja     118f <Port_Puts+0x5f>
mov    %edi,%ebp
mov    %edi,%eax
lea    0xeb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb4(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
lea    0xeca(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jne    11c4 <Port_Puts+0x94>
xor    %eax,%eax
call   1040 <App_Exit@plt>
jmp    11c4 <Port_Puts+0x94>
movb   $0x0,(%rsp)
jmp    11ad <Port_Puts+0x7d>
lea    0xe85(%rip),%rsi
jmp    11a5 <Port_Puts+0x75>
lea    0xe85(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xe88(%rip),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"FATAL ERROR!\00"
@.str.1 = [9 x i8] c"Warning:\00"
@.str.2 = [2 x i8] c"I\00"
@.str.3 = [16 x i8] c"Debug - %s: %s\0A\00"
@.str.4 = [15 x i8] c"%s - [%s]: %s\0A\00"
define void @Port_Puts(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [32 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
switch i32 %8, label %22 [
i32 0, label %9
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
]
9: ; preds = %3, %3
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %24
12: ; preds = %3
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %24
15: ; preds = %3
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %24
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %19, i8* %20)
br label %34
22: ; preds = %3
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
store i8 0, i8* %23
br label %24
24: ; preds = %22, %15, %12, %9
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* %26, i8* %27)
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 (...) @App_Exit()
br label %33
33: ; preds = %31, %24
br label %34
34: ; preds = %33, %18
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"FATAL ERROR!\00"
@.str.1 = [9 x i8] c"Warning:\00"
@.str.2 = [2 x i8] c"I\00"
@.str.3 = [16 x i8] c"Debug - %s: %s\0A\00"
@.str.4 = [15 x i8] c"%s - [%s]: %s\0A\00"
define void @Port_Puts(i32 %0, i8* %1, i8* %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
switch i32 %0, label %12 [
i32 0, label %15
i32 1, label %15
i32 2, label %6
i32 3, label %8
i32 4, label %10
]
6: ; preds = %3
%7 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %13
8: ; preds = %3
%9 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %13
10: ; preds = %3
%11 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %2)
br label %21
12: ; preds = %3
store i8 0, i8* %5
br label %13
13: ; preds = %12, %8, %6
%14 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %1, i8* %2)
br label %21
15: ; preds = %3, %3
%16 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %1, i8* %2)
%18 = icmp eq i32 %0, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (...) @App_Exit()
br label %21
21: ; preds = %13, %15, %19, %10
ret void
}