#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*/ sleep(int);
int main(int argc, char **argv) {
  pid_t pid = fork();
  if (!pid) {
    sleep(1);
    printf("Je suis le fils mon pid est %i, mon père est %i.\n", getpid(),
           getppid());
  } else {
    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)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11ab <main+0x5b>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getppid@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
jmp    11c3 <main+0x73>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e16(%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     1172 <main+0x22>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xec7(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
jmp    1197 <main+0x47>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getppid@plt>
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    0x2e3d(%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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @fork()
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = call i32 @sleep(i32 1)
%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 %19
15: ; preds = %2
%16 = call i32 (...) @getpid()
%17 = load i32, i32* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %15, %10
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}

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 %10
5: ; preds = %2
%6 = tail call i32 @sleep(i32 1)
%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)
br label %13
10: ; preds = %2
%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 = %10, %5
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}