#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 errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
char *strerror(int);
int strlen(char *);
int /*<<< orphan*/ vsnprintf(char *, int, char const *, int /*<<< orphan*/);
void _printErr(const char *fmt, va_list ap, int errNoFlag) {
  char buf[256];
  int errno_save = errno;
  vsnprintf(buf, 256, fmt, ap);
  if (errNoFlag)
    snprintf(buf + strlen(buf), 256 - strlen(buf), ": %s",
             strerror(errno_save));
  if (strlen(buf) < 256 - 1)
    strcat(buf, "\n");
  fflush(stdout);
  fputs(buf, stderr);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<_printErr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    $0x100,%esi
call   1030 <vsnprintf@plt>
cmpl   $0x0,-0x10(%rbp)
je     1228 <_printErr+0xb8>
lea    -0x110(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x128(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x100,%eax
sub    %ecx,%eax
mov    %eax,-0x118(%rbp)
mov    -0x114(%rbp),%edi
call   1090 <strerror@plt>
mov    -0x120(%rbp),%rdi
mov    -0x118(%rbp),%esi
mov    %rax,%rcx
lea    0xddd(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xff,%eax
jge    1252 <_printErr+0xe2>
lea    -0x110(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1080 <strcat@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x110(%rbp),%rdi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_printErr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edx,%ebp
mov    %esi,%ecx
mov    %rdi,%rdx
mov    0x2e4d(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rdi
mov    $0x100,%ebx
mov    $0x100,%esi
call   1030 <vsnprintf@plt>
test   %ebp,%ebp
je     11db <_printErr+0x6b>
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbp
mov    %r15,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebx
mov    %r14d,%edi
call   1090 <strerror@plt>
lea    0xe32(%rip),%rdx
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
mov    %rsp,%rdi
call   1040 <strlen@plt>
cmp    $0xfe,%eax
jg     11f9 <_printErr+0x89>
lea    0xe14(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strcat@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2dd2(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%rdi
call   1060 <fputs@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [5 x i8] c": %s\00"
@.str.1 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@stderr = global i32 0
define void @_printErr(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* @errno
store i32 %9, i32* %8
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = call i32 @vsnprintf(i8* %10, i32 256, i8* %11, i32 %12)
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %3
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = sub nsw i32 256, %23
%25 = load i32, i32* %8
%26 = call i8* @strerror(i32 %25)
%27 = call i32 @snprintf(i8* %21, i32 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %16, %3
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = icmp slt i32 %30, 255
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %32, %28
%36 = load i32, i32* @stdout
%37 = call i32 @fflush(i32 %36)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%39 = load i32, i32* @stderr
%40 = call i32 @fputs(i8* %38, i32 %39)
%41 = load i32, i32* @stderr
%42 = call i32 @fflush(i32 %41)
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [5 x i8] c": %s\00"
@.str.1 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@stderr = global i32 0
define void @_printErr(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @errno
%7 = call i32 @vsnprintf(i8* %5, i32 256, i8* %0, i32 %1)
%8 = icmp eq i32 %2, 0
br i1 %8, label %17, label %9
9: ; preds = %3
%10 = call i32 @strlen(i8* %5)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %11
%13 = call i32 @strlen(i8* %5)
%14 = sub nsw i32 256, %13
%15 = call i8* @strerror(i32 %6)
%16 = call i32 @snprintf(i8* %12, i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %9, %3
%18 = call i32 @strlen(i8* %5)
%19 = icmp slt i32 %18, 255
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
%25 = load i32, i32* @stderr
%26 = call i32 @fputs(i8* %5, i32 %25)
%27 = load i32, i32* @stderr
%28 = call i32 @fflush(i32 %27)
ret void
}