#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*/ errno;
int execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ printf(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  char *child_argv[] = {"childp", "hello", "darling", NULL};
  int child = fork();
  if (child == 0) {
    int ret =
        execvp("/home/waywu01/work/abucket/glib_misc/cmake-build-debug/childp",
               child_argv);
    if (ret == -1)
      printf("execvp failed because: %s\n", strerror(errno));
    exit(0);
  }
  int wstatus;
  wait(&wstatus);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c73(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c70(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c6d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c6a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11f7 <main+0x97>
lea    -0x30(%rbp),%rsi
lea    0xe4d(%rip),%rdi
call   1040 <execvp@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    11f0 <main+0x90>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
lea    -0x3c(%rbp),%rdi
call   1070 <wait@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movaps 0x2c95(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c79(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     1198 <main+0x38>
lea    0xc(%rsp),%rdi
call   1070 <wait@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret
lea    0xe6f(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <execvp@plt>
cmp    $0xffffffff,%eax
jne    11cb <main+0x6b>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe89(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"childp\00"
@.str.1 = [6 x i8] c"hello\00"
@.str.2 = [8 x i8] c"darling\00"
@__const.main.child_argv = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [62 x i8] c"/home/waywu01/work/abucket/glib_misc/cmake-build-debug/childp\00"
@.str.4 = [27 x i8] c"execvp failed because: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [4 x i8*]* %6 to i8*
%11 = call i32 (...) @fork()
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %2
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 0
%16 = call i32 @execvp(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8** %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %14
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %2
%26 = call i32 @wait(i32* %9)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"childp\00"
@.str.1 = [6 x i8] c"hello\00"
@.str.2 = [8 x i8] c"darling\00"
@__const.main.child_argv = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [62 x i8] c"/home/waywu01/work/abucket/glib_misc/cmake-build-debug/childp\00"
@.str.4 = [27 x i8] c"execvp failed because: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i8*]
%4 = alloca i32
%5 = bitcast [4 x i8*]* %3 to i8*
%6 = tail call i32 (...) @fork()
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%10 = call i32 @execvp(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8** %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %8
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = bitcast i32* %4 to i8*
%20 = call i32 @wait(i32* %4)
ret i32 0
}