#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*/ free(char *);
int /*<<< orphan*/ payload_activate(char *, char **, char *const *);
char *payload_deploy(char *, size_t);
char *payload_extract(char *, size_t *);
int main(int argc, char *argv[], char *const envp[]) {
  (void)argc;
  size_t payload_size;
  char *payload = payload_extract(argv[0], &payload_size);
  char *payload_path = payload_deploy(payload, payload_size);
  payload_activate(payload_path, argv, envp);
  free(payload);
  free(payload_path);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <payload_extract@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <payload_deploy@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <payload_activate@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    (%rsi),%rdi
mov    %rsp,%rsi
call   1040 <payload_extract@plt>
mov    %rax,%r12
mov    (%rsp),%rsi
mov    %rax,%rdi
call   1050 <payload_deploy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <payload_activate@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i32, i32* %5
%12 = load i8**, i8*** %6
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i8* @payload_extract(i8* %14, i64* %8)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = load i64, i64* %8
%18 = call i8* @payload_deploy(i8* %16, i64 %17)
store i8* %18, i8** %10
%19 = load i8*, i8** %10
%20 = load i8**, i8*** %6
%21 = load i8**, i8*** %7
%22 = call i32 @payload_activate(i8* %19, i8** %20, i8** %21)
%23 = load i8*, i8** %9
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %10
%26 = call i32 @free(i8* %25)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = load i8*, i8** %1
%7 = call i8* @payload_extract(i8* %6, i64* %4)
%8 = load i64, i64* %4
%9 = call i8* @payload_deploy(i8* %7, i64 %8)
%10 = call i32 @payload_activate(i8* %9, i8** %1, i8** %2)
%11 = call i32 @free(i8* %7)
%12 = call i32 @free(i8* %9)
ret i32 0
}