#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*/ clog_get_header(int, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
int clog_console_log_callback_fun(int loglvl, int reqlvl, const char *format,
                                  va_list ap, void *args) {
  if (reqlvl >= loglvl) {
    char head[128] = {0};
    clog_get_header(reqlvl, head, 128);
    fprintf(stdout, head);
    vfprintf(stdout, format, ap);
  }
  return 0;
}


x86 assembly (clang, -O0):
<clog_console_log_callback_fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11b9 <clog_console_log_callback_fun+0x79>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1050 <clog_get_header@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rsi
call   1040 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <vfprintf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clog_console_log_callback_fun>:
cmp    %edi,%esi
jl     11ae <clog_console_log_callback_fun+0x7e>
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %esi,%edi
mov    %r14,%rsi
mov    $0x80,%edx
call   1040 <clog_get_header@plt>
mov    0x2e57(%rip),%r15
mov    (%r15),%edi
mov    %r14,%rsi
call   1030 <fprintf@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <vfprintf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@stdout = global i32 0
define i32 @clog_console_log_callback_fun(i32 %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [128 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %5
%16 = bitcast [128 x i8]* %11 to i8*
%17 = load i32, i32* %7
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%19 = call i32 @clog_get_header(i32 %17, i8* %18, i32 128)
%20 = load i32, i32* @stdout
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%22 = call i32 @fprintf(i32 %20, i8* %21)
%23 = load i32, i32* @stdout
%24 = load i8*, i8** %8
%25 = load i32, i32* %9
%26 = call i32 @vfprintf(i32 %23, i8* %24, i32 %25)
br label %27
27: ; preds = %15, %5
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @clog_console_log_callback_fun(i32 %0, i32 %1, i8* %2, i32 %3, i8* nocapture readnone %4) {
%6 = alloca [128 x i8]
%7 = icmp slt i32 %1, %0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%10 = call i32 @clog_get_header(i32 %1, i8* %9, i32 128)
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* %9)
%13 = load i32, i32* @stdout
%14 = call i32 @vfprintf(i32 %13, i8* %2, i32 %3)
br label %15
15: ; preds = %8, %5
ret i32 0
}