#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*/ strncat(char *, char *, int);
void getPrefix(char *prefix, int log_level, int prefixId) {
  if (prefix != NULL) {
    switch (log_level) {
    case 1: {
      strncat(prefix, "INFO", (7 - 1));
      break;
    }
    case 2: {
      strncat(prefix, "WARN", (7 - 1));
      break;
    }
    case 3: {
      strncat(prefix, "ERROR", (7 - 1));
      break;
    }
    case 4: {
      strncat(prefix, "DEBUG", (7 - 1));
      break;
    }
    case 0xffff: {
      switch (prefixId) {
      case 0: {
        strncat(prefix, "PROLOG", (7 - 1));
        break;
      }
      case 1: {
        strncat(prefix, "EPILOG", (7 - 1));
        break;
      }
      default: {
        strncat(prefix, "VERBOSE", (7 - 1));
        break;
      }
      }
      break;
    }
    }
  }
}


x86 assembly (clang, -O0):
<getPrefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1266 <getPrefix+0x156>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     1187 <getPrefix+0x77>
jmp    1141 <getPrefix+0x31>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11a1 <getPrefix+0x91>
jmp    1152 <getPrefix+0x42>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     11bb <getPrefix+0xab>
jmp    1163 <getPrefix+0x53>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     11d5 <getPrefix+0xc5>
jmp    1174 <getPrefix+0x64>
mov    -0x14(%rbp),%eax
sub    $0xffff,%eax
je     11ef <getPrefix+0xdf>
jmp    1261 <getPrefix+0x151>
mov    -0x8(%rbp),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    1261 <getPrefix+0x151>
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    1261 <getPrefix+0x151>
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    1261 <getPrefix+0x151>
mov    -0x8(%rbp),%rdi
lea    0xe30(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    1261 <getPrefix+0x151>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1213 <getPrefix+0x103>
jmp    1202 <getPrefix+0xf2>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     122d <getPrefix+0x11d>
jmp    1247 <getPrefix+0x137>
mov    -0x8(%rbp),%rdi
lea    0xdf8(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    125c <getPrefix+0x14c>
mov    -0x8(%rbp),%rdi
lea    0xde5(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    125c <getPrefix+0x14c>
mov    -0x8(%rbp),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncat@plt>
jmp    1261 <getPrefix+0x151>
jmp    1266 <getPrefix+0x156>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPrefix>:
test   %rdi,%rdi
je     1179 <getPrefix+0x69>
lea    -0x1(%rsi),%eax
cmp    $0x3,%eax
ja     1145 <getPrefix+0x35>
lea    0xeec(%rip),%rsi
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeda(%rip),%rsi
mov    $0x6,%edx
jmp    1030 <strncat@plt>
cmp    $0xffff,%esi
jne    1179 <getPrefix+0x69>
cmp    $0x1,%edx
lea    0xed6(%rip),%rax
lea    0xed6(%rip),%rcx
cmove  %rax,%rcx
test   %edx,%edx
lea    0xebb(%rip),%rsi
cmovne %rcx,%rsi
mov    $0x6,%edx
jmp    1030 <strncat@plt>
ret
lea    0xe99(%rip),%rsi
mov    $0x6,%edx
jmp    1030 <strncat@plt>
lea    0xe8e(%rip),%rsi
mov    $0x6,%edx
jmp    1030 <strncat@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"INFO\00"
@.str.1 = [5 x i8] c"WARN\00"
@.str.2 = [6 x i8] c"ERROR\00"
@.str.3 = [6 x i8] c"DEBUG\00"
@.str.4 = [7 x i8] c"PROLOG\00"
@.str.5 = [7 x i8] c"EPILOG\00"
@.str.6 = [8 x i8] c"VERBOSE\00"
define void @getPrefix(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %36
9: ; preds = %3
%10 = load i32, i32* %5
switch i32 %10, label %35 [
i32 1, label %11
i32 2, label %14
i32 3, label %17
i32 4, label %20
i32 65535, label %23
]
11: ; preds = %9
%12 = load i8*, i8** %4
%13 = call i32 @strncat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 6)
br label %35
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = call i32 @strncat(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 6)
br label %35
17: ; preds = %9
%18 = load i8*, i8** %4
%19 = call i32 @strncat(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 6)
br label %35
20: ; preds = %9
%21 = load i8*, i8** %4
%22 = call i32 @strncat(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 6)
br label %35
23: ; preds = %9
%24 = load i32, i32* %6
switch i32 %24, label %31 [
i32 0, label %25
i32 1, label %28
]
25: ; preds = %23
%26 = load i8*, i8** %4
%27 = call i32 @strncat(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
br label %34
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = call i32 @strncat(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
br label %34
31: ; preds = %23
%32 = load i8*, i8** %4
%33 = call i32 @strncat(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 6)
br label %34
34: ; preds = %31, %28, %25
br label %35
35: ; preds = %9, %34, %20, %17, %14, %11
br label %36
36: ; preds = %35, %3
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"INFO\00"
@.str.1 = [5 x i8] c"WARN\00"
@.str.2 = [6 x i8] c"ERROR\00"
@.str.3 = [6 x i8] c"DEBUG\00"
@.str.4 = [7 x i8] c"PROLOG\00"
@.str.5 = [7 x i8] c"EPILOG\00"
@.str.6 = [8 x i8] c"VERBOSE\00"
define void @getPrefix(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %17, label %5
5: ; preds = %3
switch i32 %1, label %17 [
i32 1, label %14
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 65535, label %9
]
6: ; preds = %5
br label %14
7: ; preds = %5
br label %14
8: ; preds = %5
br label %14
9: ; preds = %5
%10 = icmp eq i32 %2, 1
%11 = select i1 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0)
%12 = icmp eq i32 %2, 0
%13 = select i1 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %11
br label %14
14: ; preds = %9, %5, %8, %7, %6
%15 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %5 ], [ %13, %9 ]
%16 = tail call i32 @strncat(i8* %0, i8* %15, i32 6)
br label %17
17: ; preds = %14, %5, %3
ret void
}