#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 ecore_direct_compare(void const *, void const *);
int strcmp(char const *, char const *);
int ecore_str_compare(const void *key1, const void *key2) {
  const char *k1, *k2;
  if (!key1 || !key2)
    return ecore_direct_compare(key1, key2);
  else if (key1 == key2)
    return 0;
  k1 = key1;
  k2 = key2;
  return strcmp(k1, k2);
}


x86 assembly (clang, -O0):
<ecore_str_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <ecore_str_compare+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    115b <ecore_str_compare+0x3b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ecore_direct_compare@plt>
mov    %eax,-0x4(%rbp)
jmp    119a <ecore_str_compare+0x7a>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1175 <ecore_str_compare+0x55>
movl   $0x0,-0x4(%rbp)
jmp    119a <ecore_str_compare+0x7a>
jmp    117a <ecore_str_compare+0x5a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecore_str_compare>:
test   %rdi,%rdi
je     1134 <ecore_str_compare+0x14>
test   %rsi,%rsi
je     1134 <ecore_str_compare+0x14>
cmp    %rsi,%rdi
je     1139 <ecore_str_compare+0x19>
jmp    1030 <strcmp@plt>
jmp    1040 <ecore_direct_compare@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @ecore_str_compare(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %17, label %13
13: ; preds = %10, %2
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i32 @ecore_direct_compare(i8* %14, i8* %15)
store i32 %16, i32* %3
br label %29
17: ; preds = %10
%18 = load i8*, i8** %4
%19 = load i8*, i8** %5
%20 = icmp eq i8* %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %3
br label %29
22: ; preds = %17
br label %23
23: ; preds = %22
%24 = load i8*, i8** %4
store i8* %24, i8** %6
%25 = load i8*, i8** %5
store i8* %25, i8** %7
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = call i32 @strcmp(i8* %26, i8* %27)
store i32 %28, i32* %3
br label %29
29: ; preds = %23, %21, %13
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @ecore_str_compare(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @ecore_direct_compare(i8* %0, i8* %1)
br label %12
8: ; preds = %2
%9 = icmp eq i8* %0, %1
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @strcmp(i8* %0, i8* %1)
br label %12
12: ; preds = %8, %10, %6
%13 = phi i32 [ %11, %10 ], [ %7, %6 ], [ 0, %8 ]
ret i32 %13
}