#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 */
scalar_t__ execve(char *, char **, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(void) {
  char *args[3];
  char *env[1];
  args[0] = "/tmp/target4";
  args[1] = "hi there";
  args[2] = NULL;
  env[0] = NULL;
  if (0 > execve("/tmp/target4", args, env))
    fprintf(stderr, "execve failed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xecc(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    0xe9c(%rip),%rdi
call   1030 <execve@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    118c <main+0x6c>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xed5(%rip),%rdi
mov    %rdi,0x10(%rsp)
lea    0xed6(%rip),%rax
mov    %rax,0x18(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <execve@plt>
test   %rax,%rax
jns    1177 <main+0x57>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/target4\00"
@.str.1 = [9 x i8] c"hi there\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"execve failed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8*]
%3 = alloca [1 x i8*]
store i32 0, i32* %1
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 2
store i8* null, i8** %6
%7 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
store i8* null, i8** %7
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%9 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
%10 = call i64 @execve(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %8, i8** %9)
%11 = icmp sgt i64 0, %10
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %12, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/target4\00"
@.str.1 = [9 x i8] c"hi there\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"execve failed.\0A\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = alloca [1 x i8*]
%3 = bitcast [3 x i8*]* %1 to i8*
%4 = bitcast [1 x i8*]* %2 to i8*
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %7
%8 = getelementptr inbounds [1 x i8*], [1 x i8*]* %2, i64 0, i64 0
store i8* null, i8** %8
%9 = call i64 @execve(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %5, i8** %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %11, %0
ret i32 0
}