#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int count;
  pid_t rtn = 1;
  int sleepTime = 200;
  for (count = 0; count < 5; count++) {
    if (rtn > 0) {
      sleepTime += 200;
      rtn = fork();
    } else {
      break;
    }
  }
  if (rtn == 0) {
    char countChar[256];
    char iterationsChar[256];
    char microChar[256];
    char sleepChar[256];
    sprintf(countChar, "%d", count);
    sprintf(iterationsChar, "%d", 1000);
    sprintf(microChar, "%d", 1000000);
    sprintf(sleepChar, "%d", sleepTime);
    char *my_args[6];
    my_args[0] = "filho";
    my_args[1] = countChar;
    my_args[2] = iterationsChar;
    my_args[3] = microChar;
    my_args[4] = sleepChar;
    my_args[5] = NULL;
    execv("filho", my_args);
  } else {
    for (count = 0; count < 5; count++) {
      wait(NULL);
    }
    kill(rtn, SIGTERM);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x1,-0x20(%rbp)
movl   $0xc8,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11d7 <main+0x77>
cmpq   $0x0,-0x20(%rbp)
jle    11bf <main+0x5f>
mov    -0x24(%rbp),%eax
add    $0xc8,%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x20(%rbp)
jmp    11c4 <main+0x64>
jmp    11d7 <main+0x77>
jmp    11c9 <main+0x69>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x2f>
cmpq   $0x0,-0x20(%rbp)
jne    12a7 <main+0x147>
lea    -0x130(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe0d(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xdfa(%rip),%rsi
mov    $0x3e8,%edx
call   1040 <sprintf@plt>
lea    -0x330(%rbp),%rdi
lea    0xde2(%rip),%rsi
mov    $0xf4240,%edx
call   1040 <sprintf@plt>
lea    -0x430(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xdc7(%rip),%rsi
call   1040 <sprintf@plt>
lea    0xdbe(%rip),%rax
mov    %rax,-0x460(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x458(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x330(%rbp),%rax
mov    %rax,-0x448(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x440(%rbp)
movq   $0x0,-0x438(%rbp)
lea    -0x460(%rbp),%rsi
lea    0xd66(%rip),%rdi
call   1070 <execv@plt>
jmp    12e8 <main+0x188>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    12cf <main+0x16f>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12ae <main+0x14e>
mov    -0x20(%rbp),%rdi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    $0xc8,%ebx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
mov    %edx,%ebp
add    $0xc8,%ebx
xor    %eax,%eax
call   1080 <fork@plt>
mov    %rax,%r14
lea    0x1(%rbp),%edx
cmp    $0x3,%ebp
ja     119f <main+0x3f>
test   %r14,%r14
jg     1180 <main+0x20>
test   %r14,%r14
jne    1248 <main+0xe8>
lea    0xe51(%rip),%r15
lea    0x330(%rsp),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x230(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x3e8,%edx
call   1040 <sprintf@plt>
lea    0x130(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0xf4240,%edx
call   1040 <sprintf@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <sprintf@plt>
lea    0xdf8(%rip),%rdi
mov    %rdi,(%rsp)
mov    %r14,0x8(%rsp)
mov    %r12,0x10(%rsp)
mov    %r13,0x18(%rsp)
mov    %rbp,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %rsp,%rsi
call   1070 <execv@plt>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1060 <wait@plt>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %edi,%edi
call   1060 <wait@plt>
xor    %edi,%edi
call   1060 <wait@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1030 <kill@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"filho\00"
@SIGTERM = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
%13 = alloca [6 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1, i64* %7
store i32 200, i32* %8
store i32 0, i32* %6
br label %14
14: ; preds = %26, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i64, i64* %7
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 200
store i32 %22, i32* %8
%23 = call i64 (...) @fork()
store i64 %23, i64* %7
br label %25
24: ; preds = %17
br label %29
25: ; preds = %20
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %14
29: ; preds = %24, %14
%30 = load i64, i64* %7
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %55
32: ; preds = %29
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%34 = load i32, i32* %6
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%37 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1000)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%39 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1000000)
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%41 = load i32, i32* %8
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %43
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%45 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 1
store i8* %44, i8** %45
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%47 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 2
store i8* %46, i8** %47
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%49 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 3
store i8* %48, i8** %49
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%51 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 4
store i8* %50, i8** %51
%52 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 5
store i8* null, i8** %52
%53 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 0
%54 = call i32 @execv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %53)
br label %69
55: ; preds = %29
store i32 0, i32* %6
br label %56
56: ; preds = %61, %55
%57 = load i32, i32* %6
%58 = icmp slt i32 %57, 5
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = call i32 @wait(i32* null)
br label %61
61: ; preds = %59
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %56
64: ; preds = %56
%65 = load i64, i64* %7
%66 = load i32, i32* @SIGTERM
%67 = call i32 @kill(i64 %65, i32 %66)
%68 = call i32 @exit(i32 0)
unreachable
69: ; preds = %32
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"filho\00"
@SIGTERM = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca [6 x i8*]
br label %8
8: ; preds = %2, %8
%9 = phi i32 [ 200, %2 ], [ %11, %8 ]
%10 = phi i32 [ 0, %2 ], [ %13, %8 ]
%11 = add nuw nsw i32 %9, 200
%12 = tail call i64 (...) @fork()
%13 = add nuw nsw i32 %10, 1
%14 = icmp ult i32 %10, 4
%15 = icmp sgt i64 %12, 0
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %8, label %17
17: ; preds = %8
%18 = icmp eq i64 %12, 0
br i1 %18, label %28, label %19
19: ; preds = %17
%20 = tail call i32 @wait(i32* null)
%21 = tail call i32 @wait(i32* null)
%22 = tail call i32 @wait(i32* null)
%23 = tail call i32 @wait(i32* null)
%24 = tail call i32 @wait(i32* null)
%25 = load i32, i32* @SIGTERM
%26 = tail call i32 @kill(i64 %12, i32 %25)
%27 = tail call i32 @exit(i32 0)
unreachable
28: ; preds = %17
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%33 = call i32 @sprintf(i8* %29, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%34 = call i32 @sprintf(i8* %30, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1000)
%35 = call i32 @sprintf(i8* %31, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1000000)
%36 = call i32 @sprintf(i8* %32, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%37 = bitcast [6 x i8*]* %7 to i8*
%38 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %38
%39 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 1
store i8* %29, i8** %39
%40 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 2
store i8* %30, i8** %40
%41 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 3
store i8* %31, i8** %41
%42 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 4
store i8* %32, i8** %42
%43 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 5
store i8* null, i8** %43
%44 = call i32 @execv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %38)
ret i32 0
}