#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*/ LINUX_REBOOT_CMD_RESTART;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int findStrInFile(char *, int, char *, int);
int /*<<< orphan*/ free(char *);
char *getMemInFile(char *, int, int);
char *getenv(char *);
int /*<<< orphan*/ import(char *, int, int);
int /*<<< orphan*/ javascriptUpdate();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
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");
  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=utf-8\">\n</head>\n<body> <h1> Import Settings</h1>");
  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("%s", "RFC1867 ....");
    return -1;
  }
  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("%s", "RFC1867 ....");
    goto err;
  }
  line = getMemInFile(filename, line_begin, line_end - line_begin);
  if (strncasecmp(line, "content-disposition: form-data;",
                  strlen("content-disposition: form-data;"))) {
    printf("%s", "RFC1867 ....");
    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("%s", "RFC1867 ....");
    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("%s", "RFC1867 ....");
    goto err;
  }
  line_begin = line_end + 2;
  if ((line_end = findStrInFile(filename, line_begin, "\r\n", 2)) == -1) {
    printf("%s", "RFC1867 ....");
    goto err;
  }
  file_begin = line_end + 2;
  if ((file_end =
           findStrInFile(filename, file_begin, boundary, boundary_len)) == -1) {
    printf("%s", "RFC1867 ....");
    goto err;
  }
  file_end -= 2;
  import(filename, file_begin, file_end - file_begin);
  printf("done");
  javascriptUpdate();
  printf("</body></html>\n");
  sleep(3);
  reboot(LINUX_REBOOT_CMD_RESTART);
