#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
void print_error(char *file, unsigned int line, int errnum, char *s) {
  fflush(stdout);
  if (file == NULL || line == 0)
    fprintf(stderr, "[-] %s: %s\n", s, strerror(errnum));
  else
    fprintf(stderr, "[-] %s:%d: %s: %s\n", file, line, s, strerror(errnum));
}


x86 assembly (clang, -O0):
<print_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
cmpq   $0x0,-0x8(%rbp)
je     1169 <print_error+0x39>
cmpl   $0x0,-0xc(%rbp)
jne    11a2 <print_error+0x72>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11eb <print_error+0xbb>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%r8
mov    %rax,%r9
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_error>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%r12d
mov    %ebp,%edi
call   1050 <strerror@plt>
test   %rbx,%rbx
je     1191 <print_error+0x61>
test   %r15d,%r15d
je     1191 <print_error+0x61>
lea    0xe99(%rip),%rsi
mov    %r12d,%edi
mov    %rbx,%rdx
mov    %r15d,%ecx
mov    %r14,%r8
mov    %rax,%r9
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>
lea    0xe68(%rip),%rsi
mov    %r12d,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stdout = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"[-] %s: %s\0A\00"
@.str.1 = [19 x i8] c"[-] %s:%d: %s: %s\0A\00"
define void @print_error(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = load i32, i32* @stdout
%6 = tail call i32 @fflush(i32 %5)
%7 = icmp eq i8* %0, null
%8 = icmp eq i32 %1, 0
%9 = or i1 %7, %8
%10 = load i32, i32* @stderr
%11 = tail call i8* @strerror(i32 %2)
br i1 %9, label %12, label %14
12: ; preds = %4
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %11)
br label %16
14: ; preds = %4
%15 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1, i8* %3, i8* %11)
br label %16
16: ; preds = %14, %12
ret void
}