#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 logger(char type, const char *msg) {
  switch (type) {
  case 'i':
    fprintf(stderr, "info: %s\n", msg);
    break;
  case 'w':
    fprintf(stderr, "warning: %s\n", msg);
    break;
  case 'e':
    fprintf(stderr, "error: %s\n", msg);
    break;
  default:
    fprintf(stderr, "default: %s\n", msg);
  }
}


x86 assembly (clang, -O0):
<logger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x65,%eax
je     1195 <logger+0x85>
jmp    1137 <logger+0x27>
mov    -0x14(%rbp),%eax
sub    $0x69,%eax
je     1159 <logger+0x49>
jmp    1148 <logger+0x38>
mov    -0x14(%rbp),%eax
sub    $0x77,%eax
je     1177 <logger+0x67>
jmp    11b3 <logger+0xa3>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe93(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11cc <logger+0xbc>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11cc <logger+0xbc>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe6e(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11cc <logger+0xbc>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe5b(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logger>:
mov    %rsi,%rdx
cmp    $0x65,%edi
je     112b <logger+0x1b>
cmp    $0x69,%edi
je     1134 <logger+0x24>
cmp    $0x77,%edi
jne    113d <logger+0x2d>
lea    0xee1(%rip),%rsi
jmp    1144 <logger+0x34>
lea    0xee5(%rip),%rsi
jmp    1144 <logger+0x34>
lea    0xec5(%rip),%rsi
jmp    1144 <logger+0x34>
lea    0xede(%rip),%rsi
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [10 x i8] c"info: %s\0A\00"
@.str.1 = [13 x i8] c"warning: %s\0A\00"
@.str.2 = [11 x i8] c"error: %s\0A\00"
@.str.3 = [13 x i8] c"default: %s\0A\00"
define void @logger(i8 signext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
store i8 %0, i8* %3
store i8* %1, i8** %4
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
switch i32 %6, label %19 [
i32 105, label %7
i32 119, label %11
i32 101, label %15
]
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %4
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %23
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %4
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %4
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %23
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %4
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %15, %11, %7
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [10 x i8] c"info: %s\0A\00"
@.str.1 = [13 x i8] c"warning: %s\0A\00"
@.str.2 = [11 x i8] c"error: %s\0A\00"
@.str.3 = [13 x i8] c"default: %s\0A\00"
define void @logger(i8 signext %0, i8* %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %6 [
i32 105, label %7
i32 119, label %4
i32 101, label %5
]
4: ; preds = %2
br label %7
5: ; preds = %2
br label %7
6: ; preds = %2
br label %7
7: ; preds = %2, %6, %5, %4
%8 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* %8, i8* %1)
ret void
}