#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*/ exit(int /*<<< orphan*/);
int findStrInFile(char *, int, char *, int);
int /*<<< orphan*/ free(char *);
char *getMemInFile(char *, int, int);
char *getenv(char *);
int import(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int file_begin, file_end;
  int line_begin, line_end;
  char *boundary;
  int boundary_len;
  char *filename = getenv("UPLOAD_FILENAME");
  int file_size, result;
  printf("Server: %s\nPragma: no-cache\nContent-type: text/html\n",
         getenv("SERVER_SOFTWARE"));
  printf("\n<html>\n<head>\n<TITLE>Import Settings</TITLE>\n<link "
         "rel=stylesheet href=/style/normal_ws.css type=text/css>\n<meta "
         "http-equiv=\"content-type\" content=\"text/html; "
         "charset=iso-8859-1\">\n</head>\n<body> ");
  if (!filename) {
    printf("failed, can't get env var.\n");
    return -1;
  }
  line_begin = 0;
  if ((line_end = findStrInFile(filename, line_begin, "\r\n", 2)) == -1) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  boundary_len = line_end - line_begin;
  boundary = getMemInFile(filename, line_begin, boundary_len);
  char *line, *semicolon, *user_filename;
  line_begin = line_end + 2;
  if ((line_end = findStrInFile(filename, line_begin, "\r\n", 2)) == -1) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  line = getMemInFile(filename, line_begin, line_end - line_begin);
  if (strncasecmp(line, "content-disposition: form-data;",
                  strlen("content-disposition: form-data;"))) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  semicolon = line + strlen("content-disposition: form-data;") + 1;
  if (!(semicolon = strchr(semicolon, ';'))) {
    printf("dont support multi-field upload.\n");
    goto err;
  }
  user_filename = semicolon + 2;
  if (strncasecmp(user_filename, "filename=", strlen("filename="))) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  user_filename += strlen("filename=");
  free(line);
  line_begin = line_end + 2;
  if ((line_end = findStrInFile(filename, line_begin, "\r\n", 2)) == -1) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  line_begin = line_end + 2;
  if ((line_end = findStrInFile(filename, line_begin, "\r\n", 2)) == -1) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  file_begin = line_end + 2;
  if ((file_end =
           findStrInFile(filename, file_begin, boundary, boundary_len)) == -1) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  file_end -= 2;
  file_size = file_end - file_begin;
  if (file_size > 1000000) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  }
  result = import(filename, file_begin, file_end - file_begin);
  if (result) {
    printf(
        "<script>parent.upload_message='Not a valid configuration.';</script>");
    goto err;
  } else {
    system("sleep 3 && reboot &");
    printf("</body> <script>function waitingpage(){top.location.href = "
           "'/local/advance/proceeding.asp';}waitingpage();</script></html>");
  }
