#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_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int fd_fifo;
  int s_len;
  char input_buf[20];
  printf("Please input some words:\n");
  scanf("%[^\n]", input_buf);
  s_len = strlen(input_buf);
  mkfifo("/home/elvin/myfifo", 0777);
  fd_fifo = open("/home/elvin/myfifo", O_WRONLY);
  write(fd_fifo, input_buf, s_len);
  close(fd_fifo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1080 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xe72(%rip),%rdi
mov    $0x1ff,%esi
call   1070 <mkfifo@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
lea    0xe58(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1080 <scanf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0xe5f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1070 <mkfifo@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please input some words:\0A\00"
@.str.1 = [6 x i8] c"%[^\0A]\00"
@.str.2 = [19 x i8] c"/home/elvin/myfifo\00"
@O_WRONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
%10 = call i32 @mkfifo(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 511)
%11 = load i32, i32* @O_WRONLY
%12 = call i32 @open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 @write(i32 %13, i8* %14, i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @close(i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%[^\0A]\00"
@.str.2 = [19 x i8] c"/home/elvin/myfifo\00"
@O_WRONLY = global i32 0
@str = [25 x i8] c"Please input some words:\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = call i32 @mkfifo(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 511)
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = call i32 @write(i32 %8, i8* %2, i32 %5)
%10 = call i32 @close(i32 %8)
ret i32 0
}