#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*/ command;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
size_t strlen(char *);
int main(int argc, char **argv) {
  size_t n;
  char buff[(100)];
  char command[(100)];
  FILE *fp;
  fgets(buff, (100), stdin);
  n = strlen(buff);
  if ('\n' == buff[n - 1]) {
    --n;
  }
  snprintf(command, sizeof(command), "cat %s", buff);
  if (NULL == (fp = popen(command, "r"))) {
    perror("popen error");
    exit(EXIT_FAILURE);
  }
  while (NULL != fgets(buff, (100), fp)) {
    fputs(buff, stdout);
  }
  pclose(fp);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    0x2e44(%rip),%rax
mov    (%rax),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
movsbl -0x80(%rbp,%rax,1),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    11e4 <main+0x64>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
lea    -0xf0(%rbp),%rdi
lea    -0x80(%rbp),%rcx
mov    $0x64,%esi
lea    0xe05(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0xf0(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,%rcx
mov    %rcx,-0xf8(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1242 <main+0xc2>
lea    0xdd8(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1247 <main+0xc7>
lea    -0x80(%rbp),%rdi
mov    -0xf8(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1281 <main+0x101>
lea    -0x80(%rbp),%rdi
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
jmp    1247 <main+0xc7>
mov    -0xf8(%rbp),%rdi
call   1040 <pclose@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    0x2e65(%rip),%rax
mov    (%rax),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    0xe63(%rip),%rdx
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rcx
call   1040 <snprintf@plt>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
test   %rax,%rax
jne    11e0 <main+0x70>
lea    0xe3a(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1230 <main+0xc0>
mov    0x2dd1(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1210 <main+0xa0>
mov    %r14,%rdi
call   1030 <pclose@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [7 x i8] c"cat %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"popen error\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%11 = load i32*, i32** @stdin
%12 = call i32* @fgets(i8* %10, i32 100, i32* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
store i64 %14, i64* %6
%15 = load i64, i64* %6
%16 = sub i64 %15, 1
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 10, %19
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i64, i64* %6
%23 = add i64 %22, -1
store i64 %23, i64* %6
br label %24
24: ; preds = %21, %2
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%27 = call i32 @snprintf(i8* %25, i32 100, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%29 = call i32* @popen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %9
%30 = icmp eq i32* null, %29
br i1 %30, label %31, label %35
31: ; preds = %24
%32 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %24
br label %36
36: ; preds = %41, %35
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%38 = load i32*, i32** %9
%39 = call i32* @fgets(i8* %37, i32 100, i32* %38)
%40 = icmp ne i32* null, %39
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%43 = load i32, i32* @stdout
%44 = call i32 @fputs(i8* %42, i32 %43)
br label %36
45: ; preds = %36
%46 = load i32*, i32** %9
%47 = call i32 @pclose(i32* %46)
%48 = load i32, i32* @EXIT_SUCCESS
%49 = call i32 @exit(i32 %48)
unreachable
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [7 x i8] c"cat %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"popen error\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = load i32*, i32** @stdin
%8 = call i32* @fgets(i8* %5, i32 100, i32* %7)
%9 = call i32 @snprintf(i8* %6, i32 100, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = call i32* @fgets(i8* %5, i32 100, i32* %10)
%14 = icmp eq i32* %13, null
br i1 %14, label %24, label %19
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %12, %19
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* %5, i32 %20)
%22 = call i32* @fgets(i8* %5, i32 100, i32* %10)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %19
24: ; preds = %19, %12
%25 = call i32 @pclose(i32* %10)
%26 = load i32, i32* @EXIT_SUCCESS
%27 = call i32 @exit(i32 %26)
unreachable
}