#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ p_vaddr;
};
typedef TYPE_1__ Elf32_Phdr;

/* Variables and functions */
int phcmp(const void *v1, const void *v2) {
  const Elf32_Phdr *h1 = v1;
  const Elf32_Phdr *h2 = v2;
  if (h1->p_vaddr > h2->p_vaddr)
    return 1;
  else if (h1->p_vaddr < h2->p_vaddr)
    return -1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<phcmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jle    113c <phcmp+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    1163 <phcmp+0x63>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jge    115c <phcmp+0x5c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1163 <phcmp+0x63>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<phcmp>:
mov    (%rdi),%rax
mov    (%rsi),%rcx
xor    %edx,%edx
cmp    %rcx,%rax
setl   %dl
neg    %edx
cmp    %rcx,%rax
mov    $0x1,%eax
cmovle %edx,%eax
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i64 }
define i32 @phcmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.TYPE_2__*
%7 = alloca %struct.TYPE_2__*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to %struct.TYPE_2__*
store %struct.TYPE_2__* %9, %struct.TYPE_2__** %6
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to %struct.TYPE_2__*
store %struct.TYPE_2__* %11, %struct.TYPE_2__** %7
%12 = load %struct.TYPE_2__*, %struct.TYPE_2__** %6
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = icmp sgt i64 %14, %17
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 1, i32* %3
br label %30
20: ; preds = %2
%21 = load %struct.TYPE_2__*, %struct.TYPE_2__** %6
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
%23 = load i64, i64* %22
%24 = load %struct.TYPE_2__*, %struct.TYPE_2__** %7
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = icmp slt i64 %23, %26
br i1 %27, label %28, label %29
28: ; preds = %20
store i32 -1, i32* %3
br label %30
29: ; preds = %20
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @phcmp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i64*
%4 = load i64, i64* %3
%5 = bitcast i8* %1 to i64*
%6 = load i64, i64* %5
%7 = icmp sgt i64 %4, %6
%8 = icmp slt i64 %4, %6
%9 = sext i1 %8 to i32
%10 = select i1 %7, i32 1, i32 %9
ret i32 %10
}