#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 utf8_charcmp(char const *, char const *);
char *utf8_next_char(char const *);
int gui_keyboard_cmp(const char *key, const char *search) {
  int diff;
  while (search[0]) {
    diff = utf8_charcmp(key, search);
    if (diff != 0)
      return diff;
    key = utf8_next_char(key);
    search = utf8_next_char(search);
  }
  return 0;
}


x86 assembly (clang, -O0):
<gui_keyboard_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1181 <gui_keyboard_cmp+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <utf8_charcmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1162 <gui_keyboard_cmp+0x42>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1188 <gui_keyboard_cmp+0x68>
mov    -0x10(%rbp),%rdi
call   1040 <utf8_next_char@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <utf8_next_char@plt>
mov    %rax,-0x18(%rbp)
jmp    1130 <gui_keyboard_cmp+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_keyboard_cmp>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
cmpb   $0x0,(%rsi)
je     116f <gui_keyboard_cmp+0x4f>
mov    %rsi,%rbx
mov    %rdi,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <utf8_charcmp@plt>
test   %eax,%eax
jne    116c <gui_keyboard_cmp+0x4c>
mov    %rbp,%rdi
call   1040 <utf8_next_char@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <utf8_next_char@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1140 <gui_keyboard_cmp+0x20>
jmp    116f <gui_keyboard_cmp+0x4f>
mov    %eax,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @gui_keyboard_cmp(i8* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2, %10
%6 = phi i8* [ %12, %10 ], [ %1, %2 ]
%7 = phi i8* [ %11, %10 ], [ %0, %2 ]
%8 = tail call i32 @utf8_charcmp(i8* %7, i8* %6)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = tail call i8* @utf8_next_char(i8* %7)
%12 = tail call i8* @utf8_next_char(i8* %6)
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %5, %10, %2
%16 = phi i32 [ 0, %2 ], [ 0, %10 ], [ %8, %5 ]
ret i32 %16
}