#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_RDONLY;
int S_IFIFO;
int /*<<< orphan*/ dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main() {
  printf("SORT : Waiting for LIST\n");
  printf("SORT : The sorted output is::\n");
  mknod("mypipe", S_IFIFO | 0666, 0);
  int fd_read = open("mypipe", O_RDONLY);
  dup2(fd_read, 0);
  execl("/bin/sort", "/bin/sort", NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xeb2(%rip),%rdi
xor    %edx,%edx
call   1050 <mknod@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
lea    0xe9b(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
lea    0xe89(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1070 <execl@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e68(%rip),%rax
mov    $0x1b6,%esi
or     (%rax),%esi
lea    0xe82(%rip),%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <mknod@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <open@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <dup2@plt>
lea    0xe5e(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1070 <execl@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"SORT : Waiting for LIST\0A\00"
@.str.1 = [31 x i8] c"SORT : The sorted output is::\0A\00"
@.str.2 = [7 x i8] c"mypipe\00"
@S_IFIFO = global i32 0
@O_RDONLY = global i32 0
@.str.3 = [10 x i8] c"/bin/sort\00"
define i32 @main() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @S_IFIFO
%5 = or i32 %4, 438
%6 = call i32 @mknod(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 0)
%7 = load i32, i32* @O_RDONLY
%8 = call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %7)
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = call i32 @dup2(i32 %9, i32 0)
%11 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* null)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"mypipe\00"
@S_IFIFO = global i32 0
@O_RDONLY = global i32 0
@.str.3 = [10 x i8] c"/bin/sort\00"
@str = [24 x i8] c"SORT : Waiting for LIST\00"
@str.4 = [30 x i8] c"SORT : The sorted output is::\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
%3 = load i32, i32* @S_IFIFO
%4 = or i32 %3, 438
%5 = tail call i32 @mknod(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 0)
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 @dup2(i32 %7, i32 0)
%9 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* null)
ret i32 0
}