#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 S_IFIFO;
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char dir_name[50] = {'\0'};
  dir_name[0] = '.';
  printf("LIST : Initiating a named pipe\n");
  mknod("mypipe", S_IFIFO | 0666, 0);
  printf("LIST : Waiting for SORT to begin\n");
  int fd_write = open("mypipe", O_WRONLY);
  printf("Enter a directory name for ls command to take \n(default : pwd, to "
         "skip this press (ctrl+D)) :: ");
  scanf("%s", dir_name);
  dup2(fd_write, 1);
  execl("/bin/ls", "/bin/ls", "-l", dir_name, NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
movb   $0x2e,-0x40(%rbp)
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe72(%rip),%rdi
xor    %edx,%edx
call   1060 <mknod@plt>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
lea    0xe4f(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x44(%rbp)
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x44(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
lea    -0x40(%rbp),%rcx
lea    0xe9f(%rip),%rsi
lea    0xea0(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1090 <execl@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x30(%rsp)
movb   $0x2e,(%rsp)
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e3a(%rip),%rax
mov    $0x1b6,%esi
or     (%rax),%esi
lea    0xe4c(%rip),%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <mknod@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
mov    %eax,%ebx
lea    0xe23(%rip),%rdi
call   1050 <printf@plt>
lea    0xe77(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
lea    0xe5c(%rip),%rdi
lea    0xe5d(%rip),%rdx
mov    %rdi,%rsi
mov    %r14,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"LIST : Initiating a named pipe\0A\00"
@.str.1 = [7 x i8] c"mypipe\00"
@S_IFIFO = global i32 0
@.str.2 = [34 x i8] c"LIST : Waiting for SORT to begin\0A\00"
@O_WRONLY = global i32 0
@.str.3 = [96 x i8] c"Enter a directory name for ls command to take \0A(default : pwd, to skip this press (ctrl+D)) :: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"/bin/ls\00"
@.str.6 = [3 x i8] c"-l\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca i32
%3 = bitcast [50 x i8]* %1 to i8*
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
store i8 46, i8* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @S_IFIFO
%7 = or i32 %6, 438
%8 = call i32 @mknod(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 0)
%9 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @O_WRONLY
%11 = call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %10)
store i32 %11, i32* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %2
%16 = call i32 @dup2(i32 %15, i32 1)
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%18 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %17, i32* null)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"mypipe\00"
@S_IFIFO = global i32 0
@O_WRONLY = global i32 0
@.str.3 = [96 x i8] c"Enter a directory name for ls command to take \0A(default : pwd, to skip this press (ctrl+D)) :: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"/bin/ls\00"
@.str.6 = [3 x i8] c"-l\00"
@str = [31 x i8] c"LIST : Initiating a named pipe\00"
@str.7 = [33 x i8] c"LIST : Waiting for SORT to begin\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
store i8 46, i8* %2
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @S_IFIFO
%5 = or i32 %4, 438
%6 = tail call i32 @mknod(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
%8 = load i32, i32* @O_WRONLY
%9 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%12 = call i32 @dup2(i32 %9, i32 1)
%13 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2, i32* null)
ret i32 0
}