#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 */

/* Variables and functions */
int /*<<< orphan*/ execvp(char *, char **);
scalar_t__ getenv(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ setenv(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
int usage();
int main(int argc, char *argv[]) {
  if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
    return usage();
  setenv("LESS_TERMCAP_"
         "mb",
         "\e["
         "5"
         ";"
         "31"
         "m",
         0);
  setenv("LESS_TERMCAP_"
         "md",
         "\e["
         "1"
         ";"
         "34"
         "m",
         0);
  setenv("LESS_TERMCAP_"
         "me",
         "\e["
         "0"
         ";"
         "0"
         "m",
         0);
  setenv("LESS_TERMCAP_"
         "us",
         "\e["
         "4"
         ";"
         "36"
         "m",
         0);
  setenv("LESS_TERMCAP_"
         "ue",
         "\e["
         "0"
         ";"
         "0"
         "m",
         0);
  argv[0] = getenv("PAGER") ?: "less";
  execvp(argv[0], argv);
  perror("could not launch PAGER");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11c9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11ba <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11c9 <main+0x69>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1297 <main+0x137>
lea    0xe3a(%rip),%rdi
lea    0xe43(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe3d(%rip),%rdi
lea    0xe46(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe40(%rip),%rdi
lea    0xe49(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe42(%rip),%rdi
lea    0xe4b(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe45(%rip),%rdi
lea    0xe1f(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe56(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1259 <main+0xf9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1269 <main+0x109>
lea    0xe19(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1269 <main+0x109>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <execvp@plt>
lea    0xdf3(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jne    11a4 <main+0x44>
mov    0x8(%r14),%rbx
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1196 <main+0x36>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11a4 <main+0x44>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <usage@plt>
lea    0xe5f(%rip),%rdi
lea    0xe68(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe62(%rip),%rdi
lea    0xe6b(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe65(%rip),%rdi
lea    0xe6e(%rip),%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe64(%rip),%rdi
lea    0xe6d(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
lea    0xe7c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xe57(%rip),%rdi
cmovne %rax,%rdi
mov    %rdi,(%r14)
mov    %r14,%rsi
call   1080 <execvp@plt>
lea    0xe46(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [16 x i8] c"LESS_TERMCAP_mb\00"
@.str.3 = [8 x i8] c"\1B[5;31m\00"
@.str.4 = [16 x i8] c"LESS_TERMCAP_md\00"
@.str.5 = [8 x i8] c"\1B[1;34m\00"
@.str.6 = [16 x i8] c"LESS_TERMCAP_me\00"
@.str.7 = [7 x i8] c"\1B[0;0m\00"
@.str.8 = [16 x i8] c"LESS_TERMCAP_us\00"
@.str.9 = [8 x i8] c"\1B[4;36m\00"
@.str.10 = [16 x i8] c"LESS_TERMCAP_ue\00"
@.str.11 = [6 x i8] c"PAGER\00"
@.str.12 = [5 x i8] c"less\00"
@.str.13 = [23 x i8] c"could not launch PAGER\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %14, %8
%21 = call i32 (...) @usage()
store i32 %21, i32* %3
br label %43
22: ; preds = %14, %2
%23 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 0)
%24 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 0)
%25 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 0)
%26 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 0)
%27 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 0)
%28 = call i64 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = inttoptr i64 %28 to i8*
br label %33
32: ; preds = %22
br label %33
33: ; preds = %32, %30
%34 = phi i8* [ %31, %30 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), %32 ]
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
store i8* %34, i8** %36
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = call i32 @execvp(i8* %39, i8** %40)
%42 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %3
br label %43
43: ; preds = %33, %20
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [16 x i8] c"LESS_TERMCAP_mb\00"
@.str.3 = [8 x i8] c"\1B[5;31m\00"
@.str.4 = [16 x i8] c"LESS_TERMCAP_md\00"
@.str.5 = [8 x i8] c"\1B[1;34m\00"
@.str.6 = [16 x i8] c"LESS_TERMCAP_me\00"
@.str.7 = [7 x i8] c"\1B[0;0m\00"
@.str.8 = [16 x i8] c"LESS_TERMCAP_us\00"
@.str.9 = [8 x i8] c"\1B[4;36m\00"
@.str.10 = [16 x i8] c"LESS_TERMCAP_ue\00"
@.str.11 = [6 x i8] c"PAGER\00"
@.str.12 = [5 x i8] c"less\00"
@.str.13 = [23 x i8] c"could not launch PAGER\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9, %4
%13 = tail call i32 (...) @usage()
br label %26
14: ; preds = %9, %2
%15 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 0)
%16 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 0)
%17 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 0)
%18 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 0)
%19 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 0)
%20 = tail call i64 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = inttoptr i64 %20 to i8*
%23 = select i1 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %22
store i8* %23, i8** %1
%24 = tail call i32 @execvp(i8* %23, i8** %1)
%25 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
br label %26
26: ; preds = %14, %12
%27 = phi i32 [ 1, %14 ], [ %13, %12 ]
ret i32 %27
}