#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*/ execve(char *, char **, char **);
int /*<<< orphan*/ printf(char *);
void testexec(char *envp[]) {
  printf("in testexec() \n");
  char cmd[100] = "bin/argtest";
  char *argv[10];
  argv[0] = "shashi\0";
  argv[1] = "ranjan\0";
  execve(cmd, argv, envp);
}


x86 assembly (clang, -O0):
<testexec>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    0xf0d(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xf07(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1040 <execve@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testexec>:
push   %rbx
sub    $0xc0,%rsp
mov    %rdi,%rbx
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe86(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xed7(%rip),%rax
mov    %rax,0x70(%rsp)
lea    0xed3(%rip),%rax
mov    %rax,0x78(%rsp)
mov    %rsp,%rdi
lea    0x70(%rsp),%rsi
mov    %rbx,%rdx
call   1040 <execve@plt>
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"in testexec() \0A\00"
@__const.testexec.cmd = [100 x i8] c"bin/argtest\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [8 x i8] c"shashi\00\00"
@.str.2 = [8 x i8] c"ranjan\00\00"
define void @testexec(i8** %0) {
%2 = alloca i8**
%3 = alloca [100 x i8]
%4 = alloca [10 x i8*]
store i8** %0, i8*** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = bitcast [100 x i8]* %3 to i8*
%7 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
%11 = load i8**, i8*** %2
%12 = call i32 @execve(i8* %9, i8** %10, i8** %11)
ret void
}

LLVM IR (-O2):
@__const.testexec.cmd = [100 x i8] c"bin/argtest\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [8 x i8] c"shashi\00\00"
@.str.2 = [8 x i8] c"ranjan\00\00"
@str = [15 x i8] c"in testexec() \00"
define void @testexec(i8** %0) {
%2 = alloca [100 x i8]
%3 = alloca [10 x i8*]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = bitcast [10 x i8*]* %3 to i8*
%7 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = call i32 @execve(i8* %5, i8** %7, i8** %0)
ret void
}