#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 fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ writer();
int main(int argc, char *argv[]) {
  int pid, i;
  if (argc != 1) {
    printf("forma de uso: %s\n", argv[0]);
  }
  for (i = 0; i < 3; ++i) {
    if ((pid = fork()) < 0) {
      perror("fork");
      return -1;
    } else if (pid == 0) {
      writer();
    } else {
    }
  }
  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     1173 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11e2 <main+0xa2>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11af <main+0x6f>
lea    0xe74(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e9 <main+0xa9>
cmpl   $0x0,-0x14(%rbp)
jne    11c5 <main+0x85>
mov    $0x0,%al
call   1040 <writer@plt>
jmp    11ca <main+0x8a>
jmp    11ca <main+0x8a>
jmp    11cf <main+0x8f>
jmp    11d4 <main+0x94>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117a <main+0x3a>
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     1155 <main+0x15>
mov    (%rsi),%rsi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
js     1197 <main+0x57>
jne    1169 <main+0x29>
xor    %eax,%eax
call   1040 <writer@plt>
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
js     1197 <main+0x57>
jne    117d <main+0x3d>
xor    %eax,%eax
call   1040 <writer@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
js     1197 <main+0x57>
jne    11a8 <main+0x68>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <writer@plt>
jmp    11a8 <main+0x68>
lea    0xe74(%rip),%rdi
call   1050 <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 = [5 x i8] c"fork\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
store i32 0, i32* %7
br label %16
16: ; preds = %32, %15
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = call i32 (...) @fork()
store i32 %20, i32* %6
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %36
24: ; preds = %19
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (...) @writer()
br label %30
29: ; preds = %24
br label %30
30: ; preds = %29, %27
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %16
35: ; preds = %16
store i32 0, i32* %3
br label %36
36: ; preds = %35, %22
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [18 x i8] c"forma de uso: %s\0A\00"
@.str.1 = [5 x i8] c"fork\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 = %23, %16, %7
%11 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %30
12: ; preds = %7
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 (...) @writer()
br label %16
16: ; preds = %12, %14
%17 = tail call i32 (...) @fork()
%18 = icmp slt i32 %17, 0
br i1 %18, label %10, label %19
19: ; preds = %16
%20 = icmp eq i32 %17, 0
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = tail call i32 (...) @writer()
br label %23
23: ; preds = %21, %19
%24 = tail call i32 (...) @fork()
%25 = icmp slt i32 %24, 0
br i1 %25, label %10, label %26
26: ; preds = %23
%27 = icmp eq i32 %24, 0
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call i32 (...) @writer()
br label %30
30: ; preds = %26, %28, %10
%31 = phi i32 [ -1, %10 ], [ 0, %28 ], [ 0, %26 ]
ret i32 %31
}