#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 getConfigInt(char *);
int /*<<< orphan*/ printf(char *, char, char *);
int wombatlog(char *text, int status) {
  char level;
  switch (status) {
  case 1:
    level = 'a';
    break;
  case 2:
    level = 'i';
    break;
  case 5:
    level = 'W';
    break;
  case 10:
    level = 'A';
    break;
  default:
    level = '?';
  }
  if (status >= getConfigInt("loglevel")) {
    printf("[%c] %s\n", level, text);
  }
  return 0;
}


x86 assembly (clang, -O0):
<wombatlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     117c <wombatlog+0x5c>
mov    -0x18(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x61,-0xd(%rbp)
jmp    1180 <wombatlog+0x60>
movb   $0x69,-0xd(%rbp)
jmp    1180 <wombatlog+0x60>
movb   $0x57,-0xd(%rbp)
jmp    1180 <wombatlog+0x60>
movb   $0x41,-0xd(%rbp)
jmp    1180 <wombatlog+0x60>
movb   $0x3f,-0xd(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe9b(%rip),%rdi
call   1030 <getConfigInt@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jl     11b5 <wombatlog+0x95>
mov    -0xd(%rbp),%al
mov    -0x8(%rbp),%rdx
lea    0xe84(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wombatlog>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
lea    -0x1(%rbx),%eax
mov    $0x3f,%bpl
cmp    $0x9,%eax
ja     1141 <wombatlog+0x21>
cltq
lea    0xed5(%rip),%rcx
mov    (%rax,%rcx,1),%bpl
lea    0xeb8(%rip),%rdi
call   1030 <getConfigInt@plt>
cmp    %ebx,%eax
jg     1164 <wombatlog+0x44>
movsbl %bpl,%esi
lea    0xead(%rip),%rdi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"loglevel\00"
@.str.1 = [9 x i8] c"[%c] %s\0A\00"
define i32 @wombatlog(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
switch i32 %6, label %11 [
i32 1, label %7
i32 2, label %8
i32 5, label %9
i32 10, label %10
]
7: ; preds = %2
store i8 97, i8* %5
br label %12
8: ; preds = %2
store i8 105, i8* %5
br label %12
9: ; preds = %2
store i8 87, i8* %5
br label %12
10: ; preds = %2
store i8 65, i8* %5
br label %12
11: ; preds = %2
store i8 63, i8* %5
br label %12
12: ; preds = %11, %10, %9, %8, %7
%13 = load i32, i32* %4
%14 = call i32 @getConfigInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8, i8* %5
%18 = load i8*, i8** %3
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8 signext %17, i8* %18)
br label %20
20: ; preds = %16, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"loglevel\00"
@.str.1 = [9 x i8] c"[%c] %s\0A\00"
@switch.table.wombatlog = [10 x i8] c"ai??W????A"
define i32 @wombatlog(i8* %0, i32 %1) {
%3 = add i32 %1, -1
%4 = icmp ult i32 %3, 10
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [10 x i8], [10 x i8]* @switch.table.wombatlog, i64 0, i64 %6
%8 = load i8, i8* %7
br label %9
9: ; preds = %2, %5
%10 = phi i8 [ %8, %5 ], [ 63, %2 ]
%11 = tail call i32 @getConfigInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = icmp sgt i32 %11, %1
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8 signext %10, i8* %0)
br label %15
15: ; preds = %13, %9
ret i32 0
}