#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(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 /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
void Info_SetValueForKey(char *s, const char *key, const char *value) {
  char newi[1024];
  if (strlen(s) >= 1024) {
    ;
    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(s, key);
  if (!value || !strlen(value))
    return;
  snprintf(newi, sizeof(newi), "\\%s\\%s", key, value);
  if (strlen(newi) + strlen(s) > 1024) {
    Com_Printf("Info string length exceeded\n");
    return;
  }
  strcat(newi, s);
  strcpy(s, newi);
}


x86 assembly (clang, -O0):
<Info_SetValueForKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x400,%eax
jl     11a0 <Info_SetValueForKey+0x30>
jmp    1313 <Info_SetValueForKey+0x1a3>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    11d0 <Info_SetValueForKey+0x60>
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11e1 <Info_SetValueForKey+0x71>
lea    0xe29(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    1313 <Info_SetValueForKey+0x1a3>
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1211 <Info_SetValueForKey+0xa1>
mov    -0x18(%rbp),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1222 <Info_SetValueForKey+0xb2>
lea    0xe0b(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    1313 <Info_SetValueForKey+0x1a3>
mov    -0x10(%rbp),%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1252 <Info_SetValueForKey+0xe2>
mov    -0x18(%rbp),%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1263 <Info_SetValueForKey+0xf3>
lea    0xdf5(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    1313 <Info_SetValueForKey+0x1a3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <Info_RemoveKey@plt>
cmpq   $0x0,-0x18(%rbp)
je     128d <Info_SetValueForKey+0x11d>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    1292 <Info_SetValueForKey+0x122>
jmp    1313 <Info_SetValueForKey+0x1a3>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x400,%esi
lea    0xdc4(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x424(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x424(%rbp),%eax
add    %ecx,%eax
cmp    $0x400,%eax
jle    12f3 <Info_SetValueForKey+0x183>
lea    0xd8f(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    1313 <Info_SetValueForKey+0x1a3>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Info_SetValueForKey>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x3ff,%eax
jle    11a4 <Info_SetValueForKey+0x34>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    11c8 <Info_SetValueForKey+0x58>
mov    %r14,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e3 <Info_SetValueForKey+0x73>
lea    0xe31(%rip),%rdi
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <Com_Printf@plt>
mov    %r15,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1207 <Info_SetValueForKey+0x97>
mov    %r14,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1210 <Info_SetValueForKey+0xa0>
lea    0xe15(%rip),%rdi
jmp    11cf <Info_SetValueForKey+0x5f>
mov    %r15,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1234 <Info_SetValueForKey+0xc4>
mov    %r14,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     123d <Info_SetValueForKey+0xcd>
lea    0xe13(%rip),%rdi
jmp    11cf <Info_SetValueForKey+0x5f>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <Info_RemoveKey@plt>
test   %r14,%r14
je     1194 <Info_SetValueForKey+0x24>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1194 <Info_SetValueForKey+0x24>
lea    0xe09(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r15,%rcx
mov    %r14,%r8
call   1060 <snprintf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %ebp,%eax
cmp    $0x401,%eax
jl     12aa <Info_SetValueForKey+0x13a>
lea    0xdd8(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    1194 <Info_SetValueForKey+0x24>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    1194 <Info_SetValueForKey+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 = [29 x i8] c"Info string length exceeded\0A\00"
define void @Info_SetValueForKey(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1024 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, 1024
br i1 %10, label %11, label %12
11: ; preds = %3
br label %73
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 %73
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 %73
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 %73
42: ; preds = %36
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = call i32 @Info_RemoveKey(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 %73
53: ; preds = %48
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%55 = load i8*, i8** %5
%56 = load i8*, i8** %6
%57 = call i32 @snprintf(i8* %54, i32 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %55, i8* %56)
%58 = getelementptr inbounds [1024 x i8], [1024 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, 1024
br i1 %63, label %64, label %66
64: ; preds = %53
%65 = call i32 @Com_Printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %73
66: ; preds = %53
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%68 = load i8*, i8** %4
%69 = call i32 @strcat(i8* %67, i8* %68)
%70 = load i8*, i8** %4
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%72 = call i32 @strcpy(i8* %70, i8* %71)
br label %73
73: ; 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 = [29 x i8] c"Info string length exceeded\0A\00"
define void @Info_SetValueForKey(i8* %0, i8* %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 1023
br i1 %7, label %49, 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 %49
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 %49
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 %49
32: ; preds = %27
%33 = tail call i32 @Info_RemoveKey(i8* %0, i8* %1)
%34 = icmp eq i8* %2, null
br i1 %34, label %49, label %35
35: ; preds = %32
%36 = tail call i32 @strlen(i8* %2)
%37 = icmp eq i32 %36, 0
br i1 %37, label %49, label %38
38: ; preds = %35
%39 = call i32 @snprintf(i8* %5, i32 1024, 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, 1024
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 @Com_Printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %49
46: ; preds = %38
%47 = call i32 @strcat(i8* %5, i8* %0)
%48 = call i32 @strcpy(i8* %0, i8* %5)
br label %49
49: ; preds = %32, %35, %3, %46, %44, %30, %22, %14
ret void
}