#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 MAP_ANONYMOUS;
int MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
scalar_t__ fork();
int getpid();
unsigned long *mmap(int /*<<< orphan*/ *, int, int, int, int,
                    int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
scalar_t__ wait(int *);
int main() {
  pid_t pid, wpid;
  int n = 0, status = 0, i = 0;
  unsigned short proceed = 0;
  unsigned long *fib, *pfib, *ppfib;
  printf("Fibchild - fibonacci series \n");
  printf("Give the length of fibonacci series to be printed: ");
  scanf("%d", &n);
  printf("\n");
  fib = mmap(NULL, sizeof *fib, PROT_READ | PROT_WRITE,
             MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  pfib = mmap(NULL, sizeof *pfib, PROT_READ | PROT_WRITE,
              MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  ppfib = mmap(NULL, sizeof *ppfib, PROT_READ | PROT_WRITE,
               MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  i = 1;
  proceed = 1;
  while (i <= n && proceed) {
    pid = fork();
    proceed = 0;
    if (pid > 0)
      printf("Child process created: %d \n", pid);
    if (!pid) {
      printf("Child process executing: %d \n", getpid());
      *ppfib = *pfib;
      *pfib = *fib;
      if (i < 3) {
        *fib = 1;
      } else {
        *fib = *pfib + *ppfib;
      }
      printf("fib(%d) = %lu\t", i, *fib);
      printf("fib(%d) = %lu\t", i - 1, *pfib);
      printf("fib(%d) = %lu\n", i - 2, *ppfib);
    } else if (pid > 0) {
      printf("Parent process waiting: %d \n", getpid());
      wpid = wait(&status);
      proceed = 1;
      printf("Child process ended: %d with status=%d\n\n", wpid, status);
    }
    i++;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movw   $0x0,-0x26(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xf34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    0x2df4(%rip),%rax
or     (%rax),%edx
mov    0x2e0b(%rip),%rax
mov    (%rax),%ecx
mov    0x2df2(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
mov    0x2db5(%rip),%rax
or     (%rax),%edx
mov    0x2dcc(%rip),%rax
mov    (%rax),%ecx
mov    0x2db3(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%edx
mov    0x2d76(%rip),%rax
or     (%rax),%edx
mov    0x2d8d(%rip),%rax
mov    (%rax),%ecx
mov    0x2d74(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x40(%rbp)
movl   $0x1,-0x24(%rbp)
movw   $0x1,-0x26(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x41(%rbp)
jg     12ac <main+0x14c>
movzwl -0x26(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    12bc <main+0x15c>
jmp    1407 <main+0x2a7>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x10(%rbp)
movw   $0x0,-0x26(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    12ea <main+0x18a>
mov    -0x10(%rbp),%rsi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    13aa <main+0x24a>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x3,-0x24(%rbp)
jge    1342 <main+0x1e2>
mov    -0x30(%rbp),%rax
movq   $0x1,(%rax)
jmp    1357 <main+0x1f7>
mov    -0x38(%rbp),%rax
mov    (%rax),%rcx
mov    -0x40(%rbp),%rax
add    (%rax),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%rdx
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%esi
sub    $0x2,%esi
mov    -0x40(%rbp),%rax
mov    (%rax),%rdx
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13f9 <main+0x299>
cmpq   $0x0,-0x10(%rbp)
jle    13f4 <main+0x294>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1070 <wait@plt>
mov    %rax,-0x18(%rbp)
movw   $0x1,-0x26(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13f9 <main+0x299>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    128e <main+0x12e>
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xf31(%rip),%rdi
call   1040 <puts@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe76(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e1f(%rip),%r14
mov    0x2de8(%rip),%rbx
mov    (%rbx),%edx
or     (%r14),%edx
mov    0x2dfc(%rip),%r15
mov    0x2de5(%rip),%rbp
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    (%rbx),%edx
or     (%r14),%edx
mov    %rax,0x8(%rsp)
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    (%rbx),%edx
or     (%r14),%edx
mov    %rax,0x10(%rsp)
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
cmpl   $0x0,0x4(%rsp)
jle    14fd <main+0x37d>
mov    %rax,%r12
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
jle    13a8 <main+0x228>
lea    0xdba(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xdfa(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rdi
call   1090 <wait@plt>
mov    (%rsp),%edx
lea    0xdfc(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmpl   $0x2,0x4(%rsp)
jl     14fd <main+0x37d>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
jle    141a <main+0x29a>
lea    0xd5b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xd9b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rdi
call   1090 <wait@plt>
mov    (%rsp),%edx
lea    0xd9d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmpl   $0x3,0x4(%rsp)
jl     14fd <main+0x37d>
mov    $0x3,%ebx
lea    0xd07(%rip),%r13
lea    0xd58(%rip),%rbp
mov    %rsp,%r14
lea    0xd6b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
jle    1489 <main+0x309>
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1090 <wait@plt>
mov    (%rsp),%edx
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x1(%rbx),%eax
cmp    0x4(%rsp),%ebx
mov    %eax,%ebx
jl     1350 <main+0x1d0>
jmp    14fd <main+0x37d>
jne    14fd <main+0x37d>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xc97(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rbp
mov    0x0(%rbp),%rax
mov    %rax,(%r12)
mov    0x8(%rsp),%rcx
mov    (%rcx),%rax
mov    %rax,0x0(%rbp)
movq   $0x1,(%rcx)
lea    0xc85(%rip),%rbx
mov    $0x1,%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebx
jmp    14e9 <main+0x369>
jne    14fd <main+0x37d>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xc23(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rbp
mov    0x0(%rbp),%rax
mov    %rax,(%r12)
mov    0x8(%rsp),%rcx
mov    (%rcx),%rax
mov    %rax,0x0(%rbp)
movq   $0x1,(%rcx)
lea    0xc11(%rip),%r14
mov    $0x1,%edx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%rdx
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    14e9 <main+0x369>
jne    14fd <main+0x37d>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xbba(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rbp
mov    0x0(%rbp),%rax
mov    %rax,(%r12)
mov    0x8(%rsp),%rax
mov    (%rax),%rdx
mov    %rdx,0x0(%rbp)
add    (%r12),%rdx
mov    %rdx,(%rax)
lea    0xba8(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    -0x1(%rbx),%esi
mov    0x0(%rbp),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0xfffffffe,%ebx
mov    (%r12),%rdx
lea    0xb8c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Fibchild - fibonacci series \0A\00"
@.str.1 = [52 x i8] c"Give the length of fibonacci series to be printed: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str.4 = [28 x i8] c"Child process created: %d \0A\00"
@.str.5 = [30 x i8] c"Child process executing: %d \0A\00"
@.str.6 = [15 x i8] c"fib(%d) = %lu\09\00"
@.str.7 = [15 x i8] c"fib(%d) = %lu\0A\00"
@.str.8 = [29 x i8] c"Parent process waiting: %d \0A\00"
@.str.9 = [41 x i8] c"Child process ended: %d with status=%d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i16
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i64*
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i16 0, i16* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* @PROT_READ
%16 = load i32, i32* @PROT_WRITE
%17 = or i32 %15, %16
%18 = load i32, i32* @MAP_SHARED
%19 = load i32, i32* @MAP_ANONYMOUS
%20 = or i32 %18, %19
%21 = call i64* @mmap(i32* null, i32 8, i32 %17, i32 %20, i32 -1, i32 0)
store i64* %21, i64** %8
%22 = load i32, i32* @PROT_READ
%23 = load i32, i32* @PROT_WRITE
%24 = or i32 %22, %23
%25 = load i32, i32* @MAP_SHARED
%26 = load i32, i32* @MAP_ANONYMOUS
%27 = or i32 %25, %26
%28 = call i64* @mmap(i32* null, i32 8, i32 %24, i32 %27, i32 -1, i32 0)
store i64* %28, i64** %9
%29 = load i32, i32* @PROT_READ
%30 = load i32, i32* @PROT_WRITE
%31 = or i32 %29, %30
%32 = load i32, i32* @MAP_SHARED
%33 = load i32, i32* @MAP_ANONYMOUS
%34 = or i32 %32, %33
%35 = call i64* @mmap(i32* null, i32 8, i32 %31, i32 %34, i32 -1, i32 0)
store i64* %35, i64** %10
store i32 1, i32* %6
store i16 1, i16* %7
br label %36
36: ; preds = %102, %0
%37 = load i32, i32* %6
%38 = load i32, i32* %4
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i16, i16* %7
%42 = zext i16 %41 to i32
%43 = icmp ne i32 %42, 0
br label %44
44: ; preds = %40, %36
%45 = phi i1 [ false, %36 ], [ %43, %40 ]
br i1 %45, label %46, label %105
46: ; preds = %44
%47 = call i64 (...) @fork()
store i64 %47, i64* %2
store i16 0, i16* %7
%48 = load i64, i64* %2
%49 = icmp sgt i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i64, i64* %2
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 %51)
br label %53
53: ; preds = %50, %46
%54 = load i64, i64* %2
%55 = icmp ne i64 %54, 0
br i1 %55, label %91, label %56
56: ; preds = %53
%57 = call i32 (...) @getpid()
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %57)
%59 = load i64*, i64** %9
%60 = load i64, i64* %59
%61 = load i64*, i64** %10
store i64 %60, i64* %61
%62 = load i64*, i64** %8
%63 = load i64, i64* %62
%64 = load i64*, i64** %9
store i64 %63, i64* %64
%65 = load i32, i32* %6
%66 = icmp slt i32 %65, 3
br i1 %66, label %67, label %69
67: ; preds = %56
%68 = load i64*, i64** %8
store i64 1, i64* %68
br label %76
69: ; preds = %56
%70 = load i64*, i64** %9
%71 = load i64, i64* %70
%72 = load i64*, i64** %10
%73 = load i64, i64* %72
%74 = add i64 %71, %73
%75 = load i64*, i64** %8
store i64 %74, i64* %75
br label %76
76: ; preds = %69, %67
%77 = load i32, i32* %6
%78 = load i64*, i64** %8
%79 = load i64, i64* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %77, i64 %79)
%81 = load i32, i32* %6
%82 = sub nsw i32 %81, 1
%83 = load i64*, i64** %9
%84 = load i64, i64* %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %82, i64 %84)
%86 = load i32, i32* %6
%87 = sub nsw i32 %86, 2
%88 = load i64*, i64** %10
%89 = load i64, i64* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %87, i64 %89)
br label %102
91: ; preds = %53
%92 = load i64, i64* %2
%93 = icmp sgt i64 %92, 0
br i1 %93, label %94, label %101
94: ; preds = %91
%95 = call i32 (...) @getpid()
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %95)
%97 = call i64 @wait(i32* %5)
store i64 %97, i64* %3
store i16 1, i16* %7
%98 = load i64, i64* %3
%99 = load i32, i32* %5
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i64 %98, i32 %99)
br label %101
101: ; preds = %94, %91
br label %102
102: ; preds = %101, %76
%103 = load i32, i32* %6
%104 = add nsw i32 %103, 1
store i32 %104, i32* %6
br label %36
105: ; preds = %44
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [52 x i8] c"Give the length of fibonacci series to be printed: \00"
@.str.2 = [3 x i8] c"%d\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str.4 = [28 x i8] c"Child process created: %d \0A\00"
@.str.5 = [30 x i8] c"Child process executing: %d \0A\00"
@.str.6 = [15 x i8] c"fib(%d) = %lu\09\00"
@.str.7 = [15 x i8] c"fib(%d) = %lu\0A\00"
@.str.8 = [29 x i8] c"Parent process waiting: %d \0A\00"
@.str.9 = [41 x i8] c"Child process ended: %d with status=%d\0A\0A\00"
@str = [29 x i8] c"Fibchild - fibonacci series \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 @putchar(i32 10)
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @MAP_SHARED
%13 = load i32, i32* @MAP_ANONYMOUS
%14 = or i32 %13, %12
%15 = call i64* @mmap(i32* null, i32 8, i32 %11, i32 %14, i32 -1, i32 0)
%16 = load i32, i32* @PROT_READ
%17 = load i32, i32* @PROT_WRITE
%18 = or i32 %17, %16
%19 = load i32, i32* @MAP_SHARED
%20 = load i32, i32* @MAP_ANONYMOUS
%21 = or i32 %20, %19
%22 = call i64* @mmap(i32* null, i32 8, i32 %18, i32 %21, i32 -1, i32 0)
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @PROT_WRITE
%25 = or i32 %24, %23
%26 = load i32, i32* @MAP_SHARED
%27 = load i32, i32* @MAP_ANONYMOUS
%28 = or i32 %27, %26
%29 = call i64* @mmap(i32* null, i32 8, i32 %25, i32 %28, i32 -1, i32 0)
%30 = load i32, i32* %1
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %108
32: ; preds = %0
%33 = call i64 (...) @fork()
%34 = icmp sgt i64 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %32
%36 = icmp eq i64 %33, 0
br i1 %36, label %37, label %108
37: ; preds = %35
%38 = call i32 (...) @getpid()
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = load i64, i64* %22
store i64 %40, i64* %29
%41 = load i64, i64* %15
store i64 %41, i64* %22
store i64 1, i64* %15
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 1, i64 1)
%43 = load i64, i64* %22
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 0, i64 %43)
br label %104
45: ; preds = %32
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 %33)
%47 = call i32 (...) @getpid()
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %47)
%49 = call i64 @wait(i32* %2)
%50 = load i32, i32* %2
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i64 %49, i32 %50)
%52 = load i32, i32* %1
%53 = icmp sgt i32 %52, 1
br i1 %53, label %54, label %108
54: ; preds = %45
%55 = call i64 (...) @fork()
%56 = icmp sgt i64 %55, 0
br i1 %56, label %67, label %57
57: ; preds = %54
%58 = icmp eq i64 %55, 0
br i1 %58, label %59, label %108
59: ; preds = %57
%60 = call i32 (...) @getpid()
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = load i64, i64* %22
store i64 %62, i64* %29
%63 = load i64, i64* %15
store i64 %63, i64* %22
store i64 1, i64* %15
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 2, i64 1)
%65 = load i64, i64* %22
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 1, i64 %65)
br label %104
67: ; preds = %54
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 %55)
%69 = call i32 (...) @getpid()
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %69)
%71 = call i64 @wait(i32* %2)
%72 = load i32, i32* %2
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i64 %71, i32 %72)
%74 = load i32, i32* %1
%75 = icmp sgt i32 %74, 2
br i1 %75, label %76, label %108
76: ; preds = %67, %94
%77 = phi i32 [ %101, %94 ], [ 3, %67 ]
%78 = call i64 (...) @fork()
%79 = icmp sgt i64 %78, 0
br i1 %79, label %94, label %80
80: ; preds = %76
%81 = icmp eq i64 %78, 0
br i1 %81, label %82, label %108
82: ; preds = %80
%83 = call i32 (...) @getpid()
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = load i64, i64* %22
store i64 %85, i64* %29
%86 = load i64, i64* %15
store i64 %86, i64* %22
%87 = load i64, i64* %29
%88 = add i64 %87, %86
store i64 %88, i64* %15
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %77, i64 %88)
%90 = add nsw i32 %77, -1
%91 = load i64, i64* %22
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %90, i64 %91)
%93 = add nsw i32 %77, -2
br label %104
94: ; preds = %76
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 %78)
%96 = call i32 (...) @getpid()
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %96)
%98 = call i64 @wait(i32* %2)
%99 = load i32, i32* %2
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i64 %98, i32 %99)
%101 = add nuw nsw i32 %77, 1
%102 = load i32, i32* %1
%103 = icmp slt i32 %77, %102
br i1 %103, label %76, label %108
104: ; preds = %37, %59, %82
%105 = phi i32 [ %93, %82 ], [ 0, %59 ], [ -1, %37 ]
%106 = load i64, i64* %29
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %105, i64 %106)
br label %108
108: ; preds = %94, %104, %80, %57, %35, %45, %67, %0
%109 = call i32 @putchar(i32 10)
ret i32 0
}