#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 /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int i = 0;
  pid_t pid = fork();
  if (!pid) {
    printf("Je suis le fils mon pid est %i, mon père est %i.\n", getpid(),
           getppid());
  } else {
    wait(NULL);
    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   1070 <fork@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11a8 <main+0x58>
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    0xe62(%rip),%rdi
call   1040 <printf@plt>
jmp    11c9 <main+0x79>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     1179 <main+0x29>
mov    %eax,%ebx
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xec0(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
jmp    1194 <main+0x44>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getppid@plt>
lea    0xe70(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
pop    %rbx
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 %15, label %11
11: ; preds = %2
%12 = call i32 (...) @getpid()
%13 = call i32 (...) @getppid()
%14 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
br label %20
15: ; preds = %2
%16 = call i32 @wait(i32* null)
%17 = call i32 (...) @getpid()
%18 = load i32, i32* %7
%19 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
br label %20
20: ; preds = %15, %11
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

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 %9
5: ; preds = %2
%6 = tail call i32 (...) @getpid()
%7 = tail call i32 (...) @getppid()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
br label %13
9: ; preds = %2
%10 = tail call i32 @wait(i32* null)
%11 = tail call i32 (...) @getpid()
%12 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %3)
br label %13
13: ; preds = %9, %5
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}