#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 */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int main(int argc, char *argv[]) {
  char buf[512];
  FILE *fp_in, *fp_out;
  if (argc != 2) {
    fprintf(stderr, "Uso: %s <pathname>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((fp_in = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Err.: %d fopen() %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((fp_out = popen("${PAGER:-less}", "w")) == NULL) {
    fprintf(stderr, "Err.: %d popen() %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  while (fgets(buf, 512, fp_in) != NULL) {
    if (fputs(buf, fp_out) == EOF) {
      fprintf(stderr, "Err.: %d fputs() %s\n", errno, strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  if (ferror(fp_in)) {
    fprintf(stderr, "Err.: %d ferror() %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (pclose(fp_out) == -1) {
    fprintf(stderr, "Err.: %d pclose() %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11df <main+0x4f>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe26(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmp    $0x0,%rax
jne    125b <main+0xcb>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x228(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x224(%rbp)
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x228(%rbp),%edi
mov    -0x224(%rbp),%edx
mov    %rax,%rcx
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xdc9(%rip),%rdi
lea    0xdd1(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x220(%rbp)
cmp    $0x0,%rax
jne    12d6 <main+0x146>
mov    0x2d52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x230(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x22c(%rbp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x230(%rbp),%edi
mov    -0x22c(%rbp),%edx
mov    %rax,%rcx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    12db <main+0x14b>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     137c <main+0x1ec>
lea    -0x210(%rbp),%rdi
mov    -0x220(%rbp),%rsi
call   1050 <fputs@plt>
mov    0x2cd1(%rip),%rcx
cmp    (%rcx),%rax
jne    1377 <main+0x1e7>
mov    0x2cb1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x238(%rbp)
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x234(%rbp)
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x238(%rbp),%edi
mov    -0x234(%rbp),%edx
mov    %rax,%rcx
lea    0xcef(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    12db <main+0x14b>
mov    -0x218(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     13e9 <main+0x259>
mov    0x2c3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x240(%rbp)
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x23c(%rbp)
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x240(%rbp),%edi
mov    -0x23c(%rbp),%edx
mov    %rax,%rcx
lea    0xc92(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x220(%rbp),%rdi
call   1040 <pclose@plt>
cmp    $0xffffffff,%eax
jne    1455 <main+0x2c5>
mov    0x2bd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x248(%rbp)
mov    0x2bbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x244(%rbp)
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x248(%rbp),%edi
mov    -0x244(%rbp),%edx
mov    %rax,%rcx
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b7a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2b64(%rip),%rax
mov    (%rax),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
cmp    $0x2,%edi
jne    128b <main+0xfb>
mov    0x8(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12a7 <main+0x117>
mov    %rax,%r14
lea    0xe62(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     12cc <main+0x13c>
mov    %rax,%r15
mov    %rsp,%rbx
mov    0x2dfd(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1252 <main+0xc2>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
cmp    0x0(%rbp),%rax
jne    11f0 <main+0x60>
mov    0x2dbb(%rip),%rax
mov    (%rax),%ebx
mov    0x2daa(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xe1b(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    12f1 <main+0x161>
mov    %r15,%rdi
call   1040 <pclose@plt>
cmp    $0xffffffff,%eax
je     1316 <main+0x186>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd62(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1244 <main+0xb4>
mov    0x2d2a(%rip),%rax
mov    (%rax),%ebx
mov    0x2d19(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd4f(%rip),%rsi
jmp    1236 <main+0xa6>
mov    0x2d05(%rip),%rax
mov    (%rax),%ebx
mov    0x2cf4(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd50(%rip),%rsi
jmp    1236 <main+0xa6>
mov    0x2ce0(%rip),%rax
mov    (%rax),%ebx
mov    0x2ccf(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd55(%rip),%rsi
jmp    1236 <main+0xa6>
mov    0x2cbb(%rip),%rax
mov    (%rax),%ebx
mov    0x2caa(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd46(%rip),%rsi
jmp    1236 <main+0xa6>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Uso: %s <pathname>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Err.: %d fopen() %s\0A\00"
@errno = global i32 0
@.str.3 = [15 x i8] c"${PAGER:-less}\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [21 x i8] c"Err.: %d popen() %s\0A\00"
@EOF = global i64 0
@.str.6 = [21 x i8] c"Err.: %d fputs() %s\0A\00"
@.str.7 = [22 x i8] c"Err.: %d ferror() %s\0A\00"
@.str.8 = [22 x i8] c"Err.: %d pclose() %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %33
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %27, i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %19
%34 = call i32* @popen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %34, i32** %8
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = load i32, i32* @errno
%40 = call i8* @strerror(i32 %39)
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %38, i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %33
br label %45
45: ; preds = %64, %44
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%47 = load i32*, i32** %7
%48 = call i32* @fgets(i8* %46, i32 512, i32* %47)
%49 = icmp ne i32* %48, null
br i1 %49, label %50, label %65
50: ; preds = %45
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%52 = load i32*, i32** %8
%53 = call i64 @fputs(i8* %51, i32* %52)
%54 = load i64, i64* @EOF
%55 = icmp eq i64 %53, %54
br i1 %55, label %56, label %64
56: ; preds = %50
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %58, i8* %60)
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %50
br label %45
65: ; preds = %45
%66 = load i32*, i32** %7
%67 = call i64 @ferror(i32* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %77
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = load i32, i32* @errno
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %71, i8* %73)
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %65
%78 = load i32*, i32** %8
%79 = call i32 @pclose(i32* %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %89
81: ; preds = %77
%82 = load i32, i32* @stderr
%83 = load i32, i32* @errno
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %83, i8* %85)
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %77
%90 = load i32, i32* @EXIT_SUCCESS
ret i32 %90
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Uso: %s <pathname>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Err.: %d fopen() %s\0A\00"
@errno = global i32 0
@.str.3 = [15 x i8] c"${PAGER:-less}\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [21 x i8] c"Err.: %d popen() %s\0A\00"
@EOF = global i64 0
@.str.6 = [21 x i8] c"Err.: %d fputs() %s\0A\00"
@.str.7 = [22 x i8] c"Err.: %d ferror() %s\0A\00"
@.str.8 = [22 x i8] c"Err.: %d pclose() %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %19, i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %12
%25 = tail call i32* @popen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = tail call i8* @strerror(i32 %29)
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %29, i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %24, %37
%35 = call i32* @fgets(i8* %4, i32 512, i32* %15)
%36 = icmp eq i32* %35, null
br i1 %36, label %48, label %37
37: ; preds = %34
%38 = call i64 @fputs(i8* %4, i32* %25)
%39 = load i64, i64* @EOF
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %34
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %43, i8* %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %34
%49 = call i64 @ferror(i32* %15)
%50 = icmp eq i64 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %53, i8* %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %48
%59 = call i32 @pclose(i32* %25)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %68
61: ; preds = %58
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %63, i8* %64)
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %58
%69 = load i32, i32* @EXIT_SUCCESS
ret i32 %69
}