#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ flockfile(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ funlockfile(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vlogbug(unsigned *pc, const char *level, const char *func, const char *fmt,
             va_list ap) {
  flockfile(stderr);
  if (*pc < 5) {
    (*pc)++;
    fprintf(stderr, "%s: call to %s(", level, func);
    vfprintf(stderr, fmt, ap);
    fputs(")\n", stderr);
    fflush(stderr);
  }
  funlockfile(stderr);
}


x86 assembly (clang, -O0):
<vlogbug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1050 <flockfile@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x5,(%rax)
jae    11f7 <vlogbug+0x97>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe46(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <vfprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
lea    0xe2c(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1030 <funlockfile@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vlogbug>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbp
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
call   1050 <flockfile@plt>
mov    0x0(%rbp),%eax
cmp    $0x4,%eax
ja     11cc <vlogbug+0x6c>
add    $0x1,%eax
mov    %eax,0x0(%rbp)
mov    (%rbx),%edi
lea    0xe61(%rip),%rsi
mov    %r13,%rdx
mov    %r12,%rcx
call   1060 <fprintf@plt>
mov    (%rbx),%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1080 <vfprintf@plt>
mov    (%rbx),%esi
lea    0xe50(%rip),%rdi
call   1040 <fputs@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    (%rbx),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <funlockfile@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"%s: call to %s(\00"
@.str.1 = [3 x i8] c")\0A\00"
define void @vlogbug(i32* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%11 = load i32, i32* @stderr
%12 = call i32 @flockfile(i32 %11)
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = icmp ult i32 %14, 5
br i1 %15, label %16, label %32
16: ; preds = %5
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = add i32 %18, 1
store i32 %19, i32* %17
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %9
%26 = load i32, i32* %10
%27 = call i32 @vfprintf(i32 %24, i8* %25, i32 %26)
%28 = load i32, i32* @stderr
%29 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @stderr
%31 = call i32 @fflush(i32 %30)
br label %32
32: ; preds = %16, %5
%33 = load i32, i32* @stderr
%34 = call i32 @funlockfile(i32 %33)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"%s: call to %s(\00"
@.str.1 = [3 x i8] c")\0A\00"
define void @vlogbug(i32* nocapture %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = load i32, i32* @stderr
%7 = tail call i32 @flockfile(i32 %6)
%8 = load i32, i32* %0
%9 = icmp ult i32 %8, 5
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = add nuw nsw i32 %8, 1
store i32 %11, i32* %0
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%14 = load i32, i32* @stderr
%15 = tail call i32 @vfprintf(i32 %14, i8* %3, i32 %4)
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @stderr
%19 = tail call i32 @fflush(i32 %18)
br label %20
20: ; preds = %10, %5
%21 = load i32, i32* @stderr
%22 = tail call i32 @funlockfile(i32 %21)
ret void
}