#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 *);
int /*<<< orphan*/ trap_Key_GetBindingBuf(int, char *, int);
void Controls_GetKeyBindings(char *command, int *twokeys) {
  int count;
  int j;
  char b[256];
  twokeys[0] = twokeys[1] = -1;
  count = 0;
  for (j = 0; j < 256; j++) {
    trap_Key_GetBindingBuf(j, b, 256);
    if (*b == 0) {
      continue;
    }
    if (!Q_stricmp(b, command)) {
      twokeys[count] = j;
      count++;
      if (count == 2)
        break;
    }
  }
  if (count == 0) {
    twokeys[0] = -1;
    twokeys[1] = -1;
  } else if (count < 2) {
    twokeys[count] = -1;
  }
}


x86 assembly (clang, -O0):
<Controls_GetKeyBindings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    11e3 <Controls_GetKeyBindings+0xc3>
mov    -0x18(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1040 <trap_Key_GetBindingBuf@plt>
movsbl -0x120(%rbp),%eax
cmp    $0x0,%eax
jne    118c <Controls_GetKeyBindings+0x6c>
jmp    11d5 <Controls_GetKeyBindings+0xb5>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <Q_stricmp@plt>
cmp    $0x0,%eax
jne    11d0 <Controls_GetKeyBindings+0xb0>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jne    11cb <Controls_GetKeyBindings+0xab>
jmp    11e3 <Controls_GetKeyBindings+0xc3>
jmp    11d0 <Controls_GetKeyBindings+0xb0>
jmp    11d5 <Controls_GetKeyBindings+0xb5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <Controls_GetKeyBindings+0x36>
cmpl   $0x0,-0x14(%rbp)
jne    1207 <Controls_GetKeyBindings+0xe7>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
jmp    1225 <Controls_GetKeyBindings+0x105>
cmpl   $0x2,-0x14(%rbp)
jge    1220 <Controls_GetKeyBindings+0x100>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1225 <Controls_GetKeyBindings+0x105>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Controls_GetKeyBindings>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
movq   $0xffffffffffffffff,(%rsi)
xor    %ebp,%ebp
mov    %rsp,%rbx
jmp    115b <Controls_GetKeyBindings+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11d5 <Controls_GetKeyBindings+0xb5>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1040 <trap_Key_GetBindingBuf@plt>
cmpb   $0x0,(%rsp)
je     1150 <Controls_GetKeyBindings+0x30>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <Q_stricmp@plt>
test   %eax,%eax
jne    1150 <Controls_GetKeyBindings+0x30>
mov    %ebp,(%r14)
cmp    $0xff,%ebp
je     11dc <Controls_GetKeyBindings+0xbc>
add    $0x1,%ebp
mov    %rsp,%r15
jmp    11ab <Controls_GetKeyBindings+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11dc <Controls_GetKeyBindings+0xbc>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1040 <trap_Key_GetBindingBuf@plt>
cmpb   $0x0,(%rsp)
je     11a0 <Controls_GetKeyBindings+0x80>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <Q_stricmp@plt>
test   %eax,%eax
jne    11a0 <Controls_GetKeyBindings+0x80>
mov    %ebp,0x4(%r14)
jmp    11e4 <Controls_GetKeyBindings+0xc4>
movl   $0xffffffff,(%r14)
movl   $0xffffffff,0x4(%r14)
ff
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Controls_GetKeyBindings(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x i8]
store i8* %0, i8** %3
store i32* %1, i32** %4
%8 = load i32*, i32** %4
%9 = getelementptr inbounds i32, i32* %8, i64 1
store i32 -1, i32* %9
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 0
store i32 -1, i32* %11
store i32 0, i32* %5
store i32 0, i32* %6
br label %12
12: ; preds = %42, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %45
15: ; preds = %12
%16 = load i32, i32* %6
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = call i32 @trap_Key_GetBindingBuf(i32 %16, i8* %17, i32 256)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %15
br label %42
24: ; preds = %15
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = call i32 @Q_stricmp(i8* %25, i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %41, label %29
29: ; preds = %24
%30 = load i32, i32* %6
%31 = load i32*, i32** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 %30, i32* %34
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 2
br i1 %38, label %39, label %40
39: ; preds = %29
br label %45
40: ; preds = %29
br label %41
41: ; preds = %40, %24
br label %42
42: ; preds = %41, %23
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %12
45: ; preds = %39, %12
%46 = load i32, i32* %5
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = load i32*, i32** %4
%50 = getelementptr inbounds i32, i32* %49, i64 0
store i32 -1, i32* %50
%51 = load i32*, i32** %4
%52 = getelementptr inbounds i32, i32* %51, i64 1
store i32 -1, i32* %52
br label %62
53: ; preds = %45
%54 = load i32, i32* %5
%55 = icmp slt i32 %54, 2
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = load i32*, i32** %4
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
store i32 -1, i32* %60
br label %61
61: ; preds = %56, %53
br label %62
62: ; preds = %61, %48
ret void
}

LLVM IR (-O2):
define void @Controls_GetKeyBindings(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i32, i32* %1, i64 1
store i32 -1, i32* %5
store i32 -1, i32* %1
br label %6
6: ; preds = %2, %17
%7 = phi i32 [ %18, %17 ], [ 0, %2 ]
%8 = call i32 @trap_Key_GetBindingBuf(i32 %7, i8* %4, i32 256)
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = call i32 @Q_stricmp(i8* %4, i8* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
store i32 %7, i32* %1
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, 256
br i1 %16, label %34, label %20
17: ; preds = %11, %6
%18 = add nuw nsw i32 %7, 1
%19 = icmp eq i32 %18, 256
br i1 %19, label %33, label %6
20: ; preds = %14, %30
%21 = phi i32 [ %31, %30 ], [ %15, %14 ]
%22 = call i32 @trap_Key_GetBindingBuf(i32 %21, i8* %4, i32 256)
%23 = load i8, i8* %4
%24 = icmp eq i8 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = call i32 @Q_stricmp(i8* %4, i8* %0)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %21, i32* %29
br label %35
30: ; preds = %25, %20
%31 = add nuw nsw i32 %21, 1
%32 = icmp eq i32 %31, 256
br i1 %32, label %34, label %20
33: ; preds = %17
store i32 -1, i32* %1
br label %34
34: ; preds = %14, %30, %33
store i32 -1, i32* %5
br label %35
35: ; preds = %28, %34
ret void
}