#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 donJose() {
  char *msgs[4] = {"Hola don Pepito", "Paso usted por mi casa?",
                   "Vio usted a mi abuela?", "Adios don Pepito"};
  char buffer[100] = {0};
  int me = openPipe("PepitoToJose");
  int pepito = openPipe("JoseToPepito");
  sleep(randBound(1000, 5000));
  write(pepito, msgs[0], strlen(msgs[0]) + 1);
  read(me, buffer, 99);
  printf("Pepito: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(pepito, msgs[1], strlen(msgs[1]) + 1);
  read(me, buffer, 99);
  printf("Pepito: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(pepito, msgs[2], strlen(msgs[2]) + 1);
  read(me, buffer, 99);
  printf("Pepito: %s\n", buffer);
  sleep(randBound(1000, 5000));
  write(pepito, msgs[3], strlen(msgs[3]) + 1);
  read(me, buffer, 99);
  printf("Pepito: %s\n", buffer);
  closePipe("PepitoToJose");
  closePipe("JoseToPepito");
}


x86 assembly (clang, -O0):
<donJose>:
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    0xe6f(%rip),%rdi
call   1090 <openPipe@plt>
mov    %eax,-0xa4(%rbp)
lea    0xe6a(%rip),%rdi
call   1090 <openPipe@plt>
mov    %eax,-0xa8(%rbp)
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa8(%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    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa8(%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    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd7f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa8(%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    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd06(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   10a0 <randBound@plt>
mov    %eax,%edi
call   10b0 <sleep@plt>
mov    -0xa8(%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>
mov    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x63,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xc8d(%rip),%rdi
call   1050 <printf@plt>
lea    0xc67(%rip),%rdi
call   1080 <closePipe@plt>
lea    0xc68(%rip),%rdi
call   1080 <closePipe@plt>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<donJose>:
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    0xea3(%rip),%r14
mov    %r14,%rdi
call   1070 <openPipe@plt>
mov    %eax,%r12d
lea    0xe9e(%rip),%r15
mov    %r15,%rdi
call   1070 <openPipe@plt>
mov    %eax,%ebx
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xe1a(%rip),%rsi
mov    $0x10,%edx
mov    %ebx,%edi
call   1030 <write@plt>
mov    %rsp,%rbp
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
lea    0xe5e(%rip),%r13
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xddc(%rip),%rsi
mov    $0x18,%edx
mov    %ebx,%edi
call   1030 <write@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xdb0(%rip),%rsi
mov    $0x17,%edx
mov    %ebx,%edi
call   1030 <write@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    $0x3e8,%edi
mov    $0x1388,%esi
call   1080 <randBound@plt>
mov    %eax,%edi
call   1090 <sleep@plt>
lea    0xd83(%rip),%rsi
mov    $0x11,%edx
mov    %ebx,%edi
call   1030 <write@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x63,%edx
call   1050 <read@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@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 = [16 x i8] c"Hola don Pepito\00"
@.str.1 = [24 x i8] c"Paso usted por mi casa?\00"
@.str.2 = [23 x i8] c"Vio usted a mi abuela?\00"
@.str.3 = [17 x i8] c"Adios don Pepito\00"
@__const.donJose.msgs = [4 x i8*] [i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 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 = [12 x i8] c"Pepito: %s\0A\00"
define i32 @donJose() {
%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 = call i32 @randBound(i32 1000, i32 5000)
%11 = call i32 @sleep(i32 %10)
%12 = load i32, i32* %5
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%16 = load i8*, i8** %15
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 1
%19 = call i32 @write(i32 %12, i8* %14, i64 %18)
%20 = load i32, i32* %4
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%22 = call i32 @read(i32 %20, i8* %21, i32 99)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %23)
%25 = call i32 @randBound(i32 1000, i32 5000)
%26 = call i32 @sleep(i32 %25)
%27 = load i32, i32* %5
%28 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strlen(i8* %31)
%33 = add nsw i64 %32, 1
%34 = call i32 @write(i32 %27, i8* %29, i64 %33)
%35 = load i32, i32* %4
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%37 = call i32 @read(i32 %35, i8* %36, i32 99)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %38)
%40 = call i32 @randBound(i32 1000, i32 5000)
%41 = call i32 @sleep(i32 %40)
%42 = load i32, i32* %5
%43 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%44 = load i8*, i8** %43
%45 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%46 = load i8*, i8** %45
%47 = call i64 @strlen(i8* %46)
%48 = add nsw i64 %47, 1
%49 = call i32 @write(i32 %42, i8* %44, i64 %48)
%50 = load i32, i32* %4
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%52 = call i32 @read(i32 %50, i8* %51, i32 99)
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%54 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %53)
%55 = call i32 @randBound(i32 1000, i32 5000)
%56 = call i32 @sleep(i32 %55)
%57 = load i32, i32* %5
%58 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%59 = load i8*, i8** %58
%60 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%61 = load i8*, i8** %60
%62 = call i64 @strlen(i8* %61)
%63 = add nsw i64 %62, 1
%64 = call i32 @write(i32 %57, i8* %59, i64 %63)
%65 = load i32, i32* %4
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%67 = call i32 @read(i32 %65, i8* %66, i32 99)
%68 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%69 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %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 = [16 x i8] c"Hola don Pepito\00"
@.str.1 = [24 x i8] c"Paso usted por mi casa?\00"
@.str.2 = [23 x i8] c"Vio usted a mi abuela?\00"
@.str.3 = [17 x i8] c"Adios don Pepito\00"
@.str.4 = [13 x i8] c"PepitoToJose\00"
@.str.5 = [13 x i8] c"JoseToPepito\00"
@.str.6 = [12 x i8] c"Pepito: %s\0A\00"
define i32 @donJose() {
%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 = tail call i32 @randBound(i32 1000, i32 5000)
%6 = tail call i32 @sleep(i32 %5)
%7 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 16)
%8 = call i32 @read(i32 %3, i8* %2, i32 99)
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%10 = call i32 @randBound(i32 1000, i32 5000)
%11 = call i32 @sleep(i32 %10)
%12 = call i32 @write(i32 %4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 24)
%13 = call i32 @read(i32 %3, i8* %2, i32 99)
%14 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%15 = call i32 @randBound(i32 1000, i32 5000)
%16 = call i32 @sleep(i32 %15)
%17 = call i32 @write(i32 %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i64 23)
%18 = call i32 @read(i32 %3, i8* %2, i32 99)
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%20 = call i32 @randBound(i32 1000, i32 5000)
%21 = call i32 @sleep(i32 %20)
%22 = call i32 @write(i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 17)
%23 = call i32 @read(i32 %3, i8* %2, i32 99)
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%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
}