#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ execl(char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  for (i = 0; i < 5; i++) {
    pid_t proc_id = fork();
    if (proc_id == -1) {
      perror("fork");
      exit(EXIT_FAILURE);
    }
    if (proc_id == 0) {
      execl("/bin/cat", "cat", "/proc/loadavg", NULL);
      perror("execl");
      exit(EXIT_FAILURE);
    }
    wait(NULL);
  }
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11fe <main+0xae>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11a5 <main+0x55>
lea    0xe6e(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
jne    11e7 <main+0x97>
lea    0xe4f(%rip),%rdi
lea    0xe4d(%rip),%rsi
lea    0xe4a(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execl@plt>
lea    0xe48(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     11d1 <main+0x81>
cmp    $0xffffffff,%eax
je     11c8 <main+0x78>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     11c8 <main+0x78>
test   %eax,%eax
je     11d1 <main+0x81>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     11c8 <main+0x78>
test   %eax,%eax
je     11d1 <main+0x81>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     11c8 <main+0x78>
test   %eax,%eax
je     11d1 <main+0x81>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     11c8 <main+0x78>
test   %eax,%eax
je     11d1 <main+0x81>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe31(%rip),%rdi
jmp    11f4 <main+0xa4>
lea    0xe2d(%rip),%rdi
lea    0xe2b(%rip),%rsi
lea    0xe28(%rip),%rdx
xor    %ecx,%ecx
call   1050 <execl@plt>
lea    0xe28(%rip),%rdi
call   1030 <perror@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"fork\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"/bin/cat\00"
@.str.2 = [4 x i8] c"cat\00"
@.str.3 = [14 x i8] c"/proc/loadavg\00"
@.str.4 = [6 x i8] c"execl\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = call i32 (...) @fork()
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %11
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32* null)
%24 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %19
%28 = call i32 @wait(i32* null)
br label %29
29: ; preds = %27
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %8
32: ; preds = %8
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [5 x i8] c"fork\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"/bin/cat\00"
@.str.2 = [4 x i8] c"cat\00"
@.str.3 = [14 x i8] c"/proc/loadavg\00"
@.str.4 = [6 x i8] c"execl\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @fork()
switch i32 %3, label %13 [
i32 -1, label %4
i32 0, label %8
]
4: ; preds = %22, %19, %16, %13, %2
%5 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %22, %19, %16, %13, %2
%9 = tail call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32* null)
%10 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = tail call i32 @wait(i32* null)
%15 = tail call i32 (...) @fork()
switch i32 %15, label %16 [
i32 -1, label %4
i32 0, label %8
]
16: ; preds = %13
%17 = tail call i32 @wait(i32* null)
%18 = tail call i32 (...) @fork()
switch i32 %18, label %19 [
i32 -1, label %4
i32 0, label %8
]
19: ; preds = %16
%20 = tail call i32 @wait(i32* null)
%21 = tail call i32 (...) @fork()
switch i32 %21, label %22 [
i32 -1, label %4
i32 0, label %8
]
22: ; preds = %19
%23 = tail call i32 @wait(i32* null)
%24 = tail call i32 (...) @fork()
switch i32 %24, label %25 [
i32 -1, label %4
i32 0, label %8
]
25: ; preds = %22
%26 = tail call i32 @wait(i32* null)
ret i32 0
}