err:
  printf("<script>parent.reload_configuration_backup_page();</script>");
  free(boundary);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe33(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
lea    0xe68(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1225 <main+0x75>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xffffffff,%eax
add    $0x70,%rsp
pop    %rbp
ret
movl   $0x0,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xefc(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    1263 <main+0xb3>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10b0 <getMemInFile@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xea0(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    12bf <main+0x10f>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
sub    -0x1c(%rbp),%edx
call   10b0 <getMemInFile@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xe9a(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
lea    0xe88(%rip),%rsi
call   1090 <strncasecmp@plt>
cmp    $0x0,%rax
je     1318 <main+0x168>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    0xe57(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    $0x3b,%esi
call   1070 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    136f <main+0x1bf>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x50(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xe36(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%edx
lea    0xe24(%rip),%rsi
call   1090 <strncasecmp@plt>
cmp    $0x0,%rax
je     13be <main+0x20e>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
lea    0xdfb(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xd3c(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    1423 <main+0x273>
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xcfc(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    1463 <main+0x2b3>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    149e <main+0x2ee>
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0xf4240,-0x3c(%rbp)
jle    14d0 <main+0x320>
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
call   10c0 <import@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     1502 <main+0x352>
lea    0xc43(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
lea    0xcc1(%rip),%rdi
call   1060 <system@plt>
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1521 <main+0x371>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe2e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe64(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe23(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
test   %rbx,%rbx
jne    122a <main+0x6a>
lea    0x1046(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xee9(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
jne    1258 <main+0x98>
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    13d9 <main+0x219>
mov    %eax,%r13d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   10c0 <getMemInFile@plt>
mov    %rax,%r14
mov    %r13d,%ebp
add    $0x2,%ebp
lea    0xea3(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13cb <main+0x20b>
mov    %eax,%r15d
mov    %eax,%edx
sub    %ebp,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10c0 <getMemInFile@plt>
mov    %rax,%r12
lea    0xeb8(%rip),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   10a0 <strncasecmp@plt>
test   %rax,%rax
jne    13cb <main+0x20b>
lea    0xe93(%rip),%rdi
call   1060 <strlen@plt>
cltq
lea    (%r12,%rax,1),%rdi
add    $0x1,%rdi
mov    $0x3b,%esi
call   1080 <strchr@plt>
test   %rax,%rax
jne    12fe <main+0x13e>
lea    0xf7e(%rip),%rdi
call   1050 <puts@plt>
jmp    13d9 <main+0x219>
mov    %rax,%rbp
add    $0x2,%rbp
lea    0xe76(%rip),%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
lea    0xe67(%rip),%rsi
mov    %eax,%edx
call   10a0 <strncasecmp@plt>
test   %rax,%rax
jne    13cb <main+0x20b>
lea    0xe50(%rip),%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
call   1040 <free@plt>
add    $0x2,%r15d
lea    0xdd0(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13cb <main+0x20b>
add    $0x2,%eax
lea    0xdb1(%rip),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13cb <main+0x20b>
mov    %eax,%ebp
lea    0x2(%rbp),%r15d
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
mov    %r13d,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13cb <main+0x20b>
sub    %ebp,%eax
add    $0xfffffffc,%eax
cmp    $0xf4241,%eax
jge    13cb <main+0x20b>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   10d0 <import@plt>
test   %eax,%eax
jne    13cb <main+0x20b>
lea    0xdcf(%rip),%rdi
call   1070 <system@plt>
lea    0xdd7(%rip),%rdi
jmp    13d2 <main+0x212>
lea    0xd4b(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"UPLOAD_FILENAME\00"
@.str.1 = [53 x i8] c"Server: %s\0APragma: no-cache\0AContent-type: text/html\0A\00"
@.str.2 = [16 x i8] c"SERVER_SOFTWARE\00"
@.str.3 = [197 x i8] c"\0A<html>\0A<head>\0A<TITLE>Import Settings</TITLE>\0A<link rel=stylesheet href=/style/normal_ws.css type=text/css>\0A<meta http-equiv=\22content-type\22 content=\22text/html; charset=iso-8859-1\22>\0A</head>\0A<body> \00"
@.str.4 = [28 x i8] c"failed, can't get env var.\0A\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [69 x i8] c"<script>parent.upload_message='Not a valid configuration.';</script>\00"
@.str.7 = [32 x i8] c"content-disposition: form-data;\00"
@.str.8 = [34 x i8] c"dont support multi-field upload.\0A\00"
@.str.9 = [10 x i8] c"filename=\00"
@.str.10 = [20 x i8] c"sleep 3 && reboot &\00"
@.str.11 = [123 x i8] c"</body> <script>function waitingpage(){top.location.href = '/local/advance/proceeding.asp';}waitingpage();</script></html>\00"
@.str.12 = [60 x i8] c"<script>parent.reload_configuration_backup_page();</script>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %12
%19 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([197 x i8], [197 x i8]* @.str.3, i64 0, i64 0))
%22 = load i8*, i8** %12
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
ret i32 -1
26: ; preds = %2
store i32 0, i32* %8
%27 = load i8*, i8** %12
%28 = load i32, i32* %8
%29 = call i32 @findStrInFile(i8* %27, i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %29, i32* %9
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
33: ; preds = %26
%34 = load i32, i32* %9
%35 = load i32, i32* %8
%36 = sub nsw i32 %34, %35
store i32 %36, i32* %11
%37 = load i8*, i8** %12
%38 = load i32, i32* %8
%39 = load i32, i32* %11
%40 = call i8* @getMemInFile(i8* %37, i32 %38, i32 %39)
store i8* %40, i8** %10
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 2
store i32 %42, i32* %8
%43 = load i8*, i8** %12
%44 = load i32, i32* %8
%45 = call i32 @findStrInFile(i8* %43, i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %45, i32* %9
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
49: ; preds = %33
%50 = load i8*, i8** %12
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = load i32, i32* %8
%54 = sub nsw i32 %52, %53
%55 = call i8* @getMemInFile(i8* %50, i32 %51, i32 %54)
store i8* %55, i8** %15
%56 = load i8*, i8** %15
%57 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%58 = call i64 @strncasecmp(i8* %56, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %49
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
62: ; preds = %49
%63 = load i8*, i8** %15
%64 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = getelementptr inbounds i8, i8* %66, i64 1
store i8* %67, i8** %16
%68 = load i8*, i8** %16
%69 = call i8* @strchr(i8* %68, i8 signext 59)
store i8* %69, i8** %16
%70 = icmp ne i8* %69, null
br i1 %70, label %73, label %71
71: ; preds = %62
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %142
73: ; preds = %62
%74 = load i8*, i8** %16
%75 = getelementptr inbounds i8, i8* %74, i64 2
store i8* %75, i8** %17
%76 = load i8*, i8** %17
%77 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%78 = call i64 @strncasecmp(i8* %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %73
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
82: ; preds = %73
%83 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%84 = load i8*, i8** %17
%85 = sext i32 %83 to i64
%86 = getelementptr inbounds i8, i8* %84, i64 %85
store i8* %86, i8** %17
%87 = load i8*, i8** %15
%88 = call i32 @free(i8* %87)
%89 = load i32, i32* %9
%90 = add nsw i32 %89, 2
store i32 %90, i32* %8
%91 = load i8*, i8** %12
%92 = load i32, i32* %8
%93 = call i32 @findStrInFile(i8* %91, i32 %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %93, i32* %9
%94 = icmp eq i32 %93, -1
br i1 %94, label %95, label %97
95: ; preds = %82
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
97: ; preds = %82
%98 = load i32, i32* %9
%99 = add nsw i32 %98, 2
store i32 %99, i32* %8
%100 = load i8*, i8** %12
%101 = load i32, i32* %8
%102 = call i32 @findStrInFile(i8* %100, i32 %101, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %102, i32* %9
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %106
104: ; preds = %97
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
106: ; preds = %97
%107 = load i32, i32* %9
%108 = add nsw i32 %107, 2
store i32 %108, i32* %6
%109 = load i8*, i8** %12
%110 = load i32, i32* %6
%111 = load i8*, i8** %10
%112 = load i32, i32* %11
%113 = call i32 @findStrInFile(i8* %109, i32 %110, i8* %111, i32 %112)
store i32 %113, i32* %7
%114 = icmp eq i32 %113, -1
br i1 %114, label %115, label %117
115: ; preds = %106
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
117: ; preds = %106
%118 = load i32, i32* %7
%119 = sub nsw i32 %118, 2
store i32 %119, i32* %7
%120 = load i32, i32* %7
%121 = load i32, i32* %6
%122 = sub nsw i32 %120, %121
store i32 %122, i32* %13
%123 = load i32, i32* %13
%124 = icmp sgt i32 %123, 1000000
br i1 %124, label %125, label %127
125: ; preds = %117
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
127: ; preds = %117
%128 = load i8*, i8** %12
%129 = load i32, i32* %6
%130 = load i32, i32* %7
%131 = load i32, i32* %6
%132 = sub nsw i32 %130, %131
%133 = call i32 @import(i8* %128, i32 %129, i32 %132)
store i32 %133, i32* %14
%134 = load i32, i32* %14
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %127
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %142
138: ; preds = %127
%139 = call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.11, i64 0, i64 0))
br label %141
141: ; preds = %138
br label %142
142: ; preds = %141, %136, %125, %115, %104, %95, %80, %71, %60, %47, %31
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.12, i64 0, i64 0))
%144 = load i8*, i8** %10
%145 = call i32 @free(i8* %144)
%146 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [16 x i8] c"UPLOAD_FILENAME\00"
@.str.1 = [53 x i8] c"Server: %s\0APragma: no-cache\0AContent-type: text/html\0A\00"
@.str.2 = [16 x i8] c"SERVER_SOFTWARE\00"
@.str.3 = [197 x i8] c"\0A<html>\0A<head>\0A<TITLE>Import Settings</TITLE>\0A<link rel=stylesheet href=/style/normal_ws.css type=text/css>\0A<meta http-equiv=\22content-type\22 content=\22text/html; charset=iso-8859-1\22>\0A</head>\0A<body> \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [69 x i8] c"<script>parent.upload_message='Not a valid configuration.';</script>\00"
@.str.7 = [32 x i8] c"content-disposition: form-data;\00"
@.str.9 = [10 x i8] c"filename=\00"
@.str.10 = [20 x i8] c"sleep 3 && reboot &\00"
@.str.11 = [123 x i8] c"</body> <script>function waitingpage(){top.location.href = '/local/advance/proceeding.asp';}waitingpage();</script></html>\00"
@.str.12 = [60 x i8] c"<script>parent.reload_configuration_backup_page();</script>\00"
@str = [27 x i8] c"failed, can't get env var.\00"
@str.13 = [33 x i8] c"dont support multi-field upload.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([197 x i8], [197 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i8* %3, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
ret i32 -1
10: ; preds = %2
%11 = tail call i32 @findStrInFile(i8* %3, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
15: ; preds = %10
%16 = tail call i8* @getMemInFile(i8* %3, i32 0, i32 %11)
%17 = add nsw i32 %11, 2
%18 = tail call i32 @findStrInFile(i8* %3, i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
22: ; preds = %15
%23 = sub nsw i32 %18, %17
%24 = tail call i8* @getMemInFile(i8* %3, i32 %17, i32 %23)
%25 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%26 = tail call i64 @strncasecmp(i8* %24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
30: ; preds = %22
%31 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %24, i64 %32
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = tail call i8* @strchr(i8* %34, i8 signext 59)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0))
br label %80
39: ; preds = %30
%40 = getelementptr inbounds i8, i8* %35, i64 2
%41 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%42 = tail call i64 @strncasecmp(i8* %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
46: ; preds = %39
%47 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%48 = tail call i32 @free(i8* %24)
%49 = add nsw i32 %18, 2
%50 = tail call i32 @findStrInFile(i8* %3, i32 %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
54: ; preds = %46
%55 = add nsw i32 %50, 2
%56 = tail call i32 @findStrInFile(i8* %3, i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
60: ; preds = %54
%61 = add nsw i32 %56, 2
%62 = tail call i32 @findStrInFile(i8* %3, i32 %61, i8* %16, i32 %11)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
66: ; preds = %60
%67 = sub i32 -4, %56
%68 = add i32 %67, %62
%69 = icmp sgt i32 %68, 1000000
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
72: ; preds = %66
%73 = tail call i32 @import(i8* %3, i32 %61, i32 %68)
%74 = icmp eq i32 %73, 0
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %80
77: ; preds = %72
%78 = tail call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([123 x i8], [123 x i8]* @.str.11, i64 0, i64 0))
br label %80
80: ; preds = %77, %75, %70, %64, %58, %52, %44, %37, %28, %20, %13
%81 = phi i8* [ undef, %13 ], [ %16, %20 ], [ %16, %28 ], [ %16, %44 ], [ %16, %52 ], [ %16, %58 ], [ %16, %64 ], [ %16, %70 ], [ %16, %75 ], [ %16, %77 ], [ %16, %37 ]
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.12, i64 0, i64 0))
%83 = tail call i32 @free(i8* %81)
%84 = tail call i32 @exit(i32 0)
unreachable
}