#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void msg_callback(const char *message, int severity, void *ptr) {
  if (severity == 0) {
    fprintf(stderr, "--- %s\n", message);
  } else if (severity == 1) {
    fprintf(stderr, "*** %s\n", message);
  } else if (severity == 2) {
    fprintf(stderr, "!!! %s\n", message);
  }
}


x86 assembly (clang, -O0):
<msg_callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    114b <msg_callback+0x3b>
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xebf(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11a0 <msg_callback+0x90>
cmpl   $0x1,-0xc(%rbp)
jne    1173 <msg_callback+0x63>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe9f(%rip),%rsi
call   1030 <fprintf@plt>
jmp    119b <msg_callback+0x8b>
cmpl   $0x2,-0xc(%rbp)
jne    1196 <msg_callback+0x86>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
jmp    119b <msg_callback+0x8b>
jmp    11a0 <msg_callback+0x90>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_callback>:
cmp    $0x2,%esi
ja     1137 <msg_callback+0x27>
mov    %rdi,%rdx
movslq %esi,%rax
lea    0xef6(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
jmp    1030 <fprintf@plt>
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"--- %s\0A\00"
@.str.1 = [8 x i8] c"*** %s\0A\00"
@.str.2 = [8 x i8] c"!!! %s\0A\00"
@reltable.msg_callback = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.msg_callback to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.msg_callback to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.msg_callback to i64)) to i32)]
define void @msg_callback(i8* %0, i32 %1, i8* nocapture readnone %2) {
%4 = icmp ult i32 %1, 3
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = sext i32 %1 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.msg_callback to i8*), i64 %7)
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* %8, i8* %0)
br label %11
11: ; preds = %3, %5
ret void
}