#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 */
struct schema {
  int dummy;
};
struct field {
  int dummy;
};
typedef scalar_t__ int64_t;

/* Variables and functions */
scalar_t__ field_data_get(struct field *, void *);
struct field *schema_field_get_primary(struct schema *);
int schema_compare_record(struct schema *schema, void *left, void *right) {
  struct field *field = schema_field_get_primary(schema);
  int64_t v1 = field_data_get(field, left);
  int64_t v2 = field_data_get(field, right);
  if (v1 < v2)
    return -1;
  if (v1 > v2)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<schema_compare_record>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <schema_field_get_primary@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <field_data_get@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <field_data_get@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jge    117d <schema_compare_record+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <schema_compare_record+0x7e>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jle    1197 <schema_compare_record+0x77>
movl   $0x1,-0x4(%rbp)
jmp    119e <schema_compare_record+0x7e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<schema_compare_record>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
call   1030 <schema_field_get_primary@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <field_data_get@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <field_data_get@plt>
xor    %ecx,%ecx
cmp    %rax,%r15
setg   %cl
mov    $0xffffffff,%eax
cmovge %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.schema = type { i32 }
%struct.field = type { i32 }
define i32 @schema_compare_record(%struct.schema* %0, i8* %1, i8* %2) {
%4 = tail call %struct.field* @schema_field_get_primary(%struct.schema* %0)
%5 = tail call i64 @field_data_get(%struct.field* %4, i8* %1)
%6 = tail call i64 @field_data_get(%struct.field* %4, i8* %2)
%7 = icmp slt i64 %5, %6
%8 = icmp sgt i64 %5, %6
%9 = zext i1 %8 to i32
%10 = select i1 %7, i32 -1, i32 %9
ret i32 %10
}