#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 *, char const *,
                           int, char const *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
void ylog_default_handler(const char *file, int line, int level,
                          const char *message) {
  char lvl[8];
  switch (level) {
  case 1:
    strcpy(lvl, "ERROR");
    break;
  case 2:
    strcpy(lvl, "WARN");
    break;
  case 3:
    strcpy(lvl, "info");
    break;
  case 4:
    strcpy(lvl, "debug");
    break;
  case 5:
    strcpy(lvl, "trace");
    break;
  default:
    sprintf(lvl, "%d", level);
  };
  fprintf(stderr, "--%s-- %s:%d: %s\n", lvl, file, line, message);
  ;
}


x86 assembly (clang, -O0):
<ylog_default_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     11d8 <ylog_default_handler+0xa8>
mov    -0x28(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11eb <ylog_default_handler+0xbb>
lea    -0x20(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11eb <ylog_default_handler+0xbb>
lea    -0x20(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11eb <ylog_default_handler+0xbb>
lea    -0x20(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11eb <ylog_default_handler+0xbb>
lea    -0x20(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11eb <ylog_default_handler+0xbb>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe4a(%rip),%rsi
call   1050 <sprintf@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    -0x18(%rbp),%r9
lea    0xe28(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ylog_default_handler>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
lea    -0x1(%rdx),%eax
cmp    $0x4,%eax
ja     1161 <ylog_default_handler+0x31>
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb5(%rip),%rsi
jmp    1196 <ylog_default_handler+0x66>
lea    0xec8(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <sprintf@plt>
jmp    11a0 <ylog_default_handler+0x70>
lea    0xe9f(%rip),%rsi
jmp    1196 <ylog_default_handler+0x66>
lea    0xe9b(%rip),%rsi
jmp    1196 <ylog_default_handler+0x66>
lea    0xe97(%rip),%rsi
jmp    1196 <ylog_default_handler+0x66>
lea    0xe94(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %r14,%r9
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"ERROR\00"
@.str.1 = [5 x i8] c"WARN\00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [6 x i8] c"debug\00"
@.str.4 = [6 x i8] c"trace\00"
@.str.5 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.6 = [18 x i8] c"--%s-- %s:%d: %s\0A\00"
define void @ylog_default_handler(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [8 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i32, i32* %7
switch i32 %10, label %26 [
i32 1, label %11
i32 2, label %14
i32 3, label %17
i32 4, label %20
i32 5, label %23
]
11: ; preds = %4
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %30
14: ; preds = %4
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %30
17: ; preds = %4
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %30
20: ; preds = %4
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %30
23: ; preds = %4
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %30
26: ; preds = %4
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%28 = load i32, i32* %7
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %23, %20, %17, %14, %11
%31 = load i32, i32* @stderr
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = load i8*, i8** %8
%36 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %32, i8* %33, i32 %34, i8* %35)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"ERROR\00"
@.str.1 = [5 x i8] c"WARN\00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [6 x i8] c"debug\00"
@.str.4 = [6 x i8] c"trace\00"
@.str.5 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.6 = [18 x i8] c"--%s-- %s:%d: %s\0A\00"
define void @ylog_default_handler(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca [8 x i8]
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
switch i32 %2, label %17 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
7: ; preds = %4
%8 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %4
%10 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %19
11: ; preds = %4
%12 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %19
13: ; preds = %4
%14 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %19
15: ; preds = %4
%16 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %19
17: ; preds = %4
%18 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %2)
br label %19
19: ; preds = %17, %15, %13, %11, %9, %7
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %6, i8* %0, i32 %1, i8* %3)
ret void
}