#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 get_loglevel();
int /*<<< orphan*/ printf(char *, char *, char *);
void con_log(char *msg, char *src, int level) {
  if (level > get_loglevel())
    return;
  else
    switch (get_loglevel()) {
    case 5:
      printf("DEBUG: [%s] %s \n", src, msg);
      break;
    case 4:
      printf("STRONG: [%s] %s \n", src, msg);
      break;
    case 3:
      printf("MIDDLE: [%s] %s \n", src, msg);
      break;
    case 2:
      printf("ERROR: [%s] %s \n", src, msg);
      break;
    case 1:
      break;
    }
}


x86 assembly (clang, -O0):
<con_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <get_loglevel@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jle    1152 <con_log+0x32>
jmp    11ed <con_log+0xcd>
xor    %eax,%eax
call   1030 <get_loglevel@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     11e8 <con_log+0xc8>
mov    -0x20(%rbp),%rax
lea    0xe8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
jmp    11e8 <con_log+0xc8>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
jmp    11e8 <con_log+0xc8>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
jmp    11e8 <con_log+0xc8>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
jmp    11e8 <con_log+0xc8>
jmp    11e8 <con_log+0xc8>
jmp    11ed <con_log+0xcd>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<con_log>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <get_loglevel@plt>
cmp    %ebp,%eax
jl     1165 <con_log+0x45>
xor    %eax,%eax
call   1030 <get_loglevel@plt>
add    $0xfffffffe,%eax
cmp    $0x3,%eax
ja     1165 <con_log+0x45>
cltq
lea    0xef9(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"DEBUG: [%s] %s \0A\00"
@.str.1 = [18 x i8] c"STRONG: [%s] %s \0A\00"
@.str.2 = [18 x i8] c"MIDDLE: [%s] %s \0A\00"
@.str.3 = [17 x i8] c"ERROR: [%s] %s \0A\00"
@reltable.con_log = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.con_log to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.con_log to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.con_log to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.con_log to i64)) to i32)]
define void @con_log(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 (...) @get_loglevel()
%5 = icmp slt i32 %4, %2
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = tail call i32 (...) @get_loglevel()
%8 = add i32 %7, -2
%9 = icmp ult i32 %8, 4
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = sext i32 %8 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.con_log to i8*), i64 %12)
%14 = tail call i32 @printf(i8* %13, i8* %1, i8* %0)
br label %15
15: ; preds = %6, %10, %3
ret void
}