#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  FILE *fp1, *fp2;
  char buffer[80] = {0};
  char received[80] = {0};
  fp1 = fopen("PRE_PIPE", "w");
  printf("Enter a string to compress (no spaces): ");
  scanf("%s", buffer);
  fputs(buffer, fp1);
  fclose(fp1);
  mknod("POST_PIPE", S_IFIFO | 0666, 0);
  fp2 = fopen("POST_PIPE", "r");
  fgets(received, 80, fp2);
  printf("Received from server: %s\n", received);
  fclose(fp2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
lea    0xe44(%rip),%rdi
lea    0xe46(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1090 <scanf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
lea    0xe21(%rip),%rdi
xor    %edx,%edx
call   1080 <mknod@plt>
lea    0xe13(%rip),%rdi
lea    0xe16(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1070 <fgets@plt>
lea    -0xc0(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe45(%rip),%rdi
lea    0xe47(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
lea    0x50(%rsp),%r14
mov    %r14,%rsi
call   1080 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2dda(%rip),%rax
mov    $0x1b6,%esi
or     (%rax),%esi
lea    0xe23(%rip),%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   1070 <mknod@plt>
lea    0xe1c(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
lea    0xdf9(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"PRE_PIPE\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [41 x i8] c"Enter a string to compress (no spaces): \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [10 x i8] c"POST_PIPE\00"
@S_IFIFO = global i32 0
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [26 x i8] c"Received from server: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
store i32 0, i32* %1
%6 = bitcast [80 x i8]* %4 to i8*
%7 = bitcast [80 x i8]* %5 to i8*
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%13 = load i32*, i32** %2
%14 = call i32 @fputs(i8* %12, i32* %13)
%15 = load i32*, i32** %2
%16 = call i32 @fclose(i32* %15)
%17 = load i32, i32* @S_IFIFO
%18 = or i32 %17, 438
%19 = call i32 @mknod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 0)
%20 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %20, i32** %3
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%22 = load i32*, i32** %3
%23 = call i32 @fgets(i8* %21, i32 80, i32* %22)
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = load i32*, i32** %3
%27 = call i32 @fclose(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"PRE_PIPE\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [41 x i8] c"Enter a string to compress (no spaces): \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [10 x i8] c"POST_PIPE\00"
@S_IFIFO = global i32 0
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [26 x i8] c"Received from server: %s\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%8 = call i32 @fputs(i8* %3, i32* %5)
%9 = call i32 @fclose(i32* %5)
%10 = load i32, i32* @S_IFIFO
%11 = or i32 %10, 438
%12 = call i32 @mknod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 0)
%13 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @fgets(i8* %4, i32 80, i32* %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%16 = call i32 @fclose(i32* %13)
ret i32 0
}