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


x86 assembly (clang, -O0):
<fatalerr>:
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,-0x10(%rbp)
jne    117d <fatalerr+0x4d>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11d4 <fatalerr+0xa4>
cmpq   $0x0,-0x18(%rbp)
jne    11ac <fatalerr+0x7c>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11cf <fatalerr+0x9f>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11d4 <fatalerr+0xa4>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<fatalerr>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2e8d(%rip),%rax
test   %rbx,%rbx
jne    116d <fatalerr+0x3d>
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11a1 <fatalerr+0x71>
mov    (%rax),%edi
test   %r15,%r15
jne    118a <fatalerr+0x5a>
lea    0xe90(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11a1 <fatalerr+0x71>
lea    0xe89(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
@.str.1 = [15 x i8] c"ERROR: %s: %s\0A\00"
@.str.2 = [19 x i8] c"ERROR: %s: %s: %s\0A\00"
define void @fatalerr(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** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %4
%14 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %30
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21)
br label %29
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %26, i8* %27)
br label %29
29: ; preds = %23, %18
br label %30
30: ; preds = %29, %11
%31 = load i32, i32* @stderr
%32 = call i32 @fflush(i32 %31)
%33 = call i32 @exit(i32 1)
unreachable
}

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