#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*/ execlp(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(void) {
  if (fork() == 0) {
    printf("the child\n");
    if (fork() == 0) {
      printf("do something you want\n");
      execlp("drracket", NULL);
      sleep(5);
      printf("done\n");
      exit(0);
    } else
      exit(0);
  } else {
    wait(NULL);
    printf("the parent\n");
    sleep(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    11dd <main+0x7d>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    11d6 <main+0x76>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <execlp@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
xor    %edi,%edi
call   1040 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     118e <main+0x2e>
xor    %edi,%edi
call   1070 <wait@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
jne    11d6 <main+0x76>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0xe47(%rip),%rdi
xor    %esi,%esi
call   1050 <execlp@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"the child\0A\00"
@.str.1 = [23 x i8] c"do something you want\0A\00"
@.str.2 = [9 x i8] c"drracket\00"
@.str.3 = [6 x i8] c"done\0A\00"
@.str.4 = [12 x i8] c"the parent\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @fork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %16
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i64 (...) @fork()
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @execlp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* null)
%11 = call i32 @sleep(i32 5)
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %4
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %0
%17 = call i32 @wait(i32* null)
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @sleep(i32 10)
br label %20
20: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c"drracket\00"
@str = [11 x i8] c"the parent\00"
@str.5 = [10 x i8] c"the child\00"
@str.6 = [22 x i8] c"do something you want\00"
@str.7 = [5 x i8] c"done\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %15
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @execlp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* null)
%10 = tail call i32 @sleep(i32 5)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.7, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %3
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %0
%16 = tail call i32 @wait(i32* null)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @sleep(i32 10)
ret i32 0
}