#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*/ agent_a();
int /*<<< orphan*/ agent_b();
int /*<<< orphan*/ agent_c();
int fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ pusher_a();
int /*<<< orphan*/ pusher_b();
int /*<<< orphan*/ pusher_c();
int main(int argc, char *argv[]) {
  int pid, i;
  if (argc != 1) {
    printf("forma de uso: %s\n", argv[0]);
  }
  if ((pid = fork()) < 0) {
    perror("fork1");
    return -1;
  } else if (pid == 0) {
    pusher_a();
  }
  if ((pid = fork()) < 0) {
    perror("fork2");
    return -1;
  } else if (pid == 0) {
    pusher_b();
  }
  if ((pid = fork()) < 0) {
    perror("fork3");
    return -1;
  } else if (pid == 0) {
    pusher_c();
  }
  if ((pid = fork()) < 0) {
    perror("fork4");
    return -1;
  } else if (pid == 0) {
    agent_a();
  }
  if ((pid = fork()) < 0) {
    perror("fork5");
    return -1;
  } else if (pid == 0) {
    agent_b();
  }
  if ((pid = fork()) < 0) {
    perror("fork6");
    return -1;
  } else if (pid == 0) {
    agent_c();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11c3 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11ee <main+0x5e>
lea    0xe35(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1350 <main+0x1c0>
cmpl   $0x0,-0x14(%rbp)
jne    11ff <main+0x6f>
mov    $0x0,%al
call   1070 <pusher_a@plt>
jmp    1204 <main+0x74>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    122f <main+0x9f>
lea    0xdfa(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1350 <main+0x1c0>
cmpl   $0x0,-0x14(%rbp)
jne    1240 <main+0xb0>
mov    $0x0,%al
call   1030 <pusher_b@plt>
jmp    1245 <main+0xb5>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1270 <main+0xe0>
lea    0xdbf(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1350 <main+0x1c0>
cmpl   $0x0,-0x14(%rbp)
jne    1281 <main+0xf1>
mov    $0x0,%al
call   1080 <pusher_c@plt>
jmp    1286 <main+0xf6>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12b1 <main+0x121>
lea    0xd84(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1350 <main+0x1c0>
cmpl   $0x0,-0x14(%rbp)
jne    12c2 <main+0x132>
mov    $0x0,%al
call   1060 <agent_a@plt>
jmp    12c7 <main+0x137>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12f2 <main+0x162>
lea    0xd49(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1350 <main+0x1c0>
cmpl   $0x0,-0x14(%rbp)
jne    1303 <main+0x173>
mov    $0x0,%al
call   10a0 <agent_b@plt>
jmp    1308 <main+0x178>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1333 <main+0x1a3>
lea    0xd0e(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1350 <main+0x1c0>
cmpl   $0x0,-0x14(%rbp)
jne    1344 <main+0x1b4>
mov    $0x0,%al
call   1050 <agent_c@plt>
jmp    1349 <main+0x1b9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
je     11a5 <main+0x15>
mov    (%rsi),%rsi
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
js     1223 <main+0x93>
jne    11b9 <main+0x29>
xor    %eax,%eax
call   1070 <pusher_a@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
js     122c <main+0x9c>
jne    11cd <main+0x3d>
xor    %eax,%eax
call   1030 <pusher_b@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
js     1235 <main+0xa5>
jne    11e1 <main+0x51>
xor    %eax,%eax
call   1080 <pusher_c@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
js     123e <main+0xae>
jne    11f5 <main+0x65>
xor    %eax,%eax
call   1060 <agent_a@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
js     1247 <main+0xb7>
jne    1209 <main+0x79>
xor    %eax,%eax
call   10a0 <agent_b@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
js     1250 <main+0xc0>
jne    1261 <main+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <agent_c@plt>
jmp    1261 <main+0xd1>
lea    0xde8(%rip),%rdi
jmp    1257 <main+0xc7>
lea    0xde5(%rip),%rdi
jmp    1257 <main+0xc7>
lea    0xde2(%rip),%rdi
jmp    1257 <main+0xc7>
lea    0xddf(%rip),%rdi
jmp    1257 <main+0xc7>
lea    0xddc(%rip),%rdi
jmp    1257 <main+0xc7>
lea    0xdd9(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"forma de uso: %s\0A\00"
@.str.1 = [6 x i8] c"fork1\00"
@.str.2 = [6 x i8] c"fork2\00"
@.str.3 = [6 x i8] c"fork3\00"
@.str.4 = [6 x i8] c"fork4\00"
@.str.5 = [6 x i8] c"fork5\00"
@.str.6 = [6 x i8] c"fork6\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %2
%16 = call i32 (...) @fork()
store i32 %16, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
20: ; preds = %15
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (...) @pusher_a()
br label %25
25: ; preds = %23, %20
br label %26
26: ; preds = %25
%27 = call i32 (...) @fork()
store i32 %27, i32* %6
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
31: ; preds = %26
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (...) @pusher_b()
br label %36
36: ; preds = %34, %31
br label %37
37: ; preds = %36
%38 = call i32 (...) @fork()
store i32 %38, i32* %6
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
42: ; preds = %37
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (...) @pusher_c()
br label %47
47: ; preds = %45, %42
br label %48
48: ; preds = %47
%49 = call i32 (...) @fork()
store i32 %49, i32* %6
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
53: ; preds = %48
%54 = load i32, i32* %6
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 (...) @agent_a()
br label %58
58: ; preds = %56, %53
br label %59
59: ; preds = %58
%60 = call i32 (...) @fork()
store i32 %60, i32* %6
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
64: ; preds = %59
%65 = load i32, i32* %6
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 (...) @agent_b()
br label %69
69: ; preds = %67, %64
br label %70
70: ; preds = %69
%71 = call i32 (...) @fork()
store i32 %71, i32* %6
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
75: ; preds = %70
%76 = load i32, i32* %6
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 (...) @agent_c()
br label %80
80: ; preds = %78, %75
br label %81
81: ; preds = %80
store i32 0, i32* %3
br label %82
82: ; preds = %81, %73, %62, %51, %40, %29, %18
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@.str = [18 x i8] c"forma de uso: %s\0A\00"
@.str.1 = [6 x i8] c"fork1\00"
@.str.2 = [6 x i8] c"fork2\00"
@.str.3 = [6 x i8] c"fork3\00"
@.str.4 = [6 x i8] c"fork4\00"
@.str.5 = [6 x i8] c"fork5\00"
@.str.6 = [6 x i8] c"fork6\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %4, %2
%8 = tail call i32 (...) @fork()
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %61
12: ; preds = %7
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 (...) @pusher_a()
br label %16
16: ; preds = %12, %14
%17 = tail call i32 (...) @fork()
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %61
21: ; preds = %16
%22 = icmp eq i32 %17, 0
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 (...) @pusher_b()
br label %25
25: ; preds = %21, %23
%26 = tail call i32 (...) @fork()
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %61
30: ; preds = %25
%31 = icmp eq i32 %26, 0
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = tail call i32 (...) @pusher_c()
br label %34
34: ; preds = %30, %32
%35 = tail call i32 (...) @fork()
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %61
39: ; preds = %34
%40 = icmp eq i32 %35, 0
br i1 %40, label %41, label %43
41: ; preds = %39
%42 = tail call i32 (...) @agent_a()
br label %43
43: ; preds = %39, %41
%44 = tail call i32 (...) @fork()
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %61
48: ; preds = %43
%49 = icmp eq i32 %44, 0
br i1 %49, label %50, label %52
50: ; preds = %48
%51 = tail call i32 (...) @agent_b()
br label %52
52: ; preds = %48, %50
%53 = tail call i32 (...) @fork()
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %61
57: ; preds = %52
%58 = icmp eq i32 %53, 0
br i1 %58, label %59, label %61
59: ; preds = %57
%60 = tail call i32 (...) @agent_c()
br label %61
61: ; preds = %59, %57, %55, %46, %37, %28, %19, %10
%62 = phi i32 [ -1, %10 ], [ -1, %19 ], [ -1, %28 ], [ -1, %37 ], [ -1, %46 ], [ -1, %55 ], [ 0, %57 ], [ 0, %59 ]
ret i32 %62
}