#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ exp(double);
int fork();
int getpid();
int /*<<< orphan*/ log(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  int pid;
  printf("pid du père : %d \n", getpid());
  pid = fork();
  if (pid == 0) {
    for (i = 0; i < 500; i++) {
      printf(" [1 %d : %d] ", getpid(), i);
      for (j = 0; j < 100; j++) {
        log(exp(10.0));
        printf("-");
      }
      printf("\n");
    }
    exit(0);
  }
  pid = fork();
  if (pid == 0) {
    for (i = 500; i < 1000; i++) {
      printf(" [2 %d : %d] ", getpid(), i);
      for (j = 0; j < 100; j++) {
        log(exp(10.0));
        printf(".");
      }
      printf("\n");
    }
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1225 <main+0xc5>
movl   $0x0,-0x4(%rbp)
cmpl   $0x1f4,-0x4(%rbp)
jge    121e <main+0xbe>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    1202 <main+0xa2>
movsd  0xe26(%rip),%xmm0
call   1050 <exp@plt>
mov    %eax,%edi
call   1060 <log@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c8 <main+0x68>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    119a <main+0x3a>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    12cb <main+0x16b>
movl   $0x1f4,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    12c4 <main+0x164>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    12a8 <main+0x148>
movsd  0xd80(%rip),%xmm0
call   1050 <exp@plt>
mov    %eax,%edi
call   1060 <log@plt>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126e <main+0x10e>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1240 <main+0xe0>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe86(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11a8 <main+0x38>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     121a <main+0xaa>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe6d(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x64,%ebx
nopw   0x0(%rax,%rax,1)
movsd  0xe18(%rip),%xmm0
call   1060 <exp@plt>
mov    %eax,%edi
call   1070 <log@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x1f4,%ebp
jne    11c0 <main+0x50>
jmp    1288 <main+0x118>
mov    $0x1f4,%ebx
lea    0xe04(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x64,%ebp
nopw   0x0(%rax,%rax,1)
movsd  0xda8(%rip),%xmm0
call   1060 <exp@plt>
mov    %eax,%edi
call   1070 <log@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1250 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0x3e8,%ebx
jne    1230 <main+0xc0>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"pid du p\C3\A8re : %d \0A\00"
@.str.1 = [14 x i8] c" [1 %d : %d] \00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [14 x i8] c" [2 %d : %d] \00"
@.str.5 = [2 x i8] c".\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @getpid()
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 (...) @fork()
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %34
9: ; preds = %0
store i32 0, i32* %1
br label %10
10: ; preds = %29, %9
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 500
br i1 %12, label %13, label %32
13: ; preds = %10
%14 = call i32 (...) @getpid()
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
store i32 0, i32* %2
br label %17
17: ; preds = %24, %13
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 100
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = call i32 @exp(double 1.000000e+01)
%22 = call i32 @log(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %20
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %17
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = load i32, i32* %1
%31 = add nsw i32 %30, 1
store i32 %31, i32* %1
br label %10
32: ; preds = %10
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %0
%35 = call i32 (...) @fork()
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %63
38: ; preds = %34
store i32 500, i32* %1
br label %39
39: ; preds = %58, %38
%40 = load i32, i32* %1
%41 = icmp slt i32 %40, 1000
br i1 %41, label %42, label %61
42: ; preds = %39
%43 = call i32 (...) @getpid()
%44 = load i32, i32* %1
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %44)
store i32 0, i32* %2
br label %46
46: ; preds = %53, %42
%47 = load i32, i32* %2
%48 = icmp slt i32 %47, 100
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = call i32 @exp(double 1.000000e+01)
%51 = call i32 @log(i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %49
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
store i32 %55, i32* %2
br label %46
56: ; preds = %46
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56
%59 = load i32, i32* %1
%60 = add nsw i32 %59, 1
store i32 %60, i32* %1
br label %39
61: ; preds = %39
%62 = call i32 @exit(i32 0)
unreachable
63: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"pid du p\C3\A8re : %d \0A\00"
@.str.1 = [14 x i8] c" [1 %d : %d] \00"
@.str.4 = [14 x i8] c" [2 %d : %d] \00"
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 (...) @fork()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %22
5: ; preds = %0, %16
%6 = phi i32 [ %18, %16 ], [ 0, %0 ]
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %6)
br label %9
9: ; preds = %5, %9
%10 = phi i32 [ 0, %5 ], [ %14, %9 ]
%11 = tail call i32 @exp(double 1.000000e+01)
%12 = tail call i32 @log(i32 %11)
%13 = tail call i32 @putchar(i32 45)
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %9
16: ; preds = %9
%17 = tail call i32 @putchar(i32 10)
%18 = add nuw nsw i32 %6, 1
%19 = icmp eq i32 %18, 500
br i1 %19, label %20, label %5
20: ; preds = %16
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %0
%23 = tail call i32 (...) @fork()
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %42
25: ; preds = %22, %36
%26 = phi i32 [ %38, %36 ], [ 500, %22 ]
%27 = tail call i32 (...) @getpid()
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %26)
br label %29
29: ; preds = %25, %29
%30 = phi i32 [ 0, %25 ], [ %34, %29 ]
%31 = tail call i32 @exp(double 1.000000e+01)
%32 = tail call i32 @log(i32 %31)
%33 = tail call i32 @putchar(i32 46)
%34 = add nuw nsw i32 %30, 1
%35 = icmp eq i32 %34, 100
br i1 %35, label %36, label %29
36: ; preds = %29
%37 = tail call i32 @putchar(i32 10)
%38 = add nuw nsw i32 %26, 1
%39 = icmp eq i32 %38, 1000
br i1 %39, label %40, label %25
40: ; preds = %36
%41 = tail call i32 @exit(i32 0)
unreachable
42: ; preds = %22
ret i32 0
}