#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*/ execlp(char *, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main() {
  char *command1_argv[50] = {"ps", "elf"};
  char *command2_argv[50] = {"ps", "u"};
  printf("Running ps with execvp\n");
  execvp("ps", command1_argv);
  printf("Done with execvp. Running ps with execlp\n");
  execlp("ps", "ps", "xu", 0);
  printf("Done.\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x330,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    0xe84(%rip),%rax
mov    %rax,-0x1a0(%rbp)
lea    0xe79(%rip),%rax
mov    %rax,-0x198(%rbp)
lea    -0x330(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    0xe55(%rip),%rax
mov    %rax,-0x330(%rbp)
lea    0xe91(%rip),%rax
mov    %rax,-0x328(%rbp)
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1050 <execvp@plt>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
lea    0xe0e(%rip),%rsi
lea    0xe50(%rip),%rdx
xor    %ecx,%ecx
mov    %rsi,%rdi
call   1070 <execlp@plt>
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x190,%rsp
lea    0x10(%rsp),%rdi
mov    $0x180,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe90(%rip),%rbx
mov    %rbx,(%rsp)
lea    0xe88(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <execvp@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5d(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1070 <execlp@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"ps\00"
@.str.1 = [4 x i8] c"elf\00"
@.str.2 = [2 x i8] c"u\00"
@.str.3 = [24 x i8] c"Running ps with execvp\0A\00"
@.str.4 = [42 x i8] c"Done with execvp. Running ps with execlp\0A\00"
@.str.5 = [3 x i8] c"xu\00"
@.str.6 = [7 x i8] c"Done.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8*]
%3 = alloca [50 x i8*]
store i32 0, i32* %1
%4 = bitcast [50 x i8*]* %2 to i8*
%5 = bitcast i8* %4 to <{ i8*, i8*, [48 x i8*] }>*
%6 = getelementptr inbounds <{ i8*, i8*, [48 x i8*] }>, <{ i8*, i8*, [48 x i8*] }>* %5, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %6
%7 = getelementptr inbounds <{ i8*, i8*, [48 x i8*] }>, <{ i8*, i8*, [48 x i8*] }>* %5, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %7
%8 = bitcast [50 x i8*]* %3 to i8*
%9 = bitcast i8* %8 to <{ i8*, i8*, [48 x i8*] }>*
%10 = getelementptr inbounds <{ i8*, i8*, [48 x i8*] }>, <{ i8*, i8*, [48 x i8*] }>* %9, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds <{ i8*, i8*, [48 x i8*] }>, <{ i8*, i8*, [48 x i8*] }>* %9, i32 0, i32 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8** %11
%12 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [50 x i8*], [50 x i8*]* %2, i64 0, i64 0
%14 = call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"ps\00"
@.str.1 = [4 x i8] c"elf\00"
@.str.5 = [3 x i8] c"xu\00"
@str = [23 x i8] c"Running ps with execvp\00"
@str.7 = [41 x i8] c"Done with execvp. Running ps with execlp\00"
@str.8 = [6 x i8] c"Done.\00"
define i32 @main() {
%1 = alloca [50 x i8*]
%2 = bitcast [50 x i8*]* %1 to i8*
%3 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 2
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [50 x i8*], [50 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%8 = call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0))
%10 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 0)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
}