#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*/ BigInfo_RemoveKey(char *, char const *);
int /*<<< orphan*/ Com_Printf(char *);
int /*<<< orphan*/ Com_sprintf(char *, int, char *, char const *, char const *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
void BigInfo_SetValueForKey(char *s, const char *key, const char *value) {
  char newi[8192];
  if (strlen(s) >= 8192) {
    Com_Printf("Error: Info_SetValueForKey: oversize infostring");
  }
  if (strchr(key, '\\') || strchr(value, '\\')) {
    Com_Printf("Error: Can't use keys or values with a \\\n");
    return;
  }
  if (strchr(key, ';') || strchr(value, ';')) {
    Com_Printf("Error: Can't use keys or values with a semicolon\n");
    return;
  }
  if (strchr(key, '\"') || strchr(value, '\"')) {
    Com_Printf("Error: Can't use keys or values with a \"\n");
    return;
  }
  BigInfo_RemoveKey(s, key);
  if (!value || !strlen(value))
    return;
  Com_sprintf(newi, sizeof(newi), "\\%s\\%s", key, value);
  if (strlen(newi) + strlen(s) > 8192) {
    Com_Printf("Error: Info string length exceeded\n");
    return;
  }
  strcat(newi, s);
  strcpy(s, newi);
}


x86 assembly (clang, -O0):
<BigInfo_SetValueForKey>:
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   1040 <strlen@plt>
cmp    $0x2000,%eax
jl     11a7 <BigInfo_SetValueForKey+0x37>
lea    0xe5e(%rip),%rdi
call   1080 <Com_Printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    11d7 <BigInfo_SetValueForKey+0x67>
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11e8 <BigInfo_SetValueForKey+0x78>
lea    0xe52(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    131a <BigInfo_SetValueForKey+0x1aa>
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1218 <BigInfo_SetValueForKey+0xa8>
mov    -0x18(%rbp),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1229 <BigInfo_SetValueForKey+0xb9>
lea    0xe3b(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    131a <BigInfo_SetValueForKey+0x1aa>
mov    -0x10(%rbp),%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1259 <BigInfo_SetValueForKey+0xe9>
mov    -0x18(%rbp),%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     126a <BigInfo_SetValueForKey+0xfa>
lea    0xe2c(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    131a <BigInfo_SetValueForKey+0x1aa>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <BigInfo_RemoveKey@plt>
cmpq   $0x0,-0x18(%rbp)
je     1294 <BigInfo_SetValueForKey+0x124>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    1299 <BigInfo_SetValueForKey+0x129>
jmp    131a <BigInfo_SetValueForKey+0x1aa>
lea    -0x2020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x2000,%esi
lea    0xe02(%rip),%rdx
call   1070 <Com_sprintf@plt>
lea    -0x2020(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2024(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2024(%rbp),%eax
add    %ecx,%eax
cmp    $0x2000,%eax
jle    12fa <BigInfo_SetValueForKey+0x18a>
lea    0xdcd(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    131a <BigInfo_SetValueForKey+0x1aa>
lea    -0x2020(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BigInfo_SetValueForKey>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
cmp    $0x2000,%eax
jl     119f <BigInfo_SetValueForKey+0x2f>
lea    0xe66(%rip),%rdi
call   1080 <Com_Printf@plt>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    11c3 <BigInfo_SetValueForKey+0x53>
mov    %r14,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11dd <BigInfo_SetValueForKey+0x6d>
lea    0xe66(%rip),%rdi
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1080 <Com_Printf@plt>
mov    %rbx,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1201 <BigInfo_SetValueForKey+0x91>
mov    %r14,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     120a <BigInfo_SetValueForKey+0x9a>
lea    0xe52(%rip),%rdi
jmp    11ca <BigInfo_SetValueForKey+0x5a>
mov    %rbx,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    122e <BigInfo_SetValueForKey+0xbe>
mov    %r14,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1237 <BigInfo_SetValueForKey+0xc7>
lea    0xe57(%rip),%rdi
jmp    11ca <BigInfo_SetValueForKey+0x5a>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <BigInfo_RemoveKey@plt>
test   %r14,%r14
je     12b2 <BigInfo_SetValueForKey+0x142>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     12b2 <BigInfo_SetValueForKey+0x142>
lea    0xe5c(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x2000,%esi
mov    %rbx,%rcx
mov    %r14,%r8
call   1070 <Com_sprintf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
cmp    $0x2001,%eax
jl     1299 <BigInfo_SetValueForKey+0x129>
lea    0xe2b(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    12b2 <BigInfo_SetValueForKey+0x142>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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