#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 */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int execlp(char *, char *, int /*<<< orphan*/ *);
int execv(char *, char *const *);
int execve(char *, int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main(void) {
  int flag;
  pid_t pid;
  char *const argv[] = {"%U", "--user-data-dir=/home/Administrator/.chromiun",
                        NULL};
  if ((pid = fork()) == 0) {
    printf("in child process 1......\n");
    sleep(1);
    printf("sleep  1 over!\n");
    char *envp[] = {"PATH=.", NULL};
    flag = execve("hello", NULL, envp);
    if (flag == -1)
      printf("exec error!\n");
  }
  if ((pid = fork()) == 0) {
    printf("in child process 2......\n");
    sleep(2);
    printf("sleep  2 over!\n");
    flag = execlp("ls", "-al", NULL);
    if (flag == -1)
      printf("exec error!\n");
  }
  if ((pid = fork()) == 0) {
    printf("in child process 3......\n");
    sleep(3);
    printf("sleep  3 over!\n");
    flag = execv("/usr/bin/chromium-browser", argv);
    if (flag == -1)
      printf("exec error!\n");
  }
  printf("in parent process ......\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2c7a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c77(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c74(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    120d <main+0xad>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2c44(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c41(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x40(%rbp),%rdx
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <execve@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1208 <main+0xa8>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <main+0xad>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    1277 <main+0x117>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
lea    0xe56(%rip),%rdi
lea    0xe52(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execlp@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1272 <main+0x112>
lea    0xdfb(%rip),%rdi
call   1030 <printf@plt>
jmp    1277 <main+0x117>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    12da <main+0x17a>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3,%edi
call   1060 <sleep@plt>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1070 <execv@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    12d5 <main+0x175>
lea    0xd98(%rip),%rdi
call   1030 <printf@plt>
jmp    12da <main+0x17a>
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0x2c95(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0x2c79(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
jne    11d6 <main+0x76>
lea    0xf3a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
movaps 0x2c60(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe7d(%rip),%rdi
mov    %rsp,%rdx
xor    %esi,%esi
call   1040 <execve@plt>
cmp    $0xffffffff,%eax
jne    11d6 <main+0x76>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
jne    1229 <main+0xc9>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe34(%rip),%rdi
lea    0xe30(%rip),%rsi
xor    %edx,%edx
call   1050 <execlp@plt>
cmp    $0xffffffff,%eax
jne    1229 <main+0xc9>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
jne    1278 <main+0x118>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1060 <sleep@plt>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
lea    0xde8(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1070 <execv@plt>
cmp    $0xffffffff,%eax
jne    1278 <main+0x118>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xde0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%U\00"
@.str.1 = [46 x i8] c"--user-data-dir=/home/Administrator/.chromiun\00"
@__const.main.argv = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [26 x i8] c"in child process 1......\0A\00"
@.str.3 = [16 x i8] c"sleep 1 over!\0A\00"
@.str.4 = [7 x i8] c"PATH=.\00"
@__const.main.envp = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str.5 = [6 x i8] c"hello\00"
@.str.6 = [13 x i8] c"exec error!\0A\00"
@.str.7 = [26 x i8] c"in child process 2......\0A\00"
@.str.8 = [16 x i8] c"sleep 2 over!\0A\00"
@.str.9 = [3 x i8] c"ls\00"
@.str.10 = [4 x i8] c"-al\00"
@.str.11 = [26 x i8] c"in child process 3......\0A\00"
@.str.12 = [16 x i8] c"sleep 3 over!\0A\00"
@.str.13 = [26 x i8] c"/usr/bin/chromium-browser\00"
@.str.14 = [26 x i8] c"in parent process ......\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8*]
%5 = alloca [2 x i8*]
store i32 0, i32* %1
%6 = bitcast [3 x i8*]* %4 to i8*
%7 = call i32 (...) @fork()
store i32 %7, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @sleep(i32 1)
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%13 = bitcast [2 x i8*]* %5 to i8*
%14 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%15 = call i32 @execve(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* null, i8** %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %9
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %20
20: ; preds = %18, %9
br label %21
21: ; preds = %20, %0
%22 = call i32 (...) @fork()
store i32 %22, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 @sleep(i32 2)
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%28 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32* null)
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
br label %34
34: ; preds = %33, %21
%35 = call i32 (...) @fork()
store i32 %35, i32* %3
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%39 = call i32 @sleep(i32 3)
%40 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
%41 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%42 = call i32 @execv(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8** %41)
store i32 %42, i32* %2
%43 = load i32, i32* %2
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %37
br label %48
48: ; preds = %47, %34
%49 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%U\00"
@.str.1 = [46 x i8] c"--user-data-dir=/home/Administrator/.chromiun\00"
@__const.main.argv = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.4 = [7 x i8] c"PATH=.\00"
@__const.main.envp = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str.5 = [6 x i8] c"hello\00"
@.str.9 = [3 x i8] c"ls\00"
@.str.10 = [4 x i8] c"-al\00"
@.str.13 = [26 x i8] c"/usr/bin/chromium-browser\00"
@str = [25 x i8] c"in parent process ......\00"
@str.15 = [25 x i8] c"in child process 3......\00"
@str.16 = [15 x i8] c"sleep 3 over!\00"
@str.18 = [25 x i8] c"in child process 2......\00"
@str.19 = [15 x i8] c"sleep 2 over!\00"
@str.21 = [25 x i8] c"in child process 1......\00"
@str.22 = [15 x i8] c"sleep 1 over!\00"
@str.23 = [12 x i8] c"exec error!\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = alloca [2 x i8*]
%3 = bitcast [3 x i8*]* %1 to i8*
%4 = tail call i32 (...) @fork()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.21, i64 0, i64 0))
%8 = tail call i32 @sleep(i32 1)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.22, i64 0, i64 0))
%10 = bitcast [2 x i8*]* %2 to i8*
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%12 = call i32 @execve(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* null, i8** %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.23, i64 0, i64 0))
br label %16
16: ; preds = %14, %6
br label %17
17: ; preds = %16, %0
%18 = call i32 (...) @fork()
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.18, i64 0, i64 0))
%22 = call i32 @sleep(i32 2)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.19, i64 0, i64 0))
%24 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32* null)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.23, i64 0, i64 0))
br label %28
28: ; preds = %20, %26, %17
%29 = call i32 (...) @fork()
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.15, i64 0, i64 0))
%33 = call i32 @sleep(i32 3)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0))
%35 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%36 = call i32 @execv(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8** %35)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.23, i64 0, i64 0))
br label %40
40: ; preds = %31, %38, %28
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
ret i32 0
}