#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 atoi(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int compare_scores(const void *s1, const void *s2) {
  char score_s1[80];
  char score_s2[80];
  strcpy(score_s1, (char *)s1 + strlen("Gold: ") * sizeof(char));
  strcpy(score_s2, (char *)s2 + strlen("Gold: ") * sizeof(char));
  int score1 = atoi(score_s1);
  int score2 = atoi(score_s2);
  if (score1 > score2)
    return -1;
  else if (score1 == score2)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<compare_scores>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    0xea0(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xe8(%rbp),%rsi
mov    -0xe0(%rbp),%rdi
cltq
shl    $0x0,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0xc0(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    0xe5f(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xd8(%rbp),%rsi
mov    -0xd0(%rbp),%rdi
cltq
shl    $0x0,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc4(%rbp)
lea    -0xc0(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc8(%rbp)
mov    -0xc4(%rbp),%eax
cmp    -0xc8(%rbp),%eax
jle    1201 <compare_scores+0xd1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1226 <compare_scores+0xf6>
mov    -0xc4(%rbp),%eax
cmp    -0xc8(%rbp),%eax
jne    121f <compare_scores+0xef>
movl   $0x0,-0x4(%rbp)
jmp    1226 <compare_scores+0xf6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_scores>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa0,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb4(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %rbx,%rsi
lea    0x50(%rsp),%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %r14,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <atoi@plt>
xor    %ecx,%ecx
cmp    %eax,%ebp
setne  %cl
mov    $0xffffffff,%eax
cmovle %ecx,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Gold: \00"
define i32 @compare_scores(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 1
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = call i32 @strcpy(i8* %10, i8* %15)
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 1
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = call i32 @strcpy(i8* %17, i8* %22)
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %8
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %2
store i32 -1, i32* %3
br label %38
32: ; preds = %2
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 0, i32* %3
br label %38
37: ; preds = %32
store i32 1, i32* %3
br label %38
38: ; preds = %37, %36, %31
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [7 x i8] c"Gold: \00"
define i32 @compare_scores(i8* %0, i8* %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = call i32 @strcpy(i8* %5, i8* %9)
%11 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = call i32 @strcpy(i8* %6, i8* %13)
%15 = call i32 @atoi(i8* %5)
%16 = call i32 @atoi(i8* %6)
%17 = icmp sgt i32 %15, %16
%18 = icmp ne i32 %15, %16
%19 = zext i1 %18 to i32
%20 = select i1 %17, i32 -1, i32 %19
ret i32 %20
}