#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*/ printf(char *, int);
int run(char **, char ***, unsigned int);
int main(int argc, char *argv[]) {
  char *program_name[] = {
      "/bin/ls",
      "/usr/bin/wc",
      "/usr/bin/awk",
  };
  char *ls_argv[] = {"ls", "-al", NULL};
  char *wc_argv[] = {"wc", NULL};
  char *awk_argv[] = {"awk", "{ print $2 }", NULL};
  char **program_argv[] = {
      ls_argv,
      wc_argv,
      awk_argv,
  };
  unsigned int count = 3;
  int status = run(program_name, program_argv, count);
  printf("[+] Status : %d\n", status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c70(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c6d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c6a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c6f(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2c6c(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c69(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c6e(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c6b(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c68(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0x2c65(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0x2c62(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
movl   $0x3,-0xa4(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0xa4(%rbp),%edx
call   1030 <run@plt>
mov    %eax,-0xa8(%rbp)
mov    -0xa8(%rbp),%esi
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x88,%rsp
mov    0x2c92(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0x2c73(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
mov    0x2c97(%rip),%rax
mov    %rax,0x60(%rsp)
movaps 0x2c7b(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c8f(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0x2ca3(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0x2c87(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x50(%rsp),%rax
mov    %rax,(%rsp)
lea    0x40(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0x20(%rsp),%rax
mov    %rax,0x10(%rsp)
lea    0x70(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x3,%edx
call   1030 <run@plt>
lea    0xe7e(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/ls\00"
@.str.1 = [12 x i8] c"/usr/bin/wc\00"
@.str.2 = [13 x i8] c"/usr/bin/awk\00"
@__const.main.program_name = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [3 x i8] c"ls\00"
@.str.4 = [4 x i8] c"-al\00"
@__const.main.ls_argv = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str.5 = [3 x i8] c"wc\00"
@__const.main.wc_argv = [2 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* null]
@.str.6 = [4 x i8] c"awk\00"
@.str.7 = [13 x i8] c"{ print $2 }\00"
@__const.main.awk_argv = [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i32 0, i32 0), i8* null]
@.str.8 = [17 x i8] c"[+] Status : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i8*]
%7 = alloca [3 x i8*]
%8 = alloca [2 x i8*]
%9 = alloca [3 x i8*]
%10 = alloca [3 x i8**]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [3 x i8*]* %6 to i8*
%14 = bitcast [3 x i8*]* %7 to i8*
%15 = bitcast [2 x i8*]* %8 to i8*
%16 = bitcast [3 x i8*]* %9 to i8*
%17 = getelementptr inbounds [3 x i8**], [3 x i8**]* %10, i64 0, i64 0
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
store i8** %18, i8*** %17
%19 = getelementptr inbounds i8**, i8*** %17, i64 1
%20 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
store i8** %20, i8*** %19
%21 = getelementptr inbounds i8**, i8*** %19, i64 1
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 0
store i8** %22, i8*** %21
store i32 3, i32* %11
%23 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%24 = getelementptr inbounds [3 x i8**], [3 x i8**]* %10, i64 0, i64 0
%25 = load i32, i32* %11
%26 = call i32 @run(i8** %23, i8*** %24, i32 %25)
store i32 %26, i32* %12
%27 = load i32, i32* %12
%28 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/ls\00"
@.str.1 = [12 x i8] c"/usr/bin/wc\00"
@.str.2 = [13 x i8] c"/usr/bin/awk\00"
@__const.main.program_name = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [3 x i8] c"ls\00"
@.str.4 = [4 x i8] c"-al\00"
@__const.main.ls_argv = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str.5 = [3 x i8] c"wc\00"
@__const.main.wc_argv = [2 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* null]
@.str.6 = [4 x i8] c"awk\00"
@.str.7 = [13 x i8] c"{ print $2 }\00"
@__const.main.awk_argv = [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i32 0, i32 0), i8* null]
@.str.8 = [17 x i8] c"[+] Status : %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i8*]
%4 = alloca [3 x i8*]
%5 = alloca [2 x i8*]
%6 = alloca [3 x i8*]
%7 = alloca [3 x i8**]
%8 = bitcast [3 x i8*]* %3 to i8*
%9 = bitcast [3 x i8*]* %4 to i8*
%10 = bitcast [2 x i8*]* %5 to i8*
%11 = bitcast [3 x i8*]* %6 to i8*
%12 = bitcast [3 x i8**]* %7 to i8*
%13 = getelementptr inbounds [3 x i8**], [3 x i8**]* %7, i64 0, i64 0
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
store i8** %14, i8*** %13
%15 = getelementptr inbounds [3 x i8**], [3 x i8**]* %7, i64 0, i64 1
%16 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
store i8** %16, i8*** %15
%17 = getelementptr inbounds [3 x i8**], [3 x i8**]* %7, i64 0, i64 2
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
store i8** %18, i8*** %17
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
%20 = call i32 @run(i8** %19, i8*** %13, i32 3)
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %20)
ret i32 0
}