#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 atoi(char *);
int fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
char *getenv(char *);
scalar_t__ malloc(int);
int memcmp(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int main(void) {
  char *buf = NULL;
  char *content_type = NULL;
  char *p1 = NULL;
  char *p2 = NULL;
  char boundary[256] = {0};
  char *content_length = NULL;
  int len = 0;
  char pattern[256] = {0};
  int read_len = 0;
  char *p3 = NULL;
  char *p4 = NULL;
  char *p5 = NULL;
  int ret = 0;
  int i = 0;
  int rest = 0;
  char file_content_type[256] = {0};
  char *file_buf = NULL;
  content_type = getenv("CONTENT_TYPE");
  p1 = strstr(content_type, "multipart/form-data");
  if (p1 != NULL) {
    p2 = strstr(p1, "boundary=");
    if (p2 != NULL) {
      strcpy(boundary, p2 + strlen("boundary="));
      content_length = getenv("CONTENT_LENGTH");
      len = atoi(content_length);
      buf = (char *)malloc(sizeof(char) * (len + 1));
      memset(buf, 0, len + 1);
      read_len = fread(buf, sizeof(char), len, stdin);
      if (len == read_len) {
        strcat(pattern, "--");
        strcat(pattern, boundary);
        p3 = strstr(buf, pattern);
        if (p3 != NULL) {
          p4 = strstr(p3, "Content-Type: ");
          if (p4 != NULL) {
            p5 = strstr(p4, "\r\n\r\n");
            if (p5 != NULL) {
              strncpy(file_content_type, p4 + strlen("Content-Type: "),
                      p5 - (p4 + strlen("Content-Type: ")));
              rest = len - ((p5 + 4) - buf);
              for (i = 0; i < rest; i++) {
                ret = memcmp(p5 + 4 + i, pattern, strlen(pattern));
                if (ret == 0) {
                  file_buf = (char *)malloc(sizeof(char) * (i - 1));
                  memset(file_buf, 0, i - 1);
                  memcpy(file_buf, p5 + 4, i - 2);
                  printf("Content-type: text/plain\n");
                  printf("Content-length: %d\n", i - 2);
                  printf("\n");
                  fwrite(file_buf, sizeof(char), i - 2, stdout);
                  free(file_buf);
                  break;
                }
              }
            }
          }
        }
      }
      free(buf);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3c0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
movq   $0x0,-0x138(%rbp)
movl   $0x0,-0x13c(%rbp)
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
movl   $0x0,-0x244(%rbp)
movq   $0x0,-0x250(%rbp)
movq   $0x0,-0x258(%rbp)
movq   $0x0,-0x260(%rbp)
movl   $0x0,-0x264(%rbp)
movl   $0x0,-0x268(%rbp)
movl   $0x0,-0x26c(%rbp)
lea    -0x370(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
movq   $0x0,-0x378(%rbp)
lea    0xd35(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1698 <main+0x4a8>
mov    -0x20(%rbp),%rdi
lea    0xd23(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1693 <main+0x4a3>
lea    -0x130(%rbp),%rax
mov    %rax,-0x380(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x388(%rbp)
lea    0xcef(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x388(%rbp),%rsi
mov    -0x380(%rbp),%rdi
cltq
add    %rax,%rsi
call   1060 <strcpy@plt>
lea    0xcd5(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x13c(%rbp)
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x13c(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x13c(%rbp),%edx
mov    0x2c35(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fread@plt>
mov    %eax,-0x244(%rbp)
mov    -0x13c(%rbp),%eax
cmp    -0x244(%rbp),%eax
jne    168a <main+0x49a>
lea    -0x240(%rbp),%rdi
lea    0xc55(%rip),%rsi
call   10f0 <strcat@plt>
lea    -0x240(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x250(%rbp)
cmpq   $0x0,-0x250(%rbp)
je     1685 <main+0x495>
mov    -0x250(%rbp),%rdi
lea    0xc0d(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x258(%rbp)
cmpq   $0x0,-0x258(%rbp)
je     1680 <main+0x490>
mov    -0x258(%rbp),%rdi
lea    0xbf4(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x260(%rbp)
cmpq   $0x0,-0x260(%rbp)
je     167b <main+0x48b>
lea    -0x370(%rbp),%rax
mov    %rax,-0x3a0(%rbp)
mov    -0x258(%rbp),%rax
mov    %rax,-0x3b0(%rbp)
lea    0xba8(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x3b0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x398(%rbp)
mov    -0x260(%rbp),%rax
mov    %rax,-0x390(%rbp)
mov    -0x258(%rbp),%rax
mov    %rax,-0x3a8(%rbp)
lea    0xb6a(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x3a8(%rbp),%rcx
mov    -0x3a0(%rbp),%rdi
mov    -0x398(%rbp),%rsi
mov    %eax,%edx
mov    -0x390(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1050 <strncpy@plt>
movslq -0x13c(%rbp),%rax
mov    -0x260(%rbp),%rcx
add    $0x4,%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
mov    %eax,-0x26c(%rbp)
movl   $0x0,-0x268(%rbp)
mov    -0x268(%rbp),%eax
cmp    -0x26c(%rbp),%eax
jge    1676 <main+0x486>
mov    -0x260(%rbp),%rax
add    $0x4,%rax
movslq -0x268(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x3c0(%rbp)
lea    -0x240(%rbp),%rax
mov    %rax,-0x3b8(%rbp)
lea    -0x240(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x3c0(%rbp),%rdi
mov    -0x3b8(%rbp),%rsi
mov    %eax,%edx
call   10b0 <memcmp@plt>
mov    %eax,-0x264(%rbp)
cmpl   $0x0,-0x264(%rbp)
jne    165d <main+0x46d>
mov    -0x268(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x378(%rbp)
mov    -0x378(%rbp),%rdi
mov    -0x268(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
mov    -0x378(%rbp),%rdi
mov    -0x260(%rbp),%rsi
add    $0x4,%rsi
mov    -0x268(%rbp),%edx
sub    $0x2,%edx
call   10c0 <memcpy@plt>
lea    0xa54(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x268(%rbp),%esi
sub    $0x2,%esi
lea    0xa57(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xa2d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x378(%rbp),%rdi
mov    -0x268(%rbp),%edx
sub    $0x2,%edx
mov    0x2998(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1100 <fwrite@plt>
mov    -0x378(%rbp),%rdi
call   1040 <free@plt>
jmp    1676 <main+0x486>
jmp    1662 <main+0x472>
mov    -0x268(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x268(%rbp)
jmp    1532 <main+0x342>
jmp    167b <main+0x48b>
jmp    1680 <main+0x490>
jmp    1685 <main+0x495>
jmp    168a <main+0x49a>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
jmp    1698 <main+0x4a8>
xor    %eax,%eax
add    $0x3c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x308,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x2f0(%rsp)
movaps %xmm0,0x2e0(%rsp)
movaps %xmm0,0x2d0(%rsp)
movaps %xmm0,0x2c0(%rsp)
movaps %xmm0,0x2b0(%rsp)
movaps %xmm0,0x2a0(%rsp)
movaps %xmm0,0x290(%rsp)
movaps %xmm0,0x280(%rsp)
movaps %xmm0,0x270(%rsp)
movaps %xmm0,0x260(%rsp)
movaps %xmm0,0x250(%rsp)
movaps %xmm0,0x240(%rsp)
movaps %xmm0,0x230(%rsp)
movaps %xmm0,0x220(%rsp)
movaps %xmm0,0x210(%rsp)
movaps %xmm0,0x200(%rsp)
lea    0xc6e(%rip),%rdi
call   1030 <getenv@plt>
lea    0xc6f(%rip),%rsi
mov    %rax,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
je     15a4 <main+0x394>
lea    0xc6b(%rip),%rsi
mov    %rax,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
je     15a4 <main+0x394>
mov    %rax,%rbx
lea    0xc50(%rip),%rdi
call   10a0 <strlen@plt>
cltq
add    %rax,%rbx
lea    0x100(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <strcpy@plt>
lea    0xc39(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1100 <atoi@plt>
mov    %eax,%ebx
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
call   10f0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   10c0 <memset@plt>
mov    0x2bc7(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1090 <fread@plt>
cmp    %eax,%ebx
jne    159c <main+0x38c>
lea    0xbf9(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1110 <strcat@plt>
lea    0x100(%rsp),%rsi
mov    %rbp,%rdi
call   1110 <strcat@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     159c <main+0x38c>
lea    0xbc6(%rip),%rsi
mov    %rax,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
je     159c <main+0x38c>
mov    %rax,%r12
lea    0xbba(%rip),%rsi
mov    %rax,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
je     159c <main+0x38c>
mov    %rax,%r15
lea    0xb90(%rip),%r13
mov    %r13,%rdi
call   10a0 <strlen@plt>
cltq
mov    %r12,%rbp
add    %rax,%rbp
mov    %r13,%rdi
call   10a0 <strlen@plt>
add    %r12d,%eax
mov    %r15d,%edx
sub    %eax,%edx
lea    0x200(%rsp),%rdi
mov    %rbp,%rsi
call   1060 <strncpy@plt>
add    $0x4,%r15
mov    %r14d,%eax
sub    %r15d,%eax
add    %eax,%ebx
test   %ebx,%ebx
jle    159c <main+0x38c>
mov    %ebx,%r13d
neg    %r13
xor    %ebx,%ebx
mov    %rsp,%r12
mov    %r15,%rbp
nop
mov    %r12,%rdi
call   10a0 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   10d0 <memcmp@plt>
test   %eax,%eax
je     1528 <main+0x318>
add    $0xffffffffffffffff,%rbx
add    $0x1,%rbp
cmp    %rbx,%r13
jne    1500 <main+0x2f0>
jmp    159c <main+0x38c>
mov    %ebx,%ebp
not    %ebp
mov    %ebp,%edi
call   10f0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   10c0 <memset@plt>
mov    $0xfffffffe,%ebp
sub    %ebx,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   10e0 <memcpy@plt>
lea    0xb08(%rip),%rdi
call   1080 <puts@plt>
lea    0xae8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    0x2a55(%rip),%rax
mov    (%rax),%ecx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1120 <fwrite@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x308,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"CONTENT_TYPE\00"
@.str.1 = [20 x i8] c"multipart/form-data\00"
@.str.2 = [10 x i8] c"boundary=\00"
@.str.3 = [15 x i8] c"CONTENT_LENGTH\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"--\00"
@.str.5 = [15 x i8] c"Content-Type: \00"
@.str.6 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.7 = [26 x i8] c"Content-type: text/plain\0A\00"
@.str.8 = [20 x i8] c"Content-length: %d\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [256 x i8]
%18 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
%19 = bitcast [256 x i8]* %6 to i8*
store i8* null, i8** %7
store i32 0, i32* %8
%20 = bitcast [256 x i8]* %9 to i8*
store i32 0, i32* %10
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%21 = bitcast [256 x i8]* %17 to i8*
store i8* null, i8** %18
%22 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %3
%23 = load i8*, i8** %3
%24 = call i8* @strstr(i8* %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %165
27: ; preds = %0
%28 = load i8*, i8** %4
%29 = call i8* @strstr(i8* %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i8* %29, i8** %5
%30 = load i8*, i8** %5
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %164
32: ; preds = %27
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%34 = load i8*, i8** %5
%35 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = call i32 @strcpy(i8* %33, i8* %37)
%39 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i8* %39, i8** %7
%40 = load i8*, i8** %7
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = mul i64 1, %44
%46 = trunc i64 %45 to i32
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %2
%49 = load i8*, i8** %2
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
%52 = call i32 @memset(i8* %49, i32 0, i32 %51)
%53 = load i8*, i8** %2
%54 = load i32, i32* %8
%55 = load i32, i32* @stdin
%56 = call i32 @fread(i8* %53, i32 1, i32 %54, i32 %55)
store i32 %56, i32* %10
%57 = load i32, i32* %8
%58 = load i32, i32* %10
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %161
60: ; preds = %32
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%62 = call i32 @strcat(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%65 = call i32 @strcat(i8* %63, i8* %64)
%66 = load i8*, i8** %2
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%68 = call i8* @strstr(i8* %66, i8* %67)
store i8* %68, i8** %11
%69 = load i8*, i8** %11
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %160
71: ; preds = %60
%72 = load i8*, i8** %11
%73 = call i8* @strstr(i8* %72, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i8* %73, i8** %12
%74 = load i8*, i8** %12
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %159
76: ; preds = %71
%77 = load i8*, i8** %12
%78 = call i8* @strstr(i8* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i8* %78, i8** %13
%79 = load i8*, i8** %13
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %158
81: ; preds = %76
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%83 = load i8*, i8** %12
%84 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8*, i8** %13
%88 = load i8*, i8** %12
%89 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = ptrtoint i8* %87 to i64
%93 = ptrtoint i8* %91 to i64
%94 = sub i64 %92, %93
%95 = trunc i64 %94 to i32
%96 = call i32 @strncpy(i8* %82, i8* %86, i32 %95)
%97 = load i32, i32* %8
%98 = sext i32 %97 to i64
%99 = load i8*, i8** %13
%100 = getelementptr inbounds i8, i8* %99, i64 4
%101 = load i8*, i8** %2
%102 = ptrtoint i8* %100 to i64
%103 = ptrtoint i8* %101 to i64
%104 = sub i64 %102, %103
%105 = sub nsw i64 %98, %104
%106 = trunc i64 %105 to i32
store i32 %106, i32* %16
store i32 0, i32* %15
br label %107
107: ; preds = %154, %81
%108 = load i32, i32* %15
%109 = load i32, i32* %16
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %157
111: ; preds = %107
%112 = load i8*, i8** %13
%113 = getelementptr inbounds i8, i8* %112, i64 4
%114 = load i32, i32* %15
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%118 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%119 = call i32 @strlen(i8* %118)
%120 = call i32 @memcmp(i8* %116, i8* %117, i32 %119)
store i32 %120, i32* %14
%121 = load i32, i32* %14
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %153
123: ; preds = %111
%124 = load i32, i32* %15
%125 = sub nsw i32 %124, 1
%126 = sext i32 %125 to i64
%127 = mul i64 1, %126
%128 = trunc i64 %127 to i32
%129 = call i64 @malloc(i32 %128)
%130 = inttoptr i64 %129 to i8*
store i8* %130, i8** %18
%131 = load i8*, i8** %18
%132 = load i32, i32* %15
%133 = sub nsw i32 %132, 1
%134 = call i32 @memset(i8* %131, i32 0, i32 %133)
%135 = load i8*, i8** %18
%136 = load i8*, i8** %13
%137 = getelementptr inbounds i8, i8* %136, i64 4
%138 = load i32, i32* %15
%139 = sub nsw i32 %138, 2
%140 = call i32 @memcpy(i8* %135, i8* %137, i32 %139)
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%142 = load i32, i32* %15
%143 = sub nsw i32 %142, 2
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%146 = load i8*, i8** %18
%147 = load i32, i32* %15
%148 = sub nsw i32 %147, 2
%149 = load i32, i32* @stdout
%150 = call i32 @fwrite(i8* %146, i32 1, i32 %148, i32 %149)
%151 = load i8*, i8** %18
%152 = call i32 @free(i8* %151)
br label %157
153: ; preds = %111
br label %154
154: ; preds = %153
%155 = load i32, i32* %15
%156 = add nsw i32 %155, 1
store i32 %156, i32* %15
br label %107
157: ; preds = %123, %107
br label %158
158: ; preds = %157, %76
br label %159
159: ; preds = %158, %71
br label %160
160: ; preds = %159, %60
br label %161
161: ; preds = %160, %32
%162 = load i8*, i8** %2
%163 = call i32 @free(i8* %162)
br label %164
164: ; preds = %161, %27
br label %165
165: ; preds = %164, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"CONTENT_TYPE\00"
@.str.1 = [20 x i8] c"multipart/form-data\00"
@.str.2 = [10 x i8] c"boundary=\00"
@.str.3 = [15 x i8] c"CONTENT_LENGTH\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"--\00"
@.str.5 = [15 x i8] c"Content-Type: \00"
@.str.6 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.8 = [20 x i8] c"Content-length: %d\0A\00"
@stdout = global i32 0
@str = [25 x i8] c"Content-type: text/plain\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = tail call i8* @strstr(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %83, label %10
10: ; preds = %0
%11 = tail call i8* @strstr(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %83, label %13
13: ; preds = %10
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %11, i64 %15
%17 = call i32 @strcpy(i8* %4, i8* %16)
%18 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @atoi(i8* %18)
%20 = add nsw i32 %19, 1
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
%23 = call i32 @memset(i8* %22, i32 0, i32 %20)
%24 = load i32, i32* @stdin
%25 = call i32 @fread(i8* %22, i32 1, i32 %19, i32 %24)
%26 = icmp eq i32 %19, %25
br i1 %26, label %27, label %81
27: ; preds = %13
%28 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @strcat(i8* %5, i8* %4)
%30 = call i8* @strstr(i8* dereferenceable(1) %22, i8* %5)
%31 = icmp eq i8* %30, null
br i1 %31, label %81, label %32
32: ; preds = %27
%33 = call i8* @strstr(i8* %30, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %81, label %35
35: ; preds = %32
%36 = call i8* @strstr(i8* %33, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i8* %36, null
br i1 %37, label %81, label %38
38: ; preds = %35
%39 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %33, i64 %40
%42 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %33, i64 %43
%45 = ptrtoint i8* %36 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = trunc i64 %47 to i32
%49 = call i32 @strncpy(i8* %6, i8* %41, i32 %48)
%50 = getelementptr inbounds i8, i8* %36, i64 4
%51 = ptrtoint i8* %50 to i64
%52 = sub i64 %21, %51
%53 = trunc i64 %52 to i32
%54 = add i32 %19, %53
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %81
56: ; preds = %38
%57 = zext i32 %54 to i64
br label %58
58: ; preds = %56, %78
%59 = phi i64 [ 0, %56 ], [ %79, %78 ]
%60 = getelementptr inbounds i8, i8* %50, i64 %59
%61 = call i32 @strlen(i8* %5)
%62 = call i32 @memcmp(i8* %60, i8* %5, i32 %61)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %78
64: ; preds = %58
%65 = trunc i64 %59 to i32
%66 = add nsw i32 %65, -1
%67 = call i64 @malloc(i32 %66)
%68 = inttoptr i64 %67 to i8*
%69 = call i32 @memset(i8* %68, i32 0, i32 %66)
%70 = add nsw i32 %65, -2
%71 = call i32 @memcpy(i8* %68, i8* %50, i32 %70)
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %70)
%74 = call i32 @putchar(i32 10)
%75 = load i32, i32* @stdout
%76 = call i32 @fwrite(i8* %68, i32 1, i32 %70, i32 %75)
%77 = call i32 @free(i8* %68)
br label %81
78: ; preds = %58
%79 = add nuw nsw i64 %59, 1
%80 = icmp eq i64 %79, %57
br i1 %80, label %81, label %58
81: ; preds = %78, %38, %27, %35, %64, %32, %13
%82 = call i32 @free(i8* %22)
br label %83
83: ; preds = %10, %81, %0
ret i32 0
}