#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("Can't use keys or values with a \\\n");
    return;
  }
  if (strstr(key, ";")) {
    Com_Printf("Can't use keys or values with a semicolon\n");
    return;
  }
  if (strstr(key, "\"") || strstr(value, "\"")) {
    Com_Printf("Can't use keys or values with a \"\n");
    return;
  }
  if (strlen(key) > 64 - 1 || strlen(value) > 64 - 1) {
    Com_Printf("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("%s: Info string length exceeded\n", key);
    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     11b8 <Info_SetValueForKey+0x68>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
jmp    139d <Info_SetValueForKey+0x24d>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11e5 <Info_SetValueForKey+0x95>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
jmp    139d <Info_SetValueForKey+0x24d>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    1219 <Info_SetValueForKey+0xc9>
mov    -0x18(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     122c <Info_SetValueForKey+0xdc>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
jmp    139d <Info_SetValueForKey+0x24d>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3f,%eax
jg     1250 <Info_SetValueForKey+0x100>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3f,%eax
jle    1263 <Info_SetValueForKey+0x113>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
jmp    139d <Info_SetValueForKey+0x24d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <Info_RemoveKey@plt>
cmpq   $0x0,-0x18(%rbp)
je     128d <Info_SetValueForKey+0x13d>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1292 <Info_SetValueForKey+0x142>
jmp    139d <Info_SetValueForKey+0x24d>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x200,%esi
lea    0xdf4(%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    12fa <Info_SetValueForKey+0x1aa>
mov    -0x10(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
jmp    139d <Info_SetValueForKey+0x24d>
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     1396 <Info_SetValueForKey+0x246>
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     1391 <Info_SetValueForKey+0x241>
cmpl   $0x7f,-0x22c(%rbp)
jge    1391 <Info_SetValueForKey+0x241>
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    1321 <Info_SetValueForKey+0x1d1>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Info_SetValueForKey>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
jne    1190 <Info_SetValueForKey+0x40>
lea    0xe7d(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11ad <Info_SetValueForKey+0x5d>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <Com_Printf@plt>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11ca <Info_SetValueForKey+0x7a>
lea    0xe5f(%rip),%rdi
jmp    1197 <Info_SetValueForKey+0x47>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11f2 <Info_SetValueForKey+0xa2>
lea    0xe6d(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11fb <Info_SetValueForKey+0xab>
lea    0xe5b(%rip),%rdi
jmp    1197 <Info_SetValueForKey+0x47>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3f,%eax
jg     1215 <Info_SetValueForKey+0xc5>
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    $0x40,%eax
jl     1221 <Info_SetValueForKey+0xd1>
lea    0xe5b(%rip),%rdi
jmp    1197 <Info_SetValueForKey+0x47>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <Info_RemoveKey@plt>
test   %r15,%r15
je     12ce <Info_SetValueForKey+0x17e>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     12ce <Info_SetValueForKey+0x17e>
lea    0xe55(%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,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cmp    $0x201,%eax
jl     1290 <Info_SetValueForKey+0x140>
lea    0xe24(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <Com_Printf@plt>
jmp    12ce <Info_SetValueForKey+0x17e>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %r14,%rax
mov    (%rsp),%dl
test   %dl,%dl
je     12cb <Info_SetValueForKey+0x17b>
lea    0x1(%rsp),%rcx
jmp    12b6 <Info_SetValueForKey+0x166>
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
je     12cb <Info_SetValueForKey+0x17b>
and    $0x7f,%dl
cmp    $0x20,%dl
jb     12ab <Info_SetValueForKey+0x15b>
cmp    $0x7f,%dl
je     12ab <Info_SetValueForKey+0x15b>
mov    %dl,(%rax)
add    $0x1,%rax
jmp    12ab <Info_SetValueForKey+0x15b>
movb   $0x0,(%rax)
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\\\00"
@.str.1 = [35 x i8] c"Can't use keys or values with a \\\0A\00"
@.str.2 = [2 x i8] c";\00"
@.str.3 = [43 x i8] c"Can't use keys or values with a semicolon\0A\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [35 x i8] c"Can't use keys or values with a \22\0A\00"
@.str.6 = [42 x i8] c"Keys and values must be < 64 characters.\0A\00"
@.str.7 = [7 x i8] c"\\%s\\%s\00"
@.str.8 = [33 x i8] c"%s: 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 [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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %103
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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %103
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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %103
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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %103
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 %103
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 %72
69: ; preds = %57
%70 = load i8*, i8** %5
%71 = call i32 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %70)
br label %103
72: ; preds = %57
%73 = load i8*, i8** %4
%74 = call i32 @strlen(i8* %73)
%75 = load i8*, i8** %4
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8* %77, i8** %4
%78 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
store i8* %78, i8** %8
br label %79
79: ; preds = %100, %72
%80 = load i8*, i8** %8
%81 = load i8, i8* %80
%82 = icmp ne i8 %81, 0
br i1 %82, label %83, label %101
83: ; preds = %79
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %8
%86 = load i8, i8* %84
%87 = sext i8 %86 to i32
store i32 %87, i32* %9
%88 = load i32, i32* %9
%89 = and i32 %88, 127
store i32 %89, i32* %9
%90 = load i32, i32* %9
%91 = icmp sge i32 %90, 32
br i1 %91, label %92, label %100
92: ; preds = %83
%93 = load i32, i32* %9
%94 = icmp slt i32 %93, 127
br i1 %94, label %95, label %100
95: ; preds = %92
%96 = load i32, i32* %9
%97 = trunc i32 %96 to i8
%98 = load i8*, i8** %4
%99 = getelementptr inbounds i8, i8* %98, i32 1
store i8* %99, i8** %4
store i8 %97, i8* %98
br label %100
100: ; preds = %95, %92, %83
br label %79
101: ; preds = %79
%102 = load i8*, i8** %4
store i8 0, i8* %102
br label %103
103: ; preds = %101, %69, %56, %44, %34, %24, %18
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\\\00"
@.str.1 = [35 x i8] c"Can't use keys or values with a \\\0A\00"
@.str.2 = [2 x i8] c";\00"
@.str.3 = [43 x i8] c"Can't use keys or values with a semicolon\0A\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [35 x i8] c"Can't use keys or values with a \22\0A\00"
@.str.6 = [42 x i8] c"Keys and values must be < 64 characters.\0A\00"
@.str.7 = [7 x i8] c"\\%s\\%s\00"
@.str.8 = [33 x i8] c"%s: Info 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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([43 x i8], [43 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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([35 x i8], [35 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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([42 x i8], [42 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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %1)
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
}