#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 errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
char *strerror(int);
void errhandler(int nLine, const char *szFile, const char *szString) {
  int err = errno;
  fprintf(stdout, "%s:%d Error : %s", szFile, nLine, szString);
  fprintf(stdout, "\n");
  if (err != 0) {
    fprintf(stdout, "C-Lib   errno    = %d\n", err);
    fprintf(stdout, "C-Lib   strerror = %s\n", strerror(err));
  }
  exit(1);
}


x86 assembly (clang, -O0):
<errhandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11d4 <errhandler+0xa4>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<errhandler>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%r8
mov    %rsi,%rdx
mov    %edi,%ecx
mov    0x2e9e(%rip),%rax
mov    (%rax),%ebx
mov    0x2e8d(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xeab(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xec0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebx,%ebx
je     11a1 <errhandler+0x71>
mov    0x0(%rbp),%edi
lea    0xe96(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%rbp),%ebp
mov    %ebx,%edi
call   1050 <strerror@plt>
lea    0xe93(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

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

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