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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int STDIN_FILENO;
int /*<<< orphan*/ close(int);
int dup2(int, int);
int /*<<< orphan*/ errno;
scalar_t__ execl(char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *getenv(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
char *strrchr(char *, char);
scalar_t__ waitpid(scalar_t__, int /*<<< orphan*/ *, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int n, fd[2];
  pid_t pid;
  char *pager, *argv0;
  char line[512];
  FILE *fp;
  if (argc != 2) {
    fprintf(stderr, "Uso: %s <pathname>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((fp = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Err.(%s) can't open\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  if (pipe(fd) < 0) {
    fprintf(stderr, "Err.(%s) - opening pipe\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((pid = fork()) < 0) {
    fprintf(stderr, "Err.(%s) - fork()\n", strerror(errno));
    exit(EXIT_FAILURE);
  } else if (pid > 0) {
    close(fd[0]);
    while (fgets(line, 512, fp) != NULL) {
      n = strlen(line);
      if (write(fd[1], line, n) != n) {
        fprintf(stderr, "Err.(%s) - write pipe\n", strerror(errno));
        exit(EXIT_FAILURE);
      }
    }
    if (ferror(fp)) {
      fprintf(stderr, "Err.(%s) - fgets error\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
    close(fd[1]);
    if (waitpid(pid, NULL, 0) < 0) {
      fprintf(stderr, "Err.(%s) - waitpid()\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
  } else {
    close(fd[1]);
    if (fd[0] != STDIN_FILENO) {
      if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO) {
        fprintf(stderr, "Err.(%s) - dup2()\n", strerror(errno));
        exit(EXIT_FAILURE);
      }
      close(fd[0]);
    }
    if ((pager = getenv("PAGER")) == NULL)
      pager = "/bin/less";
    if ((argv0 = strrchr(pager, '/')) != NULL)
      argv0++;
    else
      argv0 = pager;
    if (execl(pager, argv0, (char *)0) < 0) {
      fprintf(stderr, "Err.(%s) - execl()\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     124d <main+0x4d>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc6(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb8(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x248(%rbp)
cmp    $0x0,%rax
jne    129d <main+0x9d>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd8c(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    -0x1c(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0x0,%rax
jge    12f0 <main+0xf0>
mov    0x2d29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24c(%rbp)
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x24c(%rbp),%edi
mov    %rax,%rdx
lea    0xd4e(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jge    1345 <main+0x145>
mov    0x2cd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x250(%rbp)
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x250(%rbp),%edi
mov    %rax,%rdx
lea    0xd12(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
cmpq   $0x0,-0x28(%rbp)
jle    14a5 <main+0x2a5>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
lea    -0x240(%rbp),%rdi
mov    -0x248(%rbp),%rdx
mov    $0x200,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     13e9 <main+0x1e9>
lea    -0x240(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x240(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <write@plt>
cmp    -0x14(%rbp),%eax
je     13e4 <main+0x1e4>
mov    0x2c35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x254(%rbp)
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x254(%rbp),%edi
mov    %rax,%rdx
lea    0xc86(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    1358 <main+0x158>
mov    -0x248(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     143f <main+0x23f>
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x258(%rbp)
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x258(%rbp),%edi
mov    %rax,%rdx
lea    0xc42(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
cmp    $0x0,%rax
jge    14a0 <main+0x2a0>
mov    0x2b79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x25c(%rbp)
mov    0x2b62(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x25c(%rbp),%edi
mov    %rax,%rdx
lea    0xbf9(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    15e1 <main+0x3e1>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%eax
mov    0x2b09(%rip),%rcx
cmp    (%rcx),%eax
je     1527 <main+0x327>
mov    -0x1c(%rbp),%edi
mov    0x2af7(%rip),%rax
mov    (%rax),%esi
call   1070 <dup2@plt>
mov    0x2ae9(%rip),%rcx
cmp    (%rcx),%eax
je     151f <main+0x31f>
mov    0x2afa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x260(%rbp)
mov    0x2ae3(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x260(%rbp),%edi
mov    %rax,%rdx
lea    0xb90(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2ab8(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
lea    0xb81(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    154c <main+0x34c>
lea    0xb6d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1579 <main+0x379>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1581 <main+0x381>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1110 <execl@plt>
cmp    $0x0,%rax
jge    15dc <main+0x3dc>
mov    0x2a3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x264(%rbp)
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x264(%rbp),%edi
mov    %rax,%rdx
lea    0xaf6(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x29fb(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    15e1 <main+0x3e1>
jmp    15e6 <main+0x3e6>
mov    0x29db(%rip),%rax
mov    (%rax),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    13b2 <main+0x1b2>
mov    0x8(%rbx),%rdi
lea    0xdf0(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     13ca <main+0x1ca>
mov    %rax,%r15
lea    0x8(%rsp),%rdi
call   10a0 <pipe@plt>
test   %rax,%rax
js     13e3 <main+0x1e3>
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
js     1406 <main+0x206>
je     1326 <main+0x126>
mov    %rax,%r14
mov    0x8(%rsp),%edi
call   1090 <close@plt>
lea    0x10(%rsp),%rbx
nop
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     12d7 <main+0xd7>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %ebp,%eax
je     1270 <main+0x70>
mov    0x2d38(%rip),%rax
mov    (%rax),%ebx
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xd98(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10c0 <fprintf@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1429 <main+0x229>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
test   %rax,%rax
jns    139b <main+0x19b>
mov    0x2cd3(%rip),%rax
mov    (%rax),%ebx
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xd62(%rip),%rsi
jmp    12bf <main+0xbf>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    0x8(%rsp),%edi
mov    0x2c86(%rip),%rbx
mov    (%rbx),%esi
cmp    %esi,%edi
je     1356 <main+0x156>
call   1070 <dup2@plt>
cmp    (%rbx),%eax
jne    146f <main+0x26f>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
lea    0xd52(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xd49(%rip),%rbx
cmovne %rax,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
lea    0x1(%rax),%rsi
test   %rax,%rax
cmove  %rbx,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1110 <execl@plt>
test   %rax,%rax
js     144c <main+0x24c>
mov    0x2c26(%rip),%rax
mov    (%rax),%eax
add    $0x218,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc3b(%rip),%rsi
jmp    12c4 <main+0xc4>
mov    0x2c0f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xc38(%rip),%rsi
jmp    12c4 <main+0xc4>
mov    0x2bf6(%rip),%rax
mov    (%rax),%ebx
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc2a(%rip),%rsi
jmp    12bf <main+0xbf>
mov    0x2bd3(%rip),%rax
mov    (%rax),%ebx
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc20(%rip),%rsi
jmp    12bf <main+0xbf>
mov    0x2bb0(%rip),%rax
mov    (%rax),%ebx
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc27(%rip),%rsi
jmp    12bf <main+0xbf>
mov    0x2b8d(%rip),%rax
mov    (%rax),%ebx
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc55(%rip),%rsi
jmp    12bf <main+0xbf>
mov    0x2b6a(%rip),%rax
mov    (%rax),%ebx
mov    0x2b59(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc0f(%rip),%rsi
jmp    12bf <main+0xbf>

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.(%s) can't open\0A\00"
@.str.3 = [25 x i8] c"Err.(%s) - opening pipe\0A\00"
@errno = global i32 0
@.str.4 = [19 x i8] c"Err.(%s) - fork()\0A\00"
@.str.5 = [23 x i8] c"Err.(%s) - write pipe\0A\00"
@.str.6 = [24 x i8] c"Err.(%s) - fgets error\0A\00"
@.str.7 = [22 x i8] c"Err.(%s) - waitpid()\0A\00"
@STDIN_FILENO = global i32 0
@.str.8 = [19 x i8] c"Err.(%s) - dup2()\0A\00"
@.str.9 = [6 x i8] c"PAGER\00"
@.str.10 = [10 x i8] c"/bin/less\00"
@.str.11 = [20 x i8] c"Err.(%s) - execl()\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 i32
%7 = alloca [2 x i32]
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [512 x i8]
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %12
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %23
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%39 = call i64 @pipe(i32* %38)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %37
%49 = call i64 (...) @fork()
store i64 %49, i64* %8
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %48
%59 = load i64, i64* %8
%60 = icmp sgt i64 %59, 0
br i1 %60, label %61, label %114
61: ; preds = %58
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%63 = load i32, i32* %62
%64 = call i32 @close(i32 %63)
br label %65
65: ; preds = %87, %61
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%67 = load i32*, i32** %12
%68 = call i32* @fgets(i8* %66, i32 512, i32* %67)
%69 = icmp ne i32* %68, null
br i1 %69, label %70, label %88
70: ; preds = %65
%71 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%72 = call i32 @strlen(i8* %71)
store i32 %72, i32* %6
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%74 = load i32, i32* %73
%75 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%76 = load i32, i32* %6
%77 = call i32 @write(i32 %74, i8* %75, i32 %76)
%78 = load i32, i32* %6
%79 = icmp ne i32 %77, %78
br i1 %79, label %80, label %87
80: ; preds = %70
%81 = load i32, i32* @stderr
%82 = load i32, i32* @errno
%83 = call i8* @strerror(i32 %82)
%84 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %70
br label %65
88: ; preds = %65
%89 = load i32*, i32** %12
%90 = call i64 @ferror(i32* %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %99
92: ; preds = %88
%93 = load i32, i32* @stderr
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %95)
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %88
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @close(i32 %101)
%103 = load i64, i64* %8
%104 = call i64 @waitpid(i64 %103, i32* null, i32 0)
%105 = icmp slt i64 %104, 0
br i1 %105, label %106, label %113
106: ; preds = %99
%107 = load i32, i32* @stderr
%108 = load i32, i32* @errno
%109 = call i8* @strerror(i32 %108)
%110 = call i32 @fprintf(i32 %107, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %109)
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %99
br label %166
114: ; preds = %58
%115 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%116 = load i32, i32* %115
%117 = call i32 @close(i32 %116)
%118 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%119 = load i32, i32* %118
%120 = load i32, i32* @STDIN_FILENO
%121 = icmp ne i32 %119, %120
br i1 %121, label %122, label %140
122: ; preds = %114
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%124 = load i32, i32* %123
%125 = load i32, i32* @STDIN_FILENO
%126 = call i32 @dup2(i32 %124, i32 %125)
%127 = load i32, i32* @STDIN_FILENO
%128 = icmp ne i32 %126, %127
br i1 %128, label %129, label %136
129: ; preds = %122
%130 = load i32, i32* @stderr
%131 = load i32, i32* @errno
%132 = call i8* @strerror(i32 %131)
%133 = call i32 @fprintf(i32 %130, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %132)
%134 = load i32, i32* @EXIT_FAILURE
%135 = call i32 @exit(i32 %134)
unreachable
136: ; preds = %122
%137 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%138 = load i32, i32* %137
%139 = call i32 @close(i32 %138)
br label %140
140: ; preds = %136, %114
%141 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
store i8* %141, i8** %9
%142 = icmp eq i8* %141, null
br i1 %142, label %143, label %144
143: ; preds = %140
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8** %9
br label %144
144: ; preds = %143, %140
%145 = load i8*, i8** %9
%146 = call i8* @strrchr(i8* %145, i8 signext 47)
store i8* %146, i8** %10
%147 = icmp ne i8* %146, null
br i1 %147, label %148, label %151
148: ; preds = %144
%149 = load i8*, i8** %10
%150 = getelementptr inbounds i8, i8* %149, i32 1
store i8* %150, i8** %10
br label %153
151: ; preds = %144
%152 = load i8*, i8** %9
store i8* %152, i8** %10
br label %153
153: ; preds = %151, %148
%154 = load i8*, i8** %9
%155 = load i8*, i8** %10
%156 = call i64 @execl(i8* %154, i8* %155, i8* null)
%157 = icmp slt i64 %156, 0
br i1 %157, label %158, label %165
158: ; preds = %153
%159 = load i32, i32* @stderr
%160 = load i32, i32* @errno
%161 = call i8* @strerror(i32 %160)
%162 = call i32 @fprintf(i32 %159, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %161)
%163 = load i32, i32* @EXIT_FAILURE
%164 = call i32 @exit(i32 %163)
unreachable
165: ; preds = %153
br label %166
166: ; preds = %165, %113
br label %167
167: ; preds = %166
%168 = load i32, i32* @EXIT_SUCCESS
ret i32 %168
}

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.(%s) can't open\0A\00"
@.str.3 = [25 x i8] c"Err.(%s) - opening pipe\0A\00"
@errno = global i32 0
@.str.4 = [19 x i8] c"Err.(%s) - fork()\0A\00"
@.str.5 = [23 x i8] c"Err.(%s) - write pipe\0A\00"
@.str.6 = [24 x i8] c"Err.(%s) - fgets error\0A\00"
@.str.7 = [22 x i8] c"Err.(%s) - waitpid()\0A\00"
@STDIN_FILENO = global i32 0
@.str.8 = [19 x i8] c"Err.(%s) - dup2()\0A\00"
@.str.9 = [6 x i8] c"PAGER\00"
@.str.10 = [10 x i8] c"/bin/less\00"
@.str.11 = [20 x i8] c"Err.(%s) - execl()\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [512 x i8]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %15
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %14
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%27 = call i64 @pipe(i32* %26)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %25
%37 = call i64 (...) @fork()
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %36
%47 = icmp eq i64 %37, 0
br i1 %47, label %89, label %48
48: ; preds = %46
%49 = load i32, i32* %26
%50 = call i32 @close(i32 %49)
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %52
52: ; preds = %55, %48
%53 = call i32* @fgets(i8* %6, i32 512, i32* %17)
%54 = icmp eq i32* %53, null
br i1 %54, label %67, label %55
55: ; preds = %52
%56 = call i32 @strlen(i8* %6)
%57 = load i32, i32* %51
%58 = call i32 @write(i32 %57, i8* %6, i32 %56)
%59 = icmp eq i32 %58, %56
br i1 %59, label %52, label %60
60: ; preds = %55
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %63)
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %52
%68 = call i64 @ferror(i32* %17)
%69 = icmp eq i64 %68, 0
br i1 %69, label %77, label %70
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %73)
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %67
%78 = load i32, i32* %51
%79 = call i32 @close(i32 %78)
%80 = call i64 @waitpid(i64 %37, i32* null, i32 0)
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %127
82: ; preds = %77
%83 = load i32, i32* @stderr
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %85)
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %46
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%91 = load i32, i32* %90
%92 = call i32 @close(i32 %91)
%93 = load i32, i32* %26
%94 = load i32, i32* @STDIN_FILENO
%95 = icmp eq i32 %93, %94
br i1 %95, label %110, label %96
96: ; preds = %89
%97 = call i32 @dup2(i32 %93, i32 %94)
%98 = load i32, i32* @STDIN_FILENO
%99 = icmp eq i32 %97, %98
br i1 %99, label %107, label %100
100: ; preds = %96
%101 = load i32, i32* @stderr
%102 = load i32, i32* @errno
%103 = call i8* @strerror(i32 %102)
%104 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %103)
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %96
%108 = load i32, i32* %26
%109 = call i32 @close(i32 %108)
br label %110
110: ; preds = %107, %89
%111 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%112 = icmp eq i8* %111, null
%113 = select i1 %112, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %111
%114 = call i8* @strrchr(i8* dereferenceable(1) %113, i8 signext 47)
%115 = icmp eq i8* %114, null
%116 = getelementptr inbounds i8, i8* %114, i64 1
%117 = select i1 %115, i8* %113, i8* %116
%118 = call i64 @execl(i8* %113, i8* %117, i8* null)
%119 = icmp slt i64 %118, 0
br i1 %119, label %120, label %127
120: ; preds = %110
%121 = load i32, i32* @stderr
%122 = load i32, i32* @errno
%123 = call i8* @strerror(i32 %122)
%124 = call i32 @fprintf(i32 %121, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %123)
%125 = load i32, i32* @EXIT_FAILURE
%126 = call i32 @exit(i32 %125)
unreachable
127: ; preds = %77, %110
%128 = load i32, i32* @EXIT_SUCCESS
ret i32 %128
}