#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*/ newi;

/* Variables and functions */
int /*<<< orphan*/ Com_Printf(char *);
int /*<<< orphan*/ Info_RemoveKey_Big(char *, char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strchr(char const *, char);
int strlen(char const *);
void Info_SetValueForKey_Big(char *s, const char *key, const char *value) {
  char newi[8192];
  if (strlen(s) >= 8192) {
    ;
    return;
  }
  if (strchr(key, '\\') || strchr(value, '\\')) {
    Com_Printf("Can't use keys or values with a \\\n");
    return;
  }
  if (strchr(key, ';') || strchr(value, ';')) {
    Com_Printf("Can't use keys or values with a semicolon\n");
    return;
  }
  if (strchr(key, '\"') || strchr(value, '\"')) {
    Com_Printf("Can't use keys or values with a \"\n");
    return;
  }
  Info_RemoveKey_Big(s, key);
  if (!value || !strlen(value))
    return;
  snprintf(newi, sizeof(newi), "\\%s\\%s", key, value);
  if (strlen(newi) + strlen(s) > 8192) {
    Com_Printf("BIG Info string length exceeded\n");
    return;
  }
  strcat(s, newi);
}


x86 assembly (clang, -O0):
<Info_SetValueForKey_Big>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2000,%eax
jl     1190 <Info_SetValueForKey_Big+0x30>
jmp    12f3 <Info_SetValueForKey_Big+0x193>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11c0 <Info_SetValueForKey_Big+0x60>
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11d1 <Info_SetValueForKey_Big+0x71>
lea    0xe39(%rip),%rdi
call   1060 <Com_Printf@plt>
jmp    12f3 <Info_SetValueForKey_Big+0x193>
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    1201 <Info_SetValueForKey_Big+0xa1>
mov    -0x18(%rbp),%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1212 <Info_SetValueForKey_Big+0xb2>
lea    0xe1b(%rip),%rdi
call   1060 <Com_Printf@plt>
jmp    12f3 <Info_SetValueForKey_Big+0x193>
mov    -0x10(%rbp),%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    1242 <Info_SetValueForKey_Big+0xe2>
mov    -0x18(%rbp),%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1253 <Info_SetValueForKey_Big+0xf3>
lea    0xe05(%rip),%rdi
call   1060 <Com_Printf@plt>
jmp    12f3 <Info_SetValueForKey_Big+0x193>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <Info_RemoveKey_Big@plt>
cmpq   $0x0,-0x18(%rbp)
je     127d <Info_SetValueForKey_Big+0x11d>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1282 <Info_SetValueForKey_Big+0x122>
jmp    12f3 <Info_SetValueForKey_Big+0x193>
lea    -0x2020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x2000,%esi
lea    0xdd4(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x2020(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2024(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2024(%rbp),%eax
add    %ecx,%eax
cmp    $0x2000,%eax
jle    12e3 <Info_SetValueForKey_Big+0x183>
lea    0xd9f(%rip),%rdi
call   1060 <Com_Printf@plt>
jmp    12f3 <Info_SetValueForKey_Big+0x193>
mov    -0x8(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1080 <strcat@plt>
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Info_SetValueForKey_Big>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2000,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x1fff,%eax
jle    1194 <Info_SetValueForKey_Big+0x34>
add    $0x2000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11b8 <Info_SetValueForKey_Big+0x58>
mov    %r14,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11d3 <Info_SetValueForKey_Big+0x73>
lea    0xe41(%rip),%rdi
add    $0x2000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <Com_Printf@plt>
mov    %r15,%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11f7 <Info_SetValueForKey_Big+0x97>
mov    %r14,%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1200 <Info_SetValueForKey_Big+0xa0>
lea    0xe25(%rip),%rdi
jmp    11bf <Info_SetValueForKey_Big+0x5f>
mov    %r15,%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1224 <Info_SetValueForKey_Big+0xc4>
mov    %r14,%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     122d <Info_SetValueForKey_Big+0xcd>
lea    0xe23(%rip),%rdi
jmp    11bf <Info_SetValueForKey_Big+0x5f>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <Info_RemoveKey_Big@plt>
test   %r14,%r14
je     1184 <Info_SetValueForKey_Big+0x24>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1184 <Info_SetValueForKey_Big+0x24>
lea    0xe19(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x2000,%esi
mov    %r15,%rcx
mov    %r14,%r8
call   1050 <snprintf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cmp    $0x2001,%eax
jl     129a <Info_SetValueForKey_Big+0x13a>
lea    0xde8(%rip),%rdi
call   1060 <Com_Printf@plt>
jmp    1184 <Info_SetValueForKey_Big+0x24>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
jmp    1184 <Info_SetValueForKey_Big+0x24>

LLVM IR (-O0):
@.str = [35 x i8] c"Can't use keys or values with a \\\0A\00"
@.str.1 = [43 x i8] c"Can't use keys or values with a semicolon\0A\00"
@.str.2 = [35 x i8] c"Can't use keys or values with a \22\0A\00"
@.str.3 = [7 x i8] c"\\%s\\%s\00"
@.str.4 = [33 x i8] c"BIG Info string length exceeded\0A\00"
define void @Info_SetValueForKey_Big(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [8192 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = icmp sge i32 %9, 8192
br i1 %10, label %11, label %12
11: ; preds = %3
br label %70
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i64 @strchr(i8* %13, i8 signext 92)
%15 = icmp ne i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = call i64 @strchr(i8* %17, i8 signext 92)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16, %12
%21 = call i32 @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %70
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = call i64 @strchr(i8* %23, i8 signext 59)
%25 = icmp ne i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = call i64 @strchr(i8* %27, i8 signext 59)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26, %22
%31 = call i32 @Com_Printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %70
32: ; preds = %26
%33 = load i8*, i8** %5
%34 = call i64 @strchr(i8* %33, i8 signext 34)
%35 = icmp ne i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i8*, i8** %6
%38 = call i64 @strchr(i8* %37, i8 signext 34)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36, %32
%41 = call i32 @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %70
42: ; preds = %36
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = call i32 @Info_RemoveKey_Big(i8* %43, i8* %44)
%46 = load i8*, i8** %6
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %52
48: ; preds = %42
%49 = load i8*, i8** %6
%50 = call i32 @strlen(i8* %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %48, %42
br label %70
53: ; preds = %48
%54 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%55 = load i8*, i8** %5
%56 = load i8*, i8** %6
%57 = call i32 @snprintf(i8* %54, i32 8192, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %55, i8* %56)
%58 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%59 = call i32 @strlen(i8* %58)
%60 = load i8*, i8** %4
%61 = call i32 @strlen(i8* %60)
%62 = add nsw i32 %59, %61
%63 = icmp sgt i32 %62, 8192
br i1 %63, label %64, label %66
64: ; preds = %53
%65 = call i32 @Com_Printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %70
66: ; preds = %53
%67 = load i8*, i8** %4
%68 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%69 = call i32 @strcat(i8* %67, i8* %68)
br label %70
70: ; preds = %66, %64, %52, %40, %30, %20, %11
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"Can't use keys or values with a \\\0A\00"
@.str.1 = [43 x i8] c"Can't use keys or values with a semicolon\0A\00"
@.str.2 = [35 x i8] c"Can't use keys or values with a \22\0A\00"
@.str.3 = [7 x i8] c"\\%s\\%s\00"
@.str.4 = [33 x i8] c"BIG Info string length exceeded\0A\00"
define void @Info_SetValueForKey_Big(i8* %0, i8* %1, i8* %2) {
%4 = alloca [8192 x i8]
%5 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 8191
br i1 %7, label %48, label %8
8: ; preds = %3
%9 = tail call i64 @strchr(i8* %1, i8 signext 92)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i64 @strchr(i8* %2, i8 signext 92)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11, %8
%15 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %48
16: ; preds = %11
%17 = tail call i64 @strchr(i8* %1, i8 signext 59)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i64 @strchr(i8* %2, i8 signext 59)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19, %16
%23 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %48
24: ; preds = %19
%25 = tail call i64 @strchr(i8* %1, i8 signext 34)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = tail call i64 @strchr(i8* %2, i8 signext 34)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27, %24
%31 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %48
32: ; preds = %27
%33 = tail call i32 @Info_RemoveKey_Big(i8* %0, i8* %1)
%34 = icmp eq i8* %2, null
br i1 %34, label %48, label %35
35: ; preds = %32
%36 = tail call i32 @strlen(i8* %2)
%37 = icmp eq i32 %36, 0
br i1 %37, label %48, label %38
38: ; preds = %35
%39 = call i32 @snprintf(i8* %5, i32 8192, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %2)
%40 = call i32 @strlen(i8* %5)
%41 = call i32 @strlen(i8* %0)
%42 = add nsw i32 %41, %40
%43 = icmp sgt i32 %42, 8192
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 @Com_Printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %48
46: ; preds = %38
%47 = call i32 @strcat(i8* %0, i8* %5)
br label %48
48: ; preds = %32, %35, %3, %46, %44, %30, %22, %14
ret void
}