#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *nc_strerror(int);
int /*<<< orphan*/ stderr;
void fail(int code) {
  if (code != 0)
    fprintf(stderr, "***Fail: %s\n", nc_strerror(code));
  exit((code == 0 ? EXIT_SUCCESS : EXIT_FAILURE));
}


x86 assembly (clang, -O0):
<fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     116b <fail+0x3b>
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <nc_strerror@plt>
mov    -0x8(%rbp),%edi
mov    %rax,%rdx
lea    0xe9a(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1186 <fail+0x56>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <fail+0x62>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<fail>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
je     115a <fail+0x2a>
mov    0x2ea0(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1050 <nc_strerror@plt>
lea    0xeb0(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1030 <fprintf@plt>
test   %ebx,%ebx
jne    116c <fail+0x3c>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"***Fail: %s\0A\00"
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define void @fail(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = load i32, i32* %2
%8 = call i8* @nc_strerror(i32 %7)
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %5, %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = load i32, i32* @EXIT_SUCCESS
br label %17
15: ; preds = %10
%16 = load i32, i32* @EXIT_FAILURE
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ %16, %15 ]
%19 = call i32 @exit(i32 %18)
unreachable
}

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