#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 */
typedef int /*<<< orphan*/ va_list;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void x264_log_default(void *p_unused, int i_level, const char *psz_fmt,
                      va_list arg) {
  char *psz_prefix;
  switch (i_level) {
  case 0:
    psz_prefix = "error";
    break;
  case 1:
    psz_prefix = "warning";
    break;
  case 2:
    psz_prefix = "info";
    break;
  case 3:
    psz_prefix = "debug";
    break;
  default:
    psz_prefix = "unknown";
    break;
  }
  fprintf(stderr, "x264 [%s]: ", psz_prefix);
  vfprintf(stderr, psz_fmt, arg);
}


x86 assembly (clang, -O0):
<x264_log_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x3,%rax
ja     119b <x264_log_default+0x7b>
mov    -0x30(%rbp),%rax
lea    0xeae(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11a6 <x264_log_default+0x86>
lea    0xea4(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11a6 <x264_log_default+0x86>
lea    0xe9c(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11a6 <x264_log_default+0x86>
lea    0xe91(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11a6 <x264_log_default+0x86>
lea    0xe87(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <vfprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x264_log_default>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbx
cmp    $0x3,%esi
ja     1142 <x264_log_default+0x22>
movslq %esi,%rax
lea    0xef7(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
jmp    1149 <x264_log_default+0x29>
lea    0xed0(%rip),%rdx
mov    0x2e90(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xec7(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <vfprintf@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"error\00"
@.str.1 = [8 x i8] c"warning\00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [6 x i8] c"debug\00"
@.str.4 = [8 x i8] c"unknown\00"
@stderr = global i32 0
@.str.5 = [12 x i8] c"x264 [%s]: \00"
@reltable.x264_log_default = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.x264_log_default to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.x264_log_default to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.x264_log_default to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.x264_log_default to i64)) to i32)]
define void @x264_log_default(i8* nocapture readnone %0, i32 %1, i8* %2, i32 %3) {
%5 = icmp ult i32 %1, 4
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = sext i32 %1 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.x264_log_default to i8*), i64 %8)
br label %10
10: ; preds = %4, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %4 ]
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %11)
%14 = load i32, i32* @stderr
%15 = tail call i32 @vfprintf(i32 %14, i8* %2, i32 %3)
ret void
}