#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 *, int,
                           char const *, char const *, int, char const *);
int /*<<< orphan*/ stderr;
void test_fail_call(const char *call, int rv, const char *errmsg,
                    const char *message, const char *file, int line) {
  if (errmsg == NULL)
    errmsg = "(null)";
  fprintf(stderr, "%s:%d: FAILED %s\n  %s -> %d\n  error message: %s\n", file,
          line, message, call, rv, errmsg);
  exit(1);
}


x86 assembly (clang, -O0):
<test_fail_call>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1155 <test_fail_call+0x35>
lea    0xeaf(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x8(%rbp),%r9
mov    -0xc(%rbp),%r10d
mov    -0x18(%rbp),%rax
lea    0xe8b(%rip),%rsi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<test_fail_call>:
push   %rbx
mov    %rcx,%r11
mov    %esi,%r10d
mov    %rdi,%rax
test   %rdx,%rdx
lea    0xecc(%rip),%rbx
cmovne %rdx,%rbx
mov    0x2ea1(%rip),%rcx
mov    (%rcx),%edi
lea    0xebf(%rip),%rsi
mov    %r8,%rdx
mov    %r9d,%ecx
mov    %r11,%r8
mov    %rax,%r9
push   %rbx
push   %r10
call   1030 <fprintf@plt>
add    $0x10,%rsp
mov    $0x1,%edi
call   1040 <exit@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"(null)\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"%s:%d: FAILED %s\0A %s -> %d\0A error message: %s\0A\00"
define void @test_fail_call(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = icmp eq i8* %2, null
%8 = select i1 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %5, i8* %3, i8* %0, i32 %1, i8* %8)
%11 = tail call i32 @exit(i32 1)
unreachable
}