#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*/ exit(int /*<<< orphan*/);
int fork();
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  int status;
  int i;
  printf("P: Création d'un fils\n");
  int ret = fork();
  if (ret == 0) {
    for (i = 0; i < 100; i++) {
      printf("F ");
    }
    exit(0);
  }
  printf("P: %d filsid=%d Attendre le fils\n", getpid(), ret);
  wait(&status);
  printf("P:status = %d\n", status);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11b5 <main+0x65>
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    11ae <main+0x5e>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1188 <main+0x38>
xor    %edi,%edi
call   1050 <exit@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1060 <wait@plt>
mov    -0x14(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     11ba <main+0x5a>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rdi
call   1070 <wait@plt>
mov    0x4(%rsp),%esi
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x64,%ebp
lea    0xe3a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x70>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"P: Cr\C3\A9ation d'un fils\0A\00"
@.str.1 = [3 x i8] c"F \00"
@.str.2 = [34 x i8] c"P: %d filsid=%d Attendre le fils\0A\00"
@.str.3 = [15 x i8] c"P:status = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @fork()
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %2
store i32 0, i32* %6
br label %13
13: ; preds = %18, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %13
21: ; preds = %13
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %2
%24 = call i32 (...) @getpid()
%25 = load i32, i32* %7
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
%27 = call i32 @wait(i32* %5)
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"F \00"
@.str.2 = [34 x i8] c"P: %d filsid=%d Attendre le fils\0A\00"
@.str.3 = [15 x i8] c"P:status = %d\0A\00"
@str = [23 x i8] c"P: Cr\C3\A9ation d'un fils\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @fork()
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ 0, %2 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = tail call i32 (...) @getpid()
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %6)
%18 = call i32 @wait(i32* %3)
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %19)
ret i32 0
}