#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 */
struct t_gui_key {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *gui_keyboard_get_internal_code(char const *);
int /*<<< orphan*/ gui_keyboard_new(int /*<<< orphan*/ *, char const *,
                                    char const *);
struct t_gui_key *gui_keyboard_search(int /*<<< orphan*/ *, char *);
void gui_keyboard_default_bind(const char *key, const char *command) {
  struct t_gui_key *ptr_key;
  char *internal_code;
  internal_code = gui_keyboard_get_internal_code(key);
  ptr_key = gui_keyboard_search(NULL, (internal_code) ? internal_code : key);
  if (!ptr_key) {
    gui_keyboard_new(NULL, key, command);
  }
  if (internal_code)
    free(internal_code);
}


x86 assembly (clang, -O0):
<gui_keyboard_default_bind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <gui_keyboard_get_internal_code@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1175 <gui_keyboard_default_bind+0x35>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    117d <gui_keyboard_default_bind+0x3d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <gui_keyboard_search@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11aa <gui_keyboard_default_bind+0x6a>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
call   1050 <gui_keyboard_new@plt>
cmpq   $0x0,-0x20(%rbp)
je     11be <gui_keyboard_default_bind+0x7e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_keyboard_default_bind>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <gui_keyboard_get_internal_code@plt>
mov    %rax,%rbx
test   %rax,%rax
mov    %rax,%rsi
cmove  %r15,%rsi
xor    %edi,%edi
call   1060 <gui_keyboard_search@plt>
test   %rax,%rax
je     117b <gui_keyboard_default_bind+0x3b>
test   %rbx,%rbx
je     118d <gui_keyboard_default_bind+0x4d>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
xor    %edi,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <gui_keyboard_new@plt>
test   %rbx,%rbx
jne    116e <gui_keyboard_default_bind+0x2e>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.t_gui_key = type { i32 }
define void @gui_keyboard_default_bind(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.t_gui_key*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @gui_keyboard_get_internal_code(i8* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i8*, i8** %6
br label %15
13: ; preds = %2
%14 = load i8*, i8** %3
br label %15
15: ; preds = %13, %11
%16 = phi i8* [ %12, %11 ], [ %14, %13 ]
%17 = call %struct.t_gui_key* @gui_keyboard_search(i32* null, i8* %16)
store %struct.t_gui_key* %17, %struct.t_gui_key** %5
%18 = load %struct.t_gui_key*, %struct.t_gui_key** %5
%19 = icmp ne %struct.t_gui_key* %18, null
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i32 @gui_keyboard_new(i32* null, i8* %21, i8* %22)
br label %24
24: ; preds = %20, %15
%25 = load i8*, i8** %6
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %27, %24
ret void
}

LLVM IR (-O2):
%struct.t_gui_key = type { i32 }
define void @gui_keyboard_default_bind(i8* %0, i8* %1) {
%3 = tail call i8* @gui_keyboard_get_internal_code(i8* %0)
%4 = icmp eq i8* %3, null
%5 = select i1 %4, i8* %0, i8* %3
%6 = tail call %struct.t_gui_key* @gui_keyboard_search(i32* null, i8* %5)
%7 = icmp eq %struct.t_gui_key* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @gui_keyboard_new(i32* null, i8* %0, i8* %1)
br label %10
10: ; preds = %8, %2
br i1 %4, label %13, label %11
11: ; preds = %10
%12 = tail call i32 @free(i8* %3)
br label %13
13: ; preds = %11, %10
ret void
}