#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 */
typedef int /*<<< orphan*/ _linestr;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, long);
int /*<<< orphan*/ stdout;
void _test_ptr_null(const char *file, long line, const char *desc,
                    const void *ptr) {
  do {
    const char *_exprstr = (ptr == NULL) ? "PASS" : "FAIL";
    char _linestr[BUFSIZ];
    if (!(ptr == NULL)) {
      snprintf(_linestr, sizeof(_linestr), " (%s:%ld)", file, line);
    } else {
      _linestr[0] = 0;
    }
    if ("%p" == 0) {
      printf("\tValue: "
             "%p"
             "\n"
             "[%s] %s%s\n",
             ptr, _exprstr, desc, _linestr);
    } else {
      printf("\tActual: "
             "%p"
             "\n"
             "\tExpected: "
             "%p"
             "\n"
             "[%s] %s%s\n",
             ptr, (void *)0, _exprstr, desc, _linestr);
    }
    if (!(ptr == NULL)) {
      printf("\t%s:%ld\n", file, line);
    }
    fflush(stdout);
  } while (0);
  ;
}


x86 assembly (clang, -O0):
<_test_ptr_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
test   %rax,%rax
lea    0xeaa(%rip),%rcx
lea    0xea8(%rip),%rax
cmove  %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c3 <_test_ptr_null+0x93>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe51(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11ca <_test_ptr_null+0x9a>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%r9
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe33(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     120d <_test_ptr_null+0xdd>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_test_ptr_null>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r9
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9b(%rip),%rax
lea    0xe99(%rip),%r14
test   %rcx,%rcx
cmove  %rax,%r14
je     11c7 <_test_ptr_null+0x97>
mov    %rcx,%r13
mov    %rdi,%r12
lea    0xe88(%rip),%rdx
mov    %rbx,%rdi
mov    %r12,%rcx
mov    %r9,%r8
mov    %r9,-0x30(%rbp)
call   1040 <snprintf@plt>
lea    0xe79(%rip),%rdi
mov    %r13,%rsi
xor    %edx,%edx
mov    %r14,%rcx
mov    %r15,%r8
mov    %rbx,%r9
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %r12,%rsi
mov    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e5 <_test_ptr_null+0xb5>
movb   $0x0,(%rbx)
lea    0xe43(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %r14,%rcx
mov    %r15,%r8
mov    %rbx,%r9
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"PASS\00"
@.str.1 = [5 x i8] c"FAIL\00"
@BUFSIZ = global i32 0
@.str.2 = [10 x i8] c" (%s:%ld)\00"
@.str.3 = [37 x i8] c"\09Actual: %p\0A\09Expected: %p\0A[%s] %s%s\0A\00"
@.str.4 = [9 x i8] c"\09%s:%ld\0A\00"
@stdout = global i32 0
define void @_test_ptr_null(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
br label %12
12: ; preds = %4
%13 = load i8*, i8** %8
%14 = icmp eq i8* %13, null
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
store i8* %16, i8** %9
%17 = load i32, i32* @BUFSIZ
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %10
%20 = alloca i8, i64 %18
store i64 %18, i64* %11
%21 = load i8*, i8** %8
%22 = icmp eq i8* %21, null
br i1 %22, label %28, label %23
23: ; preds = %12
%24 = trunc i64 %18 to i32
%25 = load i8*, i8** %5
%26 = load i64, i64* %6
%27 = call i32 @snprintf(i8* %20, i32 %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %25, i64 %26)
br label %30
28: ; preds = %12
%29 = getelementptr inbounds i8, i8* %20, i64 0
store i8 0, i8* %29
br label %30
30: ; preds = %28, %23
%31 = load i8*, i8** %8
%32 = load i8*, i8** %9
%33 = load i8*, i8** %7
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %31, i8* null, i8* %32, i8* %33, i8* %20)
%35 = load i8*, i8** %8
%36 = icmp eq i8* %35, null
br i1 %36, label %41, label %37
37: ; preds = %30
%38 = load i8*, i8** %5
%39 = load i64, i64* %6
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %38, i64 %39)
br label %41
41: ; preds = %37, %30
%42 = load i32, i32* @stdout
%43 = call i32 @fflush(i32 %42)
%44 = load i8*, i8** %10
br label %45
45: ; preds = %41
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"PASS\00"
@.str.1 = [5 x i8] c"FAIL\00"
@BUFSIZ = global i32 0
@.str.2 = [10 x i8] c" (%s:%ld)\00"
@.str.3 = [37 x i8] c"\09Actual: %p\0A\09Expected: %p\0A[%s] %s%s\0A\00"
@.str.4 = [9 x i8] c"\09%s:%ld\0A\00"
@stdout = global i32 0
define void @_test_ptr_null(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %3, null
%6 = select i1 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
br i1 %5, label %10, label %12
10: ; preds = %4
store i8 0, i8* %9
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* null, i8* %6, i8* %2, i8* %9)
br label %16
12: ; preds = %4
%13 = call i32 @snprintf(i8* %9, i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %0, i64 %1)
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* null, i8* %6, i8* %2, i8* %9)
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %0, i64 %1)
br label %16
16: ; preds = %10, %12
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
ret void
}