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

/* Variables and functions */
int S_IFIFO;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main(void) {
  FILE *fp;
  char readbuf[80];
  while (readbuf == NULL) {
    fp = fopen("MYFIFO", "r");
    fgets(readbuf, 80, fp);
    printf("Received string: %s\n", readbuf);
    if (readbuf != NULL) {
      FILE *fp2;
      umask(0);
      mknod("MYFIFO2", S_IFIFO | 0666, 0);
      fp2 = fopen("MYFIFO2", "w");
      strcat(readbuf, " > result.txt");
      printf("%s", readbuf);
      char results[800];
      fputs(results, fp2);
      fclose(fp2);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x390,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rax
cmp    $0x0,%rax
jne    1252 <main+0xd2>
lea    0xe59(%rip),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
lea    -0x60(%rbp),%rsi
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <umask@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe28(%rip),%rdi
xor    %edx,%edx
call   1080 <mknod@plt>
lea    0xe1a(%rip),%rdi
lea    0xe1b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x60(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
lea    -0x390(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1192 <main+0x12>
xor    %eax,%eax
add    $0x390,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"MYFIFO\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Received string: %s\0A\00"
@.str.3 = [8 x i8] c"MYFIFO2\00"
@S_IFIFO = global i32 0
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [14 x i8] c" > result.txt\00"
@.str.6 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [80 x i8]
%4 = alloca i32*
%5 = alloca [800 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %9, %0
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %30
9: ; preds = %6
%10 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32 @fgets(i8* %11, i32 80, i32* %12)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = call i32 @umask(i32 0)
%17 = load i32, i32* @S_IFIFO
%18 = or i32 %17, 438
%19 = call i32 @mknod(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 0)
%20 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %20, i32** %4
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [800 x i8], [800 x i8]* %5, i64 0, i64 0
%26 = load i32*, i32** %4
%27 = call i32 @fputs(i8* %25, i32* %26)
%28 = load i32*, i32** %4
%29 = call i32 @fclose(i32* %28)
br label %6
30: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@S_IFIFO = global i32 0
define i32 @main() {
ret i32 0
}