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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/ *, char const *,
                            int /*<<< orphan*/);
void mcx_err_f(FILE *fp, const char *caller, const char *fmt, va_list *args) {
  if (caller)
    fprintf(fp, "___ [%s] ", caller);
  else
    fprintf(fp, "___ ");
  vfprintf(fp, fmt, *args);
  fprintf(fp, "\n");
  return;
}


x86 assembly (clang, -O0):
<mcx_err_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115e <mcx_err_f+0x3e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1170 <mcx_err_f+0x50>
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1040 <vfprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcx_err_f>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
je     1169 <mcx_err_f+0x29>
mov    %rsi,%rdx
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1182 <mcx_err_f+0x42>
lea    0xe9a(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <vfprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"___ [%s] \00"
@.str.1 = [5 x i8] c"___ \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @mcx_err_f(i32* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i32*, i32** %5
%13 = load i8*, i8** %6
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %18
15: ; preds = %4
%16 = load i32*, i32** %5
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %11
%19 = load i32*, i32** %5
%20 = load i8*, i8** %7
%21 = load i32*, i32** %8
%22 = load i32, i32* %21
%23 = call i32 @vfprintf(i32* %19, i8* %20, i32 %22)
%24 = load i32*, i32** %5
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"___ [%s] \00"
@.str.1 = [5 x i8] c"___ \00"
define void @mcx_err_f(i32* nocapture %0, i8* %1, i8* nocapture %2, i32* nocapture %3) {
%5 = icmp eq i8* %1, null
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %10
8: ; preds = %4
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 4, i64 1, i32* %0)
br label %10
10: ; preds = %8, %6
%11 = load i32, i32* %3
%12 = tail call i32 @vfprintf(i32* %0, i8* %2, i32 %11)
%13 = tail call i32 @fputc(i32 10, i32* %0)
ret void
}