#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
int strncmp(char *, char *, int);
int compare_custom_index(void *a, void *b) {
  int32_t *ia, *ib;
  char *sa, *sb;
  ia = a;
  ib = b;
  sa = (void *)ia + sizeof(int32_t);
  sb = (void *)ib + sizeof(int32_t);
  return ((*ia < *ib) ? -1 : (*ia > *ib) ? 1 : strncmp(sa, sb, 5));
}


x86 assembly (clang, -O0):
<compare_custom_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
jge    1169 <compare_custom_index+0x59>
mov    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11a5 <compare_custom_index+0x95>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
jle    118a <compare_custom_index+0x7a>
mov    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    119f <compare_custom_index+0x8f>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_custom_index>:
mov    %rdi,%rcx
add    $0x8,%rdi
mov    (%rsi),%rdx
add    $0x8,%rsi
mov    $0xffffffff,%eax
cmp    %rdx,(%rcx)
jl     112f <compare_custom_index+0x1f>
mov    $0x1,%eax
jle    1130 <compare_custom_index+0x20>
ret
mov    $0x5,%edx
jmp    1030 <strncmp@plt>

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

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