#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int wait(int /*<<< orphan*/ *);
int main(void) {
  pid_t pid;
  pid = fork();
  if (pid == 0) {
    execl("./register", "register", NULL);
    perror("register");
    exit(1);
  }
  pid = fork();
  if (pid == 0) {
    execl("./login", "login", NULL);
    perror("login");
    exit(1);
  }
  pid = fork();
  if (pid == 0) {
    execl("./add_friend", "add_friend", NULL);
    perror("add_friend");
    exit(1);
  }
  pid = fork();
  if (pid == 0) {
    execl("./talk", "talk", NULL);
    perror("talk");
    exit(1);
  }
  pid = fork();
  if (pid == 0) {
    execl("./record", "record", NULL);
    perror("record");
    exit(1);
  }
  int ret;
  while (1) {
    ret = wait(NULL);
    if (ret < 0) {
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a2 <main+0x52>
lea    0xe84(%rip),%rdi
lea    0xe7f(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
lea    0xe6f(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e5 <main+0x95>
lea    0xe4c(%rip),%rdi
lea    0xe47(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
lea    0xe37(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1228 <main+0xd8>
lea    0xe11(%rip),%rdi
lea    0xe0c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
lea    0xdfc(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    126b <main+0x11b>
lea    0xddb(%rip),%rdi
lea    0xdd6(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
lea    0xdc6(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12ae <main+0x15e>
lea    0xd9f(%rip),%rdi
lea    0xd9a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
lea    0xd8a(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    12b3 <main+0x163>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12ce <main+0x17e>
jmp    12d3 <main+0x183>
jmp    12b3 <main+0x163>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     119f <main+0x4f>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     11af <main+0x5f>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     11bf <main+0x6f>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     11cf <main+0x7f>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     11df <main+0x8f>
nopl   (%rax)
xor    %edi,%edi
call   1060 <wait@plt>
test   %eax,%eax
jns    1190 <main+0x40>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe5a(%rip),%rdi
lea    0xe55(%rip),%rbx
jmp    11ed <main+0x9d>
lea    0xe55(%rip),%rdi
lea    0xe50(%rip),%rbx
jmp    11ed <main+0x9d>
lea    0xe4d(%rip),%rdi
lea    0xe48(%rip),%rbx
jmp    11ed <main+0x9d>
lea    0xe4a(%rip),%rdi
lea    0xe45(%rip),%rbx
jmp    11ed <main+0x9d>
lea    0xe41(%rip),%rdi
lea    0xe3c(%rip),%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <execl@plt>
mov    %rbx,%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"./register\00"
@.str.1 = [9 x i8] c"register\00"
@.str.2 = [8 x i8] c"./login\00"
@.str.3 = [6 x i8] c"login\00"
@.str.4 = [13 x i8] c"./add_friend\00"
@.str.5 = [11 x i8] c"add_friend\00"
@.str.6 = [7 x i8] c"./talk\00"
@.str.7 = [5 x i8] c"talk\00"
@.str.8 = [9 x i8] c"./record\00"
@.str.9 = [7 x i8] c"record\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 (...) @fork()
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @execl(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* null)
%9 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i64 (...) @fork()
store i64 %12, i64* %2
%13 = load i64, i64* %2
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* null)
%17 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = call i64 (...) @fork()
store i64 %20, i64* %2
%21 = load i64, i64* %2
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = call i32 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32* null)
%25 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %19
%28 = call i64 (...) @fork()
store i64 %28, i64* %2
%29 = load i64, i64* %2
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = call i32 @execl(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* null)
%33 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %27
%36 = call i64 (...) @fork()
store i64 %36, i64* %2
%37 = load i64, i64* %2
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32* null)
%41 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %35
br label %44
44: ; preds = %43, %49
%45 = call i32 @wait(i32* null)
store i32 %45, i32* %3
%46 = load i32, i32* %3
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
br label %50
49: ; preds = %44
br label %44
50: ; preds = %48
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"./register\00"
@.str.1 = [9 x i8] c"register\00"
@.str.2 = [8 x i8] c"./login\00"
@.str.3 = [6 x i8] c"login\00"
@.str.4 = [13 x i8] c"./add_friend\00"
@.str.5 = [11 x i8] c"add_friend\00"
@.str.6 = [7 x i8] c"./talk\00"
@.str.7 = [5 x i8] c"talk\00"
@.str.8 = [9 x i8] c"./record\00"
@.str.9 = [7 x i8] c"record\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 @execl(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* null)
%5 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i64 (...) @fork()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* null)
%12 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = tail call i64 (...) @fork()
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32* null)
%19 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %14
%22 = tail call i64 (...) @fork()
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = tail call i32 @execl(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* null)
%26 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %21
%29 = tail call i64 (...) @fork()
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = tail call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32* null)
%33 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %28, %35
%36 = tail call i32 @wait(i32* null)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %35
38: ; preds = %35
ret i32 0
}