#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 fork();
int getpid();
int getppid();
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, char **argv) {
  int i = 0;
  pid_t pid = fork();
  if (!pid) {
    for (i = 0; i < 10000; i++)
      printf("Je suis le fils mon pid est %i, mon père est %i.\n", getpid(),
             getppid());
  } else {
    for (i = 0; i < 10000; i++)
      printf("Je suis le père mon pid est %i, mon fils est %i.\n", getpid(),
             pid);
  }
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11ba <main+0x7a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    11b5 <main+0x75>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <getppid@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <main+0x38>
jmp    11f9 <main+0xb9>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    11f4 <main+0xb4>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%edx
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <main+0x81>
jmp    11f9 <main+0xb9>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
je     117a <main+0x3a>
mov    %eax,%ebx
mov    $0x2710,%ebp
lea    0xed6(%rip),%r14
nopl   (%rax)
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x20>
jmp    11b1 <main+0x71>
mov    $0x2710,%ebx
lea    0xe7a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <getppid@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1190 <main+0x50>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Je suis le fils mon pid est %i, mon p\C3\A8re est %i.\0A\00"
@.str.1 = [51 x i8] c"Je suis le p\C3\A8re mon pid est %i, mon fils est %i.\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = call i32 (...) @fork()
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %2
store i32 0, i32* %6
br label %12
12: ; preds = %19, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 10000
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = call i32 (...) @getpid()
%17 = call i32 (...) @getppid()
%18 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %15
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %12
22: ; preds = %12
br label %35
23: ; preds = %2
store i32 0, i32* %6
br label %24
24: ; preds = %31, %23
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 10000
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = call i32 (...) @getpid()
%29 = load i32, i32* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %24
34: ; preds = %24
br label %35
35: ; preds = %34, %22
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}

LLVM IR (-O2):
@.str = [51 x i8] c"Je suis le fils mon pid est %i, mon p\C3\A8re est %i.\0A\00"
@.str.1 = [51 x i8] c"Je suis le p\C3\A8re mon pid est %i, mon fils est %i.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @fork()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2, %5
%6 = phi i32 [ %10, %5 ], [ 0, %2 ]
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 (...) @getppid()
%9 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = add nuw nsw i32 %6, 1
%11 = icmp eq i32 %10, 10000
br i1 %11, label %18, label %5
12: ; preds = %2, %12
%13 = phi i32 [ %16, %12 ], [ 0, %2 ]
%14 = tail call i32 (...) @getpid()
%15 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %3)
%16 = add nuw nsw i32 %13, 1
%17 = icmp eq i32 %16, 10000
br i1 %17, label %18, label %12
18: ; preds = %12, %5
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}