#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*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void syserr(char *funcname, char *syscall, char *msg) {
  (void)fflush(stdout);
  if (msg == NULL)
    (void)fprintf(stderr, "ERROR: %s: %s\n", funcname, syscall);
  else
    (void)fprintf(stderr, "ERROR: %s: %s: %s\n", funcname, syscall, msg);
  (void)fflush(stderr);
  exit(-1);
}


x86 assembly (clang, -O0):
<syserr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1181 <syserr+0x51>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11a4 <syserr+0x74>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<syserr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2e8a(%rip),%r12
mov    (%r12),%edi
test   %rbx,%rbx
jne    1175 <syserr+0x45>
lea    0xe9a(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    118c <syserr+0x5c>
lea    0xe93(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r12),%edi
call   1040 <fflush@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

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

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