#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*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           unsigned int, char const *, ...);
int /*<<< orphan*/ print_trace();
int /*<<< orphan*/ stderr;
void assert_trace(const char *assertion, const char *filename, const char *func,
                  unsigned line, int val) {
  if (val)
    return;
  if (assertion)
    fprintf(stderr, "%s:%d: %s: Assertion `%s` failed.\n", filename, line, func,
            assertion);
  else
    fprintf(stderr, "%s:%d: %s: Assertion failed.\n", filename, line, func);
  print_trace();
  exit(1);
}


x86 assembly (clang, -O0):
<assert_trace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     115b <assert_trace+0x2b>
add    $0x20,%rsp
pop    %rbp
ret
cmpq   $0x0,-0x8(%rbp)
je     1191 <assert_trace+0x61>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x8(%rbp),%r9
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b3 <assert_trace+0x83>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <print_trace@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<assert_trace>:
test   %r8d,%r8d
je     1136 <assert_trace+0x6>
ret
push   %rax
mov    %rdx,%rax
mov    %rsi,%rdx
mov    %rdi,%r9
mov    0x2e99(%rip),%rsi
mov    (%rsi),%edi
test   %r9,%r9
jne    1161 <assert_trace+0x31>
lea    0xece(%rip),%rsi
mov    %rax,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1172 <assert_trace+0x42>
lea    0xe98(%rip),%rsi
mov    %rax,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <print_trace@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"%s:%d: %s: Assertion `%s` failed.\0A\00"
@.str.1 = [30 x i8] c"%s:%d: %s: Assertion failed.\0A\00"
define void @assert_trace(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %5
ret void
14: ; preds = %5
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %7
%20 = load i32, i32* %9
%21 = load i8*, i8** %8
%22 = load i8*, i8** %6
%23 = call i32 (i32, i8*, i8*, i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %20, i8* %21, i8* %22)
br label %30
24: ; preds = %14
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %7
%27 = load i32, i32* %9
%28 = load i8*, i8** %8
%29 = call i32 (i32, i8*, i8*, i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %27, i8* %28)
br label %30
30: ; preds = %24, %17
%31 = call i32 (...) @print_trace()
%32 = call i32 @exit(i32 1)
unreachable
}

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