#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*/ execl(char *, char *, char *, char *, char *,
                         int /*<<< orphan*/);
scalar_t__ fork();
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ wait(int *);
int main() {
  int res;
  printf("Le père %d \n", getpid());
  if (fork() == 0) {
    execl("/home/cnamliban/mesgit/nsy103/GCC/lesProcessus/Recouvrement/calc",
          "./calc", "2", "toto", "titi", 0);
    printf("Je ne viens jamais ici \n");
  } else {
    printf("Le père attend son fils \n");
    wait(&res);
    printf("Le fils c'est terminé avec ;e code %d\n", res);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    11c5 <main+0x75>
lea    0xe80(%rip),%rdi
lea    0xeba(%rip),%rsi
lea    0xeba(%rip),%rdx
lea    0xeb5(%rip),%rcx
lea    0xeb3(%rip),%r8
xor    %r9d,%r9d
call   1050 <execl@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ed <main+0x9d>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1060 <wait@plt>
mov    -0x8(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11ae <main+0x4e>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rdi
call   1070 <wait@plt>
mov    0x4(%rsp),%esi
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e5 <main+0x85>
lea    0xe59(%rip),%rdi
lea    0xe93(%rip),%rsi
lea    0xe93(%rip),%rdx
lea    0xe8e(%rip),%rcx
lea    0xe8c(%rip),%r8
xor    %r9d,%r9d
call   1060 <execl@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Le p\C3\A8re %d \0A\00"
@.str.1 = [65 x i8] c"/home/cnamliban/mesgit/nsy103/GCC/lesProcessus/Recouvrement/calc\00"
@.str.2 = [7 x i8] c"./calc\00"
@.str.3 = [2 x i8] c"2\00"
@.str.4 = [5 x i8] c"toto\00"
@.str.5 = [5 x i8] c"titi\00"
@.str.6 = [25 x i8] c"Je ne viens jamais ici \0A\00"
@.str.7 = [27 x i8] c"Le p\C3\A8re attend son fils \0A\00"
@.str.8 = [40 x i8] c"Le fils c'est termin\C3\A9 avec ;e code %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @getpid()
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @execl(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 0)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %15
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 @wait(i32* %2)
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %10, %7
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [14 x i8] c"Le p\C3\A8re %d \0A\00"
@.str.1 = [65 x i8] c"/home/cnamliban/mesgit/nsy103/GCC/lesProcessus/Recouvrement/calc\00"
@.str.2 = [7 x i8] c"./calc\00"
@.str.3 = [2 x i8] c"2\00"
@.str.4 = [5 x i8] c"toto\00"
@.str.5 = [5 x i8] c"titi\00"
@.str.8 = [40 x i8] c"Le fils c'est termin\C3\A9 avec ;e code %d\0A\00"
@str = [26 x i8] c"Le p\C3\A8re attend son fils \00"
@str.9 = [24 x i8] c"Je ne viens jamais ici \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @execl(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 0)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
br label %15
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%12 = call i32 @wait(i32* %1)
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %10, %7
ret i32 0
}