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

/* Variables and functions */
int /*<<< orphan*/ GetEnvData(char *, char **);
int /*<<< orphan*/ GetFormData(char *, char **);
int /*<<< orphan*/ IncludeCGI(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ IncludeEXE(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ printStr(char *);
int /*<<< orphan*/ printf(char *);
char *strchr(char *, char);
scalar_t__ strlen(char *);
scalar_t__ strncasecmp(char *, char *, scalar_t__);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
void PrintForm(char *szName) {
  char *szBuf;
  char *p, *q;
  int len;
  char *szTmp;
  char *szValue;
  GetFormData(szName, &szBuf);
  if (szBuf == NULL)
    return;
  p = szBuf;
  szTmp = (char *)malloc(strlen(szBuf) + 1);
  if (szTmp == NULL)
    return;
  while (*p) {
    q = strstr(p, "{$");
    if (q == NULL) {
      printf(p);
      break;
    } else {
      len = q - p;
      if (len) {
        strncpy(szTmp, p, len);
        szTmp[len] = '\0';
        printStr(szTmp);
      }
      p = strchr(q, '}');
      if (p == NULL) {
        printf("{$");
        p += 2;
      } else {
        len = p - q - 2;
        if (len) {
          strncpy(szTmp, q + 2, len);
          szTmp[len] = '\0';
          if (strncasecmp(szTmp, "IncludeCGI(", strlen("IncludeCGI(")) == 0) {
            IncludeCGI(szTmp, NULL);
          } else if (strncasecmp(szTmp, "IncludeEXE(", strlen("IncludeEXE(")) ==
                     0) {
            IncludeEXE(szTmp, NULL);
          } else {
            GetEnvData(szTmp, &szValue);
            if (szValue != NULL) {
              printStr(szValue);
            }
          }
        }
        p += 1;
      }
    }
  }
  free(szTmp);
}


x86 assembly (clang, -O0):
<PrintForm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <GetFormData@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11f9 <PrintForm+0x29>
jmp    13f1 <PrintForm+0x221>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    122a <PrintForm+0x5a>
jmp    13f1 <PrintForm+0x221>
jmp    122f <PrintForm+0x5f>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     13e8 <PrintForm+0x218>
mov    -0x18(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1269 <PrintForm+0x99>
mov    -0x18(%rbp),%rdi
call   1090 <printf@plt>
jmp    13e8 <PrintForm+0x218>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12a6 <PrintForm+0xd6>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
call   1050 <printStr@plt>
mov    -0x20(%rbp),%rdi
mov    $0x7d,%esi
call   1080 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12e0 <PrintForm+0x110>
lea    0xd36(%rip),%rdi
call   1090 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    13de <PrintForm+0x20e>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
sub    $0x2,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     13d2 <PrintForm+0x202>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x2,%rsi
mov    -0x24(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xcd8(%rip),%rdi
call   1070 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xcc5(%rip),%rsi
call   10d0 <strncasecmp@plt>
cmp    $0x0,%rax
jne    135f <PrintForm+0x18f>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10e0 <IncludeCGI@plt>
jmp    13cd <PrintForm+0x1fd>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xca1(%rip),%rdi
call   1070 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xc8e(%rip),%rsi
call   10d0 <strncasecmp@plt>
cmp    $0x0,%rax
jne    13a2 <PrintForm+0x1d2>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <IncludeEXE@plt>
jmp    13c8 <PrintForm+0x1f8>
mov    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <GetEnvData@plt>
cmpq   $0x0,-0x38(%rbp)
je     13c3 <PrintForm+0x1f3>
mov    -0x38(%rbp),%rdi
call   1050 <printStr@plt>
jmp    13c8 <PrintForm+0x1f8>
jmp    13cd <PrintForm+0x1fd>
jmp    13d2 <PrintForm+0x202>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    13e3 <PrintForm+0x213>
jmp    122f <PrintForm+0x5f>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintForm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%rsi
call   1060 <GetFormData@plt>
mov    0x10(%rsp),%rbx
test   %rbx,%rbx
je     1354 <PrintForm+0x184>
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%rdi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1354 <PrintForm+0x184>
mov    %rax,%r14
cmpb   $0x0,(%rbx)
je     134c <PrintForm+0x17c>
lea    0xddd(%rip),%r15
jmp    123c <PrintForm+0x6c>
mov    %r14,%rdi
xor    %esi,%esi
call   10e0 <IncludeCGI@plt>
add    $0x1,%rbx
cmpb   $0x0,(%rbx)
je     134c <PrintForm+0x17c>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
je     1344 <PrintForm+0x174>
mov    %rax,%r12
mov    %rax,%rbp
sub    %rbx,%rbp
test   %ebp,%ebp
je     127a <PrintForm+0xaa>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
call   1050 <printStr@plt>
mov    %r12,%rdi
mov    $0x7d,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1320 <PrintForm+0x150>
mov    %rax,%rbx
mov    %ebx,%r13d
sub    %r12d,%r13d
add    $0xfffffffe,%r13d
je     122f <PrintForm+0x5f>
add    $0x2,%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1040 <strncpy@plt>
movslq %r13d,%rax
movb   $0x0,(%r14,%rax,1)
mov    $0xb,%edx
mov    %r14,%rdi
lea    0xd3b(%rip),%rsi
call   10d0 <strncasecmp@plt>
test   %rax,%rax
je     1225 <PrintForm+0x55>
mov    $0xb,%edx
mov    %r14,%rdi
lea    0xd2a(%rip),%rsi
call   10d0 <strncasecmp@plt>
mov    %r14,%rdi
test   %rax,%rax
je     1338 <PrintForm+0x168>
lea    0x8(%rsp),%rsi
call   10a0 <GetEnvData@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     122f <PrintForm+0x5f>
call   1050 <printStr@plt>
jmp    122f <PrintForm+0x5f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1090 <printf@plt>
mov    $0x2,%ebx
cmpb   $0x0,(%rbx)
jne    123c <PrintForm+0x6c>
jmp    134c <PrintForm+0x17c>
xor    %esi,%esi
call   10b0 <IncludeEXE@plt>
jmp    122f <PrintForm+0x5f>
mov    %rbx,%rdi
call   1090 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"{$\00"
@.str.1 = [12 x i8] c"IncludeCGI(\00"
@.str.2 = [12 x i8] c"IncludeEXE(\00"
define void @PrintForm(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @GetFormData(i8* %9, i8** %3)
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
br label %120
14: ; preds = %1
%15 = load i8*, i8** %3
store i8* %15, i8** %4
%16 = load i8*, i8** %3
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 1
%19 = call i64 @malloc(i64 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %14
br label %120
24: ; preds = %14
br label %25
25: ; preds = %116, %24
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %117
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = call i8* @strstr(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %31, i8** %5
%32 = load i8*, i8** %5
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i8*, i8** %4
%36 = call i32 @printf(i8* %35)
br label %117
37: ; preds = %29
%38 = load i8*, i8** %5
%39 = load i8*, i8** %4
%40 = ptrtoint i8* %38 to i64
%41 = ptrtoint i8* %39 to i64
%42 = sub i64 %40, %41
%43 = trunc i64 %42 to i32
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %37
%47 = load i8*, i8** %7
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = call i32 @strncpy(i8* %47, i8* %48, i32 %49)
%51 = load i8*, i8** %7
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %7
%56 = call i32 @printStr(i8* %55)
br label %57
57: ; preds = %46, %37
%58 = load i8*, i8** %5
%59 = call i8* @strchr(i8* %58, i8 signext 125)
store i8* %59, i8** %4
%60 = load i8*, i8** %4
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %66
62: ; preds = %57
%63 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i64 2
store i8* %65, i8** %4
br label %115
66: ; preds = %57
%67 = load i8*, i8** %4
%68 = load i8*, i8** %5
%69 = ptrtoint i8* %67 to i64
%70 = ptrtoint i8* %68 to i64
%71 = sub i64 %69, %70
%72 = sub nsw i64 %71, 2
%73 = trunc i64 %72 to i32
store i32 %73, i32* %6
%74 = load i32, i32* %6
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %112
76: ; preds = %66
%77 = load i8*, i8** %7
%78 = load i8*, i8** %5
%79 = getelementptr inbounds i8, i8* %78, i64 2
%80 = load i32, i32* %6
%81 = call i32 @strncpy(i8* %77, i8* %79, i32 %80)
%82 = load i8*, i8** %7
%83 = load i32, i32* %6
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
store i8 0, i8* %85
%86 = load i8*, i8** %7
%87 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%88 = call i64 @strncasecmp(i8* %86, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %87)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %76
%91 = load i8*, i8** %7
%92 = call i32 @IncludeCGI(i8* %91, i32* null)
br label %111
93: ; preds = %76
%94 = load i8*, i8** %7
%95 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%96 = call i64 @strncasecmp(i8* %94, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %93
%99 = load i8*, i8** %7
%100 = call i32 @IncludeEXE(i8* %99, i32* null)
br label %110
101: ; preds = %93
%102 = load i8*, i8** %7
%103 = call i32 @GetEnvData(i8* %102, i8** %8)
%104 = load i8*, i8** %8
%105 = icmp ne i8* %104, null
br i1 %105, label %106, label %109
106: ; preds = %101
%107 = load i8*, i8** %8
%108 = call i32 @printStr(i8* %107)
br label %109
109: ; preds = %106, %101
br label %110
110: ; preds = %109, %98
br label %111
111: ; preds = %110, %90
br label %112
112: ; preds = %111, %66
%113 = load i8*, i8** %4
%114 = getelementptr inbounds i8, i8* %113, i64 1
store i8* %114, i8** %4
br label %115
115: ; preds = %112, %62
br label %116
116: ; preds = %115
br label %25
117: ; preds = %34, %25
%118 = load i8*, i8** %7
%119 = call i32 @free(i8* %118)
br label %120
120: ; preds = %117, %23, %13
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"{$\00"
@.str.1 = [12 x i8] c"IncludeCGI(\00"
@.str.2 = [12 x i8] c"IncludeEXE(\00"
define void @PrintForm(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = bitcast i8** %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = call i32 @GetFormData(i8* %0, i8** %2)
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %75, label %9
9: ; preds = %1
%10 = call i64 @strlen(i8* %7)
%11 = add nsw i64 %10, 1
%12 = call i64 @malloc(i64 %11)
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i64 %12, 0
br i1 %14, label %75, label %15
15: ; preds = %9
%16 = load i8, i8* %7
%17 = icmp eq i8 %16, 0
br i1 %17, label %73, label %18
18: ; preds = %15, %69
%19 = phi i8* [ %70, %69 ], [ %7, %15 ]
%20 = call i8* @strstr(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @printf(i8* %19)
br label %73
24: ; preds = %18
%25 = ptrtoint i8* %20 to i64
%26 = ptrtoint i8* %19 to i64
%27 = sub i64 %25, %26
%28 = trunc i64 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = call i32 @strncpy(i8* %13, i8* %19, i32 %28)
%32 = shl i64 %27, 32
%33 = ashr exact i64 %32, 32
%34 = getelementptr inbounds i8, i8* %13, i64 %33
store i8 0, i8* %34
%35 = call i32 @printStr(i8* %13)
br label %36
36: ; preds = %30, %24
%37 = call i8* @strchr(i8* %20, i8 signext 125)
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %69
41: ; preds = %36
%42 = ptrtoint i8* %37 to i64
%43 = sub i64 %42, %25
%44 = trunc i64 %43 to i32
%45 = add i32 %44, -2
%46 = icmp eq i32 %45, 0
br i1 %46, label %67, label %47
47: ; preds = %41
%48 = getelementptr inbounds i8, i8* %20, i64 2
%49 = call i32 @strncpy(i8* %13, i8* %48, i32 %45)
%50 = sext i32 %45 to i64
%51 = getelementptr inbounds i8, i8* %13, i64 %50
store i8 0, i8* %51
%52 = call i64 @strncasecmp(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 11)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @IncludeCGI(i8* %13, i32* null)
br label %67
56: ; preds = %47
%57 = call i64 @strncasecmp(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 11)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 @IncludeEXE(i8* %13, i32* null)
br label %67
61: ; preds = %56
%62 = call i32 @GetEnvData(i8* %13, i8** %3)
%63 = load i8*, i8** %3
%64 = icmp eq i8* %63, null
br i1 %64, label %67, label %65
65: ; preds = %61
%66 = call i32 @printStr(i8* %63)
br label %67
67: ; preds = %54, %61, %65, %59, %41
%68 = getelementptr inbounds i8, i8* %37, i64 1
br label %69
69: ; preds = %39, %67
%70 = phi i8* [ inttoptr (i64 2 to i8*), %39 ], [ %68, %67 ]
%71 = load i8, i8* %70
%72 = icmp eq i8 %71, 0
br i1 %72, label %73, label %18
73: ; preds = %69, %15, %22
%74 = call i32 @free(i8* %13)
br label %75
75: ; preds = %9, %1, %73
ret void
}