#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*/ execvp(char *, char **);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  if (fork()) {
    sleep(10);
  } else {
    char *argv[4] = {"main", "aa", "bb", NULL};
    execvp("main", argv);
    printf("not found cmdline!\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
je     116f <main+0x2f>
mov    $0xa,%edi
call   1050 <sleep@plt>
jmp    11c3 <main+0x83>
mov    0x2c8a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c87(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c84(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c81(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <execvp@plt>
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <main+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     115f <main+0x1f>
mov    $0xa,%edi
call   1050 <sleep@plt>
jmp    1196 <main+0x56>
movaps 0x2caa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c8e(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe83(%rip),%rdi
mov    %rsp,%rsi
call   1040 <execvp@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"main\00"
@.str.1 = [3 x i8] c"aa\00"
@.str.2 = [3 x i8] c"bb\00"
@__const.main.argv = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [20 x i8] c"not found cmdline!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8*]
store i32 0, i32* %1
%3 = call i64 (...) @fork()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @sleep(i32 10)
br label %12
7: ; preds = %0
%8 = bitcast [4 x i8*]* %2 to i8*
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%10 = call i32 @execvp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %13
12: ; preds = %5
store i32 0, i32* %1
br label %13
13: ; preds = %12, %7
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [5 x i8] c"main\00"
@.str.1 = [3 x i8] c"aa\00"
@.str.2 = [3 x i8] c"bb\00"
@__const.main.argv = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* null]
@str = [19 x i8] c"not found cmdline!\00"
define i32 @main() {
%1 = alloca [4 x i8*]
%2 = tail call i64 (...) @fork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @sleep(i32 10)
br label %11
6: ; preds = %0
%7 = bitcast [4 x i8*]* %1 to i8*
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%9 = call i32 @execvp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %4, %6
%12 = phi i32 [ 0, %4 ], [ -1, %6 ]
ret i32 %12
}