#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*/ test_fail_message(int /*<<< orphan*/ *, char const *, int,
                                     char *, char const *, char *, char *,
                                     char *, void const *);
int test_ptr_null(const char *file, int line, const char *s, const void *p) {
  if (p == NULL)
    return 1;
  test_fail_message(NULL, file, line, "ptr", s, "NULL", "==", "%p", p);
  return 0;
}


x86 assembly (clang, -O0):
<test_ptr_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    113e <test_ptr_null+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    1187 <test_ptr_null+0x77>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edi
lea    0xea8(%rip),%rcx
lea    0xea5(%rip),%r9
lea    0xea3(%rip),%r11
lea    0xe9f(%rip),%r10
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <test_fail_message@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ptr_null>:
push   %rbx
test   %rcx,%rcx
je     1155 <test_ptr_null+0x45>
mov    %rcx,%rax
mov    %rdx,%r8
mov    %esi,%edx
mov    %rdi,%rsi
sub    $0x8,%rsp
lea    0xee0(%rip),%r10
lea    0xed6(%rip),%r11
lea    0xec6(%rip),%rcx
lea    0xec3(%rip),%r9
xor    %ebx,%ebx
xor    %edi,%edi
push   %rax
push   %r10
push   %r11
call   1030 <test_fail_message@plt>
add    $0x20,%rsp
jmp    115a <test_ptr_null+0x4a>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ptr\00"
@.str.1 = [5 x i8] c"NULL\00"
@.str.2 = [3 x i8] c"==\00"
@.str.3 = [3 x i8] c"%p\00"
define i32 @test_ptr_null(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 1, i32* %5
br label %19
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = load i8*, i8** %8
%17 = load i8*, i8** %9
%18 = call i32 @test_fail_message(i32* null, i8* %14, i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %17)
store i32 0, i32* %5
br label %19
19: ; preds = %13, %12
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
@.str = [4 x i8] c"ptr\00"
@.str.1 = [5 x i8] c"NULL\00"
@.str.2 = [3 x i8] c"==\00"
@.str.3 = [3 x i8] c"%p\00"
define i32 @test_ptr_null(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %3, null
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @test_fail_message(i32* null, i8* %0, i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %8
8: ; preds = %4, %6
%9 = phi i32 [ 0, %6 ], [ 1, %4 ]
ret i32 %9
}