#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ mkfifo(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main(void) {
  FILE *fp;
  char readbuf[800];
  umask(0);
  mkfifo("/tmp/fifo-file", 0777);
  fp = fopen("/tmp/fifo-file", "r");
  char line[80];
  {
    fgets(line, 80, fp);
    strcat(readbuf, line);
  }
  printf("The command is:\n%s\n\n", readbuf);
  fclose(fp);
  strcat(readbuf, "> ");
  strcat(readbuf, "/tmp/fifo-file");
  system(readbuf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x380,%rsp
xor    %edi,%edi
call   1080 <umask@plt>
lea    0xe67(%rip),%rdi
mov    $0x1ff,%esi
call   1070 <mkfifo@plt>
lea    0xe56(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    -0x380(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
lea    -0x330(%rbp),%rdi
lea    -0x380(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0x330(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x330(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x330(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x330(%rbp),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x380,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x378,%rsp
xor    %edi,%edi
call   1080 <umask@plt>
lea    0xe64(%rip),%r14
mov    %r14,%rdi
mov    $0x1ff,%esi
call   1070 <mkfifo@plt>
lea    0xe5f(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
lea    0x50(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
lea    0xe2c(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe2a(%rip),%rsi
mov    %r12,%rdi
call   10a0 <strcat@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   10a0 <strcat@plt>
mov    %r12,%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x378,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/tmp/fifo-file\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"The command is:\0A%s\0A\0A\00"
@.str.3 = [3 x i8] c"> \00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca [800 x i8]
%3 = alloca [80 x i8]
%4 = call i32 @umask(i32 0)
%5 = call i32 @mkfifo(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 511)
%6 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %1
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = load i32*, i32** %1
%9 = call i32 @fgets(i8* %7, i32 80, i32* %8)
%10 = getelementptr inbounds [800 x i8], [800 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = getelementptr inbounds [800 x i8], [800 x i8]* %2, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32*, i32** %1
%16 = call i32 @fclose(i32* %15)
%17 = getelementptr inbounds [800 x i8], [800 x i8]* %2, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds [800 x i8], [800 x i8]* %2, i64 0, i64 0
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [800 x i8], [800 x i8]* %2, i64 0, i64 0
%22 = call i32 @system(i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"/tmp/fifo-file\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"The command is:\0A%s\0A\0A\00"
@.str.3 = [3 x i8] c"> \00"
define i32 @main() {
%1 = alloca [800 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [800 x i8], [800 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @umask(i32 0)
%5 = tail call i32 @mkfifo(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 511)
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%8 = call i32 @fgets(i8* %7, i32 80, i32* %6)
%9 = call i32 @strcat(i8* %3, i8* %7)
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 @fclose(i32* %6)
%12 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @system(i8* %3)
ret i32 0
}