#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 fork();
int getpid();
int /*<<< orphan*/ print_stats();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ wait(int /*<<< orphan*/ *);
int main() {
  int pid;
  int i;
  long l;
  long times[] = {500000000L * 2, 500000000L * 1, 500000000L * 3};
  for (i = 0; i < 3; i++) {
    if ((pid = fork()) == 0) {
      for (l = 0; l < times[i]; l++)
        ;
      printf("Child %d (%d) info\n", i, getpid());
      print_stats();
      exit(0);
    }
  }
  for (l = 0; l < 500000000L / 2; l++)
    ;
  printf("Parent process info\n");
  print_stats();
  while (wait(NULL) > 0)
    ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1226 <main+0xc6>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1213 <main+0xb3>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,8),%rax
jge    11e5 <main+0x85>
jmp    11d4 <main+0x74>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11bc <main+0x5c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x34(%rbp),%esi
mov    %eax,%edx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <print_stats@plt>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    1218 <main+0xb8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x37>
movq   $0x0,-0x18(%rbp)
cmpq   $0xee6b280,-0x18(%rbp)
0e
jge    1252 <main+0xf2>
jmp    1241 <main+0xe1>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    122e <main+0xce>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <print_stats@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
cmp    $0x0,%rax
jle    127f <main+0x11f>
jmp    1267 <main+0x107>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11cc <main+0x5c>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11c0 <main+0x50>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11c7 <main+0x57>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <print_stats@plt>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1080 <wait@plt>
test   %rax,%rax
jg     11b0 <main+0x40>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%ebx
jmp    11cc <main+0x5c>
mov    $0x2,%ebx
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xe26(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <print_stats@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.times = [3 x i64] [i64 1000000000, i64 500000000, i64 1500000000]
@.str = [20 x i8] c"Child %d (%d) info\0A\00"
@.str.1 = [21 x i8] c"Parent process info\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca [3 x i64]
store i32 0, i32* %1
%6 = bitcast [3 x i64]* %5 to i8*
store i32 0, i32* %3
br label %7
7: ; preds = %32, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = call i32 (...) @fork()
store i32 %11, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %10
store i64 0, i64* %4
br label %14
14: ; preds = %22, %13
%15 = load i64, i64* %4
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x i64], [3 x i64]* %5, i64 0, i64 %17
%19 = load i64, i64* %18
%20 = icmp slt i64 %15, %19
br i1 %20, label %21, label %25
21: ; preds = %14
br label %22
22: ; preds = %21
%23 = load i64, i64* %4
%24 = add nsw i64 %23, 1
store i64 %24, i64* %4
br label %14
25: ; preds = %14
%26 = load i32, i32* %3
%27 = call i32 (...) @getpid()
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
%29 = call i32 (...) @print_stats()
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %10
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %7
35: ; preds = %7
store i64 0, i64* %4
br label %36
36: ; preds = %40, %35
%37 = load i64, i64* %4
%38 = icmp slt i64 %37, 250000000
br i1 %38, label %39, label %43
39: ; preds = %36
br label %40
40: ; preds = %39
%41 = load i64, i64* %4
%42 = add nsw i64 %41, 1
store i64 %42, i64* %4
br label %36
43: ; preds = %36
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 (...) @print_stats()
br label %46
46: ; preds = %49, %43
%47 = call i64 @wait(i32* null)
%48 = icmp sgt i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
br label %46
50: ; preds = %46
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Child %d (%d) info\0A\00"
@str = [20 x i8] c"Parent process info\00"
define i32 @main() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %9
3: ; preds = %12, %9, %0
%4 = phi i32 [ 0, %0 ], [ 1, %9 ], [ 2, %12 ]
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = tail call i32 (...) @print_stats()
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = tail call i32 (...) @fork()
%11 = icmp eq i32 %10, 0
br i1 %11, label %3, label %12
12: ; preds = %9
%13 = tail call i32 (...) @fork()
%14 = icmp eq i32 %13, 0
br i1 %14, label %3, label %15
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 (...) @print_stats()
br label %18
18: ; preds = %18, %15
%19 = tail call i64 @wait(i32* null)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %18, label %21
21: ; preds = %18
ret i32 0
}