#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 /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ scanf(char *, char **);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  pid_t pid[3];
  int atob[2], btoc[2], ctoa[2], n;
  if (pipe(atob) == -1) {
    perror("pipe1 fail");
    exit(1);
  }
  if (pipe(btoc) == -1) {
    perror("pipe2 fail");
    exit(1);
  }
  if (pipe(ctoa) == -1) {
    perror("pipe3 fail");
    exit(1);
  }
  pid[0] = fork();
  if (pid[0] == 0) {
    char str1[20], str2[20], dummy[20];
    printf("I am Process P1 \nMy Pid is %ld \nPlease enter a string: ",
           getpid());
    scanf("%s", &str1);
    write(atob[1], str1, 20);
    read(ctoa[0], str2, 20);
    printf("I am Process P1 \nMy Pid is %ld \nI just received uppercase %s\n",
           getpid(), str2);
    write(atob[1], dummy, 1);
    for (n = 0; n != 2; n++) {
      close(atob[n]);
      close(btoc[n]);
      close(ctoa[n]);
    }
    exit(0);
  }
  pid[1] = fork();
  if (pid[1] == 0) {
    char str2[20], str3[20], dummy[20];
    int i, c, a;
    read(atob[0], str2, 20);
    printf("I am Process P2 \nMy Pid is %ld \n", getpid());
    printf("I just received the string %s\n", str2);
    for (i = 0; str2[i] != '\0'; i++)
      ;
    str3[i] = '\0';
    a = 0;
    for (c = i - 1; c >= 0; c--) {
      str3[c] = str2[a];
      a++;
    }
    printf("I am sending %s to P3\n", str3);
    write(btoc[1], str3, 20);
    read(atob[0], dummy, 1);
    write(btoc[1], dummy, 1);
    for (n = 0; n != 2; n++) {
      close(atob[n]);
      close(btoc[n]);
      close(ctoa[n]);
    }
    exit(0);
  }
  pid[2] = fork();
  if (pid[2] == 0) {
    char str3[20], dummy[20];
    int i;
    read(btoc[0], str3, 20);
    printf("I am Process P3 \nMy Pid is %ld \n", getpid());
    printf("I just received the string %s\n", str3);
    for (i = 0; str3[i] != '\0'; i++) {
      str3[i] = str3[i] - 32;
    }
    printf("I am sending uppercase %s back to P1 \n", str3);
    write(ctoa[1], str3, 20);
    read(btoc[0], dummy, 1);
    for (n = 0; n != 2; n++) {
      close(atob[n]);
      close(btoc[n]);
      close(ctoa[n]);
    }
    exit(0);
  }
  for (n = 0; n != 2; n++) {
    close(atob[n]);
    close(btoc[n]);
    close(ctoa[n]);
  }
  for (n = 0; n < 3; n++) {
    int status;
    waitpid(pid[n], &status, 0);
    printf("I am Process %d\nMy Pid is %d\nI am about to die\n", n + 1, pid[n]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
jne    11ea <main+0x3a>
lea    0xe25(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x20(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1212 <main+0x62>
lea    0xe08(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x28(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
jne    123a <main+0x8a>
lea    0xdeb(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1310 <main+0x160>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xde9(%rip),%rdi
call   1090 <scanf@plt>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
mov    -0x28(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x14,%edx
call   1080 <read@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    -0x60(%rbp),%rdx
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
je     1309 <main+0x159>
movslq -0x2c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x28(%rbp,%rax,4),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12ca <main+0x11a>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    14b1 <main+0x301>
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x14,%edx
call   1080 <read@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xe4(%rbp)
movslq -0xe4(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     139f <main+0x1ef>
jmp    138b <main+0x1db>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    136e <main+0x1be>
movslq -0xe4(%rbp),%rax
movb   $0x0,-0xc0(%rbp,%rax,1)
movl   $0x0,-0xec(%rbp)
mov    -0xe4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xe8(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jl     1413 <main+0x263>
movslq -0xec(%rbp),%rax
mov    -0xa0(%rbp,%rax,1),%cl
movslq -0xe8(%rbp),%rax
mov    %cl,-0xc0(%rbp,%rax,1)
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
mov    -0xe8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xe8(%rbp)
jmp    13c7 <main+0x217>
lea    -0xc0(%rbp),%rsi
lea    0xcb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%edi
lea    -0xc0(%rbp),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    -0x1c(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
je     14aa <main+0x2fa>
movslq -0x2c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x28(%rbp,%rax,4),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    146b <main+0x2bb>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    15e7 <main+0x437>
mov    -0x20(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    $0x14,%edx
call   1080 <read@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xc08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x100(%rbp),%rsi
lea    0xbbd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x124(%rbp)
movslq -0x124(%rbp),%rax
movsbl -0x100(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     155d <main+0x3ad>
movslq -0x124(%rbp),%rax
movsbl -0x100(%rbp,%rax,1),%eax
ff
sub    $0x20,%eax
mov    %al,%cl
movslq -0x124(%rbp),%rax
mov    %cl,-0x100(%rbp,%rax,1)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    150f <main+0x35f>
lea    -0x100(%rbp),%rsi
lea    0xba7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
mov    -0x20(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
je     15e0 <main+0x430>
movslq -0x2c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x28(%rbp,%rax,4),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    15a1 <main+0x3f1>
xor    %edi,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
je     162d <main+0x47d>
movslq -0x2c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1060 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x28(%rbp,%rax,4),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    15ee <main+0x43e>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    167e <main+0x4ce>
movslq -0x2c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edi
lea    -0x128(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
movslq -0x2c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edx
lea    0xad0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1634 <main+0x484>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0x10(%rsp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     12d9 <main+0x129>
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     12e2 <main+0x132>
lea    0x18(%rsp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     12eb <main+0x13b>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1301 <main+0x151>
mov    %eax,%ebx
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     137b <main+0x1cb>
mov    %eax,%ebp
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1418 <main+0x268>
mov    %eax,%r14d
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x18(%rsp),%edi
call   1060 <close@plt>
mov    0x14(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x1c(%rsp),%edi
call   1060 <close@plt>
lea    0x20(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
lea    0xebf(%rip),%r12
mov    %r12,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    %r12,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    %r12,%rdi
mov    $0x3,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd20(%rip),%rdi
jmp    12f2 <main+0x142>
lea    0xd22(%rip),%rdi
jmp    12f2 <main+0x142>
lea    0xd24(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xd12(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd3a(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    0x14(%rsp),%edi
mov    %rbx,%rsi
mov    $0x14,%edx
call   1030 <write@plt>
mov    0x18(%rsp),%edi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x14,%edx
call   1080 <read@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xcfb(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%edi
lea    0x60(%rsp),%rsi
jmp    1704 <main+0x554>
mov    0x10(%rsp),%edi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x14,%edx
call   1080 <read@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xcfb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd0c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xfffffffffffffffe,%rax
mov    $0xffffffff,%edx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%edx
cmpb   $0x0,0x22(%rsp,%rax,1)
lea    0x1(%rax),%rax
jne    13d0 <main+0x220>
lea    0x1(%rax),%r11d
movb   $0x0,0x40(%rsp,%r11,1)
cmp    $0xffffffff,%eax
je     16c0 <main+0x510>
test   %edx,%edx
mov    $0x1,%esi
cmovle %edx,%esi
neg    %esi
lea    (%rsi,%rax,1),%rdi
add    $0x2,%rdi
mov    %edi,%r8d
cmp    $0x8,%edi
jae    14bf <main+0x30f>
xor    %esi,%esi
jmp    1610 <main+0x460>
mov    0x8(%rsp),%edi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x14,%edx
call   1080 <read@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xcb5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc6f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%al
test   %al,%al
je     1480 <main+0x2d0>
lea    0x21(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xe0,%al
mov    %al,-0x1(%rcx)
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    1470 <main+0x2c0>
lea    0xc8b(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%edi
mov    %rbx,%rsi
mov    $0x14,%edx
call   1030 <write@plt>
mov    0x8(%rsp),%edi
lea    0x40(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
jmp    170e <main+0x55e>
lea    -0x1(%r8),%rbp
xor    %esi,%esi
cmp    %ebp,%eax
jb     1610 <main+0x460>
shr    $0x20,%rbp
jne    1610 <main+0x460>
cmp    $0x20,%edi
jae    14e3 <main+0x333>
xor    %esi,%esi
jmp    15a5 <main+0x3f5>
mov    %r8d,%esi
and    $0xffffffe0,%esi
test   %edx,%edx
mov    $0x1,%edi
cmovle %edx,%edi
mov    %eax,%r9d
sub    %edi,%r9d
add    $0x2,%r9d
and    $0xffffffe0,%r9d
xor    %ebx,%ebx
pxor   %xmm0,%xmm0
mov    %rax,%rdi
movdqa 0x20(%rsp,%rbx,1),%xmm1
movdqa 0x30(%rsp,%rbx,1),%xmm2
mov    %edi,%ebp
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqu %xmm1,0x31(%rsp,%rbp,1)
movdqa %xmm2,%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm1,%xmm2
movdqu %xmm2,0x21(%rsp,%rbp,1)
add    $0x20,%rbx
add    $0xffffffffffffffe0,%rdi
cmp    %rbx,%r9
jne    150a <main+0x35a>
cmp    %r8,%rsi
je     16c0 <main+0x510>
test   $0x18,%r8b
jne    15a5 <main+0x3f5>
sub    %rsi,%r11
jmp    1610 <main+0x460>
mov    %rsi,%rbp
mov    %r8d,%esi
and    $0xfffffff8,%esi
sub    %rsi,%r11
mov    %rax,%rdi
sub    %rbp,%rdi
test   %edx,%edx
mov    $0x1,%r9d
cmovle %edx,%r9d
mov    %eax,%r10d
sub    %r9d,%r10d
add    $0x2,%r10d
and    $0xfffffff8,%r10d
pxor   %xmm0,%xmm0
movq   0x20(%rsp,%rbp,1),%xmm1
punpcklbw %xmm0,%xmm1
mov    %edi,%ebx
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,0x39(%rsp,%rbx,1)
add    $0x8,%rbp
add    $0xfffffffffffffff8,%rdi
cmp    %rbp,%r10
jne    15d5 <main+0x425>
cmp    %r8,%rsi
je     16c0 <main+0x510>
mov    %rsi,%r9
not    %r9
add    %r8,%r9
test   $0x3,%r8b
je     165a <main+0x4aa>
lea    0x1(%rax),%edi
test   %edi,%edi
mov    $0x1,%ebx
cmovle %edi,%ebx
lea    0x2(%rax),%rdi
sub    %bl,%dil
movzbl %dil,%edi
and    $0x3,%edi
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r11
movzbl 0x20(%rsp,%rsi,1),%ebx
mov    %r11d,%ebp
mov    %bl,0x40(%rsp,%rbp,1)
add    $0x1,%rsi
add    $0xffffffffffffffff,%rdi
jne    1640 <main+0x490>
cmp    $0x3,%r9
jb     16c0 <main+0x510>
mov    $0xfffffffe,%edi
test   %edx,%edx
mov    $0x1,%ebp
cmovle %edx,%ebp
sub    %ebp,%eax
add    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r11,%rdi,1),%rdx
lea    0x1(%rdx),%ebp
movzbl 0x20(%rsp,%rsi,1),%ebx
movzbl 0x21(%rsp,%rsi,1),%ecx
mov    %bl,0x40(%rsp,%rbp,1)
mov    %edx,%ebp
mov    %cl,0x40(%rsp,%rbp,1)
add    $0xffffffff,%edx
movzbl 0x22(%rsp,%rsi,1),%ecx
mov    %cl,0x40(%rsp,%rdx,1)
add    $0xfffffffffffffffc,%r11
movzbl 0x23(%rsp,%rsi,1),%ecx
mov    %r11d,%edx
mov    %cl,0x40(%rsp,%rdx,1)
add    $0x4,%rsi
cmp    %rsi,%rax
jne    1680 <main+0x4d0>
lea    0xa13(%rip),%rdi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x14,%edx
call   1030 <write@plt>
mov    0x10(%rsp),%edi
lea    0x60(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x18(%rsp),%edi
call   1060 <close@plt>
mov    0x14(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x1c(%rsp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"pipe1 fail\00"
@.str.1 = [11 x i8] c"pipe2 fail\00"
@.str.2 = [11 x i8] c"pipe3 fail\00"
@.str.3 = [56 x i8] c"I am Process P1 \0AMy Pid is %ld \0APlease enter a string: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [62 x i8] c"I am Process P1 \0AMy Pid is %ld \0AI just received uppercase %s\0A\00"
@.str.6 = [33 x i8] c"I am Process P2 \0AMy Pid is %ld \0A\00"
@.str.7 = [31 x i8] c"I just received the string %s\0A\00"
@.str.8 = [23 x i8] c"I am sending %s to P3\0A\00"
@.str.9 = [33 x i8] c"I am Process P3 \0AMy Pid is %ld \0A\00"
@.str.10 = [39 x i8] c"I am sending uppercase %s back to P1 \0A\00"
@.str.11 = [48 x i8] c"I am Process %d\0AMy Pid is %d\0AI am about to die\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca i32
%7 = alloca [20 x i8]
%8 = alloca [20 x i8]
%9 = alloca [20 x i8]
%10 = alloca [20 x i8]
%11 = alloca [20 x i8]
%12 = alloca [20 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [20 x i8]
%17 = alloca [20 x i8]
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %1
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%21 = call i32 @pipe(i32* %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %0
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%28 = call i32 @pipe(i32* %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %26
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%35 = call i32 @pipe(i32* %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %33
%41 = call i32 (...) @fork()
%42 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 %41, i32* %42
%43 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %90
46: ; preds = %40
%47 = call i32 (...) @getpid()
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = bitcast [20 x i8]* %7 to i8**
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %49)
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%52 = load i32, i32* %51
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%54 = call i32 @write(i32 %52, i8* %53, i32 20)
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%58 = call i32 @read(i32 %56, i8* %57, i32 20)
%59 = call i32 (...) @getpid()
%60 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %59, i8* %60)
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%63 = load i32, i32* %62
%64 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%65 = call i32 @write(i32 %63, i8* %64, i32 1)
store i32 0, i32* %6
br label %66
66: ; preds = %85, %46
%67 = load i32, i32* %6
%68 = icmp ne i32 %67, 2
br i1 %68, label %69, label %88
69: ; preds = %66
%70 = load i32, i32* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = call i32 @close(i32 %73)
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 %76
%78 = load i32, i32* %77
%79 = call i32 @close(i32 %78)
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
br label %85
85: ; preds = %69
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 1
store i32 %87, i32* %6
br label %66
88: ; preds = %66
%89 = call i32 @exit(i32 0)
unreachable
90: ; preds = %40
%91 = call i32 (...) @fork()
%92 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32 %91, i32* %92
%93 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%94 = load i32, i32* %93
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %177
96: ; preds = %90
%97 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%98 = load i32, i32* %97
%99 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%100 = call i32 @read(i32 %98, i8* %99, i32 20)
%101 = call i32 (...) @getpid()
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %101)
%103 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %103)
store i32 0, i32* %13
br label %105
105: ; preds = %113, %96
%106 = load i32, i32* %13
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %107
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %105
br label %113
113: ; preds = %112
%114 = load i32, i32* %13
%115 = add nsw i32 %114, 1
store i32 %115, i32* %13
br label %105
116: ; preds = %105
%117 = load i32, i32* %13
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %118
store i8 0, i8* %119
store i32 0, i32* %15
%120 = load i32, i32* %13
%121 = sub nsw i32 %120, 1
store i32 %121, i32* %14
br label %122
122: ; preds = %135, %116
%123 = load i32, i32* %14
%124 = icmp sge i32 %123, 0
br i1 %124, label %125, label %138
125: ; preds = %122
%126 = load i32, i32* %15
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %127
%129 = load i8, i8* %128
%130 = load i32, i32* %14
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %131
store i8 %129, i8* %132
%133 = load i32, i32* %15
%134 = add nsw i32 %133, 1
store i32 %134, i32* %15
br label %135
135: ; preds = %125
%136 = load i32, i32* %14
%137 = add nsw i32 %136, -1
store i32 %137, i32* %14
br label %122
138: ; preds = %122
%139 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %139)
%141 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%142 = load i32, i32* %141
%143 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%144 = call i32 @write(i32 %142, i8* %143, i32 20)
%145 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%146 = load i32, i32* %145
%147 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%148 = call i32 @read(i32 %146, i8* %147, i32 1)
%149 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%150 = load i32, i32* %149
%151 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%152 = call i32 @write(i32 %150, i8* %151, i32 1)
store i32 0, i32* %6
br label %153
153: ; preds = %172, %138
%154 = load i32, i32* %6
%155 = icmp ne i32 %154, 2
br i1 %155, label %156, label %175
156: ; preds = %153
%157 = load i32, i32* %6
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 %158
%160 = load i32, i32* %159
%161 = call i32 @close(i32 %160)
%162 = load i32, i32* %6
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 %163
%165 = load i32, i32* %164
%166 = call i32 @close(i32 %165)
%167 = load i32, i32* %6
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %168
%170 = load i32, i32* %169
%171 = call i32 @close(i32 %170)
br label %172
172: ; preds = %156
%173 = load i32, i32* %6
%174 = add nsw i32 %173, 1
store i32 %174, i32* %6
br label %153
175: ; preds = %153
%176 = call i32 @exit(i32 0)
unreachable
177: ; preds = %90
%178 = call i32 (...) @fork()
%179 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 %178, i32* %179
%180 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%181 = load i32, i32* %180
%182 = icmp eq i32 %181, 0
br i1 %182, label %183, label %248
183: ; preds = %177
%184 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%185 = load i32, i32* %184
%186 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 0
%187 = call i32 @read(i32 %185, i8* %186, i32 20)
%188 = call i32 (...) @getpid()
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %188)
%190 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 0
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %190)
store i32 0, i32* %18
br label %192
192: ; preds = %210, %183
%193 = load i32, i32* %18
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 %194
%196 = load i8, i8* %195
%197 = sext i8 %196 to i32
%198 = icmp ne i32 %197, 0
br i1 %198, label %199, label %213
199: ; preds = %192
%200 = load i32, i32* %18
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 %201
%203 = load i8, i8* %202
%204 = sext i8 %203 to i32
%205 = sub nsw i32 %204, 32
%206 = trunc i32 %205 to i8
%207 = load i32, i32* %18
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 %208
store i8 %206, i8* %209
br label %210
210: ; preds = %199
%211 = load i32, i32* %18
%212 = add nsw i32 %211, 1
store i32 %212, i32* %18
br label %192
213: ; preds = %192
%214 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 0
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i8* %214)
%216 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%217 = load i32, i32* %216
%218 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 0
%219 = call i32 @write(i32 %217, i8* %218, i32 20)
%220 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%221 = load i32, i32* %220
%222 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%223 = call i32 @read(i32 %221, i8* %222, i32 1)
store i32 0, i32* %6
br label %224
224: ; preds = %243, %213
%225 = load i32, i32* %6
%226 = icmp ne i32 %225, 2
br i1 %226, label %227, label %246
227: ; preds = %224
%228 = load i32, i32* %6
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 %229
%231 = load i32, i32* %230
%232 = call i32 @close(i32 %231)
%233 = load i32, i32* %6
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 %234
%236 = load i32, i32* %235
%237 = call i32 @close(i32 %236)
%238 = load i32, i32* %6
%239 = sext i32 %238 to i64
%240 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %239
%241 = load i32, i32* %240
%242 = call i32 @close(i32 %241)
br label %243
243: ; preds = %227
%244 = load i32, i32* %6
%245 = add nsw i32 %244, 1
store i32 %245, i32* %6
br label %224
246: ; preds = %224
%247 = call i32 @exit(i32 0)
unreachable
248: ; preds = %177
store i32 0, i32* %6
br label %249
249: ; preds = %268, %248
%250 = load i32, i32* %6
%251 = icmp ne i32 %250, 2
br i1 %251, label %252, label %271
252: ; preds = %249
%253 = load i32, i32* %6
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 %254
%256 = load i32, i32* %255
%257 = call i32 @close(i32 %256)
%258 = load i32, i32* %6
%259 = sext i32 %258 to i64
%260 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 %259
%261 = load i32, i32* %260
%262 = call i32 @close(i32 %261)
%263 = load i32, i32* %6
%264 = sext i32 %263 to i64
%265 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %264
%266 = load i32, i32* %265
%267 = call i32 @close(i32 %266)
br label %268
268: ; preds = %252
%269 = load i32, i32* %6
%270 = add nsw i32 %269, 1
store i32 %270, i32* %6
br label %249
271: ; preds = %249
store i32 0, i32* %6
br label %272
272: ; preds = %288, %271
%273 = load i32, i32* %6
%274 = icmp slt i32 %273, 3
br i1 %274, label %275, label %291
275: ; preds = %272
%276 = load i32, i32* %6
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %277
%279 = load i32, i32* %278
%280 = call i32 @waitpid(i32 %279, i32* %19, i32 0)
%281 = load i32, i32* %6
%282 = add nsw i32 %281, 1
%283 = load i32, i32* %6
%284 = sext i32 %283 to i64
%285 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %284
%286 = load i32, i32* %285
%287 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0), i32 %282, i32 %286)
br label %288
288: ; preds = %275
%289 = load i32, i32* %6
%290 = add nsw i32 %289, 1
store i32 %290, i32* %6
br label %272
291: ; preds = %272
%292 = load i32, i32* %1
ret i32 %292
}

LLVM IR (-O2):
@.str = [11 x i8] c"pipe1 fail\00"
@.str.1 = [11 x i8] c"pipe2 fail\00"
@.str.2 = [11 x i8] c"pipe3 fail\00"
@.str.3 = [56 x i8] c"I am Process P1 \0AMy Pid is %ld \0APlease enter a string: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [62 x i8] c"I am Process P1 \0AMy Pid is %ld \0AI just received uppercase %s\0A\00"
@.str.6 = [33 x i8] c"I am Process P2 \0AMy Pid is %ld \0A\00"
@.str.7 = [31 x i8] c"I just received the string %s\0A\00"
@.str.8 = [23 x i8] c"I am sending %s to P3\0A\00"
@.str.9 = [33 x i8] c"I am Process P3 \0AMy Pid is %ld \0A\00"
@.str.10 = [39 x i8] c"I am sending uppercase %s back to P1 \0A\00"
@.str.11 = [48 x i8] c"I am Process %d\0AMy Pid is %d\0AI am about to die\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = alloca [20 x i8]
%8 = alloca [20 x i8]
%9 = alloca [20 x i8]
%10 = alloca [20 x i8]
%11 = alloca [20 x i8]
%12 = alloca i32
%13 = bitcast [2 x i32]* %1 to i8*
%14 = bitcast [2 x i32]* %2 to i8*
%15 = bitcast [2 x i32]* %3 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %0
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%24 = call i32 @pipe(i32* %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %22
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%31 = call i32 @pipe(i32* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %29
%37 = call i32 (...) @fork()
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %71
39: ; preds = %36
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%43 = call i32 (...) @getpid()
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = bitcast [20 x i8]* %4 to i8**
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %45)
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i32 @write(i32 %48, i8* %40, i32 20)
%50 = load i32, i32* %30
%51 = call i32 @read(i32 %50, i8* %41, i32 20)
%52 = call i32 (...) @getpid()
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %52, i8* %41)
%54 = load i32, i32* %47
%55 = call i32 @write(i32 %54, i8* %42, i32 1)
%56 = load i32, i32* %16
%57 = call i32 @close(i32 %56)
%58 = load i32, i32* %23
%59 = call i32 @close(i32 %58)
%60 = load i32, i32* %30
%61 = call i32 @close(i32 %60)
%62 = load i32, i32* %47
%63 = call i32 @close(i32 %62)
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 @close(i32 %65)
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%68 = load i32, i32* %67
%69 = call i32 @close(i32 %68)
%70 = call i32 @exit(i32 0)
unreachable
71: ; preds = %36
%72 = call i32 (...) @fork()
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %232
74: ; preds = %71
%75 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%76 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%77 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%78 = load i32, i32* %16
%79 = call i32 @read(i32 %78, i8* %75, i32 20)
%80 = call i32 (...) @getpid()
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %80)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %75)
br label %83
83: ; preds = %83, %74
%84 = phi i64 [ %88, %83 ], [ 0, %74 ]
%85 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 0
%88 = add nuw i64 %84, 1
br i1 %87, label %89, label %83
89: ; preds = %83
%90 = trunc i64 %84 to i32
%91 = and i64 %84, 4294967295
%92 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %91
store i8 0, i8* %92
%93 = icmp eq i32 %90, 0
br i1 %93, label %208, label %94
94: ; preds = %89
%95 = add i32 %90, 1
%96 = call i32 @llvm.smin.i32(i32 %90, i32 1)
%97 = sub i32 %95, %96
%98 = zext i32 %97 to i64
%99 = icmp ult i32 %97, 8
br i1 %99, label %157, label %100
100: ; preds = %94
%101 = add nsw i64 %98, -1
%102 = add i32 %90, -1
%103 = trunc i64 %101 to i32
%104 = icmp ult i32 %102, %103
%105 = icmp ugt i64 %101, 4294967295
%106 = or i1 %104, %105
br i1 %106, label %157, label %107
107: ; preds = %100
%108 = icmp ult i32 %97, 32
br i1 %108, label %137, label %109
109: ; preds = %107
%110 = and i64 %98, 4294967264
br label %111
111: ; preds = %111, %109
%112 = phi i64 [ 0, %109 ], [ %129, %111 ]
%113 = xor i64 %112, -1
%114 = add i64 %84, %113
%115 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %112
%116 = bitcast i8* %115 to <16 x i8>*
%117 = load <16 x i8>, <16 x i8>* %116
%118 = getelementptr inbounds i8, i8* %115, i64 16
%119 = bitcast i8* %118 to <16 x i8>*
%120 = load <16 x i8>, <16 x i8>* %119
%121 = and i64 %114, 4294967295
%122 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %121
%123 = shufflevector <16 x i8> %117, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%124 = getelementptr inbounds i8, i8* %122, i64 -15
%125 = bitcast i8* %124 to <16 x i8>*
store <16 x i8> %123, <16 x i8>* %125
%126 = shufflevector <16 x i8> %120, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%127 = getelementptr inbounds i8, i8* %122, i64 -31
%128 = bitcast i8* %127 to <16 x i8>*
store <16 x i8> %126, <16 x i8>* %128
%129 = add nuw i64 %112, 32
%130 = icmp eq i64 %129, %110
br i1 %130, label %131, label %111
131: ; preds = %111
%132 = icmp eq i64 %110, %98
br i1 %132, label %208, label %133
133: ; preds = %131
%134 = sub nsw i64 %91, %110
%135 = and i64 %98, 24
%136 = icmp eq i64 %135, 0
br i1 %136, label %157, label %137
137: ; preds = %107, %133
%138 = phi i64 [ %110, %133 ], [ 0, %107 ]
%139 = and i64 %98, 4294967288
%140 = sub nsw i64 %91, %139
br label %141
141: ; preds = %141, %137
%142 = phi i64 [ %138, %137 ], [ %153, %141 ]
%143 = xor i64 %142, -1
%144 = add i64 %84, %143
%145 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %142
%146 = bitcast i8* %145 to <8 x i8>*
%147 = load <8 x i8>, <8 x i8>* %146
%148 = and i64 %144, 4294967295
%149 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %148
%150 = shufflevector <8 x i8> %147, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%151 = getelementptr inbounds i8, i8* %149, i64 -7
%152 = bitcast i8* %151 to <8 x i8>*
store <8 x i8> %150, <8 x i8>* %152
%153 = add nuw i64 %142, 8
%154 = icmp eq i64 %153, %139
br i1 %154, label %155, label %141
155: ; preds = %141
%156 = icmp eq i64 %139, %98
br i1 %156, label %208, label %157
157: ; preds = %100, %94, %133, %155
%158 = phi i64 [ 0, %94 ], [ 0, %100 ], [ %110, %133 ], [ %139, %155 ]
%159 = phi i64 [ %91, %94 ], [ %91, %100 ], [ %134, %133 ], [ %140, %155 ]
%160 = xor i64 %158, -1
%161 = add nsw i64 %160, %98
%162 = and i64 %98, 3
%163 = icmp eq i64 %162, 0
br i1 %163, label %176, label %164
164: ; preds = %157, %164
%165 = phi i64 [ %173, %164 ], [ %158, %157 ]
%166 = phi i64 [ %168, %164 ], [ %159, %157 ]
%167 = phi i64 [ %174, %164 ], [ 0, %157 ]
%168 = add nsw i64 %166, -1
%169 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %165
%170 = load i8, i8* %169
%171 = and i64 %168, 4294967295
%172 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %171
store i8 %170, i8* %172
%173 = add nuw nsw i64 %165, 1
%174 = add i64 %167, 1
%175 = icmp eq i64 %174, %162
br i1 %175, label %176, label %164
176: ; preds = %164, %157
%177 = phi i64 [ %158, %157 ], [ %173, %164 ]
%178 = phi i64 [ %159, %157 ], [ %168, %164 ]
%179 = icmp ult i64 %161, 3
br i1 %179, label %208, label %180
180: ; preds = %176, %180
%181 = phi i64 [ %206, %180 ], [ %177, %176 ]
%182 = phi i64 [ %201, %180 ], [ %178, %176 ]
%183 = add i64 %182, 4294967295
%184 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %181
%185 = load i8, i8* %184
%186 = and i64 %183, 4294967295
%187 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %186
store i8 %185, i8* %187
%188 = add nuw nsw i64 %181, 1
%189 = add i64 %182, 4294967294
%190 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %188
%191 = load i8, i8* %190
%192 = and i64 %189, 4294967295
%193 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %192
store i8 %191, i8* %193
%194 = add nuw nsw i64 %181, 2
%195 = add i64 %182, 4294967293
%196 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %194
%197 = load i8, i8* %196
%198 = and i64 %195, 4294967295
%199 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %198
store i8 %197, i8* %199
%200 = add nuw nsw i64 %181, 3
%201 = add nsw i64 %182, -4
%202 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %200
%203 = load i8, i8* %202
%204 = and i64 %201, 4294967295
%205 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %204
store i8 %203, i8* %205
%206 = add nuw nsw i64 %181, 4
%207 = icmp eq i64 %206, %98
br i1 %207, label %208, label %180
208: ; preds = %176, %180, %131, %155, %89
%209 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %76)
%210 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%211 = load i32, i32* %210
%212 = call i32 @write(i32 %211, i8* %76, i32 20)
%213 = load i32, i32* %16
%214 = call i32 @read(i32 %213, i8* %77, i32 1)
%215 = load i32, i32* %210
%216 = call i32 @write(i32 %215, i8* %77, i32 1)
%217 = load i32, i32* %16
%218 = call i32 @close(i32 %217)
%219 = load i32, i32* %23
%220 = call i32 @close(i32 %219)
%221 = load i32, i32* %30
%222 = call i32 @close(i32 %221)
%223 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%224 = load i32, i32* %223
%225 = call i32 @close(i32 %224)
%226 = load i32, i32* %210
%227 = call i32 @close(i32 %226)
%228 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%229 = load i32, i32* %228
%230 = call i32 @close(i32 %229)
%231 = call i32 @exit(i32 0)
unreachable
232: ; preds = %71
%233 = call i32 (...) @fork()
%234 = icmp eq i32 %233, 0
br i1 %234, label %258, label %235
235: ; preds = %232
%236 = load i32, i32* %16
%237 = call i32 @close(i32 %236)
%238 = load i32, i32* %23
%239 = call i32 @close(i32 %238)
%240 = load i32, i32* %30
%241 = call i32 @close(i32 %240)
%242 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%243 = load i32, i32* %242
%244 = call i32 @close(i32 %243)
%245 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%246 = load i32, i32* %245
%247 = call i32 @close(i32 %246)
%248 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%249 = load i32, i32* %248
%250 = call i32 @close(i32 %249)
%251 = bitcast i32* %12 to i8*
%252 = call i32 @waitpid(i32 %37, i32* %12, i32 0)
%253 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0), i32 1, i32 %37)
%254 = call i32 @waitpid(i32 %72, i32* %12, i32 0)
%255 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0), i32 2, i32 %72)
%256 = call i32 @waitpid(i32 %233, i32* %12, i32 0)
%257 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0), i32 3, i32 %233)
ret i32 0
258: ; preds = %232
%259 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%260 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%261 = load i32, i32* %23
%262 = call i32 @read(i32 %261, i8* %259, i32 20)
%263 = call i32 (...) @getpid()
%264 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %263)
%265 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %259)
%266 = load i8, i8* %259
%267 = icmp eq i8 %266, 0
br i1 %267, label %277, label %268
268: ; preds = %258, %268
%269 = phi i64 [ %273, %268 ], [ 0, %258 ]
%270 = phi i8 [ %275, %268 ], [ %266, %258 ]
%271 = phi i8* [ %274, %268 ], [ %259, %258 ]
%272 = add i8 %270, -32
store i8 %272, i8* %271
%273 = add nuw nsw i64 %269, 1
%274 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %273
%275 = load i8, i8* %274
%276 = icmp eq i8 %275, 0
br i1 %276, label %277, label %268
277: ; preds = %268, %258
%278 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i8* %259)
%279 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%280 = load i32, i32* %279
%281 = call i32 @write(i32 %280, i8* %259, i32 20)
%282 = load i32, i32* %23
%283 = call i32 @read(i32 %282, i8* %260, i32 1)
%284 = load i32, i32* %16
%285 = call i32 @close(i32 %284)
%286 = load i32, i32* %23
%287 = call i32 @close(i32 %286)
%288 = load i32, i32* %30
%289 = call i32 @close(i32 %288)
%290 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%291 = load i32, i32* %290
%292 = call i32 @close(i32 %291)
%293 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%294 = load i32, i32* %293
%295 = call i32 @close(i32 %294)
%296 = load i32, i32* %279
%297 = call i32 @close(i32 %296)
%298 = call i32 @exit(i32 0)
unreachable
}