#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;
  }
  system("echo 1 > /tmp/uploadConfigOK");
  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/proceeding2.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    152d <main+0x37d>
lea    0xf14(%rip),%rdi
call   1060 <system@plt>
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    0xe94(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    12cb <main+0x11b>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
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    0xeab(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
lea    0xe99(%rip),%rsi
call   1090 <strncasecmp@plt>
cmp    $0x0,%rax
je     1324 <main+0x174>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    0xe68(%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    137b <main+0x1cb>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
mov    -0x50(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xe47(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%edx
lea    0xe35(%rip),%rsi
call   1090 <strncasecmp@plt>
cmp    $0x0,%rax
je     13ca <main+0x21a>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
lea    0xe0c(%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    0xd30(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    142f <main+0x27f>
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xcf0(%rip),%rdx
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    146f <main+0x2bf>
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
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    14aa <main+0x2fa>
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
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    14dc <main+0x32c>
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
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     150e <main+0x35e>
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
lea    0xcd2(%rip),%rdi
call   1060 <system@plt>
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    152d <main+0x37d>
lea    0xd43(%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    0x1064(%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    13e6 <main+0x226>
mov    %eax,%r13d
lea    0xf00(%rip),%rdi
call   1070 <system@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   10c0 <getMemInFile@plt>
mov    %rax,%r14
mov    %r13d,%ebp
add    $0x2,%ebp
lea    0xe96(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13d8 <main+0x218>
mov    %eax,%r15d
mov    %eax,%edx
sub    %ebp,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10c0 <getMemInFile@plt>
mov    %rax,%r12
lea    0xec8(%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    13d8 <main+0x218>
lea    0xea3(%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    130b <main+0x14b>
lea    0xf8f(%rip),%rdi
call   1050 <puts@plt>
jmp    13e6 <main+0x226>
mov    %rax,%rbp
add    $0x2,%rbp
lea    0xe86(%rip),%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
lea    0xe77(%rip),%rsi
mov    %eax,%edx
call   10a0 <strncasecmp@plt>
test   %rax,%rax
jne    13d8 <main+0x218>
lea    0xe60(%rip),%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
call   1040 <free@plt>
add    $0x2,%r15d
lea    0xdc3(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13d8 <main+0x218>
add    $0x2,%eax
lea    0xda4(%rip),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%ecx
call   10b0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13d8 <main+0x218>
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     13d8 <main+0x218>
sub    %ebp,%eax
add    $0xfffffffc,%eax
cmp    $0xf4241,%eax
jge    13d8 <main+0x218>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   10d0 <import@plt>
test   %eax,%eax
jne    13d8 <main+0x218>
lea    0xddf(%rip),%rdi
call   1070 <system@plt>
lea    0xde7(%rip),%rdi
jmp    13df <main+0x21f>
lea    0xd3e(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe4c(%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 = [29 x i8] c"echo 1 > /tmp/uploadConfigOK\00"
@.str.8 = [32 x i8] c"content-disposition: form-data;\00"
@.str.9 = [34 x i8] c"dont support multi-field upload.\0A\00"
@.str.10 = [10 x i8] c"filename=\00"
@.str.11 = [20 x i8] c"sleep 3 && reboot &\00"
@.str.12 = [124 x i8] c"</body> <script>function waitingpage(){top.location.href = '/local/advance/proceeding2.asp';}waitingpage();</script></html>\00"
@.str.13 = [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 %143
33: ; preds = %26
%34 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = sub nsw i32 %35, %36
store i32 %37, i32* %11
%38 = load i8*, i8** %12
%39 = load i32, i32* %8
%40 = load i32, i32* %11
%41 = call i8* @getMemInFile(i8* %38, i32 %39, i32 %40)
store i8* %41, i8** %10
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 2
store i32 %43, i32* %8
%44 = load i8*, i8** %12
%45 = load i32, i32* %8
%46 = call i32 @findStrInFile(i8* %44, i32 %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %46, i32* %9
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %33
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
50: ; preds = %33
%51 = load i8*, i8** %12
%52 = load i32, i32* %8
%53 = load i32, i32* %9
%54 = load i32, i32* %8
%55 = sub nsw i32 %53, %54
%56 = call i8* @getMemInFile(i8* %51, i32 %52, i32 %55)
store i8* %56, i8** %15
%57 = load i8*, i8** %15
%58 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%59 = call i64 @strncasecmp(i8* %57, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %50
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
63: ; preds = %50
%64 = load i8*, i8** %15
%65 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8* %68, i8** %16
%69 = load i8*, i8** %16
%70 = call i8* @strchr(i8* %69, i8 signext 59)
store i8* %70, i8** %16
%71 = icmp ne i8* %70, null
br i1 %71, label %74, label %72
72: ; preds = %63
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %143
74: ; preds = %63
%75 = load i8*, i8** %16
%76 = getelementptr inbounds i8, i8* %75, i64 2
store i8* %76, i8** %17
%77 = load i8*, i8** %17
%78 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%79 = call i64 @strncasecmp(i8* %77, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %74
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
83: ; preds = %74
%84 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%85 = load i8*, i8** %17
%86 = sext i32 %84 to i64
%87 = getelementptr inbounds i8, i8* %85, i64 %86
store i8* %87, i8** %17
%88 = load i8*, i8** %15
%89 = call i32 @free(i8* %88)
%90 = load i32, i32* %9
%91 = add nsw i32 %90, 2
store i32 %91, i32* %8
%92 = load i8*, i8** %12
%93 = load i32, i32* %8
%94 = call i32 @findStrInFile(i8* %92, i32 %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %94, i32* %9
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %83
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
98: ; preds = %83
%99 = load i32, i32* %9
%100 = add nsw i32 %99, 2
store i32 %100, i32* %8
%101 = load i8*, i8** %12
%102 = load i32, i32* %8
%103 = call i32 @findStrInFile(i8* %101, i32 %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %103, i32* %9
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %107
105: ; preds = %98
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
107: ; preds = %98
%108 = load i32, i32* %9
%109 = add nsw i32 %108, 2
store i32 %109, i32* %6
%110 = load i8*, i8** %12
%111 = load i32, i32* %6
%112 = load i8*, i8** %10
%113 = load i32, i32* %11
%114 = call i32 @findStrInFile(i8* %110, i32 %111, i8* %112, i32 %113)
store i32 %114, i32* %7
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %118
116: ; preds = %107
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
118: ; preds = %107
%119 = load i32, i32* %7
%120 = sub nsw i32 %119, 2
store i32 %120, i32* %7
%121 = load i32, i32* %7
%122 = load i32, i32* %6
%123 = sub nsw i32 %121, %122
store i32 %123, i32* %13
%124 = load i32, i32* %13
%125 = icmp sgt i32 %124, 1000000
br i1 %125, label %126, label %128
126: ; preds = %118
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
128: ; preds = %118
%129 = load i8*, i8** %12
%130 = load i32, i32* %6
%131 = load i32, i32* %7
%132 = load i32, i32* %6
%133 = sub nsw i32 %131, %132
%134 = call i32 @import(i8* %129, i32 %130, i32 %133)
store i32 %134, i32* %14
%135 = load i32, i32* %14
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %139
137: ; preds = %128
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %143
139: ; preds = %128
%140 = call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.12, i64 0, i64 0))
br label %142
142: ; preds = %139
br label %143
143: ; preds = %142, %137, %126, %116, %105, %96, %81, %72, %61, %48, %31
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0))
%145 = load i8*, i8** %10
%146 = call i32 @free(i8* %145)
%147 = 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 = [29 x i8] c"echo 1 > /tmp/uploadConfigOK\00"
@.str.8 = [32 x i8] c"content-disposition: form-data;\00"
@.str.10 = [10 x i8] c"filename=\00"
@.str.11 = [20 x i8] c"sleep 3 && reboot &\00"
@.str.12 = [124 x i8] c"</body> <script>function waitingpage(){top.location.href = '/local/advance/proceeding2.asp';}waitingpage();</script></html>\00"
@.str.13 = [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.14 = [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 %81
15: ; preds = %10
%16 = tail call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%17 = tail call i8* @getMemInFile(i8* %3, i32 0, i32 %11)
%18 = add nsw i32 %11, 2
%19 = tail call i32 @findStrInFile(i8* %3, i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
23: ; preds = %15
%24 = sub nsw i32 %19, %18
%25 = tail call i8* @getMemInFile(i8* %3, i32 %18, i32 %24)
%26 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%27 = tail call i64 @strncasecmp(i8* %25, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
31: ; preds = %23
%32 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %25, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = tail call i8* @strchr(i8* %35, i8 signext 59)
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.14, i64 0, i64 0))
br label %81
40: ; preds = %31
%41 = getelementptr inbounds i8, i8* %36, i64 2
%42 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%43 = tail call i64 @strncasecmp(i8* %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %40
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
47: ; preds = %40
%48 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%49 = tail call i32 @free(i8* %25)
%50 = add nsw i32 %19, 2
%51 = tail call i32 @findStrInFile(i8* %3, i32 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
55: ; preds = %47
%56 = add nsw i32 %51, 2
%57 = tail call i32 @findStrInFile(i8* %3, i32 %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
61: ; preds = %55
%62 = add nsw i32 %57, 2
%63 = tail call i32 @findStrInFile(i8* %3, i32 %62, i8* %17, i32 %11)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
67: ; preds = %61
%68 = sub i32 -4, %57
%69 = add i32 %68, %63
%70 = icmp sgt i32 %69, 1000000
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
73: ; preds = %67
%74 = tail call i32 @import(i8* %3, i32 %62, i32 %69)
%75 = icmp eq i32 %74, 0
br i1 %75, label %78, label %76
76: ; preds = %73
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
br label %81
78: ; preds = %73
%79 = tail call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @.str.12, i64 0, i64 0))
br label %81
81: ; preds = %78, %76, %71, %65, %59, %53, %45, %38, %29, %21, %13
%82 = phi i8* [ undef, %13 ], [ %17, %21 ], [ %17, %29 ], [ %17, %45 ], [ %17, %53 ], [ %17, %59 ], [ %17, %65 ], [ %17, %71 ], [ %17, %76 ], [ %17, %78 ], [ %17, %38 ]
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0))
%84 = tail call i32 @free(i8* %82)
%85 = tail call i32 @exit(i32 0)
unreachable
}