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

/* Variables and functions */
int /*<<< orphan*/ O_NONBLOCK;
int WEXITSTATUS(int);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int errno;
int /*<<< orphan*/ execvp(char const *, char *const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
char *getenv(char *);
int pipe2(int *, int /*<<< orphan*/);
int /*<<< orphan*/ *popen(char const *, char *);
int read(int, ...);
int /*<<< orphan*/ show_debug(char *, char const *, ...);
int /*<<< orphan*/ show_error(char *, int /*<<< orphan*/);
int /*<<< orphan*/ show_warn(char *, ...);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ strerror(int);
int waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
FILE *get_pager(void) {
  const char *pager;
  pid_t pgpid;
  int pgret;
  int pgpipe[2];
  bool pgcmdfail = false;
  FILE *retfd = NULL;
  char *const emptyvec[1] = {NULL};
  if ((pager = getenv("PAGER")) == NULL || *pager == '\0') {
    show_warn("get_pager(): couldn't get $PAGER, falling back to `more`\n");
    pager = "more";
  }
  if (pipe2(pgpipe, O_NONBLOCK) == -1) {
    show_error(
        "get_pager(): pipe2() error `%s`. falling back to normal output\n",
        strerror(errno));
    return stderr;
  }
  write(pgpipe[1], "", 1);
retry:
  switch ((pgpid = fork())) {
  case -1:
    show_warn("get_pager(): fork() failed. falling back to normal output\n");
    return stderr;
  case 0:
    execvp(pager, emptyvec);
    char nullbuf;
    read(pgpipe[0], &nullbuf, 1);
    write(pgpipe[1], "1", 2);
    exit(errno);
  default:
    if (waitpid(pgpid, &pgret, 0) == -1) {
      show_debug("pager: waitpid() error `%s`\n", strerror(errno));
      show_warn("pager: waitpid() error. falling back to normal output\n");
      return stderr;
    } else {
      pgret = WEXITSTATUS(pgret);
      if (read(pgpipe[0], &pgcmdfail, 1) == -1) {
        show_error(
            "pager: pipe read() error `%s`. falling back to normal output\n",
            strerror(errno));
        return stderr;
      }
      if (pgcmdfail) {
        show_debug("pager: execvp(pg=%s) ret -> %d (%s)\n", pager, pgret,
                   strerror(pgret));
        if (!strcmp(pager, "more")) {
          show_warn("pager: sh failed to execute more. falling back to normal "
                    "output\n");
          return stderr;
        } else {
          show_warn("pager: sh failed to execute `%s`. trying `more`...\n",
                    pager);
          pager = "more";
          goto retry;
        }
      }
    }
  }
  if ((retfd = popen(pager, "w")) == NULL) {
    show_warn("pager: couldn't popen() pager, falling back to normal output\n");
    return stderr;
  }
  assert(retfd != NULL);
  return retfd;
}


x86 assembly (clang, -O0):
<get_pager>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    0xdc2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1261 <get_pager+0x51>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    127a <get_pager+0x6a>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <show_warn@plt>
lea    0xdca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
call   1100 <pipe2@plt>
cmp    $0xffffffff,%eax
jne    12c4 <get_pager+0xb4>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    %eax,%esi
lea    0xd99(%rip),%rdi
call   10d0 <show_error@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    150b <get_pager+0x2fb>
mov    -0x1c(%rbp),%edi
lea    0xeaa(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
xor    %eax,%eax
call   1130 <fork@plt>
mov    %eax,-0x14(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x40(%rbp)
sub    $0xffffffff,%eax
je     1305 <get_pager+0xf5>
jmp    12f5 <get_pager+0xe5>
mov    -0x40(%rbp),%eax
test   %eax,%eax
je     1326 <get_pager+0x116>
jmp    1368 <get_pager+0x158>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1040 <show_warn@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    150b <get_pager+0x2fb>
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10f0 <execvp@plt>
mov    -0x20(%rbp),%edi
lea    -0x39(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    -0x1c(%rbp),%edi
lea    0xd70(%rip),%rsi
mov    $0x2,%edx
call   1050 <write@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   10c0 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    13bf <get_pager+0x1af>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
movslq %eax,%rsi
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   10b0 <show_debug@plt>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1040 <show_warn@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    150b <get_pager+0x2fb>
mov    -0x18(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
cmp    $0xffffffff,%eax
jne    1415 <get_pager+0x205>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    %eax,%esi
lea    0xd19(%rip),%rdi
call   10d0 <show_error@plt>
mov    0x2bcf(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    150b <get_pager+0x2fb>
cmpl   $0x0,-0x24(%rbp)
je     14a8 <get_pager+0x298>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%edi
call   1120 <strerror@plt>
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   10b0 <show_debug@plt>
mov    -0x10(%rbp),%rdi
lea    0xbe9(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1486 <get_pager+0x276>
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1040 <show_warn@plt>
mov    0x2b5e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    150b <get_pager+0x2fb>
mov    -0x10(%rbp),%rsi
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1040 <show_warn@plt>
lea    0xba1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12d8 <get_pager+0xc8>
jmp    14ad <get_pager+0x29d>
jmp    14b2 <get_pager+0x2a2>
mov    -0x10(%rbp),%rdi
lea    0xd31(%rip),%rsi
call   10e0 <popen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    14f1 <get_pager+0x2e1>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1040 <show_warn@plt>
mov    0x2af3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    150b <get_pager+0x2fb>
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pager>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0x14(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xdda(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1238 <get_pager+0x38>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    124d <get_pager+0x4d>
lea    0xdc7(%rip),%rdi
xor    %eax,%eax
call   1040 <show_warn@plt>
lea    0xdf3(%rip),%rbx
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdi
call   10f0 <pipe2@plt>
cmp    $0xffffffff,%eax
je     1349 <get_pager+0x149>
mov    0x1c(%rsp),%edi
lea    0xf04(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
lea    0xc(%rsp),%r14
lea    0x14(%rsp),%r15
lea    0xec5(%rip),%r12
lea    0xdaa(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1120 <fork@plt>
cmp    $0xffffffff,%eax
je     1360 <get_pager+0x160>
test   %eax,%eax
je     1405 <get_pager+0x205>
mov    %eax,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   10b0 <waitpid@plt>
cmp    $0xffffffff,%eax
je     1369 <get_pager+0x169>
mov    0xc(%rsp),%edi
call   1090 <WEXITSTATUS@plt>
mov    %eax,0xc(%rsp)
mov    0x18(%rsp),%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1391 <get_pager+0x191>
cmpl   $0x0,0x14(%rsp)
je     13af <get_pager+0x1af>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
call   1110 <strerror@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <show_debug@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     13d2 <get_pager+0x1d2>
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <show_warn@plt>
mov    %r13,%rbx
jmp    12a0 <get_pager+0xa0>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xce7(%rip),%rdi
jmp    13a6 <get_pager+0x1a6>
lea    0xd1e(%rip),%rdi
jmp    13e2 <get_pager+0x1e2>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
movslq %eax,%rsi
lea    0xd41(%rip),%rdi
xor    %eax,%eax
call   10a0 <show_debug@plt>
lea    0xd50(%rip),%rdi
jmp    13e2 <get_pager+0x1e2>
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd70(%rip),%rdi
mov    %eax,%esi
call   10c0 <show_error@plt>
jmp    13e9 <get_pager+0x1e9>
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <popen@plt>
test   %rax,%rax
je     13db <get_pager+0x1db>
mov    %rax,%rbx
mov    $0x1,%edi
call   1080 <assert@plt>
jmp    13f3 <get_pager+0x1f3>
lea    0xda0(%rip),%rdi
jmp    13e2 <get_pager+0x1e2>
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1040 <show_warn@plt>
mov    0x2be8(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   10e0 <execvp@plt>
mov    0x18(%rsp),%edi
lea    0x13(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1060 <read@plt>
mov    0x1c(%rsp),%edi
lea    0xc8e(%rip),%rsi
mov    $0x2,%edx
call   1050 <write@plt>
mov    0x2b8d(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"PAGER\00"
@.str.1 = [58 x i8] c"get_pager(): couldn't get $PAGER, falling back to `more`\0A\00"
@.str.2 = [5 x i8] c"more\00"
@O_NONBLOCK = global i32 0
@.str.3 = [64 x i8] c"get_pager(): pipe2() error `%s`. falling back to normal output\0A\00"
@errno = global i32 0
@stderr = global i32* null
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [59 x i8] c"get_pager(): fork() failed. falling back to normal output\0A\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [29 x i8] c"pager: waitpid() error `%s`\0A\00"
@.str.8 = [55 x i8] c"pager: waitpid() error. falling back to normal output\0A\00"
@.str.9 = [62 x i8] c"pager: pipe read() error `%s`. falling back to normal output\0A\00"
@.str.10 = [37 x i8] c"pager: execvp(pg=%s) ret -> %d (%s)\0A\00"
@.str.11 = [65 x i8] c"pager: sh failed to execute more. falling back to normal output\0A\00"
@.str.12 = [52 x i8] c"pager: sh failed to execute `%s`. trying `more`...\0A\00"
@.str.13 = [2 x i8] c"w\00"
@.str.14 = [62 x i8] c"pager: couldn't popen() pager, falling back to normal output\0A\00"
define i32* @get_pager() {
%1 = alloca i32*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [1 x i8*]
%9 = alloca i8
store i32 0, i32* %6
store i32* null, i32** %7
%10 = bitcast [1 x i8*]* %8 to i8*
%11 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %2
%12 = icmp eq i8* %11, null
br i1 %12, label %18, label %13
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13, %0
%19 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %18, %13
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%22 = load i32, i32* @O_NONBLOCK
%23 = call i32 @pipe2(i32* %21, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @errno
%27 = call i32 @strerror(i32 %26)
%28 = call i32 @show_error(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32*, i32** @stderr
store i32* %29, i32** %1
br label %108
30: ; preds = %20
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%32 = load i32, i32* %31
%33 = call i32 @write(i32 %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %34
34: ; preds = %90, %30
%35 = call i32 (...) @fork()
store i32 %35, i32* %3
switch i32 %35, label %51 [
i32 -1, label %36
i32 0, label %39
]
36: ; preds = %34
%37 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32*, i32** @stderr
store i32* %38, i32** %1
br label %108
39: ; preds = %34
%40 = load i8*, i8** %2
%41 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%42 = call i32 @execvp(i8* %40, i8** %41)
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%44 = load i32, i32* %43
%45 = call i32 (i32, ...) @read(i32 %44, i8* %9, i32 1)
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%47 = load i32, i32* %46
%48 = call i32 @write(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 2)
%49 = load i32, i32* @errno
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %34
%52 = load i32, i32* %3
%53 = call i32 @waitpid(i32 %52, i32* %4, i32 0)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %63
55: ; preds = %51
%56 = load i32, i32* @errno
%57 = call i32 @strerror(i32 %56)
%58 = sext i32 %57 to i64
%59 = inttoptr i64 %58 to i8*
%60 = call i32 (i8*, i8*, ...) @show_debug(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %59)
%61 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%62 = load i32*, i32** @stderr
store i32* %62, i32** %1
br label %108
63: ; preds = %51
%64 = load i32, i32* %4
%65 = call i32 @WEXITSTATUS(i32 %64)
store i32 %65, i32* %4
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%67 = load i32, i32* %66
%68 = call i32 (i32, ...) @read(i32 %67, i32* %6, i32 1)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %75
70: ; preds = %63
%71 = load i32, i32* @errno
%72 = call i32 @strerror(i32 %71)
%73 = call i32 @show_error(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.9, i64 0, i64 0), i32 %72)
%74 = load i32*, i32** @stderr
store i32* %74, i32** %1
br label %108
75: ; preds = %63
%76 = load i32, i32* %6
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %93
78: ; preds = %75
%79 = load i8*, i8** %2
%80 = load i32, i32* %4
%81 = load i32, i32* %4
%82 = call i32 @strerror(i32 %81)
%83 = call i32 (i8*, i8*, ...) @show_debug(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %79, i32 %80, i32 %82)
%84 = load i8*, i8** %2
%85 = call i32 @strcmp(i8* %84, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%86 = icmp ne i32 %85, 0
br i1 %86, label %90, label %87
87: ; preds = %78
%88 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.11, i64 0, i64 0))
%89 = load i32*, i32** @stderr
store i32* %89, i32** %1
br label %108
90: ; preds = %78
%91 = load i8*, i8** %2
%92 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0), i8* %91)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %34
93: ; preds = %75
br label %94
94: ; preds = %93
br label %95
95: ; preds = %94
%96 = load i8*, i8** %2
%97 = call i32* @popen(i8* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32* %97, i32** %7
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %102
99: ; preds = %95
%100 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.14, i64 0, i64 0))
%101 = load i32*, i32** @stderr
store i32* %101, i32** %1
br label %108
102: ; preds = %95
%103 = load i32*, i32** %7
%104 = icmp ne i32* %103, null
%105 = zext i1 %104 to i32
%106 = call i32 @assert(i32 %105)
%107 = load i32*, i32** %7
store i32* %107, i32** %1
br label %108
108: ; preds = %102, %99, %87, %70, %55, %36, %25
%109 = load i32*, i32** %1
ret i32* %109
}

LLVM IR (-O2):
@.str = [6 x i8] c"PAGER\00"
@.str.1 = [58 x i8] c"get_pager(): couldn't get $PAGER, falling back to `more`\0A\00"
@.str.2 = [5 x i8] c"more\00"
@O_NONBLOCK = global i32 0
@.str.3 = [64 x i8] c"get_pager(): pipe2() error `%s`. falling back to normal output\0A\00"
@errno = global i32 0
@stderr = global i32* null
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [59 x i8] c"get_pager(): fork() failed. falling back to normal output\0A\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [29 x i8] c"pager: waitpid() error `%s`\0A\00"
@.str.8 = [55 x i8] c"pager: waitpid() error. falling back to normal output\0A\00"
@.str.9 = [62 x i8] c"pager: pipe read() error `%s`. falling back to normal output\0A\00"
@.str.10 = [37 x i8] c"pager: execvp(pg=%s) ret -> %d (%s)\0A\00"
@.str.11 = [65 x i8] c"pager: sh failed to execute more. falling back to normal output\0A\00"
@.str.12 = [52 x i8] c"pager: sh failed to execute `%s`. trying `more`...\0A\00"
@.str.13 = [2 x i8] c"w\00"
@.str.14 = [62 x i8] c"pager: couldn't popen() pager, falling back to normal output\0A\00"
define i32* @get_pager() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca [1 x i8*]
%5 = alloca i8
%6 = bitcast i32* %1 to i8*
%7 = bitcast [2 x i32]* %2 to i8*
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast [1 x i8*]* %4 to i8*
%10 = bitcast [1 x i8*]* %4 to i64*
store i64 0, i64* %10
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13, %0
%17 = tail call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %16 ], [ %11, %13 ]
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%21 = load i32, i32* @O_NONBLOCK
%22 = call i32 @pipe2(i32* %20, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i32, i32* @errno
%26 = call i32 @strerror(i32 %25)
%27 = call i32 @show_error(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** @stderr
br label %92
29: ; preds = %18
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%31 = load i32, i32* %30
%32 = call i32 @write(i32 %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %33
33: ; preds = %82, %29
%34 = phi i8* [ %19, %29 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %82 ]
%35 = call i32 (...) @fork()
switch i32 %35, label %48 [
i32 -1, label %36
i32 0, label %39
]
36: ; preds = %33
%37 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32*, i32** @stderr
br label %92
39: ; preds = %33
%40 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%41 = call i32 @execvp(i8* %34, i8** %40)
%42 = load i32, i32* %20
%43 = call i32 (i32, ...) @read(i32 %42, i8* %5, i32 1)
%44 = load i32, i32* %30
%45 = call i32 @write(i32 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 2)
%46 = load i32, i32* @errno
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %33
%49 = call i32 @waitpid(i32 %35, i32* %1, i32 0)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i32, i32* @errno
%53 = call i32 @strerror(i32 %52)
%54 = sext i32 %53 to i64
%55 = inttoptr i64 %54 to i8*
%56 = call i32 (i8*, i8*, ...) @show_debug(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%58 = load i32*, i32** @stderr
br label %92
59: ; preds = %48
%60 = load i32, i32* %1
%61 = call i32 @WEXITSTATUS(i32 %60)
store i32 %61, i32* %1
%62 = load i32, i32* %20
%63 = call i32 (i32, ...) @read(i32 %62, i32* %3, i32 1)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %70
65: ; preds = %59
%66 = load i32, i32* @errno
%67 = call i32 @strerror(i32 %66)
%68 = call i32 @show_error(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.9, i64 0, i64 0), i32 %67)
%69 = load i32*, i32** @stderr
br label %92
70: ; preds = %59
%71 = load i32, i32* %3
%72 = icmp eq i32 %71, 0
br i1 %72, label %84, label %73
73: ; preds = %70
%74 = load i32, i32* %1
%75 = call i32 @strerror(i32 %74)
%76 = call i32 (i8*, i8*, ...) @show_debug(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %34, i32 %74, i32 %75)
%77 = call i32 @strcmp(i8* dereferenceable(1) %34, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %73
%80 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.11, i64 0, i64 0))
%81 = load i32*, i32** @stderr
br label %92
82: ; preds = %73
%83 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0), i8* %34)
br label %33
84: ; preds = %70
%85 = call i32* @popen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%86 = icmp eq i32* %85, null
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = call i32 (i8*, ...) @show_warn(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.14, i64 0, i64 0))
%89 = load i32*, i32** @stderr
br label %92
90: ; preds = %84
%91 = call i32 @assert(i32 1)
br label %92
92: ; preds = %90, %87, %79, %65, %51, %36, %24
%93 = phi i32* [ %28, %24 ], [ %58, %51 ], [ %69, %65 ], [ %81, %79 ], [ %89, %87 ], [ %85, %90 ], [ %38, %36 ]
ret i32* %93
}