#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 execvp(char *, char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int main() {
  char *argv[2];
  int ret;
  sleep(5);
  printf("execing...\n");
  argv[0] = "/bin/date";
  argv[1] = 0;
  ret = execvp(argv[0], argv);
  printf("ret=%d\n", ret);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x5,%edi
call   1050 <sleep@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <execvp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    $0x5,%edi
call   1060 <sleep@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
mov    %rdi,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rsi
call   1050 <execvp@plt>
lea    0xe8d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"execing...\0A\00"
@.str.1 = [10 x i8] c"/bin/date\00"
@.str.2 = [8 x i8] c"ret=%d\0A\00"
define i32 @main() {
%1 = alloca [2 x i8*]
%2 = alloca i32
%3 = call i32 @sleep(i32 5)
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 1
store i8* null, i8** %6
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%10 = call i32 @execvp(i8* %8, i8** %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %11)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"/bin/date\00"
@.str.2 = [8 x i8] c"ret=%d\0A\00"
@str = [11 x i8] c"execing...\00"
define i32 @main() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
%3 = tail call i32 @sleep(i32 5)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 1
store i8* null, i8** %6
%7 = call i32 @execvp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %5)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %7)
ret i32 0
}