#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 */
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vprintfError(const char *format, va_list args) {
  fprintf(stderr, "bin2c: ");
  vfprintf(stderr, format, args);
  if (errno) {
    fprintf(stderr, ": ");
    perror("");
    errno = 0;
  } else {
    fprintf(stderr, "\n");
  }
}


x86 assembly (clang, -O0):
<vprintfError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <vfprintf@plt>
mov    0x2e68(%rip),%rax
cmpq   $0x0,(%rax)
je     11ae <vprintfError+0x7e>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe73(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e36(%rip),%rax
movq   $0x0,(%rax)
jmp    11c3 <vprintfError+0x93>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vprintfError>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2ea0(%rip),%r14
mov    (%r14),%edi
lea    0xeb6(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <vfprintf@plt>
mov    0x2e75(%rip),%rbx
cmpq   $0x0,(%rbx)
mov    (%r14),%edi
jne    117c <vprintfError+0x4c>
lea    0xe95(%rip),%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>
lea    0xe82(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe7a(%rip),%rdi
call   1040 <perror@plt>
movq   $0x0,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"bin2c: \00"
@errno = global i64 0
@.str.1 = [3 x i8] c": \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"\0A\00"
define void @vprintfError(i8* %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 @vfprintf(i32 %5, i8* %0, i32 %1)
%7 = load i64, i64* @errno
%8 = icmp eq i64 %7, 0
%9 = load i32, i32* @stderr
br i1 %8, label %13, label %10
10: ; preds = %2
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* @errno
br label %15
13: ; preds = %2
%14 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
ret void
}