#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*/ benchmark(char *, char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strlen(char *);
void benchmark_file_upload(char *tmpdir, int iter) {
  char request[1024];
  char body[] =
      "--------------------------0e6bb0a28f620f98\r\n"
      "Content-Disposition: form-data; name=\"file\"; filename=\"foobar\"\r\n"
      "\r\n"
      "hello from file!\r\n"
      "--------------------------0e6bb0a28f620f98--\r\n";
  sprintf(request,
          "POST /tree/ HTTP/1.1\r\n"
          "Content-Type: multipart/form-data; "
          "boundary=------------------------0e6bb0a28f620f98\r\n"
          "Content-Length: %d\r\n"
          "\r\n"
          "%s",
          (int)strlen(body), body);
  char command[1024];
  sprintf(command, "../clax -n -r %s -l /dev/null > /dev/null", tmpdir);
  benchmark("File Upload", command, request, iter);
}


x86 assembly (clang, -O0):
<benchmark_file_upload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8d0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x4c0(%rbp),%rdi
lea    0xea0(%rip),%rsi
mov    $0xaf,%edx
call   1040 <memcpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x8c8(%rbp)
lea    -0x4c0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x8c8(%rbp),%rdi
mov    %eax,%edx
lea    -0x4c0(%rbp),%rcx
lea    0xf14(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x8c0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xf80(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x8c0(%rbp),%rsi
lea    -0x410(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xf8b(%rip),%rdi
call   1050 <benchmark@plt>
add    $0x8d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark_file_upload>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x8b8,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xea6(%rip),%rsi
mov    %rsp,%rbp
mov    $0xaf,%edx
mov    %rbp,%rdi
call   1040 <memcpy@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
lea    0xf36(%rip),%rsi
lea    0x4b0(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xf9d(%rip),%rsi
lea    0xb0(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xfab(%rip),%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1050 <benchmark@plt>
add    $0x8b8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.benchmark_file_upload.body = [175 x i8] c"--------------------------0e6bb0a28f620f98\0D\0AContent-Disposition: form-data; name=\22file\22; filename=\22foobar\22\0D\0A\0D\0Ahello from file!\0D\0A--------------------------0e6bb0a28f620f98--\0D\0A\00"
@.str = [133 x i8] c"POST /tree/ HTTP/1.1\0D\0AContent-Type: multipart/form-data; boundary=------------------------0e6bb0a28f620f98\0D\0AContent-Length: %d\0D\0A\0D\0A%s\00"
@.str.1 = [42 x i8] c"../clax -n -r %s -l /dev/null > /dev/null\00"
@.str.2 = [12 x i8] c"File Upload\00"
define void @benchmark_file_upload(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [175 x i8]
%7 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = bitcast [175 x i8]* %6 to i8*
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [175 x i8], [175 x i8]* %6, i64 0, i64 0
%11 = call i64 @strlen(i8* %10)
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds [175 x i8], [175 x i8]* %6, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = load i32, i32* %4
%21 = call i32 @benchmark(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19, i32 %20)
ret void
}

LLVM IR (-O2):
@__const.benchmark_file_upload.body = [175 x i8] c"--------------------------0e6bb0a28f620f98\0D\0AContent-Disposition: form-data; name=\22file\22; filename=\22foobar\22\0D\0A\0D\0Ahello from file!\0D\0A--------------------------0e6bb0a28f620f98--\0D\0A\00"
@.str = [133 x i8] c"POST /tree/ HTTP/1.1\0D\0AContent-Type: multipart/form-data; boundary=------------------------0e6bb0a28f620f98\0D\0AContent-Length: %d\0D\0A\0D\0A%s\00"
@.str.1 = [42 x i8] c"../clax -n -r %s -l /dev/null > /dev/null\00"
@.str.2 = [12 x i8] c"File Upload\00"
define void @benchmark_file_upload(i8* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [175 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [175 x i8], [175 x i8]* %4, i64 0, i64 0
%8 = call i64 @strlen(i8* %7)
%9 = trunc i64 %8 to i32
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %7)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = call i32 @benchmark(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %6, i32 %1)
ret void
}