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

/* 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*/ fprintStr(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
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 FprintForm(FILE *fp, 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) {
      fprintStr(fp, p);
      break;
    } else {
      len = q - p;
      if (len) {
        strncpy(szTmp, p, len);
        szTmp[len] = '\0';
        fprintStr(fp, szTmp);
      }
      p = strchr(q, '}');
      if (p == NULL) {
        fprintStr(fp, "{$");
        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, fp);
          } else if (strncasecmp(szTmp, "IncludeEXE(", strlen("IncludeEXE(")) ==
                     0) {
            IncludeEXE(szTmp, fp);
          } else {
            GetEnvData(szTmp, &szValue);
            if (szValue != NULL) {
              fprintStr(fp, szValue);
            }
          }
        }
        p += 1;
      }
    }
  }
  free(szTmp);
}


x86 assembly (clang, -O0):
<FprintForm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <GetFormData@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11ed <FprintForm+0x2d>
jmp    13f5 <FprintForm+0x235>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    121e <FprintForm+0x5e>
jmp    13f5 <FprintForm+0x235>
jmp    1223 <FprintForm+0x63>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     13ec <FprintForm+0x22c>
mov    -0x20(%rbp),%rdi
lea    0xdc5(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1261 <FprintForm+0xa1>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <fprintStr@plt>
jmp    13ec <FprintForm+0x22c>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12a2 <FprintForm+0xe2>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1080 <fprintStr@plt>
mov    -0x28(%rbp),%rdi
mov    $0x7d,%esi
call   1070 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12e0 <FprintForm+0x120>
mov    -0x8(%rbp),%rdi
lea    0xd36(%rip),%rsi
call   1080 <fprintStr@plt>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    13e2 <FprintForm+0x222>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
sub    $0x2,%rax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     13d6 <FprintForm+0x216>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x2,%rsi
mov    -0x2c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xcd8(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xcc5(%rip),%rsi
call   10c0 <strncasecmp@plt>
cmp    $0x0,%rax
jne    135f <FprintForm+0x19f>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10d0 <IncludeCGI@plt>
jmp    13d1 <FprintForm+0x211>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xca1(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rdx
lea    0xc8e(%rip),%rsi
call   10c0 <strncasecmp@plt>
cmp    $0x0,%rax
jne    13a2 <FprintForm+0x1e2>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10a0 <IncludeEXE@plt>
jmp    13cc <FprintForm+0x20c>
mov    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1090 <GetEnvData@plt>
cmpq   $0x0,-0x40(%rbp)
je     13c7 <FprintForm+0x207>
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1080 <fprintStr@plt>
jmp    13cc <FprintForm+0x20c>
jmp    13d1 <FprintForm+0x211>
jmp    13d6 <FprintForm+0x216>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    13e7 <FprintForm+0x227>
jmp    1223 <FprintForm+0x63>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FprintForm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1050 <GetFormData@plt>
mov    0x10(%rsp),%rbx
test   %rbx,%rbx
je     135b <FprintForm+0x19b>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     135b <FprintForm+0x19b>
mov    %rax,%r15
cmpb   $0x0,(%rbx)
je     1353 <FprintForm+0x193>
lea    0xde4(%rip),%r13
jmp    1239 <FprintForm+0x79>
mov    %r15,%rdi
mov    %r14,%rsi
call   10d0 <IncludeCGI@plt>
add    $0x1,%rbx
mov    %rbp,%r13
cmpb   $0x0,(%rbx)
je     1353 <FprintForm+0x193>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10e0 <strstr@plt>
test   %rax,%rax
je     1348 <FprintForm+0x188>
mov    %rax,%r12
mov    %rax,%rbp
sub    %rbx,%rbp
test   %ebp,%ebp
je     127a <FprintForm+0xba>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r15,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <fprintStr@plt>
mov    %r12,%rdi
mov    $0x7d,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1320 <FprintForm+0x160>
mov    %rax,%rbx
mov    %r13,%rbp
mov    %ebx,%r13d
sub    %r12d,%r13d
add    $0xfffffffe,%r13d
je     1229 <FprintForm+0x69>
add    $0x2,%r12
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1040 <strncpy@plt>
movslq %r13d,%rax
movb   $0x0,(%r15,%rax,1)
mov    $0xb,%edx
mov    %r15,%rdi
lea    0xd38(%rip),%rsi
call   10c0 <strncasecmp@plt>
test   %rax,%rax
je     121e <FprintForm+0x5e>
mov    $0xb,%edx
mov    %r15,%rdi
lea    0xd27(%rip),%rsi
call   10c0 <strncasecmp@plt>
mov    %r15,%rdi
test   %rax,%rax
je     133b <FprintForm+0x17b>
lea    0x8(%rsp),%rsi
call   1090 <GetEnvData@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     1229 <FprintForm+0x69>
mov    %r14,%rdi
call   1080 <fprintStr@plt>
jmp    1229 <FprintForm+0x69>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
call   1080 <fprintStr@plt>
mov    $0x2,%ebx
cmpb   $0x0,(%rbx)
jne    1239 <FprintForm+0x79>
jmp    1353 <FprintForm+0x193>
mov    %r14,%rsi
call   10a0 <IncludeEXE@plt>
jmp    1229 <FprintForm+0x69>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <fprintStr@plt>
mov    %r15,%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 @FprintForm(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @GetFormData(i8* %11, i8** %5)
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
br label %128
16: ; preds = %2
%17 = load i8*, i8** %5
store i8* %17, i8** %6
%18 = load i8*, i8** %5
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %19, 1
%21 = call i64 @malloc(i64 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %16
br label %128
26: ; preds = %16
br label %27
27: ; preds = %124, %26
%28 = load i8*, i8** %6
%29 = load i8, i8* %28
%30 = icmp ne i8 %29, 0
br i1 %30, label %31, label %125
31: ; preds = %27
%32 = load i8*, i8** %6
%33 = call i8* @strstr(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %33, i8** %7
%34 = load i8*, i8** %7
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %40
36: ; preds = %31
%37 = load i32*, i32** %3
%38 = load i8*, i8** %6
%39 = call i32 @fprintStr(i32* %37, i8* %38)
br label %125
40: ; preds = %31
%41 = load i8*, i8** %7
%42 = load i8*, i8** %6
%43 = ptrtoint i8* %41 to i64
%44 = ptrtoint i8* %42 to i64
%45 = sub i64 %43, %44
%46 = trunc i64 %45 to i32
store i32 %46, i32* %8
%47 = load i32, i32* %8
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %61
49: ; preds = %40
%50 = load i8*, i8** %9
%51 = load i8*, i8** %6
%52 = load i32, i32* %8
%53 = call i32 @strncpy(i8* %50, i8* %51, i32 %52)
%54 = load i8*, i8** %9
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 0, i8* %57
%58 = load i32*, i32** %3
%59 = load i8*, i8** %9
%60 = call i32 @fprintStr(i32* %58, i8* %59)
br label %61
61: ; preds = %49, %40
%62 = load i8*, i8** %7
%63 = call i8* @strchr(i8* %62, i8 signext 125)
store i8* %63, i8** %6
%64 = load i8*, i8** %6
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %71
66: ; preds = %61
%67 = load i32*, i32** %3
%68 = call i32 @fprintStr(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%69 = load i8*, i8** %6
%70 = getelementptr inbounds i8, i8* %69, i64 2
store i8* %70, i8** %6
br label %123
71: ; preds = %61
%72 = load i8*, i8** %6
%73 = load i8*, i8** %7
%74 = ptrtoint i8* %72 to i64
%75 = ptrtoint i8* %73 to i64
%76 = sub i64 %74, %75
%77 = sub nsw i64 %76, 2
%78 = trunc i64 %77 to i32
store i32 %78, i32* %8
%79 = load i32, i32* %8
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %120
81: ; preds = %71
%82 = load i8*, i8** %9
%83 = load i8*, i8** %7
%84 = getelementptr inbounds i8, i8* %83, i64 2
%85 = load i32, i32* %8
%86 = call i32 @strncpy(i8* %82, i8* %84, i32 %85)
%87 = load i8*, i8** %9
%88 = load i32, i32* %8
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
store i8 0, i8* %90
%91 = load i8*, i8** %9
%92 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%93 = call i64 @strncasecmp(i8* %91, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %92)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %81
%96 = load i8*, i8** %9
%97 = load i32*, i32** %3
%98 = call i32 @IncludeCGI(i8* %96, i32* %97)
br label %119
99: ; preds = %81
%100 = load i8*, i8** %9
%101 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%102 = call i64 @strncasecmp(i8* %100, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %101)
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %99
%105 = load i8*, i8** %9
%106 = load i32*, i32** %3
%107 = call i32 @IncludeEXE(i8* %105, i32* %106)
br label %118
108: ; preds = %99
%109 = load i8*, i8** %9
%110 = call i32 @GetEnvData(i8* %109, i8** %10)
%111 = load i8*, i8** %10
%112 = icmp ne i8* %111, null
br i1 %112, label %113, label %117
113: ; preds = %108
%114 = load i32*, i32** %3
%115 = load i8*, i8** %10
%116 = call i32 @fprintStr(i32* %114, i8* %115)
br label %117
117: ; preds = %113, %108
br label %118
118: ; preds = %117, %104
br label %119
119: ; preds = %118, %95
br label %120
120: ; preds = %119, %71
%121 = load i8*, i8** %6
%122 = getelementptr inbounds i8, i8* %121, i64 1
store i8* %122, i8** %6
br label %123
123: ; preds = %120, %66
br label %124
124: ; preds = %123
br label %27
125: ; preds = %36, %27
%126 = load i8*, i8** %9
%127 = call i32 @free(i8* %126)
br label %128
128: ; preds = %125, %25, %15
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 @FprintForm(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = call i32 @GetFormData(i8* %1, i8** %3)
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %76, label %10
10: ; preds = %2
%11 = call i64 @strlen(i8* %8)
%12 = add nsw i64 %11, 1
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %76, label %16
16: ; preds = %10
%17 = load i8, i8* %8
%18 = icmp eq i8 %17, 0
br i1 %18, label %74, label %19
19: ; preds = %16, %70
%20 = phi i8* [ %71, %70 ], [ %8, %16 ]
%21 = call i8* @strstr(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @fprintStr(i32* %0, i8* %20)
br label %74
25: ; preds = %19
%26 = ptrtoint i8* %21 to i64
%27 = ptrtoint i8* %20 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %25
%32 = call i32 @strncpy(i8* %14, i8* %20, i32 %29)
%33 = shl i64 %28, 32
%34 = ashr exact i64 %33, 32
%35 = getelementptr inbounds i8, i8* %14, i64 %34
store i8 0, i8* %35
%36 = call i32 @fprintStr(i32* %0, i8* %14)
br label %37
37: ; preds = %31, %25
%38 = call i8* @strchr(i8* %21, i8 signext 125)
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @fprintStr(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %70
42: ; preds = %37
%43 = ptrtoint i8* %38 to i64
%44 = sub i64 %43, %26
%45 = trunc i64 %44 to i32
%46 = add i32 %45, -2
%47 = icmp eq i32 %46, 0
br i1 %47, label %68, label %48
48: ; preds = %42
%49 = getelementptr inbounds i8, i8* %21, i64 2
%50 = call i32 @strncpy(i8* %14, i8* %49, i32 %46)
%51 = sext i32 %46 to i64
%52 = getelementptr inbounds i8, i8* %14, i64 %51
store i8 0, i8* %52
%53 = call i64 @strncasecmp(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 11)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %48
%56 = call i32 @IncludeCGI(i8* %14, i32* %0)
br label %68
57: ; preds = %48
%58 = call i64 @strncasecmp(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 11)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @IncludeEXE(i8* %14, i32* %0)
br label %68
62: ; preds = %57
%63 = call i32 @GetEnvData(i8* %14, i8** %4)
%64 = load i8*, i8** %4
%65 = icmp eq i8* %64, null
br i1 %65, label %68, label %66
66: ; preds = %62
%67 = call i32 @fprintStr(i32* %0, i8* %64)
br label %68
68: ; preds = %55, %62, %66, %60, %42
%69 = getelementptr inbounds i8, i8* %38, i64 1
br label %70
70: ; preds = %40, %68
%71 = phi i8* [ inttoptr (i64 2 to i8*), %40 ], [ %69, %68 ]
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 0
br i1 %73, label %74, label %19
74: ; preds = %70, %16, %23
%75 = call i32 @free(i8* %14)
br label %76
76: ; preds = %10, %2, %74
ret void
}