#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*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int S_IFIFO;
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  char s[1000];
  int num_read = 0;
  int i = 0;
  int fd_WK, fd_CL[2];
  mknod("WELL_KNOWN", S_IFIFO | 0666, 0);
  printf("Waiting for clients...\n");
  fd_WK = open("WELL_KNOWN", O_RDONLY);
  mknod("SRVR_2_CLA", S_IFIFO | 0666, 0);
  fd_CL[0] = open("SRVR_2_CLA", O_WRONLY);
  mknod("SRVR_2_CLB", S_IFIFO | 0666, 0);
  fd_CL[1] = open("SRVR_2_CLB", O_WRONLY);
  printf("All clients online...\n");
  printf("\nSERVER: Ready to Recieve Requests...\n");
  do {
    if ((num_read = num_read + read(fd_WK, &s[num_read], 1000)) == -1)
      perror("read");
    else {
      i++;
      printf("SERVER: %d B written\nSERVER: Client Text Recieved ::%s\n",
             num_read, s);
      s[num_read++] = '\n';
    }
  } while (num_read > 0 && i < 2);
  s[num_read] = '\0';
  for (i = 0; i < 2; i++)
    write(fd_CL[i], s, num_read);
  system("rm WELL_KNOWN SRVR_2_CLA SRVR_2_CLB");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f4(%rbp)
