#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*/ assert(int);
scalar_t__ pointer_compare(int *, int *);
void test_pointer_compare(void) {
  int array[5];
  assert(pointer_compare(&array[0], &array[4]) < 0);
  assert(pointer_compare(&array[3], &array[2]) > 0);
  assert(pointer_compare(&array[4], &array[4]) == 0);
}


x86 assembly (clang, -O0):
<test_pointer_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x10,%rsi
call   1030 <pointer_compare@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x20(%rbp),%rdi
add    $0xc,%rdi
lea    -0x20(%rbp),%rsi
add    $0x8,%rsi
call   1030 <pointer_compare@plt>
cmp    $0x0,%rax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x20(%rbp),%rdi
add    $0x10,%rdi
lea    -0x20(%rbp),%rsi
add    $0x10,%rsi
call   1030 <pointer_compare@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pointer_compare>:
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <pointer_compare@plt>
shr    $0x3f,%rax
mov    %eax,%edi
call   1040 <assert@plt>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <pointer_compare@plt>
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <pointer_compare@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @test_pointer_compare() {
%1 = alloca [5 x i32]
%2 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%4 = call i64 @pointer_compare(i32* %2, i32* %3)
%5 = icmp slt i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%10 = call i64 @pointer_compare(i32* %8, i32* %9)
%11 = icmp sgt i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%16 = call i64 @pointer_compare(i32* %14, i32* %15)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
ret void
}

LLVM IR (-O2):
define void @test_pointer_compare() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%5 = call i64 @pointer_compare(i32* %3, i32* %4)
%6 = lshr i64 %5, 63
%7 = trunc i64 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%11 = call i64 @pointer_compare(i32* %9, i32* %10)
%12 = icmp sgt i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i64 @pointer_compare(i32* %4, i32* %4)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
ret void
}