#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 EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  int pid = fork();
  if (pid == -1) {
    perror("Erreur lors du fork.");
    exit(1);
  }
  if (pid > 0) {
    while (1) {
      printf("Je suis le père et je ne sait pas que mon fils est mort.\n");
      sleep(3);
    }
  }
  if (pid == 0) {
    exit(0);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1189 <main+0x39>
lea    0xe86(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11b3 <main+0x63>
jmp    1198 <main+0x48>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3,%edi
call   1060 <sleep@plt>
jmp    1198 <main+0x48>
cmpl   $0x0,-0x8(%rbp)
jne    11c4 <main+0x74>
xor    %edi,%edi
call   1050 <exit@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     1191 <main+0x41>
test   %eax,%eax
jle    1184 <main+0x34>
lea    0xead(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1060 <sleep@plt>
jmp    1170 <main+0x20>
je     11a7 <main+0x57>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
lea    0xe68(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Erreur lors du fork.\00"
@.str.1 = [59 x i8] c"Je suis le p\C3\A8re et je ne sait pas que mon fils est mort.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @fork()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
br label %13
13: ; preds = %12, %13
%14 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @sleep(i32 3)
br label %13
16: ; preds = %9
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %16
%22 = load i32, i32* @EXIT_SUCCESS
ret i32 %22
}

LLVM IR (-O2):
@.str = [21 x i8] c"Erreur lors du fork.\00"
@EXIT_SUCCESS = global i32 0
@str = [58 x i8] c"Je suis le p\C3\A8re et je ne sait pas que mon fils est mort.\00"
define i32 @main() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %11
8: ; preds = %6, %8
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @sleep(i32 3)
br label %8
11: ; preds = %6
%12 = icmp eq i32 %1, 0
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %11
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}