#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*/ Com_sprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ Info_RemoveKey(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
void Info_SetValueForKey(char *s, char *key, char *value) {
  char newi[512], *v;
  int c;
  int maxsize = 512;
  if (strstr(key, "\\") || strstr(value, "\\")) {
    Com_Printf("^1"
               "Can't use keys or values with a \\\n");
    return;
  }
  if (strstr(key, ";")) {
    Com_Printf("^1"
               "Can't use keys or values with a semicolon\n");
    return;
  }
  if (strstr(key, "\"") || strstr(value, "\"")) {
    Com_Printf("^1"
               "Can't use keys or values with a \"\n");
    return;
  }
  if (strlen(key) > 64 - 1 || strlen(value) > 64 - 1) {
    Com_Printf("^1"
               "Keys and values must be < 64 characters.\n");
    return;
  }
  Info_RemoveKey(s, key);
  if (!value || !strlen(value))
    return;
  Com_sprintf(newi, sizeof(newi), "\\%s\\%s", key, value);
  if (strlen(newi) + strlen(s) > maxsize) {
    Com_Printf("^1"
               "Info string length exceeded\n");
    return;
  }
  s += strlen(s);
  v = newi;
  while (*v) {
    c = *v++;
    c &= 127;
    if (c >= 32 && c < 127)
      *s++ = c;
  }
  *s = 0;
}