movl   $0x0,-0x3f8(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe54(%rip),%rdi
xor    %edx,%edx
call   1070 <mknod@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
lea    0xe2f(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x3fc(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe31(%rip),%rdi
xor    %edx,%edx
call   1070 <mknod@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
lea    0xe1a(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x404(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe98(%rip),%rdi
xor    %edx,%edx
call   1070 <mknod@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x400(%rbp)
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3f4(%rbp),%eax
mov    %eax,-0x408(%rbp)
mov    -0x3fc(%rbp),%edi
movslq -0x3f4(%rbp),%rax
lea    -0x3f0(%rbp),%rsi
add    %rax,%rsi
mov    $0x3e8,%edx
call   1060 <read@plt>
mov    %eax,%ecx
mov    -0x408(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x3f4(%rbp)
cmp    $0xffffffff,%eax
jne    12bf <main+0x14f>
lea    0xdb7(%rip),%rdi
call   1090 <perror@plt>
jmp    1304 <main+0x194>
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%esi
lea    -0x3f0(%rbp),%rdx
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3f4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x3f4(%rbp)
cltq
movb   $0xa,-0x3f0(%rbp,%rax,1)
0a
jmp    1309 <main+0x199>
xor    %eax,%eax
cmpl   $0x0,-0x3f4(%rbp)
mov    %al,-0x409(%rbp)
jle    132e <main+0x1be>
cmpl   $0x2,-0x3f8(%rbp)
setl   %al
mov    %al,-0x409(%rbp)
mov    -0x409(%rbp),%al
test   $0x1,%al
jne    1268 <main+0xf8>
movslq -0x3f4(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
movl   $0x0,-0x3f8(%rbp)
cmpl   $0x2,-0x3f8(%rbp)
jge    1396 <main+0x226>
movslq -0x3f8(%rbp),%rax
mov    -0x404(%rbp,%rax,4),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f4(%rbp),%edx
call   1030 <write@plt>
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    1355 <main+0x1e5>
lea    0xd0c(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
mov    0x2e40(%rip),%r12
mov    $0x1b6,%ebp
mov    (%r12),%esi
or     %ebp,%esi
lea    0xe56(%rip),%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %edx,%edx
call   1080 <mknod@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <open@plt>
mov    %eax,%ebx
mov    (%r12),%esi
or     %ebp,%esi
lea    0xe28(%rip),%r15
mov    %r15,%rdi
xor    %edx,%edx
call   1080 <mknod@plt>
mov    0x2dd4(%rip),%r13
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1090 <open@plt>
mov    %eax,0xc(%rsp)
or     (%r12),%ebp
lea    0xe5d(%rip),%r15
mov    %r15,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1080 <mknod@plt>
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1090 <open@plt>
mov    %eax,0x8(%rsp)
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r15b
lea    0xdce(%rip),%r12
lea    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,%eax
lea    (%rsp,%rax,1),%rsi
add    $0x10,%rsi
mov    %ebx,%edi
mov    $0x3e8,%edx
call   1070 <read@plt>
mov    %eax,%ebp
add    %r14d,%ebp
cmp    $0xffffffff,%ebp
je     12f5 <main+0x175>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1(%rbp),%r14d
movslq %ebp,%rax
movb   $0xa,0x10(%rsp,%rax,1)
test   %ebp,%ebp
setns  %al
test   %r15b,%al
mov    $0x0,%r15d
jne    1260 <main+0xe0>
movslq %r14d,%rbx
movb   $0x0,0x10(%rsp,%rbx,1)
lea    0x10(%rsp),%rbp
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <write@plt>
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <write@plt>
lea    0xd77(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd1a(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%r14d
jmp    12ac <main+0x12c>

LLVM IR (-O0):
@.str = [11 x i8] c"WELL_KNOWN\00"
@S_IFIFO = global i32 0
@.str.1 = [24 x i8] c"Waiting for clients...\0A\00"
@O_RDONLY = global i32 0
@.str.2 = [11 x i8] c"SRVR_2_CLA\00"
@O_WRONLY = global i32 0
@.str.3 = [11 x i8] c"SRVR_2_CLB\00"
@.str.4 = [23 x i8] c"All clients online...\0A\00"
@.str.5 = [39 x i8] c"\0ASERVER: Ready to Recieve Requests...\0A\00"
@.str.6 = [5 x i8] c"read\00"
@.str.7 = [56 x i8] c"SERVER: %d B written\0ASERVER: Client Text Recieved ::%s\0A\00"
@.str.8 = [36 x i8] c"rm WELL_KNOWN SRVR_2_CLA SRVR_2_CLB\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x i32]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%7 = load i32, i32* @S_IFIFO
%8 = or i32 %7, 438
%9 = call i32 @mknod(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8, i32 0)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %5
%13 = load i32, i32* @S_IFIFO
%14 = or i32 %13, 438
%15 = call i32 @mknod(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 0)
%16 = load i32, i32* @O_WRONLY
%17 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %17, i32* %18
%19 = load i32, i32* @S_IFIFO
%20 = or i32 %19, 438
%21 = call i32 @mknod(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 0)
%22 = load i32, i32* @O_WRONLY
%23 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %23, i32* %24
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %55, %0
%28 = load i32, i32* %3
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %31
%33 = call i32 @read(i32 %29, i8* %32, i32 1000)
%34 = add nsw i32 %28, %33
store i32 %34, i32* %3
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %27
%37 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %48
38: ; preds = %27
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
%41 = load i32, i32* %3
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i32 %41, i8* %42)
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %46
store i8 10, i8* %47
br label %48
48: ; preds = %38, %36
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* %4
%54 = icmp slt i32 %53, 2
br label %55
55: ; preds = %52, %49
%56 = phi i1 [ false, %49 ], [ %54, %52 ]
br i1 %56, label %27, label %57
57: ; preds = %55
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %59
store i8 0, i8* %60
store i32 0, i32* %4
br label %61
61: ; preds = %72, %57
%62 = load i32, i32* %4
%63 = icmp slt i32 %62, 2
br i1 %63, label %64, label %75
64: ; preds = %61
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%70 = load i32, i32* %3
%71 = call i32 @write(i32 %68, i8* %69, i32 %70)
br label %72
72: ; preds = %64
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
store i32 %74, i32* %4
br label %61
75: ; preds = %61
%76 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"WELL_KNOWN\00"
@S_IFIFO = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [11 x i8] c"SRVR_2_CLA\00"
@O_WRONLY = global i32 0
@.str.3 = [11 x i8] c"SRVR_2_CLB\00"
@.str.6 = [5 x i8] c"read\00"
@.str.7 = [56 x i8] c"SERVER: %d B written\0ASERVER: Client Text Recieved ::%s\0A\00"
@.str.8 = [36 x i8] c"rm WELL_KNOWN SRVR_2_CLA SRVR_2_CLB\00"
@str = [23 x i8] c"Waiting for clients...\00"
@str.9 = [22 x i8] c"All clients online...\00"
@str.10 = [38 x i8] c"\0ASERVER: Ready to Recieve Requests...\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @S_IFIFO
%4 = or i32 %3, 438
%5 = tail call i32 @mknod(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @S_IFIFO
%10 = or i32 %9, 438
%11 = tail call i32 @mknod(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 0)
%12 = load i32, i32* @O_WRONLY
%13 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @S_IFIFO
%15 = or i32 %14, 438
%16 = tail call i32 @mknod(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 0)
%17 = load i32, i32* @O_WRONLY
%18 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
br label %21
21: ; preds = %31, %0
%22 = phi i1 [ false, %31 ], [ true, %0 ]
%23 = phi i32 [ %33, %31 ], [ 0, %0 ]
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %24
%26 = call i32 @read(i32 %8, i8* %25, i32 1000)
%27 = add nsw i32 %26, %23
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %38
31: ; preds = %21
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i32 %27, i8* %2)
%33 = add nuw nsw i32 %27, 1
%34 = sext i32 %27 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %34
store i8 10, i8* %35
%36 = icmp sgt i32 %27, -1
%37 = and i1 %36, %22
br i1 %37, label %21, label %38
38: ; preds = %31, %29
%39 = phi i32 [ -1, %29 ], [ %33, %31 ]
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %40
store i8 0, i8* %41
%42 = call i32 @write(i32 %13, i8* %2, i32 %39)
%43 = call i32 @write(i32 %18, i8* %2, i32 %39)
%44 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}