#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;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ bubbleSort(int *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int strlen(char *);
int /*<<< orphan*/ wait(int *);
int /*<<< orphan*/ write(int, char *, int);
int clientServerModel(int n) {
  int i, status;
  int a[n];
  int clientpipe[2];
  int serverpipe[2];
  char buffer[11];
  char ack;
  if (pipe(clientpipe) < 0 || pipe(serverpipe) < 0) {
    printf("Error in creating pipes\n");
    exit(0);
  }
  pid_t server = fork();
  if (server < 0) {
    printf("Error in forking not enough memory\n");
    exit(0);
  }
  if (server) {
    for (i = 0; i < n; i++) {
      snprintf(buffer, sizeof(buffer), "%d", rand() % 100);
      write(clientpipe[1], buffer, strlen(buffer));
      read(serverpipe[0], &ack, 1);
    }
    for (i = 0; i < n; i++) {
      read(serverpipe[0], buffer, 11);
      a[i] = atoi(buffer);
      write(clientpipe[1], "1", 1);
    }
    close(clientpipe[0]);
    close(clientpipe[1]);
  } else {
    for (i = 0; i < n; i++) {
      read(clientpipe[0], buffer, 11);
      a[i] = atoi(buffer);
      write(serverpipe[1], "1", 1);
    }
    bubbleSort(a, n);
    for (i = 0; i < n; i++) {
      snprintf(buffer, sizeof(buffer), "%d", a[i]);
      write(serverpipe[1], buffer, strlen(buffer));
      read(clientpipe[0], &ack, 1);
    }
    close(serverpipe[0]);
    close(serverpipe[1]);
  }
  wait(&status);
  if (server) {
    for (i = 0; i < n; i++)
      printf("%d ", a[i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<clientServerModel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0x0,%rax
jl     122b <clientServerModel+0x5b>
lea    -0x30(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0x0,%rax
jge    1240 <clientServerModel+0x70>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jge    126b <clientServerModel+0x9b>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
cmpq   $0x0,-0x48(%rbp)
je     136c <clientServerModel+0x19c>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fb <clientServerModel+0x12b>
lea    -0x3b(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    $0x0,%al
call   10f0 <rand@plt>
mov    -0x68(%rbp),%rdi
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0xb,%esi
lea    0xd8b(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x3b(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x3b(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x30(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    127d <clientServerModel+0xad>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1357 <clientServerModel+0x187>
mov    -0x30(%rbp),%edi
lea    -0x3b(%rbp),%rsi
mov    $0xb,%edx
call   10a0 <read@plt>
lea    -0x3b(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edx
mov    -0x50(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%edi
lea    0xd01(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1302 <clientServerModel+0x132>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
jmp    145b <clientServerModel+0x28b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13c8 <clientServerModel+0x1f8>
mov    -0x28(%rbp),%edi
lea    -0x3b(%rbp),%rsi
mov    $0xb,%edx
call   10a0 <read@plt>
lea    -0x3b(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edx
mov    -0x50(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edi
lea    0xc90(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1373 <clientServerModel+0x1a3>
mov    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <bubbleSort@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    144b <clientServerModel+0x27b>
mov    -0x50(%rbp),%rax
lea    -0x3b(%rbp),%rdi
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    $0xb,%esi
lea    0xc3b(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x74(%rbp)
lea    -0x3b(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x3b(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x28(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13db <clientServerModel+0x20b>
mov    -0x30(%rbp),%edi
call   1070 <close@plt>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
lea    -0x10(%rbp),%rdi
call   10d0 <wait@plt>
cmpq   $0x0,-0x48(%rbp)
je     14b7 <clientServerModel+0x2e7>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14a9 <clientServerModel+0x2d9>
mov    -0x50(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xbae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1476 <clientServerModel+0x2a6>
lea    0xb67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clientServerModel>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
mov    %rsp,%r15
mov    %edi,%r14d
mov    %rsp,%r12
lea    0xf(,%r14,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    -0x40(%rbp),%rdi
call   10b0 <pipe@plt>
test   %rax,%rax
js     1474 <clientServerModel+0x284>
lea    -0x38(%rbp),%rdi
call   10b0 <pipe@plt>
test   %rax,%rax
js     1474 <clientServerModel+0x284>
xor    %eax,%eax
call   1100 <fork@plt>
test   %rax,%rax
js     147d <clientServerModel+0x28d>
mov    %r15,-0x60(%rbp)
mov    %ebx,-0x30(%rbp)
mov    %rax,-0x58(%rbp)
je     1341 <clientServerModel+0x151>
test   %ebx,%ebx
jle    1335 <clientServerModel+0x145>
lea    -0x4b(%rbp),%r15
mov    -0x30(%rbp),%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1110 <rand@plt>
movslq %eax,%rcx
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ecx
mov    %r15,%rdi
mov    $0xb,%esi
lea    0xd4e(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x3c(%rbp),%ebx
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x38(%rbp),%edi
lea    -0x29(%rbp),%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
add    $0xffffffff,%r13d
jne    1280 <clientServerModel+0x90>
cmpl   $0x0,-0x30(%rbp)
jle    1335 <clientServerModel+0x145>
xor    %ebx,%ebx
lea    -0x4b(%rbp),%r13
lea    0xd0b(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%edi
mov    %r13,%rsi
mov    $0xb,%edx
call   10c0 <read@plt>
mov    %r13,%rdi
call   10d0 <atoi@plt>
mov    %eax,(%r12,%rbx,4)
mov    -0x3c(%rbp),%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1300 <clientServerModel+0x110>
mov    -0x40(%rbp),%edi
lea    -0x40(%rbp),%rbx
jmp    140e <clientServerModel+0x21e>
test   %ebx,%ebx
jle    13fd <clientServerModel+0x20d>
xor    %ebx,%ebx
lea    -0x4b(%rbp),%r13
lea    0xcad(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    -0x40(%rbp),%edi
mov    %r13,%rsi
mov    $0xb,%edx
call   10c0 <read@plt>
mov    %r13,%rdi
call   10d0 <atoi@plt>
mov    %eax,(%r12,%rbx,4)
mov    -0x34(%rbp),%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1360 <clientServerModel+0x170>
mov    %r12,%rdi
mov    -0x30(%rbp),%ebx
mov    %ebx,%esi
call   10a0 <bubbleSort@plt>
test   %ebx,%ebx
jle    1407 <clientServerModel+0x217>
xor    %ebx,%ebx
lea    -0x4b(%rbp),%r15
nopl   0x0(%rax)
mov    (%r12,%rbx,4),%ecx
mov    %r15,%rdi
mov    $0xb,%esi
lea    0xc3d(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x34(%rbp),%r13d
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x40(%rbp),%edi
lea    -0x29(%rbp),%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    13b0 <clientServerModel+0x1c0>
jmp    1407 <clientServerModel+0x217>
mov    %r12,%rdi
mov    %ebx,%esi
call   10a0 <bubbleSort@plt>
mov    -0x38(%rbp),%edi
lea    -0x38(%rbp),%rbx
call   1090 <close@plt>
mov    0x4(%rbx),%edi
call   1090 <close@plt>
lea    -0x64(%rbp),%rdi
call   10f0 <wait@plt>
cmpq   $0x0,-0x58(%rbp)
mov    -0x30(%rbp),%eax
je     1461 <clientServerModel+0x271>
test   %eax,%eax
jle    1457 <clientServerModel+0x267>
lea    0xbcc(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1440 <clientServerModel+0x250>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x60(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbb1(%rip),%rdi
jmp    1484 <clientServerModel+0x294>
lea    0xb85(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

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

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [4 x i8] c"%d \00"
@str = [35 x i8] c"Error in forking not enough memory\00"
@str.6 = [24 x i8] c"Error in creating pipes\00"
define i32 @clientServerModel(i32 %0) {
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [11 x i8]
%6 = alloca i8
%7 = bitcast i32* %2 to i8*
%8 = zext i32 %0 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = bitcast [2 x i32]* %3 to i8*
%12 = bitcast [2 x i32]* %4 to i8*
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%15 = call i64 @pipe(i32* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %1
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%19 = call i64 @pipe(i32* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17, %1
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %17
%25 = call i64 (...) @fork()
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %24
%31 = icmp eq i64 %25, 0
%32 = icmp sgt i32 %0, 0
br i1 %31, label %36, label %33
33: ; preds = %30
br i1 %32, label %34, label %66
34: ; preds = %33
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %44
36: ; preds = %30
br i1 %32, label %39, label %37
37: ; preds = %36
%38 = call i32 @bubbleSort(i32* %10, i32 %0)
br label %94
39: ; preds = %36
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
br label %68
41: ; preds = %44
br i1 %32, label %42, label %66
42: ; preds = %41
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %56
44: ; preds = %34, %44
%45 = phi i32 [ 0, %34 ], [ %54, %44 ]
%46 = call i32 (...) @rand()
%47 = srem i32 %46, 100
%48 = call i32 @snprintf(i8* %13, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %35
%50 = call i32 @strlen(i8* %13)
%51 = call i32 @write(i32 %49, i8* %13, i32 %50)
%52 = load i32, i32* %18
%53 = call i32 @read(i32 %52, i8* %6, i32 1)
%54 = add nuw nsw i32 %45, 1
%55 = icmp eq i32 %54, %0
br i1 %55, label %41, label %44
56: ; preds = %42, %56
%57 = phi i64 [ 0, %42 ], [ %64, %56 ]
%58 = load i32, i32* %18
%59 = call i32 @read(i32 %58, i8* %13, i32 11)
%60 = call i32 @atoi(i8* %13)
%61 = getelementptr inbounds i32, i32* %10, i64 %57
store i32 %60, i32* %61
%62 = load i32, i32* %43
%63 = call i32 @write(i32 %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%64 = add nuw nsw i64 %57, 1
%65 = icmp eq i64 %64, %8
br i1 %65, label %66, label %56
66: ; preds = %56, %33, %41
%67 = load i32, i32* %14
br label %96
68: ; preds = %39, %68
%69 = phi i64 [ 0, %39 ], [ %76, %68 ]
%70 = load i32, i32* %14
%71 = call i32 @read(i32 %70, i8* %13, i32 11)
%72 = call i32 @atoi(i8* %13)
%73 = getelementptr inbounds i32, i32* %10, i64 %69
store i32 %72, i32* %73
%74 = load i32, i32* %40
%75 = call i32 @write(i32 %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%76 = add nuw nsw i64 %69, 1
%77 = icmp eq i64 %76, %8
br i1 %77, label %78, label %68
78: ; preds = %68
%79 = call i32 @bubbleSort(i32* %10, i32 %0)
br i1 %32, label %80, label %94
80: ; preds = %78
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
br label %82
82: ; preds = %80, %82
%83 = phi i64 [ 0, %80 ], [ %92, %82 ]
%84 = getelementptr inbounds i32, i32* %10, i64 %83
%85 = load i32, i32* %84
%86 = call i32 @snprintf(i8* %13, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %81
%88 = call i32 @strlen(i8* %13)
%89 = call i32 @write(i32 %87, i8* %13, i32 %88)
%90 = load i32, i32* %14
%91 = call i32 @read(i32 %90, i8* %6, i32 1)
%92 = add nuw nsw i64 %83, 1
%93 = icmp eq i64 %92, %8
br i1 %93, label %94, label %82
94: ; preds = %82, %37, %78
%95 = load i32, i32* %18
br label %96
96: ; preds = %94, %66
%97 = phi i32 [ %95, %94 ], [ %67, %66 ]
%98 = phi [2 x i32]* [ %4, %94 ], [ %3, %66 ]
%99 = call i32 @close(i32 %97)
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %98, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @close(i32 %101)
%103 = call i32 @wait(i32* %2)
br i1 %31, label %115, label %104
104: ; preds = %96
%105 = icmp sgt i32 %0, 0
br i1 %105, label %106, label %113
106: ; preds = %104, %106
%107 = phi i64 [ %111, %106 ], [ 0, %104 ]
%108 = getelementptr inbounds i32, i32* %10, i64 %107
%109 = load i32, i32* %108
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %109)
%111 = add nuw nsw i64 %107, 1
%112 = icmp eq i64 %111, %8
br i1 %112, label %113, label %106
113: ; preds = %106, %104
%114 = call i32 @putchar(i32 10)
br label %115
115: ; preds = %113, %96
ret i32 undef
}