#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*/ abort();
int compare_longs(void *x_, void *y_) {
  long *x = (long *)x_;
  long *y = (long *)y_;
  if (*x == *y)
    return 0;
  else if (*x < *y)
    return -1;
  else if (*x > *y)
    return 1;
  else
    abort();
}


x86 assembly (clang, -O0):
<compare_longs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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
jne    1150 <compare_longs+0x40>
movl   $0x0,-0x4(%rbp)
jmp    1197 <compare_longs+0x87>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jge    1170 <compare_longs+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <compare_longs+0x87>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jle    1190 <compare_longs+0x80>
movl   $0x1,-0x4(%rbp)
jmp    1197 <compare_longs+0x87>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_longs>:
push   %rax
mov    (%rdi),%rcx
mov    (%rsi),%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
je     112c <compare_longs+0x1c>
mov    $0xffffffff,%eax
jl     112c <compare_longs+0x1c>
mov    $0x1,%eax
jle    112e <compare_longs+0x1e>
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define i32 @compare_longs(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i64*
%4 = bitcast i8* %1 to i64*
%5 = load i64, i64* %3
%6 = load i64, i64* %4
%7 = icmp eq i64 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = icmp slt i64 %5, %6
br i1 %9, label %14, label %10
10: ; preds = %8
%11 = icmp sgt i64 %5, %6
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %10, %8, %2
%15 = phi i32 [ 0, %2 ], [ -1, %8 ], [ 1, %10 ]
ret i32 %15
}