#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);
int fork();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ wait(int *);
int /*<<< orphan*/ write(int, int *, int);
int main() {
  int p[2], a[9], i, k, v, pid;
  for (i = 0; i <= 9; i++) {
    printf("Enter value for a[%d]\n", i);
    scanf("%d", &a[i]);
  }
  if (pipe(p) == -1) {
    perror("Error in pipe()");
    exit(1);
  } else {
    for (i = 0; i <= 9; i++) {
      write(p[1], &a[i], 4);
    }
    pid = fork();
    switch (pid) {
    case -1:
      perror("Error in fork()");
      exit(0);
    case 0:
      for (i = 0; i <= 9; i++) {
        read(p[0], &a[i], 4);
      }
      i = 0;
      do {
        k = i + 1;
        do {
          if (a[i] > a[k]) {
            v = a[i];
            a[i] = a[k];
            a[k] = v;
          }
          k++;
        } while (k <= 9);
        i++;
      } while (i <= 9);
      for (i = 0; i <= 9; i++) {
        write(p[1], &a[i], 4);
      }
      exit(0);
    default:
      wait(&pid);
      for (i = 0; i <= 9; i++) {
        read(p[0], &a[i], 4);
        printf("--> %d\n", a[i]);
      }
      exit(0);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     11e8 <main+0x58>
mov    -0x34(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe42(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a6 <main+0x16>
lea    -0xc(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1210 <main+0x80>
lea    0xe19(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     124b <main+0xbb>
mov    -0x8(%rbp),%edi
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1217 <main+0x87>
xor    %eax,%eax
call   10b0 <fork@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0xffffffff,%eax
je     1279 <main+0xe9>
jmp    1269 <main+0xd9>
mov    -0x44(%rbp),%eax
test   %eax,%eax
je     128c <main+0xfc>
jmp    137b <main+0x1eb>
lea    0xdaa(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   1090 <exit@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     12c7 <main+0x137>
mov    -0xc(%rbp),%edi
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1293 <main+0x103>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    1313 <main+0x183>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x9,-0x38(%rbp)
jle    12d7 <main+0x147>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jle    12ce <main+0x13e>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     1374 <main+0x1e4>
mov    -0x8(%rbp),%edi
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1340 <main+0x1b0>
xor    %edi,%edi
call   1090 <exit@plt>
lea    -0x40(%rbp),%rdi
call   10a0 <wait@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     13d3 <main+0x243>
mov    -0xc(%rbp),%edi
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xc7a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    138b <main+0x1fb>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe5b(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <printf@plt>
lea    0xe61(%rip),%rbp
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
lea    0x1c(%rsp),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
lea    0x20(%rsp),%r13
mov    %rbp,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <printf@plt>
lea    0x24(%rsp),%r12
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <printf@plt>
lea    0x28(%rsp),%r15
mov    %rbp,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <printf@plt>
lea    0x2c(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
lea    0x30(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <printf@plt>
lea    0x34(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0x8(%rsp),%rdi
call   1050 <pipe@plt>
cmp    $0xffffffff,%eax
jne    12e1 <main+0x151>
lea    0xd48(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x14(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rbp
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x2c(%rsp),%r13
mov    %r13,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
mov    %eax,0x34(%rsp)
cmp    $0xffffffff,%eax
je     14c0 <main+0x330>
test   %eax,%eax
jne    14d3 <main+0x343>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x14(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x20(%rsp),%r12
mov    %r12,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x24(%rsp),%r15
mov    %r15,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x28(%rsp),%r14
mov    %r14,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
mov    %r13,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
xor    %eax,%eax
jmp    148e <main+0x2fe>
nopl   0x0(%rax)
add    $0x1,%rax
cmp    $0xa,%rax
je     161e <main+0x48e>
mov    %rax,%rcx
jmp    14aa <main+0x31a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rcx
cmp    $0x9,%rcx
jae    1480 <main+0x2f0>
mov    0x10(%rsp,%rax,4),%edx
mov    0x14(%rsp,%rcx,4),%esi
cmp    %esi,%edx
jle    14a0 <main+0x310>
mov    %esi,0x10(%rsp,%rax,4)
mov    %edx,0x14(%rsp,%rcx,4)
jmp    14a0 <main+0x310>
lea    0xb63(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0x34(%rsp),%rdi
call   10a0 <wait@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x10(%rsp),%esi
mov    %r13,%r14
lea    0xb3c(%rip),%r13
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x14(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x14(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x18(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x1c(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x20(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x24(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x24(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x28(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x28(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x2c(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x30(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0x34(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x14(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter value for a[%d]\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Error in pipe()\00"
@.str.3 = [16 x i8] c"Error in fork()\00"
@.str.4 = [8 x i8] c"--> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [9 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 9
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %4
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %8
21: ; preds = %8
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%23 = call i32 @pipe(i32* %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %21
store i32 0, i32* %4
br label %29
29: ; preds = %39, %28
%30 = load i32, i32* %4
%31 = icmp sle i32 %30, 9
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%34 = load i32, i32* %33
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %36
%38 = call i32 @write(i32 %34, i32* %37, i32 4)
br label %39
39: ; preds = %32
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %29
42: ; preds = %29
%43 = call i32 (...) @fork()
store i32 %43, i32* %7
%44 = load i32, i32* %7
switch i32 %44, label %120 [
i32 -1, label %45
i32 0, label %48
]
45: ; preds = %42
%46 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @exit(i32 0)
unreachable
48: ; preds = %42
store i32 0, i32* %4
br label %49
49: ; preds = %59, %48
%50 = load i32, i32* %4
%51 = icmp sle i32 %50, 9
br i1 %51, label %52, label %62
52: ; preds = %49
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%54 = load i32, i32* %53
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %56
%58 = call i32 @read(i32 %54, i32* %57, i32 4)
br label %59
59: ; preds = %52
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %49
62: ; preds = %49
store i32 0, i32* %4
br label %63
63: ; preds = %101, %62
%64 = load i32, i32* %4
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %66
66: ; preds = %95, %63
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = icmp sgt i32 %70, %74
br i1 %75, label %76, label %92
76: ; preds = %66
%77 = load i32, i32* %4
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %78
%80 = load i32, i32* %79
store i32 %80, i32* %6
%81 = load i32, i32* %5
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = load i32, i32* %4
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %86
store i32 %84, i32* %87
%88 = load i32, i32* %6
%89 = load i32, i32* %5
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %90
store i32 %88, i32* %91
br label %92
92: ; preds = %76, %66
%93 = load i32, i32* %5
%94 = add nsw i32 %93, 1
store i32 %94, i32* %5
br label %95
95: ; preds = %92
%96 = load i32, i32* %5
%97 = icmp sle i32 %96, 9
br i1 %97, label %66, label %98
98: ; preds = %95
%99 = load i32, i32* %4
%100 = add nsw i32 %99, 1
store i32 %100, i32* %4
br label %101
101: ; preds = %98
%102 = load i32, i32* %4
%103 = icmp sle i32 %102, 9
br i1 %103, label %63, label %104
104: ; preds = %101
store i32 0, i32* %4
br label %105
105: ; preds = %115, %104
%106 = load i32, i32* %4
%107 = icmp sle i32 %106, 9
br i1 %107, label %108, label %118
108: ; preds = %105
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%110 = load i32, i32* %109
%111 = load i32, i32* %4
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %112
%114 = call i32 @write(i32 %110, i32* %113, i32 4)
br label %115
115: ; preds = %108
%116 = load i32, i32* %4
%117 = add nsw i32 %116, 1
store i32 %117, i32* %4
br label %105
118: ; preds = %105
%119 = call i32 @exit(i32 0)
unreachable
120: ; preds = %42
%121 = call i32 @wait(i32* %7)
store i32 0, i32* %4
br label %122
122: ; preds = %137, %120
%123 = load i32, i32* %4
%124 = icmp sle i32 %123, 9
br i1 %124, label %125, label %140
125: ; preds = %122
%126 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%127 = load i32, i32* %126
%128 = load i32, i32* %4
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %129
%131 = call i32 @read(i32 %127, i32* %130, i32 4)
%132 = load i32, i32* %4
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %133
%135 = load i32, i32* %134
%136 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %135)
br label %137
137: ; preds = %125
%138 = load i32, i32* %4
%139 = add nsw i32 %138, 1
store i32 %139, i32* %4
br label %122
140: ; preds = %122
%141 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter value for a[%d]\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Error in pipe()\00"
@.str.3 = [16 x i8] c"Error in fork()\00"
@.str.4 = [8 x i8] c"--> %d\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = bitcast [2 x i32]* %1 to i8*
%5 = bitcast [9 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 0)
%8 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 1)
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 2
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 3)
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 3
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 4)
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 4
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 5)
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 5
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 6)
%26 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 6
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 7)
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 7
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 8)
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 8
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 9)
%35 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 9
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %35)
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%38 = call i32 @pipe(i32* %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %63, label %40
40: ; preds = %0
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 @write(i32 %42, i32* %8, i32 4)
%44 = load i32, i32* %41
%45 = call i32 @write(i32 %44, i32* %11, i32 4)
%46 = load i32, i32* %41
%47 = call i32 @write(i32 %46, i32* %14, i32 4)
%48 = load i32, i32* %41
%49 = call i32 @write(i32 %48, i32* %17, i32 4)
%50 = load i32, i32* %41
%51 = call i32 @write(i32 %50, i32* %20, i32 4)
%52 = load i32, i32* %41
%53 = call i32 @write(i32 %52, i32* %23, i32 4)
%54 = load i32, i32* %41
%55 = call i32 @write(i32 %54, i32* %26, i32 4)
%56 = load i32, i32* %41
%57 = call i32 @write(i32 %56, i32* %29, i32 4)
%58 = load i32, i32* %41
%59 = call i32 @write(i32 %58, i32* %32, i32 4)
%60 = load i32, i32* %41
%61 = call i32 @write(i32 %60, i32* %35, i32 4)
%62 = call i32 (...) @fork()
store i32 %62, i32* %3
switch i32 %62, label %130 [
i32 -1, label %87
i32 0, label %66
]
63: ; preds = %0
%64 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %40
%67 = load i32, i32* %37
%68 = call i32 @read(i32 %67, i32* %8, i32 4)
%69 = load i32, i32* %37
%70 = call i32 @read(i32 %69, i32* %11, i32 4)
%71 = load i32, i32* %37
%72 = call i32 @read(i32 %71, i32* %14, i32 4)
%73 = load i32, i32* %37
%74 = call i32 @read(i32 %73, i32* %17, i32 4)
%75 = load i32, i32* %37
%76 = call i32 @read(i32 %75, i32* %20, i32 4)
%77 = load i32, i32* %37
%78 = call i32 @read(i32 %77, i32* %23, i32 4)
%79 = load i32, i32* %37
%80 = call i32 @read(i32 %79, i32* %26, i32 4)
%81 = load i32, i32* %37
%82 = call i32 @read(i32 %81, i32* %29, i32 4)
%83 = load i32, i32* %37
%84 = call i32 @read(i32 %83, i32* %32, i32 4)
%85 = load i32, i32* %37
%86 = call i32 @read(i32 %85, i32* %35, i32 4)
br label %90
87: ; preds = %40
%88 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%89 = call i32 @exit(i32 0)
unreachable
90: ; preds = %66, %104
%91 = phi i64 [ 0, %66 ], [ %105, %104 ]
%92 = phi i64 [ 1, %66 ], [ %106, %104 ]
%93 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 %91
br label %94
94: ; preds = %101, %90
%95 = phi i64 [ %102, %101 ], [ %92, %90 ]
%96 = load i32, i32* %93
%97 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 %95
%98 = load i32, i32* %97
%99 = icmp sgt i32 %96, %98
br i1 %99, label %100, label %101
100: ; preds = %94
store i32 %98, i32* %93
store i32 %96, i32* %97
br label %101
101: ; preds = %100, %94
%102 = add nuw nsw i64 %95, 1
%103 = icmp ult i64 %95, 9
br i1 %103, label %94, label %104
104: ; preds = %101
%105 = add nuw nsw i64 %91, 1
%106 = add nuw nsw i64 %92, 1
%107 = icmp eq i64 %105, 10
br i1 %107, label %108, label %90
108: ; preds = %104
%109 = load i32, i32* %41
%110 = call i32 @write(i32 %109, i32* %8, i32 4)
%111 = load i32, i32* %41
%112 = call i32 @write(i32 %111, i32* %11, i32 4)
%113 = load i32, i32* %41
%114 = call i32 @write(i32 %113, i32* %14, i32 4)
%115 = load i32, i32* %41
%116 = call i32 @write(i32 %115, i32* %17, i32 4)
%117 = load i32, i32* %41
%118 = call i32 @write(i32 %117, i32* %20, i32 4)
%119 = load i32, i32* %41
%120 = call i32 @write(i32 %119, i32* %23, i32 4)
%121 = load i32, i32* %41
%122 = call i32 @write(i32 %121, i32* %26, i32 4)
%123 = load i32, i32* %41
%124 = call i32 @write(i32 %123, i32* %29, i32 4)
%125 = load i32, i32* %41
%126 = call i32 @write(i32 %125, i32* %32, i32 4)
%127 = load i32, i32* %41
%128 = call i32 @write(i32 %127, i32* %35, i32 4)
%129 = call i32 @exit(i32 0)
unreachable
130: ; preds = %40
%131 = call i32 @wait(i32* %3)
%132 = load i32, i32* %37
%133 = call i32 @read(i32 %132, i32* %8, i32 4)
%134 = load i32, i32* %8
%135 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %134)
%136 = load i32, i32* %37
%137 = call i32 @read(i32 %136, i32* %11, i32 4)
%138 = load i32, i32* %11
%139 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %138)
%140 = load i32, i32* %37
%141 = call i32 @read(i32 %140, i32* %14, i32 4)
%142 = load i32, i32* %14
%143 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %142)
%144 = load i32, i32* %37
%145 = call i32 @read(i32 %144, i32* %17, i32 4)
%146 = load i32, i32* %17
%147 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %146)
%148 = load i32, i32* %37
%149 = call i32 @read(i32 %148, i32* %20, i32 4)
%150 = load i32, i32* %20
%151 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %150)
%152 = load i32, i32* %37
%153 = call i32 @read(i32 %152, i32* %23, i32 4)
%154 = load i32, i32* %23
%155 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %154)
%156 = load i32, i32* %37
%157 = call i32 @read(i32 %156, i32* %26, i32 4)
%158 = load i32, i32* %26
%159 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %158)
%160 = load i32, i32* %37
%161 = call i32 @read(i32 %160, i32* %29, i32 4)
%162 = load i32, i32* %29
%163 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %162)
%164 = load i32, i32* %37
%165 = call i32 @read(i32 %164, i32* %32, i32 4)
%166 = load i32, i32* %32
%167 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %166)
%168 = load i32, i32* %37
%169 = call i32 @read(i32 %168, i32* %35, i32 4)
%170 = load i32, i32* %35
%171 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %170)
%172 = call i32 @exit(i32 0)
unreachable
}