#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 O_CREAT;
int O_WRONLY;
int S_IRUSR;
int S_IWUSR;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
int WTERMSIG(int);
int /*<<< orphan*/ child_process(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int i;
  int fd;
  int status;
  pid_t child_pid[10];
  fd = open("child.log", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    fprintf(stderr,
            "Hi there... something wrong with opening a log file for your "
            "offspring: %s\n",
            strerror(errno));
    exit(1);
  }
  for (i = 0; i < 10; ++i) {
    child_pid[i] = fork();
    if (child_pid[i] == 0) {
      child_process(fd);
    } else if (child_pid[i] == -1) {
      fprintf(stderr, "Oops... Labour pain. Cannot give birth to child: %s\n",
              strerror(errno));
      exit(1);
    } else {
      printf("Created child with PID %d\n", child_pid[i]);
    }
  }
  close(fd);
  sleep(2);
  printf("=================================================\n");
  for (i = 0; i < 10; ++i) {
    waitpid(child_pid[i], &status, 0);
    if (WIFEXITED(status)) {
      printf("Child %d exited with status %u\n", child_pid[i],
             WEXITSTATUS(status));
    } else if (WIFSIGNALED(status)) {
      printf("Child %d killed by signal %d\n", child_pid[i], WTERMSIG(status));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
mov    0x2df2(%rip),%rax
or     (%rax),%esi
mov    0x2db1(%rip),%rax
mov    (%rax),%edx
mov    0x2dc8(%rip),%rax
or     (%rax),%edx
lea    0xddf(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1269 <main+0x89>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rdx
lea    0xdb0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    131a <main+0x13a>
mov    $0x0,%al
call   1100 <fork@plt>
mov    %eax,%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
movslq -0x14(%rbp),%rax
cmpl   $0x0,-0x50(%rbp,%rax,4)
jne    12a7 <main+0xc7>
mov    -0x18(%rbp),%edi
call   1040 <child_process@plt>
jmp    1307 <main+0x127>
movslq -0x14(%rbp),%rax
cmpl   $0xffffffff,-0x50(%rbp,%rax,4)
jne    12ec <main+0x10c>
mov    0x2d13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xd79(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1307 <main+0x127>
jmp    130c <main+0x12c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1270 <main+0x90>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    13eb <main+0x20b>
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    -0x1c(%rbp),%edi
call   10c0 <WIFEXITED@plt>
cmp    $0x0,%rax
je     139b <main+0x1bb>
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
mov    -0x5c(%rbp),%esi
mov    %eax,%edx
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13d8 <main+0x1f8>
mov    -0x1c(%rbp),%edi
call   1060 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     13d3 <main+0x1f3>
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x60(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <WTERMSIG@plt>
mov    -0x60(%rbp),%esi
mov    %eax,%edx
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13d8 <main+0x1f8>
jmp    13dd <main+0x1fd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1341 <main+0x161>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    0x2dad(%rip),%rax
mov    0x2dee(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dab(%rip),%rax
mov    0x2dc4(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xdd9(%rip),%rdi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     1502 <main+0x312>
mov    %eax,%ebp
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,%ebx
mov    %eax,0x10(%rsp)
test   %eax,%eax
je     1263 <main+0x73>
cmp    $0xffffffff,%ebx
je     14d0 <main+0x2e0>
lea    0xe33(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    126a <main+0x7a>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x14(%rsp)
test   %eax,%eax
je     1294 <main+0xa4>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xe02(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    129b <main+0xab>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x18(%rsp)
test   %eax,%eax
je     12c5 <main+0xd5>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xdd1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12cc <main+0xdc>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x1c(%rsp)
test   %eax,%eax
je     12f6 <main+0x106>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xda0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12fd <main+0x10d>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x20(%rsp)
test   %eax,%eax
je     1327 <main+0x137>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xd6f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    132e <main+0x13e>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x24(%rsp)
test   %eax,%eax
je     1358 <main+0x168>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xd3e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    135f <main+0x16f>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x28(%rsp)
test   %eax,%eax
je     1389 <main+0x199>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xd0d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1390 <main+0x1a0>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x2c(%rsp)
test   %eax,%eax
je     13ba <main+0x1ca>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xcdc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    13c1 <main+0x1d1>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x30(%rsp)
test   %eax,%eax
je     13eb <main+0x1fb>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xcab(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    13f2 <main+0x202>
mov    %ebp,%edi
call   1050 <child_process@plt>
xor    %eax,%eax
call   1110 <fork@plt>
mov    %eax,0x34(%rsp)
test   %eax,%eax
je     141c <main+0x22c>
cmp    $0xffffffff,%eax
je     14d0 <main+0x2e0>
lea    0xc7a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1423 <main+0x233>
mov    %ebp,%edi
call   1050 <child_process@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0x2,%edi
call   1100 <sleep@plt>
lea    0xca9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
lea    0xc(%rsp),%r12
lea    0xc75(%rip),%r14
lea    0xc4e(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12,%rsi
xor    %edx,%edx
call   10b0 <waitpid@plt>
mov    0xc(%rsp),%edi
call   10d0 <WIFEXITED@plt>
mov    0xc(%rsp),%edi
test   %rax,%rax
je     1490 <main+0x2a0>
call   10a0 <WEXITSTATUS@plt>
mov    %r15,%rdi
jmp    14a6 <main+0x2b6>
nopl   0x0(%rax,%rax,1)
call   1070 <WIFSIGNALED@plt>
test   %rax,%rax
je     14b1 <main+0x2c1>
mov    0xc(%rsp),%edi
call   1090 <WTERMSIG@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xa,%rbp
je     14c1 <main+0x2d1>
mov    0x10(%rsp,%rbp,4),%ebx
add    $0x1,%rbp
jmp    1460 <main+0x270>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2af9(%rip),%rax
mov    (%rax),%ebx
mov    0x2ae8(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xb68(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2ac7(%rip),%rax
mov    (%rax),%ebx
mov    0x2ab6(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xaea(%rip),%rsi
jmp    14ee <main+0x2fe>

LLVM IR (-O0):
@.str = [10 x i8] c"child.log\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@stderr = global i32 0
@.str.1 = [76 x i8] c"Hi there... something wrong with opening a log file for your offspring: %s\0A\00"
@errno = global i32 0
@.str.2 = [53 x i8] c"Oops... Labour pain. Cannot give birth to child: %s\0A\00"
@.str.3 = [27 x i8] c"Created child with PID %d\0A\00"
@.str.4 = [51 x i8] c"=================================================\0A\00"
@.str.5 = [32 x i8] c"Child %d exited with status %u\0A\00"
@.str.6 = [30 x i8] c"Child %d killed by signal %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @O_WRONLY
%11 = load i32, i32* @O_CREAT
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IRUSR
%14 = load i32, i32* @S_IWUSR
%15 = or i32 %13, %14
%16 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
store i32 0, i32* %6
br label %26
26: ; preds = %62, %25
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 10
br i1 %28, label %29, label %65
29: ; preds = %26
%30 = call i32 (...) @fork()
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %32
store i32 %30, i32* %33
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %29
%40 = load i32, i32* %7
%41 = call i32 @child_process(i32 %40)
br label %61
42: ; preds = %29
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %54
48: ; preds = %42
%49 = load i32, i32* @stderr
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %42
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %54
br label %61
61: ; preds = %60, %39
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %26
65: ; preds = %26
%66 = load i32, i32* %7
%67 = call i32 @close(i32 %66)
%68 = call i32 @sleep(i32 2)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %70
70: ; preds = %104, %65
%71 = load i32, i32* %6
%72 = icmp slt i32 %71, 10
br i1 %72, label %73, label %107
73: ; preds = %70
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = call i32 @waitpid(i32 %77, i32* %8, i32 0)
%79 = load i32, i32* %8
%80 = call i64 @WIFEXITED(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %90
82: ; preds = %73
%83 = load i32, i32* %6
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = load i32, i32* %8
%88 = call i32 @WEXITSTATUS(i32 %87)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %86, i32 %88)
br label %103
90: ; preds = %73
%91 = load i32, i32* %8
%92 = call i64 @WIFSIGNALED(i32 %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %102
94: ; preds = %90
%95 = load i32, i32* %6
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %96
%98 = load i32, i32* %97
%99 = load i32, i32* %8
%100 = call i32 @WTERMSIG(i32 %99)
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %98, i32 %100)
br label %102
102: ; preds = %94, %90
br label %103
103: ; preds = %102, %82
br label %104
104: ; preds = %103
%105 = load i32, i32* %6
%106 = add nsw i32 %105, 1
store i32 %106, i32* %6
br label %70
107: ; preds = %70
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"child.log\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@stderr = global i32 0
@.str.1 = [76 x i8] c"Hi there... something wrong with opening a log file for your offspring: %s\0A\00"
@errno = global i32 0
@.str.2 = [53 x i8] c"Oops... Labour pain. Cannot give birth to child: %s\0A\00"
@.str.3 = [27 x i8] c"Created child with PID %d\0A\00"
@.str.5 = [32 x i8] c"Child %d exited with status %u\0A\00"
@.str.6 = [30 x i8] c"Child %d killed by signal %d\0A\00"
@str = [50 x i8] c"=================================================\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [10 x i32]* %4 to i8*
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = load i32, i32* @S_IRUSR
%11 = load i32, i32* @S_IWUSR
%12 = or i32 %11, %10
%13 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = tail call i32 (...) @fork()
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
store i32 %16, i32* %17
switch i32 %16, label %32 [
i32 0, label %24
i32 -1, label %26
]
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %15
%25 = tail call i32 @child_process(i32 %13)
br label %34
26: ; preds = %90, %83, %76, %69, %62, %55, %48, %41, %34, %15
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = tail call i8* @strerror(i32 %28)
%30 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %15
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %34
34: ; preds = %24, %32
%35 = tail call i32 (...) @fork()
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 1
store i32 %35, i32* %36
switch i32 %35, label %39 [
i32 0, label %37
i32 -1, label %26
]
37: ; preds = %34
%38 = tail call i32 @child_process(i32 %13)
br label %41
39: ; preds = %34
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %41
41: ; preds = %39, %37
%42 = tail call i32 (...) @fork()
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 2
store i32 %42, i32* %43
switch i32 %42, label %46 [
i32 0, label %44
i32 -1, label %26
]
44: ; preds = %41
%45 = tail call i32 @child_process(i32 %13)
br label %48
46: ; preds = %41
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %48
48: ; preds = %46, %44
%49 = tail call i32 (...) @fork()
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 3
store i32 %49, i32* %50
switch i32 %49, label %53 [
i32 0, label %51
i32 -1, label %26
]
51: ; preds = %48
%52 = tail call i32 @child_process(i32 %13)
br label %55
53: ; preds = %48
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %55
55: ; preds = %53, %51
%56 = tail call i32 (...) @fork()
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 4
store i32 %56, i32* %57
switch i32 %56, label %60 [
i32 0, label %58
i32 -1, label %26
]
58: ; preds = %55
%59 = tail call i32 @child_process(i32 %13)
br label %62
60: ; preds = %55
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %56)
br label %62
62: ; preds = %60, %58
%63 = tail call i32 (...) @fork()
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 5
store i32 %63, i32* %64
switch i32 %63, label %67 [
i32 0, label %65
i32 -1, label %26
]
65: ; preds = %62
%66 = tail call i32 @child_process(i32 %13)
br label %69
67: ; preds = %62
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %63)
br label %69
69: ; preds = %67, %65
%70 = tail call i32 (...) @fork()
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 6
store i32 %70, i32* %71
switch i32 %70, label %74 [
i32 0, label %72
i32 -1, label %26
]
72: ; preds = %69
%73 = tail call i32 @child_process(i32 %13)
br label %76
74: ; preds = %69
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %70)
br label %76
76: ; preds = %74, %72
%77 = tail call i32 (...) @fork()
%78 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 7
store i32 %77, i32* %78
switch i32 %77, label %81 [
i32 0, label %79
i32 -1, label %26
]
79: ; preds = %76
%80 = tail call i32 @child_process(i32 %13)
br label %83
81: ; preds = %76
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %77)
br label %83
83: ; preds = %81, %79
%84 = tail call i32 (...) @fork()
%85 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 8
store i32 %84, i32* %85
switch i32 %84, label %88 [
i32 0, label %86
i32 -1, label %26
]
86: ; preds = %83
%87 = tail call i32 @child_process(i32 %13)
br label %90
88: ; preds = %83
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %84)
br label %90
90: ; preds = %88, %86
%91 = tail call i32 (...) @fork()
%92 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 9
store i32 %91, i32* %92
switch i32 %91, label %95 [
i32 0, label %93
i32 -1, label %26
]
93: ; preds = %90
%94 = tail call i32 @child_process(i32 %13)
br label %97
95: ; preds = %90
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %91)
br label %97
97: ; preds = %95, %93
%98 = tail call i32 @close(i32 %13)
%99 = tail call i32 @sleep(i32 2)
%100 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
br label %101
101: ; preds = %122, %97
%102 = phi i32 [ %16, %97 ], [ %124, %122 ]
%103 = phi i64 [ 0, %97 ], [ %120, %122 ]
%104 = call i32 @waitpid(i32 %102, i32* %3, i32 0)
%105 = load i32, i32* %3
%106 = call i64 @WIFEXITED(i32 %105)
%107 = icmp eq i64 %106, 0
%108 = load i32, i32* %3
br i1 %107, label %112, label %109
109: ; preds = %101
%110 = call i32 @WEXITSTATUS(i32 %108)
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %102, i32 %110)
br label %119
112: ; preds = %101
%113 = call i64 @WIFSIGNALED(i32 %108)
%114 = icmp eq i64 %113, 0
br i1 %114, label %119, label %115
115: ; preds = %112
%116 = load i32, i32* %3
%117 = call i32 @WTERMSIG(i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %102, i32 %117)
br label %119
119: ; preds = %109, %115, %112
%120 = add nuw nsw i64 %103, 1
%121 = icmp eq i64 %120, 10
br i1 %121, label %125, label %122
122: ; preds = %119
%123 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %120
%124 = load i32, i32* %123
br label %101
125: ; preds = %119
ret i32 0
}