#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 *, int, char *);
scalar_t__ strlen(char *);
void benchmark_command_execution(char *tmpdir, int iter) {
  char request[1024];
  char body[] = "command=echo 'foo'";
  sprintf(request,
          "POST /command\r\n"
          "Content-Type: application/x-www-form-urlencoded\r\n"
          "Content-Length: %d\r\n"
          "\r\n"
          "%s",
          (int)strlen(body), body);
  benchmark("Command Execution", "../clax -n -r . -l /dev/null > /dev/null",
            request, iter);
}


x86 assembly (clang, -O0):
<benchmark_command_execution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x428(%rbp)
mov    0xeab(%rip),%ax
mov    %ax,-0x420(%rbp)
mov    0xea0(%rip),%al
mov    %al,-0x41e(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x438(%rbp)
lea    -0x430(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x438(%rbp),%rdi
mov    %eax,%edx
lea    -0x430(%rbp),%rcx
lea    0xe6a(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x410(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xead(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1040 <benchmark@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark_command_execution>:
push   %rbp
push   %r14
push   %rbx
sub    $0x420,%rsp
mov    %esi,%r14d
movaps 0xebb(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x276f6f,0xf(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xeb0(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %eax,%edx
mov    %rbx,%rcx
call   1050 <sprintf@plt>
lea    0xef0(%rip),%rdi
lea    0xefb(%rip),%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1040 <benchmark@plt>
add    $0x420,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.benchmark_command_execution.body = [19 x i8] c"command=echo 'foo'\00"
@.str = [89 x i8] c"POST /command\0D\0AContent-Type: application/x-www-form-urlencoded\0D\0AContent-Length: %d\0D\0A\0D\0A%s\00"
@.str.1 = [18 x i8] c"Command Execution\00"
@.str.2 = [41 x i8] c"../clax -n -r . -l /dev/null > /dev/null\00"
define void @benchmark_command_execution(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [19 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = bitcast [19 x i8]* %6 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [19 x i8], [19 x i8]* %6, i64 0, i64 0
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds [19 x i8], [19 x i8]* %6, i64 0, i64 0
%13 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @benchmark(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %15)
ret void
}

LLVM IR (-O2):
@__const.benchmark_command_execution.body = [19 x i8] c"command=echo 'foo'\00"
@.str = [89 x i8] c"POST /command\0D\0AContent-Type: application/x-www-form-urlencoded\0D\0AContent-Length: %d\0D\0A\0D\0A%s\00"
@.str.1 = [18 x i8] c"Command Execution\00"
@.str.2 = [41 x i8] c"../clax -n -r . -l /dev/null > /dev/null\00"
define void @benchmark_command_execution(i8* nocapture readnone %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [19 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%7 = call i64 @strlen(i8* %6)
%8 = trunc i64 %7 to i32
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %6)
%10 = call i32 @benchmark(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %1)
ret void
}