err:
  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    0xe13(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
lea    0xe48(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1246 <main+0x76>
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    155d <main+0x38d>
movl   $0x0,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xeef(%rip),%rdx
mov    $0x2,%ecx
call   1090 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    1292 <main+0xc2>
lea    0xed5(%rip),%rdi
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    155d <main+0x38d>
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   10a0 <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    0xe85(%rip),%rdx
mov    $0x2,%ecx
call   1090 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    12f5 <main+0x125>
lea    0xe6b(%rip),%rdi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x37d>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
sub    -0x1c(%rbp),%edx
call   10a0 <getMemInFile@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xe43(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%edx
lea    0xe31(%rip),%rsi
call   1080 <strncasecmp@plt>
cmp    $0x0,%rax
je     1355 <main+0x185>
lea    0xe0b(%rip),%rdi
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x37d>
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xdf9(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0x3b,%esi
call   1060 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    13ac <main+0x1dc>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x37d>
mov    -0x48(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    0xdd8(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%edx
lea    0xdc6(%rip),%rsi
call   1080 <strncasecmp@plt>
cmp    $0x0,%rax
je     1402 <main+0x232>
lea    0xd5e(%rip),%rdi
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x37d>
lea    0xd96(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%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    0xd0c(%rip),%rdx
mov    $0x2,%ecx
call   1090 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    146e <main+0x29e>
lea    0xcf2(%rip),%rdi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x37d>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xcc5(%rip),%rdx
mov    $0x2,%ecx
call   1090 <findStrInFile@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    14b5 <main+0x2e5>
lea    0xcab(%rip),%rdi
lea    0xca7(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <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   1090 <findStrInFile@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    14f7 <main+0x327>
lea    0xc69(%rip),%rdi
lea    0xc65(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x37d>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
call   10c0 <import@plt>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   10b0 <javascriptUpdate@plt>
lea    0xc80(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x3,%edi
call   10f0 <sleep@plt>
mov    0x2aa2(%rip),%rax
mov    (%rax),%edi
call   10e0 <reboot@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe0e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe44(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe03(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %rbx,%rbx
je     125c <main+0x7c>
lea    0xefd(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
jne    127c <main+0x9c>
lea    0xee5(%rip),%rdi
lea    0xee1(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1268 <main+0x88>
lea    0xf0d(%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
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   10b0 <getMemInFile@plt>
mov    %rax,%r14
mov    %ebp,%r12d
add    $0x2,%r12d
lea    0xe93(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x1dc>
mov    %eax,%r15d
mov    %eax,%edx
sub    %r12d,%edx
mov    %rbx,%rdi
mov    %r12d,%esi
call   10b0 <getMemInFile@plt>
mov    %rax,%r12
lea    0xe70(%rip),%r13
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1090 <strncasecmp@plt>
test   %rax,%rax
jne    13bc <main+0x1dc>
lea    0xe4b(%rip),%rdi
call   1060 <strlen@plt>
cltq
lea    (%r12,%rax,1),%rdi
add    $0x1,%rdi
mov    $0x3b,%esi
call   1070 <strchr@plt>
test   %rax,%rax
jne    1325 <main+0x145>
lea    0xe70(%rip),%rdi
call   1050 <puts@plt>
jmp    13d1 <main+0x1f1>
mov    %rax,%r13
add    $0x2,%r13
lea    0xe2e(%rip),%rdi
call   1060 <strlen@plt>
mov    %r13,%rdi
lea    0xe1f(%rip),%rsi
mov    %eax,%edx
call   1090 <strncasecmp@plt>
test   %rax,%rax
jne    13bc <main+0x1dc>
lea    0xe0c(%rip),%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
call   1040 <free@plt>
add    $0x2,%r15d
lea    0xdc1(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x1dc>
add    $0x2,%eax
lea    0xda2(%rip),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%ecx
call   10a0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x1dc>
mov    %eax,%r15d
lea    0x2(%r15),%r12d
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   10a0 <findStrInFile@plt>
cmp    $0xffffffff,%eax
jne    13e0 <main+0x200>
lea    0xd6e(%rip),%rdi
lea    0xd6a(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
sub    %r15d,%eax
add    $0xfffffffc,%eax
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   10d0 <import@plt>
lea    0xd71(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   10c0 <javascriptUpdate@plt>
lea    0xd9d(%rip),%rdi
call   1050 <puts@plt>
mov    $0x3,%edi
call   1100 <sleep@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
call   10f0 <reboot@plt>
jmp    13d1 <main+0x1f1>

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 = [217 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=utf-8\22>\0A</head>\0A<body> <h1> Import Settings</h1>\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 = [3 x i8] c"%s\00"
@.str.7 = [13 x i8] c"RFC1867 ....\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 = [5 x i8] c"done\00"
@.str.12 = [16 x i8] c"</body></html>\0A\00"
@LINUX_REBOOT_CMD_RESTART = global i32 0
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 i8*
%14 = alloca i8*
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %12
%17 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([217 x i8], [217 x i8]* @.str.3, i64 0, i64 0))
%20 = load i8*, i8** %12
%21 = icmp ne i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %134
24: ; preds = %2
store i32 0, i32* %8
%25 = load i8*, i8** %12
%26 = load i32, i32* %8
%27 = call i32 @findStrInFile(i8* %25, i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %27, i32* %9
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %134
31: ; preds = %24
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = sub nsw i32 %32, %33
store i32 %34, i32* %11
%35 = load i8*, i8** %12
%36 = load i32, i32* %8
%37 = load i32, i32* %11
%38 = call i8* @getMemInFile(i8* %35, i32 %36, i32 %37)
store i8* %38, i8** %10
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 2
store i32 %40, i32* %8
%41 = load i8*, i8** %12
%42 = load i32, i32* %8
%43 = call i32 @findStrInFile(i8* %41, i32 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %43, i32* %9
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %31
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %130
47: ; preds = %31
%48 = load i8*, i8** %12
%49 = load i32, i32* %8
%50 = load i32, i32* %9
%51 = load i32, i32* %8
%52 = sub nsw i32 %50, %51
%53 = call i8* @getMemInFile(i8* %48, i32 %49, i32 %52)
store i8* %53, i8** %13
%54 = load i8*, i8** %13
%55 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%56 = call i64 @strncasecmp(i8* %54, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %47
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %130
60: ; preds = %47
%61 = load i8*, i8** %13
%62 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = getelementptr inbounds i8, i8* %64, i64 1
store i8* %65, i8** %14
%66 = load i8*, i8** %14
%67 = call i8* @strchr(i8* %66, i8 signext 59)
store i8* %67, i8** %14
%68 = icmp ne i8* %67, null
br i1 %68, label %71, label %69
69: ; preds = %60
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %130
71: ; preds = %60
%72 = load i8*, i8** %14
%73 = getelementptr inbounds i8, i8* %72, i64 2
store i8* %73, i8** %15
%74 = load i8*, i8** %15
%75 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%76 = call i64 @strncasecmp(i8* %74, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %75)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %71
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %130
80: ; preds = %71
%81 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%82 = load i8*, i8** %15
%83 = sext i32 %81 to i64
%84 = getelementptr inbounds i8, i8* %82, i64 %83
store i8* %84, i8** %15
%85 = load i8*, i8** %13
%86 = call i32 @free(i8* %85)
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 2
store i32 %88, i32* %8
%89 = load i8*, i8** %12
%90 = load i32, i32* %8
%91 = call i32 @findStrInFile(i8* %89, i32 %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %91, i32* %9
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %95
93: ; preds = %80
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %130
95: ; preds = %80
%96 = load i32, i32* %9
%97 = add nsw i32 %96, 2
store i32 %97, i32* %8
%98 = load i8*, i8** %12
%99 = load i32, i32* %8
%100 = call i32 @findStrInFile(i8* %98, i32 %99, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i32 %100, i32* %9
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %104
102: ; preds = %95
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %130
104: ; preds = %95
%105 = load i32, i32* %9
%106 = add nsw i32 %105, 2
store i32 %106, i32* %6
%107 = load i8*, i8** %12
%108 = load i32, i32* %6
%109 = load i8*, i8** %10
%110 = load i32, i32* %11
%111 = call i32 @findStrInFile(i8* %107, i32 %108, i8* %109, i32 %110)
store i32 %111, i32* %7
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %115
113: ; preds = %104
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %130
115: ; preds = %104
%116 = load i32, i32* %7
%117 = sub nsw i32 %116, 2
store i32 %117, i32* %7
%118 = load i8*, i8** %12
%119 = load i32, i32* %6
%120 = load i32, i32* %7
%121 = load i32, i32* %6
%122 = sub nsw i32 %120, %121
%123 = call i32 @import(i8* %118, i32 %119, i32 %122)
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%125 = call i32 (...) @javascriptUpdate()
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
%127 = call i32 @sleep(i32 3)
%128 = load i32, i32* @LINUX_REBOOT_CMD_RESTART
%129 = call i32 @reboot(i32 %128)
br label %130
130: ; preds = %115, %113, %102, %93, %78, %69, %58, %45
%131 = load i8*, i8** %10
%132 = call i32 @free(i8* %131)
%133 = call i32 @exit(i32 0)
unreachable
134: ; preds = %29, %22
%135 = load i32, i32* %3
ret i32 %135
}

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 = [217 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=utf-8\22>\0A</head>\0A<body> <h1> Import Settings</h1>\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [13 x i8] c"RFC1867 ....\00"
@.str.8 = [32 x i8] c"content-disposition: form-data;\00"
@.str.10 = [10 x i8] c"filename=\00"
@.str.11 = [5 x i8] c"done\00"
@LINUX_REBOOT_CMD_RESTART = global i32 0
@str = [27 x i8] c"failed, can't get env var.\00"
@str.13 = [33 x i8] c"dont support multi-field upload.\00"
@str.14 = [15 x i8] c"</body></html>\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 ([217 x i8], [217 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))
br label %79
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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %79
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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %76
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.8, i64 0, i64 0))
%26 = tail call i64 @strncasecmp(i8* %24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, 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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %76
30: ; preds = %22
%31 = tail call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, 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 %76
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.10, i64 0, i64 0))
%42 = tail call i64 @strncasecmp(i8* %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, 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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %76
46: ; preds = %39
%47 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, 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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %76
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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %76
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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %76
66: ; preds = %60
%67 = sub i32 -4, %56
%68 = add i32 %67, %62
%69 = tail call i32 @import(i8* %3, i32 %61, i32 %68)
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%71 = tail call i32 (...) @javascriptUpdate()
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%73 = tail call i32 @sleep(i32 3)
%74 = load i32, i32* @LINUX_REBOOT_CMD_RESTART
%75 = tail call i32 @reboot(i32 %74)
br label %76
76: ; preds = %66, %64, %58, %52, %44, %37, %28, %20
%77 = tail call i32 @free(i8* %16)
%78 = tail call i32 @exit(i32 0)
unreachable
79: ; preds = %13, %8
ret i32 -1
}