#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 */
char *_format_mod_log_message(char const *, char const *);
int /*<<< orphan*/ free(char *);
int monikor_vlog(int, char *, int /*<<< orphan*/);
int monikor_vlog_mod(int prio, const char *mod_name, const char *message,
                     va_list ap) {
  int ret;
  char *full_msg;
  if (!(full_msg = _format_mod_log_message(mod_name, message)))
    return -1;
  ret = monikor_vlog(prio, full_msg, ap);
  free(full_msg);
  return ret;
}


x86 assembly (clang, -O0):
<monikor_vlog_mod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <_format_mod_log_message@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    116d <monikor_vlog_mod+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <monikor_vlog_mod+0x5e>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <monikor_vlog@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<monikor_vlog_mod>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %edi,%ebp
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <_format_mod_log_message@plt>
test   %rax,%rax
je     1167 <monikor_vlog_mod+0x37>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    %r14d,%edx
call   1040 <monikor_vlog@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
jmp    116c <monikor_vlog_mod+0x3c>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @monikor_vlog_mod(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = call i8* @_format_mod_log_message(i8* %12, i8* %13)
store i8* %14, i8** %11
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %4
store i32 -1, i32* %5
br label %25
17: ; preds = %4
%18 = load i32, i32* %6
%19 = load i8*, i8** %11
%20 = load i32, i32* %9
%21 = call i32 @monikor_vlog(i32 %18, i8* %19, i32 %20)
store i32 %21, i32* %10
%22 = load i8*, i8** %11
%23 = call i32 @free(i8* %22)
%24 = load i32, i32* %10
store i32 %24, i32* %5
br label %25
25: ; preds = %17, %16
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
define i32 @monikor_vlog_mod(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i8* @_format_mod_log_message(i8* %1, i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @monikor_vlog(i32 %0, i8* %5, i32 %3)
%9 = tail call i32 @free(i8* %5)
br label %10
10: ; preds = %4, %7
%11 = phi i32 [ %8, %7 ], [ -1, %4 ]
ret i32 %11
}