#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 */
char *dtree_errstr();
scalar_t__ dtree_iserror();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
void _test_fail(const char *func, const char *file, int lineno,
                const char *desc) {
  fprintf(stderr, "Test %s (%s:%d) has FAILED\n", func, file, lineno);
  if (dtree_iserror())
    fprintf(stderr, "ERROR: %s [%s]\n", desc, dtree_errstr());
  else
    fprintf(stderr, "ERROR: %s\n", desc);
}


x86 assembly (clang, -O0):
<_test_fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <dtree_iserror@plt>
cmp    $0x0,%rax
je     11b3 <_test_fail+0x83>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <dtree_errstr@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ce <_test_fail+0x9e>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_test_fail>:
push   %rbp
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%r8d
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    0x2e9a(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <dtree_iserror@plt>
mov    0x0(%rbp),%ebp
test   %rax,%rax
je     1189 <_test_fail+0x59>
xor    %eax,%eax
call   1050 <dtree_errstr@plt>
lea    0xea8(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>
lea    0xe9c(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>

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

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