#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 */
scalar_t__ keta(char *);
int compare(char *aa, char *bb) {
  int i, j;
  if (keta(aa) > keta(bb))
    return 1;
  if (keta(aa) < keta(bb))
    return -1;
  if (keta(aa) == keta(bb) && i > j)
    return 1;
  if (keta(aa) == keta(bb) && i < j)
    return -1;
  if (keta(aa) == keta(bb) && i == j)
    return 0;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jle    1152 <compare+0x42>
movl   $0x1,-0x4(%rbp)
jmp    1239 <compare+0x129>
mov    -0x10(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jge    1184 <compare+0x74>
movl   $0xffffffff,-0x4(%rbp)
jmp    1239 <compare+0x129>
mov    -0x10(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jne    11c2 <compare+0xb2>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11c2 <compare+0xb2>
movl   $0x1,-0x4(%rbp)
jmp    1239 <compare+0x129>
mov    -0x10(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jne    1200 <compare+0xf0>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1200 <compare+0xf0>
movl   $0xffffffff,-0x4(%rbp)
jmp    1239 <compare+0x129>
mov    -0x10(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jne    1239 <compare+0x129>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1239 <compare+0x129>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <keta@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    %rcx,%rbx
jg     1188 <compare+0x78>
mov    %r15,%rdi
call   1030 <keta@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <keta@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
cmp    %rcx,%rbx
jl     1188 <compare+0x78>
mov    %r15,%rdi
call   1030 <keta@plt>
mov    %r14,%rdi
call   1030 <keta@plt>
mov    %r15,%rdi
call   1030 <keta@plt>
mov    %r14,%rdi
call   1030 <keta@plt>
mov    %r15,%rdi
call   1030 <keta@plt>
mov    %r14,%rdi
call   1030 <keta@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @compare(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @keta(i8* %8)
%10 = load i8*, i8** %5
%11 = call i64 @keta(i8* %10)
%12 = icmp sgt i64 %9, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %54
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i64 @keta(i8* %15)
%17 = load i8*, i8** %5
%18 = call i64 @keta(i8* %17)
%19 = icmp slt i64 %16, %18
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 -1, i32* %3
br label %54
21: ; preds = %14
%22 = load i8*, i8** %4
%23 = call i64 @keta(i8* %22)
%24 = load i8*, i8** %5
%25 = call i64 @keta(i8* %24)
%26 = icmp eq i64 %23, %25
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %3
br label %54
32: ; preds = %27, %21
%33 = load i8*, i8** %4
%34 = call i64 @keta(i8* %33)
%35 = load i8*, i8** %5
%36 = call i64 @keta(i8* %35)
%37 = icmp eq i64 %34, %36
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 -1, i32* %3
br label %54
43: ; preds = %38, %32
%44 = load i8*, i8** %4
%45 = call i64 @keta(i8* %44)
%46 = load i8*, i8** %5
%47 = call i64 @keta(i8* %46)
%48 = icmp eq i64 %45, %47
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = icmp eq i32 %50, %51
br i1 %52, label %53, label %54
53: ; preds = %49
store i32 0, i32* %3
br label %54
54: ; preds = %13, %20, %31, %42, %53, %49, %43
%55 = load i32, i32* %3
ret i32 %55
}

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