#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*/ ok(char const *, unsigned int, int, char const *);
int /*<<< orphan*/ putstr(char *);
int /*<<< orphan*/ sprintf(char *, char *, void *);
void ptr_is(const char *file, unsigned int line, void *got, void *expected,
            const char *name) {
  ok(file, line, got == expected, name);
  if (got != expected) {
    char buf[16];
    putstr("#         got: ");
    sprintf(buf,
            "%p"
            "\n",
            got);
    putstr(buf);
    putstr("#    expected: ");
    sprintf(buf,
            "%p"
            "\n",
            expected);
    putstr(buf);
  }
}


x86 assembly (clang, -O0):
<ptr_is>:
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    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edx
mov    -0x28(%rbp),%rcx
call   1030 <ok@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11cb <ptr_is+0x9b>
lea    0xe80(%rip),%rdi
call   1040 <putstr@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe7c(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <putstr@plt>
lea    0xe6b(%rip),%rdi
call   1040 <putstr@plt>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe53(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <putstr@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptr_is>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
xor    %edx,%edx
cmp    %rcx,%rbx
sete   %dl
mov    %r8,%rcx
call   1030 <ok@plt>
cmp    %r14,%rbx
je     11a4 <ptr_is+0x74>
lea    0xea3(%rip),%rdi
call   1040 <putstr@plt>
lea    0xea7(%rip),%r15
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
mov    %r12,%rdi
call   1040 <putstr@plt>
lea    0xe8b(%rip),%rdi
call   1040 <putstr@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <sprintf@plt>
mov    %r12,%rdi
call   1040 <putstr@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"# got: \00"
@.str.1 = [4 x i8] c"%p\0A\00"
@.str.2 = [16 x i8] c"# expected: \00"
define void @ptr_is(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [16 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = load i8*, i8** %8
%15 = load i8*, i8** %9
%16 = icmp eq i8* %14, %15
%17 = zext i1 %16 to i32
%18 = load i8*, i8** %10
%19 = call i32 @ok(i8* %12, i32 %13, i32 %17, i8* %18)
%20 = load i8*, i8** %8
%21 = load i8*, i8** %9
%22 = icmp ne i8* %20, %21
br i1 %22, label %23, label %36
23: ; preds = %5
%24 = call i32 @putstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%26 = load i8*, i8** %8
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%29 = call i32 @putstr(i8* %28)
%30 = call i32 @putstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%32 = load i8*, i8** %9
%33 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%35 = call i32 @putstr(i8* %34)
br label %36
36: ; preds = %23, %5
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"# got: \00"
@.str.1 = [4 x i8] c"%p\0A\00"
@.str.2 = [16 x i8] c"# expected: \00"
define void @ptr_is(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [16 x i8]
%7 = icmp eq i8* %2, %3
%8 = zext i1 %7 to i32
%9 = tail call i32 @ok(i8* %0, i32 %1, i32 %8, i8* %4)
br i1 %7, label %18, label %10
10: ; preds = %5
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%12 = tail call i32 @putstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%14 = call i32 @putstr(i8* %11)
%15 = call i32 @putstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%17 = call i32 @putstr(i8* %11)
br label %18
18: ; preds = %10, %5
ret void
}