#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_RDWR;
int S_IFIFO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main(void) {
  int fd;
  char buffer[80];
  int leidos;
  umask(0);
  mknod("ComunicacionFIFO", S_IFIFO | 0666, 0);
  if ((fd = open("ComunicacionFIFO", O_RDWR)) < 0) {
    perror("open");
    exit(-1);
  }
  while (1) {
    leidos = read(fd, buffer, 80);
    if (strcmp(buffer, "fin") == 0) {
      close(fd);
      return 0;
    }
    printf("\nMensaje recibido: %s\n", buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1070 <umask@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe44(%rip),%rdi
xor    %edx,%edx
call   1080 <mknod@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
lea    0xe2d(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11fa <main+0x6a>
lea    0xe26(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
jmp    11ff <main+0x6f>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
call   1050 <read@plt>
mov    %eax,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123d <main+0xad>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret
lea    -0x60(%rbp),%rsi
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
jmp    11ff <main+0x6f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
xor    %edi,%edi
call   1070 <umask@plt>
mov    0x2e30(%rip),%rax
mov    $0x1b6,%esi
or     (%rax),%esi
lea    0xe4a(%rip),%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   1080 <mknod@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <open@plt>
test   %eax,%eax
js     124e <main+0xbe>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1050 <read@plt>
lea    0xe26(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     123a <main+0xaa>
lea    0xe16(%rip),%r14
mov    %rsp,%rbx
lea    0xe08(%rip),%r15
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1050 <read@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1210 <main+0x80>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdbc(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"ComunicacionFIFO\00"
@S_IFIFO = global i32 0
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [4 x i8] c"fin\00"
@.str.3 = [23 x i8] c"\0AMensaje recibido: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [80 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @umask(i32 0)
%6 = load i32, i32* @S_IFIFO
%7 = or i32 %6, 438
%8 = call i32 @mknod(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7, i32 0)
%9 = load i32, i32* @O_RDWR
%10 = call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %0
br label %16
16: ; preds = %15, %26
%17 = load i32, i32* %2
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%19 = call i32 @read(i32 %17, i8* %18, i32 80)
store i32 %19, i32* %4
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* %2
%25 = call i32 @close(i32 %24)
ret i32 0
26: ; preds = %16
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %16
}

LLVM IR (-O2):
@.str = [17 x i8] c"ComunicacionFIFO\00"
@S_IFIFO = global i32 0
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [4 x i8] c"fin\00"
@.str.3 = [23 x i8] c"\0AMensaje recibido: %s\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 @umask(i32 0)
%4 = load i32, i32* @S_IFIFO
%5 = or i32 %4, 438
%6 = tail call i32 @mknod(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5, i32 0)
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %0
%11 = call i32 @read(i32 %8, i8* %2, i32 80)
%12 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %19
14: ; preds = %0
%15 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %19, %10
%18 = call i32 @close(i32 %8)
ret i32 0
19: ; preds = %10, %19
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%21 = call i32 @read(i32 %8, i8* %2, i32 80)
%22 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %17, label %19
}