#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 strtol(char const *, int /*<<< orphan*/ *, int);
int compare(const void *a, const void *b, void *context) {
  int i1;
  int i2;
  const char *s1 = *(char **)a;
  const char *s2 = *(char **)b;
  (void)context;
  i1 = strtol(s1, NULL, 10);
  i2 = strtol(s2, NULL, 10);
  if (i1 < i2) {
    return 1;
  }
  if (i1 > i2) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    117c <compare+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    119b <compare+0x8b>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    1194 <compare+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <compare+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%rdi
mov    (%rsi),%rbx
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
xor    %ecx,%ecx
cmp    %eax,%ebp
setg   %cl
neg    %ecx
cmp    %eax,%ebp
mov    $0x1,%eax
cmovge %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @compare(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to i8**
%14 = load i8*, i8** %13
store i8* %14, i8** %10
%15 = load i8*, i8** %6
%16 = bitcast i8* %15 to i8**
%17 = load i8*, i8** %16
store i8* %17, i8** %11
%18 = load i8*, i8** %7
%19 = load i8*, i8** %10
%20 = call i32 @strtol(i8* %19, i32* null, i32 10)
store i32 %20, i32* %8
%21 = load i8*, i8** %11
%22 = call i32 @strtol(i8* %21, i32* null, i32 10)
store i32 %22, i32* %9
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %3
store i32 1, i32* %4
br label %33
27: ; preds = %3
%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 = %27
store i32 -1, i32* %4
br label %33
32: ; preds = %27
store i32 0, i32* %4
br label %33
33: ; preds = %32, %31, %26
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @compare(i8* nocapture %0, i8* nocapture %1, i8* nocapture readnone %2) {
%4 = bitcast i8* %0 to i8**
%5 = load i8*, i8** %4
%6 = bitcast i8* %1 to i8**
%7 = load i8*, i8** %6
%8 = tail call i32 @strtol(i8* nocapture %5, i32* null, i32 10)
%9 = tail call i32 @strtol(i8* nocapture %7, i32* null, i32 10)
%10 = icmp slt i32 %8, %9
%11 = icmp sgt i32 %8, %9
%12 = sext i1 %11 to i32
%13 = select i1 %10, i32 1, i32 %12
ret i32 %13
}