#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*/ Com_Printf(char *);
int /*<<< orphan*/ Q_stricmp(char const *, char *);
int strlen(char const *);
char *Info_ValueForKey(const char *s, const char *key) {
  char pkey[8192];
  static char value[2][8192];
  static int valueindex = 0;
  char *o;
  if (!s || !key) {
    return "";
  }
  if (strlen(s) >= 8192) {
    Com_Printf("Info_ValueForKey: oversize infostring");
    return "";
  }
  valueindex ^= 1;
  if (*s == '\\') {
    s++;
  }
  while (1) {
    o = pkey;
    while (*s != '\\') {
      if (!*s) {
        return "";
      }
      *o++ = *s++;
    }
    *o = 0;
    s++;
    o = value[valueindex];
    while (*s != '\\' && *s) {
      *o++ = *s++;
    }
    *o = 0;
    if (!Q_stricmp(key, pkey)) {
      return value[valueindex];
    }
    if (!*s) {
      break;
    }
    s++;
  }
  return "";
}


x86 assembly (clang, -O0):
<Info_ValueForKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1159 <Info_ValueForKey+0x29>
cmpq   $0x0,-0x18(%rbp)
jne    1169 <Info_ValueForKey+0x39>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    133d <Info_ValueForKey+0x20d>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2000,%eax
jl     1199 <Info_ValueForKey+0x69>
lea    0xe7c(%rip),%rdi
call   1050 <Com_Printf@plt>
lea    0xe95(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    133d <Info_ValueForKey+0x20d>
mov    0x6eb1(%rip),%eax
xor    $0x1,%eax
mov    %eax,0x6ea8(%rip)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11c4 <Info_ValueForKey+0x94>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c9 <Info_ValueForKey+0x99>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x2028(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     1231 <Info_ValueForKey+0x101>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1204 <Info_ValueForKey+0xd4>
lea    0xe2a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    133d <Info_ValueForKey+0x20d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x2028(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x2028(%rbp)
mov    %cl,(%rax)
jmp    11d7 <Info_ValueForKey+0xa7>
mov    -0x2028(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movslq 0x6e02(%rip),%rcx
lea    0x2dfb(%rip),%rax
shl    $0xd,%rcx
add    %rcx,%rax
mov    %rax,-0x2028(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x2029(%rbp)
je     128e <Info_ValueForKey+0x15e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x2029(%rbp)
mov    -0x2029(%rbp),%al
test   $0x1,%al
jne    12a1 <Info_ValueForKey+0x171>
jmp    12ce <Info_ValueForKey+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x2028(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x2028(%rbp)
mov    %cl,(%rax)
jmp    1263 <Info_ValueForKey+0x133>
mov    -0x2028(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1040 <Q_stricmp@plt>
cmp    $0x0,%eax
jne    130f <Info_ValueForKey+0x1df>
movslq 0x6d58(%rip),%rcx
lea    0x2d51(%rip),%rax
shl    $0xd,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    133d <Info_ValueForKey+0x20d>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1321 <Info_ValueForKey+0x1f1>
jmp    1332 <Info_ValueForKey+0x202>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c9 <Info_ValueForKey+0x99>
lea    0xcec(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Info_ValueForKey>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2000,%rsp
lea    0xede(%rip),%r14
test   %rdi,%rdi
je     122e <Info_ValueForKey+0xfe>
mov    %rsi,%r12
test   %rsi,%rsi
je     122e <Info_ValueForKey+0xfe>
mov    %rdi,%r13
call   1030 <strlen@plt>
cmp    $0x2000,%eax
jl     117c <Info_ValueForKey+0x4c>
lea    0xe8e(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    122e <Info_ValueForKey+0xfe>
xorb   $0x1,0x6ecd(%rip)
xor    %ebx,%ebx
cmpb   $0x5c,0x0(%r13)
mov    %rsp,%r15
sete   %bl
add    %r13,%rbx
lea    0x2eb6(%rip),%r13
mov    %r15,%rax
nopl   (%rax)
mov    (%rbx),%cl
cmp    $0x5c,%cl
je     11c0 <Info_ValueForKey+0x90>
test   %cl,%cl
je     122e <Info_ValueForKey+0xfe>
add    $0x1,%rbx
mov    %cl,(%rax)
add    $0x1,%rax
jmp    11a0 <Info_ValueForKey+0x70>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rax)
movslq 0x6e86(%rip),%rax
shl    $0xd,%rax
add    %r13,%rax
add    $0x2,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%rbx),%ecx
test   %cl,%cl
je     1200 <Info_ValueForKey+0xd0>
cmp    $0x5c,%cl
je     1200 <Info_ValueForKey+0xd0>
mov    %cl,(%rax)
add    $0x1,%rax
add    $0x1,%rbx
jmp    11e0 <Info_ValueForKey+0xb0>
nopl   0x0(%rax)
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <Q_stricmp@plt>
test   %eax,%eax
je     121d <Info_ValueForKey+0xed>
cmpb   $0x0,-0x1(%rbx)
mov    %r15,%rax
jne    11a0 <Info_ValueForKey+0x70>
jmp    122e <Info_ValueForKey+0xfe>
movslq 0x6e2c(%rip),%rax
shl    $0xd,%rax
add    %rax,%r13
mov    %r13,%r14
mov    %r14,%rax
add    $0x2000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@Info_ValueForKey.value = internal global [2 x [8192 x i8]] zeroinitializer
@Info_ValueForKey.valueindex = internal global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [38 x i8] c"Info_ValueForKey: oversize infostring\00"
define i8* @Info_ValueForKey(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [8192 x i8]
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %95
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = icmp sge i32 %16, 8192
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @Com_Printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %95
20: ; preds = %14
%21 = load i32, i32* @Info_ValueForKey.valueindex
%22 = xor i32 %21, 1
store i32 %22, i32* @Info_ValueForKey.valueindex
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 92
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
br label %30
30: ; preds = %27, %20
br label %31
31: ; preds = %30, %91
%32 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
store i8* %32, i8** %7
br label %33
33: ; preds = %43, %31
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 92
br i1 %37, label %38, label %49
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %38
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %95
43: ; preds = %38
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %4
%46 = load i8, i8* %44
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %7
store i8 %46, i8* %47
br label %33
49: ; preds = %33
%50 = load i8*, i8** %7
store i8 0, i8* %50
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
%53 = load i32, i32* @Info_ValueForKey.valueindex
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [2 x [8192 x i8]], [2 x [8192 x i8]]* @Info_ValueForKey.value, i64 0, i64 %54
%56 = getelementptr inbounds [8192 x i8], [8192 x i8]* %55, i64 0, i64 0
store i8* %56, i8** %7
br label %57
57: ; preds = %69, %49
%58 = load i8*, i8** %4
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 92
br i1 %61, label %62, label %67
62: ; preds = %57
%63 = load i8*, i8** %4
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 0
br label %67
67: ; preds = %62, %57
%68 = phi i1 [ false, %57 ], [ %66, %62 ]
br i1 %68, label %69, label %75
69: ; preds = %67
%70 = load i8*, i8** %4
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %4
%72 = load i8, i8* %70
%73 = load i8*, i8** %7
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %7
store i8 %72, i8* %73
br label %57
75: ; preds = %67
%76 = load i8*, i8** %7
store i8 0, i8* %76
%77 = load i8*, i8** %5
%78 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%79 = call i32 @Q_stricmp(i8* %77, i8* %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %86, label %81
81: ; preds = %75
%82 = load i32, i32* @Info_ValueForKey.valueindex
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [2 x [8192 x i8]], [2 x [8192 x i8]]* @Info_ValueForKey.value, i64 0, i64 %83
%85 = getelementptr inbounds [8192 x i8], [8192 x i8]* %84, i64 0, i64 0
store i8* %85, i8** %3
br label %95
86: ; preds = %75
%87 = load i8*, i8** %4
%88 = load i8, i8* %87
%89 = icmp ne i8 %88, 0
br i1 %89, label %91, label %90
90: ; preds = %86
br label %94
91: ; preds = %86
%92 = load i8*, i8** %4
%93 = getelementptr inbounds i8, i8* %92, i32 1
store i8* %93, i8** %4
br label %31
94: ; preds = %90
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %95
95: ; preds = %94, %81, %42, %18, %13
%96 = load i8*, i8** %3
ret i8* %96
}

LLVM IR (-O2):
@Info_ValueForKey.value = internal global [2 x [8192 x i8]] zeroinitializer
@Info_ValueForKey.valueindex = internal unnamed_addr global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [38 x i8] c"Info_ValueForKey: oversize infostring\00"
define i8* @Info_ValueForKey(i8* %0, i8* %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%5 = icmp ne i8* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %52
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %0)
%10 = icmp sgt i32 %9, 8191
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %52
13: ; preds = %8
%14 = load i32, i32* @Info_ValueForKey.valueindex
%15 = xor i32 %14, 1
store i32 %15, i32* @Info_ValueForKey.valueindex
%16 = load i8, i8* %0
%17 = icmp eq i8 %16, 92
%18 = zext i1 %17 to i64
%19 = getelementptr i8, i8* %0, i64 %18
br label %20
20: ; preds = %27, %13
%21 = phi i8* [ %19, %13 ], [ %28, %27 ]
%22 = phi i8* [ %4, %13 ], [ %29, %27 ]
%23 = load i8, i8* %21
switch i8 %23, label %24 [
i8 92, label %30
i8 0, label %52
]
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %21, i64 1
%26 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %23, i8* %22
br label %27
27: ; preds = %24, %48
%28 = phi i8* [ %25, %24 ], [ %51, %48 ]
%29 = phi i8* [ %26, %24 ], [ %4, %48 ]
br label %20
30: ; preds = %20
store i8 0, i8* %22
%31 = load i32, i32* @Info_ValueForKey.valueindex
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [2 x [8192 x i8]], [2 x [8192 x i8]]* @Info_ValueForKey.value, i64 0, i64 %32, i64 0
br label %34
34: ; preds = %39, %30
%35 = phi i8* [ %21, %30 ], [ %37, %39 ]
%36 = phi i8* [ %33, %30 ], [ %40, %39 ]
%37 = getelementptr inbounds i8, i8* %35, i64 1
%38 = load i8, i8* %37
switch i8 %38, label %39 [
i8 92, label %41
i8 0, label %41
]
39: ; preds = %34
%40 = getelementptr inbounds i8, i8* %36, i64 1
store i8 %38, i8* %36
br label %34
41: ; preds = %34, %34
store i8 0, i8* %36
%42 = call i32 @Q_stricmp(i8* %1, i8* %4)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* @Info_ValueForKey.valueindex
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [2 x [8192 x i8]], [2 x [8192 x i8]]* @Info_ValueForKey.value, i64 0, i64 %46, i64 0
br label %52
48: ; preds = %41
%49 = load i8, i8* %37
%50 = icmp eq i8 %49, 0
%51 = getelementptr inbounds i8, i8* %35, i64 2
br i1 %50, label %52, label %27
52: ; preds = %48, %20, %2, %44, %11
%53 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %11 ], [ %47, %44 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %20 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %48 ]
ret i8* %53
}