#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*/ closePipe(char *);
int openPipe(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ randBound(int, int);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ sleep(int /*<<< orphan*/);
scalar_t__ strlen(char *);
int /*<<< orphan*/ write(int, char *, scalar_t__);
int donPepito() {
  char *msgs[4] = {"Hola don Jose", "Por su casa yo pase",
                   "A su abuela yo la vi", "Adios don Jose"};
  char buffer[100] = {0};
  int jose = openPipe("PepitoToJose");
  int me = openPipe("JoseToPepito");
  read(me, buffer, 99);
  printf("Jose: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(jose, msgs[0], strlen(msgs[0]) + 1);
  read(me, buffer, 99);
  printf("Jose: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(jose, msgs[1], strlen(msgs[1]) + 1);
  read(me, buffer, 99);
  printf("Jose: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(jose, msgs[2], strlen(msgs[2]) + 1);
  read(me, buffer, 99);
  printf("Jose: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(jose, msgs[3], strlen(msgs[3]) + 1);
  closePipe("PepitoToJose");
  closePipe("JoseToPepito");
}


x86 assembly (clang, -O0):
<donPepito>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    0x2c5e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c5b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c58(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c55(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
lea    0xe65(%rip),%rdi
call   1090 <openPipe@plt>
mov    %eax,-0xa4(%rbp)
lea    0xe60(%rip),%rdi
call   1090 <openPipe@plt>
mov    %eax,-0xa8(%rbp)
mov    -0xa8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xe4(%rbp),%edi
mov    -0xe0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    -0xa8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xdc4(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xd4(%rbp),%edi
mov    -0xd0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    -0xa8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd4b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc4(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    -0xa8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xcd2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
lea    0xc5d(%rip),%rdi
call   1080 <closePipe@plt>
lea    0xc5e(%rip),%rdi
call   1080 <closePipe@plt>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<donPepito>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe99(%rip),%r14
mov    %r14,%rdi
call   1070 <openPipe@plt>
mov    %eax,%r12d
lea    0xe94(%rip),%r15
mov    %r15,%rdi
call   1070 <openPipe@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
lea    0xe7e(%rip),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xdf6(%rip),%rsi
mov    $0xe,%edx
mov    %r12d,%edi
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xdc0(%rip),%rsi
mov    $0x14,%edx
mov    %r12d,%edi
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xd90(%rip),%rsi
mov    $0x15,%edx
mov    %r12d,%edi
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xd61(%rip),%rsi
mov    $0xf,%edx
mov    %r12d,%edi
call   1030 <write@plt>
mov    %r14,%rdi
call   1060 <closePipe@plt>
mov    %r15,%rdi
call   1060 <closePipe@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Hola don Jose\00"
@.str.1 = [20 x i8] c"Por su casa yo pase\00"
@.str.2 = [21 x i8] c"A su abuela yo la vi\00"
@.str.3 = [15 x i8] c"Adios don Jose\00"
@__const.donPepito.msgs = [4 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [13 x i8] c"PepitoToJose\00"
@.str.5 = [13 x i8] c"JoseToPepito\00"
@.str.6 = [10 x i8] c"Jose: %s\0A\00"
define i32 @donPepito() {
%1 = alloca i32
%2 = alloca [4 x i8*]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [4 x i8*]* %2 to i8*
%7 = bitcast [100 x i8]* %3 to i8*
%8 = call i32 @openPipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 %8, i32* %4
%9 = call i32 @openPipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32 @read(i32 %10, i8* %11, i32 99)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%15 = call i32 @randBound(i32 1000, i32 5000)
%16 = call i32 @sleep(i32 %15)
%17 = load i32, i32* %4
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%19 = load i8*, i8** %18
%20 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %22, 1
%24 = call i32 @write(i32 %17, i8* %19, i64 %23)
%25 = load i32, i32* %5
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%27 = call i32 @read(i32 %25, i8* %26, i32 99)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%30 = call i32 @randBound(i32 1000, i32 5000)
%31 = call i32 @sleep(i32 %30)
%32 = load i32, i32* %4
%33 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%36 = load i8*, i8** %35
%37 = call i64 @strlen(i8* %36)
%38 = add nsw i64 %37, 1
%39 = call i32 @write(i32 %32, i8* %34, i64 %38)
%40 = load i32, i32* %5
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%42 = call i32 @read(i32 %40, i8* %41, i32 99)
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %43)
%45 = call i32 @randBound(i32 1000, i32 5000)
%46 = call i32 @sleep(i32 %45)
%47 = load i32, i32* %4
%48 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%49 = load i8*, i8** %48
%50 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%51 = load i8*, i8** %50
%52 = call i64 @strlen(i8* %51)
%53 = add nsw i64 %52, 1
%54 = call i32 @write(i32 %47, i8* %49, i64 %53)
%55 = load i32, i32* %5
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%57 = call i32 @read(i32 %55, i8* %56, i32 99)
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %58)
%60 = call i32 @randBound(i32 1000, i32 5000)
%61 = call i32 @sleep(i32 %60)
%62 = load i32, i32* %4
%63 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%64 = load i8*, i8** %63
%65 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%66 = load i8*, i8** %65
%67 = call i64 @strlen(i8* %66)
%68 = add nsw i64 %67, 1
%69 = call i32 @write(i32 %62, i8* %64, i64 %68)
%70 = call i32 @closePipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%71 = call i32 @closePipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str = [14 x i8] c"Hola don Jose\00"
@.str.1 = [20 x i8] c"Por su casa yo pase\00"
@.str.2 = [21 x i8] c"A su abuela yo la vi\00"
@.str.3 = [15 x i8] c"Adios don Jose\00"
@.str.4 = [13 x i8] c"PepitoToJose\00"
@.str.5 = [13 x i8] c"JoseToPepito\00"
@.str.6 = [10 x i8] c"Jose: %s\0A\00"
define i32 @donPepito() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @openPipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%4 = tail call i32 @openPipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%5 = call i32 @read(i32 %4, i8* %2, i32 99)
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%7 = call i32 @randBound(i32 1000, i32 5000)
%8 = call i32 @sleep(i32 %7)
%9 = call i32 @write(i32 %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 14)
%10 = call i32 @read(i32 %4, i8* %2, i32 99)
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%12 = call i32 @randBound(i32 1000, i32 5000)
%13 = call i32 @sleep(i32 %12)
%14 = call i32 @write(i32 %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 20)
%15 = call i32 @read(i32 %4, i8* %2, i32 99)
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%17 = call i32 @randBound(i32 1000, i32 5000)
%18 = call i32 @sleep(i32 %17)
%19 = call i32 @write(i32 %3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 21)
%20 = call i32 @read(i32 %4, i8* %2, i32 99)
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%22 = call i32 @randBound(i32 1000, i32 5000)
%23 = call i32 @sleep(i32 %22)
%24 = call i32 @write(i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 15)
%25 = call i32 @closePipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @closePipe(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
ret i32 undef
}