#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 O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_SYNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fexecve(int, char **, char **);
int open(char *, int, ...);
int /*<<< orphan*/ write(int, void *, int);
void load_programm(void *buf) {
  int payload_file;
  char *newenviron[] = {NULL};
  char *newargv[] = {"/tmp/fuzzing_engine", NULL};
  payload_file = open("/tmp/fuzzing_engine", O_RDWR | O_CREAT | O_SYNC, 0777);
  write(payload_file, buf, (16 << 20));
  close(payload_file);
  payload_file = open("/tmp/fuzzing_engine", O_RDONLY);
  fexecve(payload_file, newargv, newenviron);
}


x86 assembly (clang, -O0):
<load_programm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2c7d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c7a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
mov    0x2e66(%rip),%rax
or     (%rax),%esi
mov    0x2e3d(%rip),%rax
or     (%rax),%esi
lea    0xe5c(%rip),%rdi
mov    $0x1ff,%edx
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x1000000,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <fexecve@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_programm>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
movaps 0x2c95(%rip),%xmm0
mov    0x2e7e(%rip),%rax
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
movaps %xmm0,0x10(%rsp)
mov    0x2e5f(%rip),%rax
or     (%rax),%esi
lea    0xe7e(%rip),%r14
mov    %r14,%rdi
mov    $0x1ff,%edx
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x1000000,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <open@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %eax,%edi
call   1050 <fexecve@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"/tmp/fuzzing_engine\00"
@__const.load_programm.newargv = [2 x i8*] [i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i32 0, i32 0), i8* null]
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_SYNC = global i32 0
@O_RDONLY = global i32 0
define void @load_programm(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [1 x i8*]
%5 = alloca [2 x i8*]
store i8* %0, i8** %2
%6 = bitcast [1 x i8*]* %4 to i8*
%7 = bitcast [2 x i8*]* %5 to i8*
%8 = load i32, i32* @O_RDWR
%9 = load i32, i32* @O_CREAT
%10 = or i32 %8, %9
%11 = load i32, i32* @O_SYNC
%12 = or i32 %10, %11
%13 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %12, i32 511)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = load i8*, i8** %2
%16 = call i32 @write(i32 %14, i8* %15, i32 16777216)
%17 = load i32, i32* %3
%18 = call i32 @close(i32 %17)
%19 = load i32, i32* @O_RDONLY
%20 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%23 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%24 = call i32 @fexecve(i32 %21, i8** %22, i8** %23)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"/tmp/fuzzing_engine\00"
@__const.load_programm.newargv = [2 x i8*] [i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i32 0, i32 0), i8* null]
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_SYNC = global i32 0
@O_RDONLY = global i32 0
define void @load_programm(i8* nocapture %0) {
%2 = alloca [1 x i8*]
%3 = alloca [2 x i8*]
%4 = bitcast [1 x i8*]* %2 to i8*
%5 = bitcast [1 x i8*]* %2 to i64*
store i64 0, i64* %5
%6 = bitcast [2 x i8*]* %3 to i8*
%7 = load i32, i32* @O_RDWR
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = load i32, i32* @O_SYNC
%11 = or i32 %9, %10
%12 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %11, i32 511)
%13 = tail call i32 @write(i32 %12, i8* %0, i32 16777216)
%14 = tail call i32 @close(i32 %12)
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%18 = getelementptr inbounds [1 x i8*], [1 x i8*]* %2, i64 0, i64 0
%19 = call i32 @fexecve(i32 %16, i8** %17, i8** %18)
ret void
}