#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 size_t uint32_t;

/* Variables and functions */
int compare_score(const void *elem1, const void *elem2, void *arg) {
  uint32_t t1 = *((uint32_t *)elem1);
  uint32_t t2 = *((uint32_t *)elem2);
  double *scores = (double *)arg;
  double f1 = scores[t1];
  double f2 = scores[t2];
  if (f1 < f2)
    return -1;
  if (f1 > f2)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<compare_score>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1172 <compare_score+0x72>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <compare_score+0x95>
movsd  -0x40(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    118e <compare_score+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    1195 <compare_score+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_score>:
mov    (%rdi),%rax
mov    (%rsi),%rcx
movsd  (%rdx,%rax,8),%xmm0
movsd  (%rdx,%rcx,8),%xmm1
xor    %ecx,%ecx
ucomisd %xmm1,%xmm0
seta   %cl
ucomisd %xmm0,%xmm1
mov    $0xffffffff,%eax
cmovbe %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @compare_score(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2) {
%4 = bitcast i8* %0 to i64*
%5 = load i64, i64* %4
%6 = bitcast i8* %1 to i64*
%7 = load i64, i64* %6
%8 = bitcast i8* %2 to double*
%9 = getelementptr inbounds double, double* %8, i64 %5
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %8, i64 %7
%12 = load double, double* %11
%13 = fcmp olt double %10, %12
%14 = fcmp ogt double %10, %12
%15 = zext i1 %14 to i32
%16 = select i1 %13, i32 -1, i32 %15
ret i32 %16
}