#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*/ bunyan(int, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strerror(int);
int vasprintf(char **, char const *, int /*<<< orphan*/);
void bunyan_vstrerror(int e, int priority, const char *fmt, va_list ap) {
  char *s;
  if (vasprintf(&s, fmt, ap) == -1)
    return;
  bunyan(priority, "%s: %s", s, strerror(e));
  free(s);
}


x86 assembly (clang, -O0):
<bunyan_vstrerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x20(%rbp),%rdi
call   1040 <vasprintf@plt>
cmp    $0xffffffff,%eax
jne    1173 <bunyan_vstrerror+0x33>
jmp    11a7 <bunyan_vstrerror+0x67>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
lea    0xe67(%rip),%rsi
call   1050 <bunyan@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bunyan_vstrerror>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
call   1040 <vasprintf@plt>
cmp    $0xffffffff,%eax
je     118b <bunyan_vstrerror+0x4b>
mov    0x8(%rsp),%rbx
mov    %ebp,%edi
call   1060 <strerror@plt>
lea    0xe8c(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <bunyan@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%s: %s\00"
define void @bunyan_vstrerror(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = call i32 @vasprintf(i8** %5, i8* %2, i32 %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = call i32 @strerror(i32 %0)
%12 = call i32 @bunyan(i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = load i8*, i8** %5
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %4, %9
ret void
}