#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_notnull(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, 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_notnull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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
cmovne %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)
jne    11c3 <_test_ptr_notnull+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_notnull+0x9a>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     11f1 <_test_ptr_notnull+0xc1>
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1201 <_test_ptr_notnull+0xd1>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x60(%rbp)
jmp    1201 <_test_ptr_notnull+0xd1>
mov    -0x40(%rbp),%r9
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1244 <_test_ptr_notnull+0x114>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d8d(%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_notnull>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xea0(%rip),%rax
lea    0xe94(%rip),%r13
test   %rcx,%rcx
cmove  %rax,%r13
je     1197 <_test_ptr_notnull+0x67>
movb   $0x0,(%rbx)
lea    0xe95(%rip),%rdi
mov    %rcx,%rsi
mov    %rcx,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    %rbx,%r9
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e3 <_test_ptr_notnull+0xb3>
mov    %rdi,%r15
lea    0xe69(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <snprintf@plt>
lea    0xe5e(%rip),%rdi
xor    %esi,%esi
mov    $0xffffffffffffffff,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    %rbx,%r9
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dee(%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_notnull(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 ne 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 ne 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** %8
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %30
br label %36
35: ; preds = %30
br label %36
36: ; preds = %35, %34
%37 = phi i8* [ %32, %34 ], [ inttoptr (i64 -1 to i8*), %35 ]
%38 = load i8*, i8** %9
%39 = load i8*, i8** %7
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %31, i8* %37, i8* %38, i8* %39, i8* %20)
%41 = load i8*, i8** %8
%42 = icmp ne i8* %41, null
br i1 %42, label %47, label %43
43: ; preds = %36
%44 = load i8*, i8** %5
%45 = load i64, i64* %6
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %44, i64 %45)
br label %47
47: ; preds = %43, %36
%48 = load i32, i32* @stdout
%49 = call i32 @fflush(i32 %48)
%50 = load i8*, i8** %10
br label %51
51: ; preds = %47
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_notnull(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.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
br i1 %5, label %12, label %10
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* %3, i8* %3, 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* null, i8* inttoptr (i64 -1 to i8*), 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
}