#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 */

/* Variables and functions */
int /*<<< orphan*/ liberr_fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ liberr_snprintf(char *, int, char *, char const *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void liberr_printError(const char *funcName, int usePerror, const char *extra) {
  if (usePerror) {
    char str[1024];
    liberr_snprintf(str, 1024,
                    "\x1B[31m"
                    "\x1B[1m"
                    "liberr error: %s()"
                    "\x1B[0m",
                    funcName);
    perror(str);
  } else
    liberr_fprintf(stderr,
                   "\x1B[31m"
                   "\x1B[1m"
                   "liberr error: %s()"
                   "\x1B[0m"
                   "\n",
                   funcName);
  if (extra != NULL)
    liberr_fprintf(stderr,
                   "\x1B[31m"
                   "\x1B[1m"
                   "liberr error: Note: %s()"
                   "\x1B[0m"
                   "\n",
                   extra);
}


x86 assembly (clang, -O0):
<liberr_printError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     117d <liberr_printError+0x4d>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x400,%esi
lea    0xe99(%rip),%rdx
call   1040 <liberr_snprintf@plt>
lea    -0x420(%rbp),%rdi
call   1050 <perror@plt>
jmp    1196 <liberr_printError+0x66>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe8f(%rip),%rsi
call   1030 <liberr_fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11ba <liberr_printError+0x8a>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe8c(%rip),%rsi
call   1030 <liberr_fprintf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<liberr_printError>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%rbx
mov    %rdi,%rcx
test   %esi,%esi
jne    1184 <liberr_printError+0x54>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
mov    %rcx,%rdx
call   1030 <liberr_fprintf@plt>
test   %rbx,%rbx
je     1179 <liberr_printError+0x49>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xed0(%rip),%rsi
mov    %rbx,%rdx
call   1030 <liberr_fprintf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe75(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1040 <liberr_snprintf@plt>
mov    %r14,%rdi
call   1050 <perror@plt>
test   %rbx,%rbx
jne    1161 <liberr_printError+0x31>
jmp    1179 <liberr_printError+0x49>

LLVM IR (-O0):
@.str = [32 x i8] c"\1B[31m\1B[1mliberr error: %s()\1B[0m\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"\1B[31m\1B[1mliberr error: %s()\1B[0m\0A\00"
@.str.2 = [39 x i8] c"\1B[31m\1B[1mliberr error: Note: %s()\1B[0m\0A\00"
define void @liberr_printError(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [1024 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = call i32 @liberr_snprintf(i8* %11, i32 1024, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = call i32 @perror(i8* %14)
br label %20
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %4
%19 = call i32 @liberr_fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %10
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %6
%26 = call i32 @liberr_fprintf(i32 %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %23, %20
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"\1B[31m\1B[1mliberr error: %s()\1B[0m\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"\1B[31m\1B[1mliberr error: %s()\1B[0m\0A\00"
@.str.2 = [39 x i8] c"\1B[31m\1B[1mliberr error: Note: %s()\1B[0m\0A\00"
define void @liberr_printError(i8* %0, i32 %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = icmp eq i32 %1, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = call i32 @liberr_snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @perror(i8* %7)
br label %13
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = tail call i32 @liberr_fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %10, %6
%14 = icmp eq i8* %2, null
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = call i32 @liberr_fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %18
18: ; preds = %15, %13
ret void
}