x86 assembly (clang, -O0):
<Info_SetValueForKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x200,-0x230(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    11a5 <Info_SetValueForKey+0x55>
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11b6 <Info_SetValueForKey+0x66>
lea    0xe56(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    138f <Info_SetValueForKey+0x23f>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11e1 <Info_SetValueForKey+0x91>
lea    0xe52(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    138f <Info_SetValueForKey+0x23f>
mov    -0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    1215 <Info_SetValueForKey+0xc5>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1226 <Info_SetValueForKey+0xd6>
lea    0xe3c(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    138f <Info_SetValueForKey+0x23f>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3f,%eax
jg     124a <Info_SetValueForKey+0xfa>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3f,%eax
jle    125b <Info_SetValueForKey+0x10b>
lea    0xe2c(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    138f <Info_SetValueForKey+0x23f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <Info_RemoveKey@plt>
cmpq   $0x0,-0x18(%rbp)
je     1285 <Info_SetValueForKey+0x135>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    128a <Info_SetValueForKey+0x13a>
jmp    138f <Info_SetValueForKey+0x23f>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x200,%esi
lea    0xe04(%rip),%rdx
call   1040 <Com_sprintf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x234(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x234(%rbp),%eax
add    %ecx,%eax
cmp    -0x230(%rbp),%eax
jle    12ec <Info_SetValueForKey+0x19c>
lea    0xdce(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    138f <Info_SetValueForKey+0x23f>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rax
cmpb   $0x0,(%rax)
je     1388 <Info_SetValueForKey+0x238>
mov    -0x228(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x228(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x22c(%rbp)
mov    -0x22c(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x22c(%rbp)
cmpl   $0x20,-0x22c(%rbp)
jl     1383 <Info_SetValueForKey+0x233>
cmpl   $0x7f,-0x22c(%rbp)
jge    1383 <Info_SetValueForKey+0x233>
mov    -0x22c(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1313 <Info_SetValueForKey+0x1c3>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Info_SetValueForKey>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
jne    118f <Info_SetValueForKey+0x3f>
lea    0xe7e(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11a9 <Info_SetValueForKey+0x59>
lea    0xe6c(%rip),%rdi
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <Com_Printf@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11c6 <Info_SetValueForKey+0x76>
lea    0xe65(%rip),%rdi
jmp    1196 <Info_SetValueForKey+0x46>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11ee <Info_SetValueForKey+0x9e>
lea    0xe75(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11f7 <Info_SetValueForKey+0xa7>
lea    0xe63(%rip),%rdi
jmp    1196 <Info_SetValueForKey+0x46>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3f,%eax
jg     1211 <Info_SetValueForKey+0xc1>
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    $0x40,%eax
jl     121d <Info_SetValueForKey+0xcd>
lea    0xe65(%rip),%rdi
jmp    1196 <Info_SetValueForKey+0x46>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <Info_RemoveKey@plt>
test   %r15,%r15
je     12c5 <Info_SetValueForKey+0x175>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     12c5 <Info_SetValueForKey+0x175>
lea    0xe61(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
mov    %r15,%r8
call   1040 <Com_sprintf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
cmp    $0x201,%eax
jl     1287 <Info_SetValueForKey+0x137>
lea    0xe30(%rip),%rdi
call   1050 <Com_Printf@plt>
jmp    12c5 <Info_SetValueForKey+0x175>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %r14,%rax
mov    (%rsp),%dl
test   %dl,%dl
je     12c2 <Info_SetValueForKey+0x172>
lea    0x1(%rsp),%rcx
jmp    12ad <Info_SetValueForKey+0x15d>
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
je     12c2 <Info_SetValueForKey+0x172>
and    $0x7f,%dl
cmp    $0x20,%dl
jb     12a2 <Info_SetValueForKey+0x152>
cmp    $0x7f,%dl
je     12a2 <Info_SetValueForKey+0x152>
mov    %dl,(%rax)
add    $0x1,%rax
jmp    12a2 <Info_SetValueForKey+0x152>
movb   $0x0,(%rax)
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\\\00"
@.str.1 = [37 x i8] c"^1Can't use keys or values with a \\\0A\00"
@.str.2 = [2 x i8] c";\00"
@.str.3 = [45 x i8] c"^1Can't use keys or values with a semicolon\0A\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [37 x i8] c"^1Can't use keys or values with a \22\0A\00"
@.str.6 = [44 x i8] c"^1Keys and values must be < 64 characters.\0A\00"
@.str.7 = [7 x i8] c"\\%s\\%s\00"
@.str.8 = [31 x i8] c"^1Info 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 [512 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 512, i32* %10
%11 = load i8*, i8** %5
%12 = call i64 @strstr(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14, %3
%19 = call i32 @Com_Printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %102
20: ; preds = %14
%21 = load i8*, i8** %5
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @Com_Printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %102
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = call i64 @strstr(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8*, i8** %6
%32 = call i64 @strstr(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30, %26
%35 = call i32 @Com_Printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
br label %102
36: ; preds = %30
%37 = load i8*, i8** %5
%38 = call i32 @strlen(i8* %37)
%39 = icmp sgt i32 %38, 63
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i8*, i8** %6
%42 = call i32 @strlen(i8* %41)
%43 = icmp sgt i32 %42, 63
br i1 %43, label %44, label %46
44: ; preds = %40, %36
%45 = call i32 @Com_Printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
br label %102
46: ; preds = %40
%47 = load i8*, i8** %4
%48 = load i8*, i8** %5
%49 = call i32 @Info_RemoveKey(i8* %47, i8* %48)
%50 = load i8*, i8** %6
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = load i8*, i8** %6
%54 = call i32 @strlen(i8* %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %52, %46
br label %102
57: ; preds = %52
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%59 = load i8*, i8** %5
%60 = load i8*, i8** %6
%61 = call i32 @Com_sprintf(i8* %58, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %59, i8* %60)
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%63 = call i32 @strlen(i8* %62)
%64 = load i8*, i8** %4
%65 = call i32 @strlen(i8* %64)
%66 = add nsw i32 %63, %65
%67 = load i32, i32* %10
%68 = icmp sgt i32 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %57
%70 = call i32 @Com_Printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %102
71: ; preds = %57
%72 = load i8*, i8** %4
%73 = call i32 @strlen(i8* %72)
%74 = load i8*, i8** %4
%75 = sext i32 %73 to i64
%76 = getelementptr inbounds i8, i8* %74, i64 %75
store i8* %76, i8** %4
%77 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
store i8* %77, i8** %8
br label %78
78: ; preds = %99, %71
%79 = load i8*, i8** %8
%80 = load i8, i8* %79
%81 = icmp ne i8 %80, 0
br i1 %81, label %82, label %100
82: ; preds = %78
%83 = load i8*, i8** %8
%84 = getelementptr inbounds i8, i8* %83, i32 1
store i8* %84, i8** %8
%85 = load i8, i8* %83
%86 = sext i8 %85 to i32
store i32 %86, i32* %9
%87 = load i32, i32* %9
%88 = and i32 %87, 127
store i32 %88, i32* %9
%89 = load i32, i32* %9
%90 = icmp sge i32 %89, 32
br i1 %90, label %91, label %99
91: ; preds = %82
%92 = load i32, i32* %9
%93 = icmp slt i32 %92, 127
br i1 %93, label %94, label %99
94: ; preds = %91
%95 = load i32, i32* %9
%96 = trunc i32 %95 to i8
%97 = load i8*, i8** %4
%98 = getelementptr inbounds i8, i8* %97, i32 1
store i8* %98, i8** %4
store i8 %96, i8* %97
br label %99
99: ; preds = %94, %91, %82
br label %78
100: ; preds = %78
%101 = load i8*, i8** %4
store i8 0, i8* %101
br label %102
102: ; preds = %100, %69, %56, %44, %34, %24, %18
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\\\00"
@.str.1 = [37 x i8] c"^1Can't use keys or values with a \\\0A\00"
@.str.2 = [2 x i8] c";\00"
@.str.3 = [45 x i8] c"^1Can't use keys or values with a semicolon\0A\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [37 x i8] c"^1Can't use keys or values with a \22\0A\00"
@.str.6 = [44 x i8] c"^1Keys and values must be < 64 characters.\0A\00"
@.str.7 = [7 x i8] c"\\%s\\%s\00"
@.str.8 = [31 x i8] c"^1Info string length exceeded\0A\00"
define void @Info_SetValueForKey(i8* %0, i8* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i64 @strstr(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %3
%12 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %71
13: ; preds = %8
%14 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %71
18: ; preds = %13
%19 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i64 @strstr(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%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 ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
br label %71
26: ; preds = %21
%27 = tail call i32 @strlen(i8* %1)
%28 = icmp sgt i32 %27, 63
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = tail call i32 @strlen(i8* %2)
%31 = icmp sgt i32 %30, 63
br i1 %31, label %32, label %34
32: ; preds = %29, %26
%33 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
br label %71
34: ; preds = %29
%35 = tail call i32 @Info_RemoveKey(i8* %0, i8* %1)
%36 = icmp eq i8* %2, null
br i1 %36, label %71, label %37
37: ; preds = %34
%38 = tail call i32 @strlen(i8* %2)
%39 = icmp eq i32 %38, 0
br i1 %39, label %71, label %40
40: ; preds = %37
%41 = call i32 @Com_sprintf(i8* %5, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, 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, 512
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = call i32 @Com_Printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %71
48: ; preds = %40
%49 = call i32 @strlen(i8* %0)
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %0, i64 %50
%52 = load i8, i8* %5
%53 = icmp eq i8 %52, 0
br i1 %53, label %69, label %54
54: ; preds = %48, %65
%55 = phi i8 [ %67, %65 ], [ %52, %48 ]
%56 = phi i8* [ %66, %65 ], [ %51, %48 ]
%57 = phi i8* [ %58, %65 ], [ %5, %48 ]
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = and i8 %55, 127
%60 = icmp ugt i8 %59, 31
%61 = icmp ne i8 %59, 127
%62 = and i1 %60, %61
br i1 %62, label %63, label %65
63: ; preds = %54
%64 = getelementptr inbounds i8, i8* %56, i64 1
store i8 %59, i8* %56
br label %65
65: ; preds = %63, %54
%66 = phi i8* [ %64, %63 ], [ %56, %54 ]
%67 = load i8, i8* %58
%68 = icmp eq i8 %67, 0
br i1 %68, label %69, label %54
69: ; preds = %65, %48
%70 = phi i8* [ %51, %48 ], [ %66, %65 ]
store i8 0, i8* %70
br label %71
71: ; preds = %34, %37, %69, %46, %32, %24, %16, %11
ret void
}