#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 memcmp(char const *, char const *, size_t);
int fcitx_dict_item_default_compare(const char *keyA, size_t keyALen,
                                    const void *dataA, const char *keyB,
                                    size_t keyBLen, const void *dataB,
                                    void *userData) {
  (void)(dataA);
  (void)(dataB);
  (void)(userData);
  size_t size = (keyALen < keyBLen) ? keyALen : keyBLen;
  int result = memcmp(keyA, keyB, size);
  if (result == 0) {
    if (keyALen < keyBLen) {
      result = -1;
    } else if (keyALen > keyBLen) {
      result = 1;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<fcitx_dict_item_default_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    114f <fcitx_dict_item_default_compare+0x3f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1157 <fcitx_dict_item_default_compare+0x47>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <memcmp@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    11b6 <fcitx_dict_item_default_compare+0xa6>
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1197 <fcitx_dict_item_default_compare+0x87>
movl   $0xffffffff,-0x3c(%rbp)
jmp    11b1 <fcitx_dict_item_default_compare+0xa1>
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    11ac <fcitx_dict_item_default_compare+0x9c>
movl   $0x1,-0x3c(%rbp)
jmp    11b1 <fcitx_dict_item_default_compare+0xa1>
jmp    11b6 <fcitx_dict_item_default_compare+0xa6>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcitx_dict_item_default_compare>:
push   %rbp
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rsi,%rbx
xor    %ebp,%ebp
cmp    %r8,%rsi
mov    %r8,%rdx
cmovb  %rsi,%rdx
seta   %bpl
mov    %rcx,%rsi
call   1030 <memcmp@plt>
cmp    $0x1,%eax
sbb    %ecx,%ecx
or     %eax,%ecx
test   %eax,%eax
cmovne %ecx,%ebp
cmp    %r14,%rbx
cmovb  %ecx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @fcitx_dict_item_default_compare(i8* nocapture %0, i64 %1, i8* nocapture readnone %2, i8* nocapture %3, i64 %4, i8* nocapture readnone %5, i8* nocapture readnone %6) {
%8 = icmp ult i64 %1, %4
%9 = select i1 %8, i64 %1, i64 %4
%10 = tail call i32 @memcmp(i8* %0, i8* %3, i64 %9)
%11 = icmp ne i32 %10, 0
%12 = or i1 %8, %11
%13 = select i1 %11, i32 %10, i32 -1
%14 = icmp ugt i64 %1, %4
%15 = zext i1 %14 to i32
%16 = select i1 %12, i32 %13, i32 %15
ret i32 %16
}