#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 /*<<< orphan*/ Q_stricmp(char *, char const *);
int /*<<< orphan*/ Q_strncpyz(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ Q_strupr(char *);
int /*<<< orphan*/ trap_Key_GetBindingBuf(int, char *, int);
int /*<<< orphan*/ trap_Key_KeynumToStringBuf(int, char *, int);
int /*<<< orphan*/ va(char *, char const *);
char *CG_getBindKeyName(const char *cmd, char *buf, int len) {
  int j;
  for (j = 0; j < 256; j++) {
    trap_Key_GetBindingBuf(j, buf, len);
    if (*buf == 0)
      continue;
    if (!Q_stricmp(buf, cmd)) {
      trap_Key_KeynumToStringBuf(j, buf, 256);
      Q_strupr(buf);
      return (buf);
    }
  }
  Q_strncpyz(buf, va("(%s)", cmd), len);
  return (buf);
}


x86 assembly (clang, -O0):
<CG_getBindKeyName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x100,-0x20(%rbp)
jge    11fb <CG_getBindKeyName+0x9b>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <trap_Key_GetBindingBuf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ab <CG_getBindKeyName+0x4b>
jmp    11ed <CG_getBindKeyName+0x8d>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <Q_stricmp@plt>
cmp    $0x0,%eax
jne    11e8 <CG_getBindKeyName+0x88>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x100,%edx
call   1040 <trap_Key_KeynumToStringBuf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <Q_strupr@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1229 <CG_getBindKeyName+0xc9>
jmp    11ed <CG_getBindKeyName+0x8d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117a <CG_getBindKeyName+0x1a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1070 <va@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
call   1080 <Q_strncpyz@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_getBindKeyName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %ebp,%ebp
jmp    118b <CG_getBindKeyName+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11c5 <CG_getBindKeyName+0x65>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <trap_Key_GetBindingBuf@plt>
cmpb   $0x0,(%rbx)
je     1180 <CG_getBindKeyName+0x20>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <Q_stricmp@plt>
test   %eax,%eax
jne    1180 <CG_getBindKeyName+0x20>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1040 <trap_Key_KeynumToStringBuf@plt>
mov    %rbx,%rdi
call   1060 <Q_strupr@plt>
jmp    11e1 <CG_getBindKeyName+0x81>
lea    0xe34(%rip),%rdi
mov    %r14,%rsi
call   1070 <va@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15d,%edx
call   1080 <Q_strncpyz@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"(%s)\00"
define i8* @CG_getBindKeyName(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %35, %3
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %38
12: ; preds = %9
%13 = load i32, i32* %8
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i32 @trap_Key_GetBindingBuf(i32 %13, i8* %14, i32 %15)
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %12
br label %35
22: ; preds = %12
%23 = load i8*, i8** %6
%24 = load i8*, i8** %5
%25 = call i32 @Q_stricmp(i8* %23, i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %22
%28 = load i32, i32* %8
%29 = load i8*, i8** %6
%30 = call i32 @trap_Key_KeynumToStringBuf(i32 %28, i8* %29, i32 256)
%31 = load i8*, i8** %6
%32 = call i32 @Q_strupr(i8* %31)
%33 = load i8*, i8** %6
store i8* %33, i8** %4
br label %45
34: ; preds = %22
br label %35
35: ; preds = %34, %21
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %9
38: ; preds = %9
%39 = load i8*, i8** %6
%40 = load i8*, i8** %5
%41 = call i32 @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %7
%43 = call i32 @Q_strncpyz(i8* %39, i32 %41, i32 %42)
%44 = load i8*, i8** %6
store i8* %44, i8** %4
br label %45
45: ; preds = %38, %27
%46 = load i8*, i8** %4
ret i8* %46
}

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