#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 */
typedef int /*<<< orphan*/ key;
typedef int /*<<< orphan*/ bindbuff;

/* Variables and functions */
int /*<<< orphan*/ Q_strcat(char *, int, char const *);
int /*<<< orphan*/ Q_stricmp(char *, char const *);
int /*<<< orphan*/ Q_strncpyz(char *, char *, int);
int /*<<< orphan*/ trap_Key_GetBindingBuf(int, char *, int);
int /*<<< orphan*/ trap_Key_KeynumToStringBuf(int, char *, int);
char *CG_KeyBinding(const char *bind) {
  static char key[32];
  char bindbuff[256];
  int i;
  key[0] = '\0';
  for (i = 0; i < 256; i++) {
    trap_Key_GetBindingBuf(i, bindbuff, sizeof(bindbuff));
    if (!Q_stricmp(bindbuff, bind)) {
      trap_Key_KeynumToStringBuf(i, key, sizeof(key));
      break;
    }
  }
  if (!key[0]) {
    Q_strncpyz(key, "\\", sizeof(key));
    Q_strcat(key, sizeof(key), bind);
  }
  return key;
}


x86 assembly (clang, -O0):
<CG_KeyBinding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,0x2efa(%rip)
movl   $0x0,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jge    11e5 <CG_KeyBinding+0x95>
mov    -0x114(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1050 <trap_Key_GetBindingBuf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <Q_stricmp@plt>
cmp    $0x0,%eax
jne    11cc <CG_KeyBinding+0x7c>
mov    -0x114(%rbp),%edi
lea    0x2ea3(%rip),%rsi
mov    $0x20,%edx
call   1040 <trap_Key_KeynumToStringBuf@plt>
jmp    11e5 <CG_KeyBinding+0x95>
jmp    11d1 <CG_KeyBinding+0x81>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1170 <CG_KeyBinding+0x20>
cmpb   $0x0,0x2e74(%rip)
jne    121f <CG_KeyBinding+0xcf>
lea    0x2e67(%rip),%rdi
lea    0xe00(%rip),%rsi
mov    $0x20,%edx
call   1070 <Q_strncpyz@plt>
mov    -0x8(%rbp),%rdx
lea    0x2e4b(%rip),%rdi
mov    $0x20,%esi
call   1060 <Q_strcat@plt>
lea    0x2e3a(%rip),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_KeyBinding>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
movb   $0x0,0x2efb(%rip)
xor    %ebp,%ebp
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1050 <trap_Key_GetBindingBuf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <Q_stricmp@plt>
test   %eax,%eax
je     11b5 <CG_KeyBinding+0x65>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1170 <CG_KeyBinding+0x20>
cmpb   $0x0,0x2ec0(%rip)
je     11d1 <CG_KeyBinding+0x81>
lea    0x2eb7(%rip),%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0x2ea4(%rip),%rsi
mov    %ebp,%edi
mov    $0x20,%edx
call   1040 <trap_Key_KeynumToStringBuf@plt>
cmpb   $0x0,0x2e91(%rip)
jne    11a2 <CG_KeyBinding+0x52>
lea    0x2e88(%rip),%rbx
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
mov    $0x20,%edx
call   1070 <Q_strncpyz@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %r14,%rdx
call   1060 <Q_strcat@plt>
jmp    11a2 <CG_KeyBinding+0x52>

LLVM IR (-O0):
@CG_KeyBinding.key = internal global [32 x i8] zeroinitializer
@.str = [2 x i8] c"\\\00"
define i8* @CG_KeyBinding(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0)
store i32 0, i32* %4
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 256
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32, i32* %4
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = call i32 @trap_Key_GetBindingBuf(i32 %9, i8* %10, i32 256)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 @Q_stricmp(i8* %12, i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %8
%17 = load i32, i32* %4
%18 = call i32 @trap_Key_KeynumToStringBuf(i32 %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0), i32 32)
br label %23
19: ; preds = %8
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %5
23: ; preds = %16, %5
%24 = load i8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0)
%25 = icmp ne i8 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = call i32 @Q_strncpyz(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 32)
%28 = load i8*, i8** %2
%29 = call i32 @Q_strcat(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0), i32 32, i8* %28)
br label %30
30: ; preds = %26, %23
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0)
}

LLVM IR (-O2):
@CG_KeyBinding.key = internal global [32 x i8] zeroinitializer
@.str = [2 x i8] c"\\\00"
define i8* @CG_KeyBinding(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0)
br label %4
4: ; preds = %1, %11
%5 = phi i32 [ 0, %1 ], [ %12, %11 ]
%6 = call i32 @trap_Key_GetBindingBuf(i32 %5, i8* %3, i32 256)
%7 = call i32 @Q_stricmp(i8* %3, i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 @trap_Key_KeynumToStringBuf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0), i32 32)
br label %14
11: ; preds = %4
%12 = add nuw nsw i32 %5, 1
%13 = icmp eq i32 %12, 256
br i1 %13, label %14, label %4
14: ; preds = %11, %9
%15 = load i8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0)
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @Q_strncpyz(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 32)
%19 = call i32 @Q_strcat(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0), i32 32, i8* %0)
br label %20
20: ; preds = %17, %14
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @CG_KeyBinding.key, i64 0, i64 0)
}