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

/* Variables and functions */
int EXIT_SUCCESS;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int fprintf(int /*<<< orphan*/, char *, ...);
int getpid();
int getppid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int wait(int *);
int main(int argc, char **argv) {
  pid_t fork_return = NULL;
  pid_t wait_return = NULL;
  pid_t fils1 = NULL;
  int error = 0;
  int wait_status = 0;
  int fprintf_return = 0;
  int main_nb_fork = 0;
  int child_nb_fork = 0;
  if (argc != 1) {
    fprintf_return = fprintf(stdout, "Usage: %s \n", argv[0]);
    if (fprintf_return < 0) {
      perror("Error fprintf");
      return fprintf_return;
    }
    return -1;
  }
  for (main_nb_fork = 0; main_nb_fork < 2; main_nb_fork++) {
    fork_return = fork();
    if (fork_return == -1) {
      error = errno;
      perror("Error fork");
      return error;
    } else if (fork_return == 0) {
      for (child_nb_fork = 0; child_nb_fork < 2; child_nb_fork++) {
        fork_return = fork();
        if (fork_return == -1) {
          error = errno;
          perror("Error fork");
          return error;
        } else if (fork_return == 0) {
          fprintf_return = fprintf(stdout, "Petit fils PID, PPID: %d, %d \n",
                                   getpid(), getppid());
          if (fprintf_return < 0) {
            perror("Error fprintf");
            return fprintf_return;
          }
          exit(0);
        }
      }
      for (child_nb_fork = 0; child_nb_fork < 2; child_nb_fork++) {
        wait_return = wait(&wait_status);
        if (wait_return == -1) {
          error = errno;
          perror("Error wait");
          return error;
        }
      }
      if (main_nb_fork == 1) {
        fprintf_return =
            fprintf(stdout, "Fils PID, PPID, PID de mon frere: %d, %d, %d \n",
                    getpid(), getppid(), fils1);
        if (fprintf_return < 0) {
          perror("Error fprintf");
          return fprintf_return;
        }
      } else {
        fprintf_return =
            fprintf(stdout, "Fils PID, PPID: %d, %d \n", getpid(), getppid());
        if (fprintf_return < 0) {
          perror("Error fprintf");
          return fprintf_return;
        }
      }
      exit(0);
    }
    if (main_nb_fork == 0) {
      fils1 = fork_return;
    }
  }
  for (main_nb_fork = 0; main_nb_fork < 2; main_nb_fork++) {
    wait_return = wait(&wait_status);
    if (wait_return == -1) {
      error = errno;
      perror("Error wait");
      return error;
    }
  }
  fprintf_return = fprintf(stdout, "Pere PID: %d \n", getpid());
  if (fprintf_return < 0) {
    perror("Error fprintf");
    return fprintf_return;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1216 <main+0xa6>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    120a <main+0x9a>
lea    0xe12(%rip),%rdi
call   1050 <perror@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1535 <main+0x3c5>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    1482 <main+0x312>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    125e <main+0xee>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xdcc(%rip),%rdi
call   1050 <perror@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
cmpl   $0x0,-0x14(%rbp)
jne    145a <main+0x2ea>
movl   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
jge    1330 <main+0x1c0>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12b0 <main+0x140>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xd7a(%rip),%rdi
call   1050 <perror@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
cmpl   $0x0,-0x14(%rbp)
jne    1318 <main+0x1a8>
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1060 <getppid@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%edx
mov    %eax,%ecx
lea    0xd3f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1311 <main+0x1a1>
lea    0xd0b(%rip),%rdi
call   1050 <perror@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    131d <main+0x1ad>
jmp    1322 <main+0x1b2>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    126f <main+0xff>
movl   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
jge    138d <main+0x21d>
lea    -0x24(%rbp),%rdi
call   1080 <wait@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    137a <main+0x20a>
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xcda(%rip),%rdi
call   1050 <perror@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
jmp    137f <main+0x20f>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1337 <main+0x1c7>
cmpl   $0x1,-0x2c(%rbp)
jne    13f7 <main+0x287>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   1060 <getppid@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%edx
mov    %eax,%ecx
mov    -0x1c(%rbp),%r8d
lea    0xc88(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    13f2 <main+0x282>
lea    0xc2a(%rip),%rdi
call   1050 <perror@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
jmp    1453 <main+0x2e3>
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1060 <getppid@plt>
mov    -0x48(%rbp),%edi
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
lea    0xc5b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    144e <main+0x2de>
lea    0xbce(%rip),%rdi
call   1050 <perror@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
jmp    1453 <main+0x2e3>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    145f <main+0x2ef>
cmpl   $0x0,-0x2c(%rbp)
jne    146f <main+0x2ff>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1474 <main+0x304>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    121d <main+0xad>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    14df <main+0x36f>
lea    -0x24(%rbp),%rdi
call   1080 <wait@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    14cc <main+0x35c>
mov    0x2b30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xb88(%rip),%rdi
call   1050 <perror@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
jmp    14d1 <main+0x361>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1489 <main+0x319>
mov    0x2af2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%edx
lea    0xb99(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1529 <main+0x3b9>
lea    0xaf3(%rip),%rdi
call   1050 <perror@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1535 <main+0x3c5>
mov    0x2aa0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
cmp    $0x1,%edi
jne    1217 <main+0xa7>
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <fork@plt>
cmp    $0xffffffff,%eax
je     12c4 <main+0x154>
mov    %eax,%ebx
test   %eax,%eax
je     125c <main+0xec>
xor    %eax,%eax
call   1090 <fork@plt>
cmp    $0xffffffff,%eax
je     12c4 <main+0x154>
test   %eax,%eax
je     1259 <main+0xe9>
lea    0x4(%rsp),%rdi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
je     12fc <main+0x18c>
lea    0x4(%rsp),%rdi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
je     12fc <main+0x18c>
mov    0x2def(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe9e(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %eax,%eax
js     12b1 <main+0x141>
mov    0x2dbd(%rip),%rax
mov    (%rax),%ebx
jmp    123a <main+0xca>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdd6(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
js     1247 <main+0xd7>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xdbc(%rip),%rdi
call   1050 <perror@plt>
mov    %ebp,%ebx
jmp    123a <main+0xca>
mov    $0x1,%bpl
xor    %eax,%eax
call   1090 <fork@plt>
cmp    $0xffffffff,%eax
je     12c4 <main+0x154>
test   %eax,%eax
je     127c <main+0x10c>
xor    %eax,%eax
call   1090 <fork@plt>
cmp    $0xffffffff,%eax
je     12c4 <main+0x154>
test   %eax,%eax
jne    12de <main+0x16e>
mov    0x2d55(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <getppid@plt>
lea    0xd89(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %eax,%eax
jns    1357 <main+0x1e7>
mov    %eax,%ebx
lea    0xd52(%rip),%rdi
call   1050 <perror@plt>
jmp    123a <main+0xca>
mov    0x2d15(%rip),%rax
mov    (%rax),%ebx
lea    0xd46(%rip),%rdi
call   1050 <perror@plt>
jmp    123a <main+0xca>
lea    0x4(%rsp),%rdi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
je     12fc <main+0x18c>
lea    0x4(%rsp),%rdi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
jne    1316 <main+0x1a6>
mov    0x2cdd(%rip),%rax
mov    (%rax),%ebx
lea    0xd38(%rip),%rdi
call   1050 <perror@plt>
jmp    123a <main+0xca>
mov    0x2cbb(%rip),%rax
mov    (%rax),%r14d
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <getppid@plt>
test   %bpl,%bpl
je     135e <main+0x1ee>
lea    0xd12(%rip),%rsi
mov    %r14d,%edi
mov    %r15d,%edx
mov    %eax,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %eax,%eax
js     12b1 <main+0x141>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xd19(%rip),%rsi
mov    %r14d,%edi
mov    %r15d,%edx
jmp    12a0 <main+0x130>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [12 x i8] c"Usage: %s \0A\00"
@.str.1 = [14 x i8] c"Error fprintf\00"
@errno = global i32 0
@.str.2 = [11 x i8] c"Error fork\00"
@.str.3 = [31 x i8] c"Petit fils PID, PPID: %d, %d \0A\00"
@.str.4 = [11 x i8] c"Error wait\00"
@.str.5 = [47 x i8] c"Fils PID, PPID, PID de mon frere: %d, %d, %d \0A\00"
@.str.6 = [25 x i8] c"Fils PID, PPID: %d, %d \0A\00"
@.str.7 = [15 x i8] c"Pere PID: %d \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %28
16: ; preds = %2
%17 = load i32, i32* @stdout
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 %21, i32* %11
%22 = load i32, i32* %11
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* %11
store i32 %26, i32* %3
br label %156
27: ; preds = %16
store i32 -1, i32* %3
br label %156
28: ; preds = %2
store i32 0, i32* %12
br label %29
29: ; preds = %126, %28
%30 = load i32, i32* %12
%31 = icmp slt i32 %30, 2
br i1 %31, label %32, label %129
32: ; preds = %29
%33 = call i32 (...) @fork()
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* @errno
store i32 %37, i32* %9
%38 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* %9
store i32 %39, i32* %3
br label %156
40: ; preds = %32
%41 = load i32, i32* %6
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %119
43: ; preds = %40
store i32 0, i32* %13
br label %44
44: ; preds = %72, %43
%45 = load i32, i32* %13
%46 = icmp slt i32 %45, 2
br i1 %46, label %47, label %75
47: ; preds = %44
%48 = call i32 (...) @fork()
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load i32, i32* @errno
store i32 %52, i32* %9
%53 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32, i32* %9
store i32 %54, i32* %3
br label %156
55: ; preds = %47
%56 = load i32, i32* %6
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %70
58: ; preds = %55
%59 = load i32, i32* @stdout
%60 = call i32 (...) @getpid()
%61 = call i32 (...) @getppid()
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %60, i32 %61)
store i32 %62, i32* %11
%63 = load i32, i32* %11
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %58
%66 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%67 = load i32, i32* %11
store i32 %67, i32* %3
br label %156
68: ; preds = %58
%69 = call i32 @exit(i32 0)
unreachable
70: ; preds = %55
br label %71
71: ; preds = %70
br label %72
72: ; preds = %71
%73 = load i32, i32* %13
%74 = add nsw i32 %73, 1
store i32 %74, i32* %13
br label %44
75: ; preds = %44
store i32 0, i32* %13
br label %76
76: ; preds = %88, %75
%77 = load i32, i32* %13
%78 = icmp slt i32 %77, 2
br i1 %78, label %79, label %91
79: ; preds = %76
%80 = call i32 @wait(i32* %10)
store i32 %80, i32* %7
%81 = load i32, i32* %7
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %87
83: ; preds = %79
%84 = load i32, i32* @errno
store i32 %84, i32* %9
%85 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%86 = load i32, i32* %9
store i32 %86, i32* %3
br label %156
87: ; preds = %79
br label %88
88: ; preds = %87
%89 = load i32, i32* %13
%90 = add nsw i32 %89, 1
store i32 %90, i32* %13
br label %76
91: ; preds = %76
%92 = load i32, i32* %12
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %106
94: ; preds = %91
%95 = load i32, i32* @stdout
%96 = call i32 (...) @getpid()
%97 = call i32 (...) @getppid()
%98 = load i32, i32* %8
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %96, i32 %97, i32 %98)
store i32 %99, i32* %11
%100 = load i32, i32* %11
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %94
%103 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%104 = load i32, i32* %11
store i32 %104, i32* %3
br label %156
105: ; preds = %94
br label %117
106: ; preds = %91
%107 = load i32, i32* @stdout
%108 = call i32 (...) @getpid()
%109 = call i32 (...) @getppid()
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %108, i32 %109)
store i32 %110, i32* %11
%111 = load i32, i32* %11
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %106
%114 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%115 = load i32, i32* %11
store i32 %115, i32* %3
br label %156
116: ; preds = %106
br label %117
117: ; preds = %116, %105
%118 = call i32 @exit(i32 0)
unreachable
119: ; preds = %40
br label %120
120: ; preds = %119
%121 = load i32, i32* %12
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %125
123: ; preds = %120
%124 = load i32, i32* %6
store i32 %124, i32* %8
br label %125
125: ; preds = %123, %120
br label %126
126: ; preds = %125
%127 = load i32, i32* %12
%128 = add nsw i32 %127, 1
store i32 %128, i32* %12
br label %29
129: ; preds = %29
store i32 0, i32* %12
br label %130
130: ; preds = %142, %129
%131 = load i32, i32* %12
%132 = icmp slt i32 %131, 2
br i1 %132, label %133, label %145
133: ; preds = %130
%134 = call i32 @wait(i32* %10)
store i32 %134, i32* %7
%135 = load i32, i32* %7
%136 = icmp eq i32 %135, -1
br i1 %136, label %137, label %141
137: ; preds = %133
%138 = load i32, i32* @errno
store i32 %138, i32* %9
%139 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%140 = load i32, i32* %9
store i32 %140, i32* %3
br label %156
141: ; preds = %133
br label %142
142: ; preds = %141
%143 = load i32, i32* %12
%144 = add nsw i32 %143, 1
store i32 %144, i32* %12
br label %130
145: ; preds = %130
%146 = load i32, i32* @stdout
%147 = call i32 (...) @getpid()
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %147)
store i32 %148, i32* %11
%149 = load i32, i32* %11
%150 = icmp slt i32 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %145
%152 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%153 = load i32, i32* %11
store i32 %153, i32* %3
br label %156
154: ; preds = %145
%155 = load i32, i32* @EXIT_SUCCESS
store i32 %155, i32* %3
br label %156
156: ; preds = %154, %151, %137, %113, %102, %83, %65, %51, %36, %27, %24
%157 = load i32, i32* %3
ret i32 %157
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [12 x i8] c"Usage: %s \0A\00"
@.str.1 = [14 x i8] c"Error fprintf\00"
@errno = global i32 0
@.str.2 = [11 x i8] c"Error fork\00"
@.str.3 = [31 x i8] c"Petit fils PID, PPID: %d, %d \0A\00"
@.str.4 = [11 x i8] c"Error wait\00"
@.str.5 = [47 x i8] c"Fils PID, PPID, PID de mon frere: %d, %d, %d \0A\00"
@.str.6 = [25 x i8] c"Fils PID, PPID: %d, %d \0A\00"
@.str.7 = [15 x i8] c"Pere PID: %d \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @fork()
switch i32 %7, label %61 [
i32 -1, label %18
i32 0, label %15
]
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %81
13: ; preds = %8
%14 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %81
15: ; preds = %61, %6
%16 = phi i1 [ true, %61 ], [ false, %6 ]
%17 = tail call i32 (...) @fork()
switch i32 %17, label %34 [
i32 -1, label %21
i32 0, label %24
]
18: ; preds = %61, %6
%19 = load i32, i32* @errno
%20 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %81
21: ; preds = %34, %15
%22 = load i32, i32* @errno
%23 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %81
24: ; preds = %34, %15
%25 = load i32, i32* @stdout
%26 = tail call i32 (...) @getpid()
%27 = tail call i32 (...) @getppid()
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %81
32: ; preds = %24
%33 = tail call i32 @exit(i32 0)
unreachable
34: ; preds = %15
%35 = tail call i32 (...) @fork()
switch i32 %35, label %36 [
i32 -1, label %21
i32 0, label %24
]
36: ; preds = %34
%37 = call i32 @wait(i32* %3)
%38 = icmp eq i32 %37, -1
br i1 %38, label %46, label %39
39: ; preds = %36
%40 = call i32 @wait(i32* %3)
%41 = icmp eq i32 %40, -1
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = load i32, i32* @stdout
%44 = call i32 (...) @getpid()
%45 = call i32 (...) @getppid()
br i1 %16, label %49, label %54
46: ; preds = %39, %36
%47 = load i32, i32* @errno
%48 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %81
49: ; preds = %42
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %44, i32 %45, i32 %7)
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %81
54: ; preds = %42
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %45)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %81
59: ; preds = %54, %49
%60 = call i32 @exit(i32 0)
unreachable
61: ; preds = %6
%62 = tail call i32 (...) @fork()
switch i32 %62, label %63 [
i32 -1, label %18
i32 0, label %15
]
63: ; preds = %61
%64 = call i32 @wait(i32* %3)
%65 = icmp eq i32 %64, -1
br i1 %65, label %74, label %66
66: ; preds = %63
%67 = call i32 @wait(i32* %3)
%68 = icmp eq i32 %67, -1
br i1 %68, label %74, label %69
69: ; preds = %66
%70 = load i32, i32* @stdout
%71 = call i32 (...) @getpid()
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %71)
%73 = icmp slt i32 %72, 0
br i1 %73, label %77, label %79
74: ; preds = %66, %63
%75 = load i32, i32* @errno
%76 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %81
77: ; preds = %69
%78 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %81
79: ; preds = %69
%80 = load i32, i32* @EXIT_SUCCESS
br label %81
81: ; preds = %8, %79, %77, %74, %57, %52, %46, %30, %21, %18, %13
%82 = phi i32 [ %11, %13 ], [ %19, %18 ], [ %22, %21 ], [ %28, %30 ], [ %47, %46 ], [ %50, %52 ], [ %55, %57 ], [ %75, %74 ], [ %72, %77 ], [ %80, %79 ], [ -1, %8 ]
ret i32 %82
}