#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 /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int mkfifo(char *, int);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int write(int, char *, int);
main() {
  int err, fifo_d;
  char buff[80];
  int leido;
  unlink("/tmp/MI_FIFO");
  err = mkfifo("/tmp/MI_FIFO", S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP |
                                   S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH);
  if (err == -1) {
    write(0, "\nError al crear FIFO, la FIFO ya existe",
          sizeof("\nError al crear FIFO, la FIFO ya existe"));
  } else {
    write(0, "\nFIFO creado correctamente\n",
          sizeof("\nFIFO creado correctamente\n"));
  }
  switch (fork()) {
  case -1:
    write(0, "\nError al crear hijo", sizeof("\nError al crear hijo"));
    return -1;
    break;
  case 0:
    write(0, "\nEntrando proceso HIJO", sizeof("\nEntrando proceso HIJO"));
    sleep(5);
    fifo_d = open("/tmp/MI_FIFO", O_RDONLY, 0);
    if (fifo_d == -1) {
      write(0, "\nHIJO: Error al abrir FIFO ",
            sizeof("\nHIJO: Error al abrir FIFO "));
      return -1;
    } else {
      write(0, "\nHIJO: FIFO abierto correctamente",
            sizeof("\nHIJO: FIFO abierto correctamente"));
    }
    leido = read(fifo_d, buff, sizeof(buff));
    if (leido == -1) {
      write(0, "\nHIJO: Error al leer en FIFO",
            sizeof("\nHIJO: Error al leer en FIFO"));
    } else {
      write(0, "\nHIJO: Leido del FIFO: ", sizeof("\nHIJO: Leido del FIFO: "));
      write(0, buff, leido - 1);
      write(0, "\n", sizeof("\n"));
    }
    close(fifo_d);
    write(0, "\nSaliendo proceso HIJO\n", sizeof("\nSaliendo proceso HIJO\n"));
    exit(0);
    break;
  default:
    write(0, "\nEntrando proceso PADRE", sizeof("\nEntrando proceso PADRE"));
    sleep(2);
    fifo_d = open("/tmp/MI_FIFO", O_WRONLY, 0);
    if (fifo_d == -1) {
      write(0, "\nPADRE: Error al abrir FIFO ",
            sizeof("\nPADRE: Error al abrir FIFO "));
      return -1;
    } else {
      write(0, "\nPADRE: FIFO abierto correctamente",
            sizeof("\nPADRE: FIFO abierto correctamente"));
    }
    err = write(fifo_d, "HOLA PROCESO HIJO", sizeof("HOLA PROCESO HIJO"));
    if (err == -1) {
      write(0, "\nPADRE: Error al escribir en FIFO",
            sizeof("\nPADRE: Error al escribir en FIFO"));
    } else {
      write(0, "\nPADRE: Escritos MENSAJE en FIFO",
            sizeof("\nPADRE: Escritos MENSAJE en FIFO"));
    }
    close(fifo_d);
    wait(NULL);
    write(0, "\nSaliendo proceso PADRE\n",
          sizeof("\nSaliendo proceso PADRE\n"));
    break;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe4a(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
mov    0x2dfd(%rip),%rax
or     (%rax),%esi
mov    0x2e0c(%rip),%rax
or     (%rax),%esi
mov    0x2dd3(%rip),%rax
or     (%rax),%esi
mov    0x2dea(%rip),%rax
or     (%rax),%esi
mov    0x2dd1(%rip),%rax
or     (%rax),%esi
mov    0x2db0(%rip),%rax
or     (%rax),%esi
mov    0x2d87(%rip),%rax
or     (%rax),%esi
mov    0x2dde(%rip),%rax
or     (%rax),%esi
lea    0xded(%rip),%rdi
call   1070 <mkfifo@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    123d <main+0x9d>
xor    %edi,%edi
lea    0xddf(%rip),%rsi
mov    $0x28,%edx
call   1040 <write@plt>
jmp    1250 <main+0xb0>
xor    %edi,%edi
lea    0xdef(%rip),%rsi
mov    $0x1c,%edx
call   1040 <write@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x68(%rbp)
sub    $0xffffffff,%eax
je     127a <main+0xda>
jmp    126a <main+0xca>
mov    -0x68(%rbp),%eax
test   %eax,%eax
je     1299 <main+0xf9>
jmp    139b <main+0x1fb>
xor    %edi,%edi
lea    0xdce(%rip),%rsi
mov    $0x15,%edx
call   1040 <write@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1485 <main+0x2e5>
xor    %edi,%edi
lea    0xdc4(%rip),%rsi
mov    $0x17,%edx
call   1040 <write@plt>
mov    $0x5,%edi
call   10a0 <sleep@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
lea    0xd3a(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    12f9 <main+0x159>
xor    %edi,%edi
lea    0xd9a(%rip),%rsi
mov    $0x1c,%edx
call   1040 <write@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1485 <main+0x2e5>
xor    %edi,%edi
lea    0xd97(%rip),%rsi
mov    $0x22,%edx
call   1040 <write@plt>
mov    -0xc(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
call   1060 <read@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    1342 <main+0x1a2>
xor    %edi,%edi
lea    0xd88(%rip),%rsi
mov    $0x1d,%edx
call   1040 <write@plt>
jmp    1379 <main+0x1d9>
xor    %edi,%edi
lea    0xd8d(%rip),%rsi
mov    $0x18,%edx
call   1040 <write@plt>
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
sub    $0x1,%edx
xor    %edi,%edi
call   1040 <write@plt>
xor    %edi,%edi
lea    0xe5d(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
xor    %edi,%edi
lea    0xd66(%rip),%rsi
mov    $0x18,%edx
call   1040 <write@plt>
xor    %edi,%edi
call   1090 <exit@plt>
xor    %edi,%edi
lea    0xd64(%rip),%rsi
mov    $0x18,%edx
call   1040 <write@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    0x2bd1(%rip),%rax
mov    (%rax),%esi
lea    0xc38(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    13fb <main+0x25b>
xor    %edi,%edi
lea    0xd3b(%rip),%rsi
mov    $0x1d,%edx
call   1040 <write@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1485 <main+0x2e5>
xor    %edi,%edi
lea    0xd39(%rip),%rsi
mov    $0x23,%edx
call   1040 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xd48(%rip),%rsi
mov    $0x12,%edx
call   1040 <write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1447 <main+0x2a7>
xor    %edi,%edi
lea    0xd3a(%rip),%rsi
mov    $0x22,%edx
call   1040 <write@plt>
jmp    145a <main+0x2ba>
xor    %edi,%edi
lea    0xd44(%rip),%rsi
mov    $0x21,%edx
call   1040 <write@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
lea    0xd41(%rip),%rsi
mov    $0x19,%edx
call   1040 <write@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
lea    0xe53(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2de4(%rip),%rax
mov    0x2e05(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e12(%rip),%rax
or     (%rax),%esi
mov    0x2dd9(%rip),%rax
or     (%rax),%esi
mov    0x2df0(%rip),%rax
or     (%rax),%esi
mov    0x2dd7(%rip),%rax
or     (%rax),%esi
mov    0x2db6(%rip),%rax
or     (%rax),%esi
mov    0x2d8d(%rip),%rax
or     (%rax),%esi
mov    0x2de4(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1070 <mkfifo@plt>
cmp    $0xffffffff,%eax
je     1223 <main+0x83>
lea    0xe1b(%rip),%rsi
xor    %edi,%edi
mov    $0x1c,%edx
jmp    1231 <main+0x91>
lea    0xde3(%rip),%rsi
xor    %edi,%edi
mov    $0x28,%edx
call   1040 <write@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %eax,%eax
je     1259 <main+0xb9>
cmp    $0xffffffff,%eax
jne    12a2 <main+0x102>
lea    0xe04(%rip),%rsi
xor    %edi,%edi
mov    $0x15,%edx
jmp    12e9 <main+0x149>
lea    0xe06(%rip),%rsi
xor    %edi,%edi
mov    $0x17,%edx
call   1040 <write@plt>
mov    $0x5,%edi
call   10a0 <sleep@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
lea    0xd7a(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
cmp    $0xffffffff,%eax
jne    12fa <main+0x15a>
lea    0xde4(%rip),%rsi
xor    %edi,%edi
mov    $0x1c,%edx
jmp    12e9 <main+0x149>
lea    0xe5f(%rip),%rsi
xor    %edi,%edi
mov    $0x18,%edx
call   1040 <write@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
lea    0xd31(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
cmp    $0xffffffff,%eax
jne    1334 <main+0x194>
lea    0xe3e(%rip),%rsi
xor    %edi,%edi
mov    $0x1d,%edx
call   1040 <write@plt>
mov    $0xffffffff,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret
mov    %eax,%ebx
lea    0xd96(%rip),%rsi
xor    %edi,%edi
mov    $0x22,%edx
call   1040 <write@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x50,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
jne    139e <main+0x1fe>
lea    0xd91(%rip),%rsi
mov    $0x1d,%edx
jmp    13ce <main+0x22e>
mov    %eax,%ebx
lea    0xe00(%rip),%rsi
xor    %edi,%edi
mov    $0x23,%edx
call   1040 <write@plt>
lea    0xe10(%rip),%rsi
mov    %ebx,%edi
mov    $0x12,%edx
call   1040 <write@plt>
xor    %edx,%edx
cmp    $0xffffffff,%eax
sete   %dl
lea    0xe07(%rip),%rax
lea    0xe22(%rip),%rsi
cmove  %rax,%rsi
add    $0x21,%edx
xor    %edi,%edi
call   1040 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
lea    0xe20(%rip),%rsi
xor    %edi,%edi
mov    $0x19,%edx
jmp    13ea <main+0x24a>
mov    %eax,%ebp
lea    0xd31(%rip),%rsi
xor    %edi,%edi
mov    $0x18,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebp
mov    %rsp,%rsi
xor    %edi,%edi
mov    %ebp,%edx
call   1040 <write@plt>
lea    0xe03(%rip),%rsi
mov    $0x2,%edx
xor    %edi,%edi
call   1040 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
lea    0xd0d(%rip),%rsi
xor    %edi,%edi
mov    $0x18,%edx
call   1040 <write@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/MI_FIFO\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.1 = [40 x i8] c"\0AError al crear FIFO, la FIFO ya existe\00"
@.str.2 = [28 x i8] c"\0AFIFO creado correctamente\0A\00"
@.str.3 = [21 x i8] c"\0AError al crear hijo\00"
@.str.4 = [23 x i8] c"\0AEntrando proceso HIJO\00"
@O_RDONLY = global i32 0
@.str.5 = [28 x i8] c"\0AHIJO: Error al abrir FIFO \00"
@.str.6 = [34 x i8] c"\0AHIJO: FIFO abierto correctamente\00"
@.str.7 = [29 x i8] c"\0AHIJO: Error al leer en FIFO\00"
@.str.8 = [24 x i8] c"\0AHIJO: Leido del FIFO: \00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [24 x i8] c"\0ASaliendo proceso HIJO\0A\00"
@.str.11 = [24 x i8] c"\0AEntrando proceso PADRE\00"
@O_WRONLY = global i32 0
@.str.12 = [29 x i8] c"\0APADRE: Error al abrir FIFO \00"
@.str.13 = [35 x i8] c"\0APADRE: FIFO abierto correctamente\00"
@.str.14 = [18 x i8] c"HOLA PROCESO HIJO\00"
@.str.15 = [34 x i8] c"\0APADRE: Error al escribir en FIFO\00"
@.str.16 = [33 x i8] c"\0APADRE: Escritos MENSAJE en FIFO\00"
@.str.17 = [25 x i8] c"\0ASaliendo proceso PADRE\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @S_IRUSR
%8 = load i32, i32* @S_IWUSR
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IXUSR
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IRGRP
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IWGRP
%15 = or i32 %13, %14
%16 = load i32, i32* @S_IXGRP
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IROTH
%19 = or i32 %17, %18
%20 = load i32, i32* @S_IWOTH
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IXOTH
%23 = or i32 %21, %22
%24 = call i32 @mkfifo(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %23)
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %0
%28 = call i32 @write(i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 40)
br label %31
29: ; preds = %0
%30 = call i32 @write(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 28)
br label %31
31: ; preds = %29, %27
%32 = call i32 (...) @fork()
switch i32 %32, label %66 [
i32 -1, label %33
i32 0, label %35
]
33: ; preds = %31
%34 = call i32 @write(i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 21)
store i32 -1, i32* %1
br label %93
35: ; preds = %31
%36 = call i32 @write(i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 23)
%37 = call i32 @sleep(i32 5)
%38 = load i32, i32* @O_RDONLY
%39 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %38, i32 0)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = call i32 @write(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 28)
store i32 -1, i32* %1
br label %93
44: ; preds = %35
%45 = call i32 @write(i32 0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 34)
br label %46
46: ; preds = %44
%47 = load i32, i32* %3
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%49 = call i32 @read(i32 %47, i8* %48, i32 80)
store i32 %49, i32* %5
%50 = load i32, i32* %5
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = call i32 @write(i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 29)
br label %61
54: ; preds = %46
%55 = call i32 @write(i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 24)
%56 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%57 = load i32, i32* %5
%58 = sub nsw i32 %57, 1
%59 = call i32 @write(i32 0, i8* %56, i32 %58)
%60 = call i32 @write(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 2)
br label %61
61: ; preds = %54, %52
%62 = load i32, i32* %3
%63 = call i32 @close(i32 %62)
%64 = call i32 @write(i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 24)
%65 = call i32 @exit(i32 0)
unreachable
66: ; preds = %31
%67 = call i32 @write(i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 24)
%68 = call i32 @sleep(i32 2)
%69 = load i32, i32* @O_WRONLY
%70 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %69, i32 0)
store i32 %70, i32* %3
%71 = load i32, i32* %3
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %66
%74 = call i32 @write(i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i32 29)
store i32 -1, i32* %1
br label %93
75: ; preds = %66
%76 = call i32 @write(i32 0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i32 35)
br label %77
77: ; preds = %75
%78 = load i32, i32* %3
%79 = call i32 @write(i32 %78, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 18)
store i32 %79, i32* %2
%80 = load i32, i32* %2
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 @write(i32 0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i32 34)
br label %86
84: ; preds = %77
%85 = call i32 @write(i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0), i32 33)
br label %86
86: ; preds = %84, %82
%87 = load i32, i32* %3
%88 = call i32 @close(i32 %87)
%89 = call i32 @wait(i32* null)
%90 = call i32 @write(i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i32 25)
br label %91
91: ; preds = %86
%92 = call i32 @exit(i32 0)
unreachable
93: ; preds = %73, %42, %33
%94 = load i32, i32* %1
ret i32 %94
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/MI_FIFO\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.1 = [40 x i8] c"\0AError al crear FIFO, la FIFO ya existe\00"
@.str.2 = [28 x i8] c"\0AFIFO creado correctamente\0A\00"
@.str.3 = [21 x i8] c"\0AError al crear hijo\00"
@.str.4 = [23 x i8] c"\0AEntrando proceso HIJO\00"
@O_RDONLY = global i32 0
@.str.5 = [28 x i8] c"\0AHIJO: Error al abrir FIFO \00"
@.str.6 = [34 x i8] c"\0AHIJO: FIFO abierto correctamente\00"
@.str.7 = [29 x i8] c"\0AHIJO: Error al leer en FIFO\00"
@.str.8 = [24 x i8] c"\0AHIJO: Leido del FIFO: \00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [24 x i8] c"\0ASaliendo proceso HIJO\0A\00"
@.str.11 = [24 x i8] c"\0AEntrando proceso PADRE\00"
@O_WRONLY = global i32 0
@.str.12 = [29 x i8] c"\0APADRE: Error al abrir FIFO \00"
@.str.13 = [35 x i8] c"\0APADRE: FIFO abierto correctamente\00"
@.str.14 = [18 x i8] c"HOLA PROCESO HIJO\00"
@.str.15 = [34 x i8] c"\0APADRE: Error al escribir en FIFO\00"
@.str.16 = [33 x i8] c"\0APADRE: Escritos MENSAJE en FIFO\00"
@.str.17 = [25 x i8] c"\0ASaliendo proceso PADRE\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @S_IRUSR
%5 = load i32, i32* @S_IWUSR
%6 = or i32 %5, %4
%7 = load i32, i32* @S_IXUSR
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IRGRP
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IWGRP
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IXGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IWOTH
%18 = or i32 %16, %17
%19 = load i32, i32* @S_IXOTH
%20 = or i32 %18, %19
%21 = tail call i32 @mkfifo(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 40)
br label %27
25: ; preds = %0
%26 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 28)
br label %27
27: ; preds = %25, %23
%28 = tail call i32 (...) @fork()
switch i32 %28, label %54 [
i32 -1, label %29
i32 0, label %31
]
29: ; preds = %27
%30 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 21)
br label %73
31: ; preds = %27
%32 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 23)
%33 = tail call i32 @sleep(i32 5)
%34 = load i32, i32* @O_RDONLY
%35 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %34, i32 0)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 28)
br label %73
39: ; preds = %31
%40 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 34)
%41 = call i32 @read(i32 %35, i8* %2, i32 80)
%42 = icmp eq i32 %41, -1
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 24)
%45 = add nsw i32 %41, -1
%46 = call i32 @write(i32 0, i8* %2, i32 %45)
br label %47
47: ; preds = %39, %43
%48 = phi i32 [ 2, %43 ], [ 29, %39 ]
%49 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %43 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), %39 ]
%50 = tail call i32 @write(i32 0, i8* %49, i32 %48)
%51 = tail call i32 @close(i32 %35)
%52 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 24)
%53 = tail call i32 @exit(i32 0)
unreachable
54: ; preds = %27
%55 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 24)
%56 = tail call i32 @sleep(i32 2)
%57 = load i32, i32* @O_WRONLY
%58 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %57, i32 0)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %54
%61 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i32 29)
br label %73
62: ; preds = %54
%63 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i32 35)
%64 = tail call i32 @write(i32 %58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 18)
%65 = icmp eq i32 %64, -1
%66 = select i1 %65, i32 34, i32 33
%67 = select i1 %65, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0)
%68 = tail call i32 @write(i32 0, i8* %67, i32 %66)
%69 = tail call i32 @close(i32 %58)
%70 = tail call i32 @wait(i32* null)
%71 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i32 25)
%72 = tail call i32 @exit(i32 0)
unreachable
73: ; preds = %60, %37, %29
ret i32 -1
}