#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 atoi(char const *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int getpid();
int getppid();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  int nbr = atoi(argv[1]);
  int nbr2 = atoi(argv[1]);
  int pid;
  for (nbr; nbr > 0; nbr--) {
    pid = fork();
    if (pid == 0) {
      printf("Je suis %d et mon père est le %d \n", getpid(), getppid());
      return 0;
    }
  }
  for (nbr2; nbr2 > 0; nbr2--) {
    wait(NULL);
  }
  exit(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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1201 <main+0x91>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11ee <main+0x7e>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <getppid@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    11f3 <main+0x83>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <main+0x36>
cmpl   $0x0,-0x18(%rbp)
jle    1222 <main+0xb2>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <wait@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1201 <main+0x91>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    11bf <main+0x4f>
mov    %eax,%ebx
lea    0x1(%rbx),%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11c6 <main+0x56>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     1190 <main+0x20>
test   %ebx,%ebx
jle    11bf <main+0x4f>
add    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1080 <wait@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     11b0 <main+0x40>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <getppid@plt>
lea    0xe23(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Je suis %d et mon p\C3\A8re est le %d \0A\00"
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %6
br label %18
18: ; preds = %30, %2
%19 = load i32, i32* %6
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = call i32 (...) @fork()
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = call i32 (...) @getpid()
%27 = call i32 (...) @getppid()
%28 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
ret i32 0
29: ; preds = %21
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, -1
store i32 %32, i32* %6
br label %18
33: ; preds = %18
%34 = load i32, i32* %7
br label %35
35: ; preds = %40, %33
%36 = load i32, i32* %7
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = call i32 @wait(i32* null)
br label %40
40: ; preds = %38
%41 = load i32, i32* %7
%42 = add nsw i32 %41, -1
store i32 %42, i32* %7
br label %35
43: ; preds = %35
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [36 x i8] c"Je suis %d et mon p\C3\A8re est le %d \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %11, label %24
7: ; preds = %11
%8 = add nsw i32 %12, -1
%9 = icmp sgt i32 %12, 1
br i1 %9, label %11, label %10
10: ; preds = %7
br i1 %6, label %19, label %24
11: ; preds = %2, %7
%12 = phi i32 [ %8, %7 ], [ %5, %2 ]
%13 = tail call i32 (...) @fork()
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %11
%16 = tail call i32 (...) @getpid()
%17 = tail call i32 (...) @getppid()
%18 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
ret i32 0
19: ; preds = %10, %19
%20 = phi i32 [ %22, %19 ], [ %5, %10 ]
%21 = tail call i32 @wait(i32* null)
%22 = add nsw i32 %20, -1
%23 = icmp ugt i32 %20, 1
br i1 %23, label %19, label %24
24: ; preds = %19, %2, %10
%25 = tail call i32 @exit(i32 0)
unreachable
}