#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ construct_path(char *, int, char const *, char const *,
                                  char const *);
int /*<<< orphan*/ construct_url(char *, int, char const *, char const *);
int /*<<< orphan*/ download_content(char *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ get_file_content(char *, char **, int /*<<< orphan*/);
char *gethome();
char *getplatform();
int /*<<< orphan*/ parse_tldrpage(char *);
scalar_t__ sstrncat(char *, size_t *, int, char const *, int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
int print_tldrpage(char const *input, char const *poverride) {
  char *output;
  char url[1024];
  char const *platform;
  char const *homedir;
  size_t len;
  char directory[512];
  struct stat sb;
  if (poverride == NULL) {
    platform = getplatform();
  } else {
    platform = poverride;
    if (strcmp(platform, "linux") != 0 && strcmp(platform, "osx") != 0 &&
        strcmp(platform, "common") != 0 && strcmp(platform, "sunos") != 0 &&
        strcmp(platform, "windows") != 0) {
      fprintf(stderr, "Error: platform %s is unsupported\n", platform);
      fprintf(stderr,
              "Supported platforms: linux / osx / sunos / windows / common\n");
      exit(EXIT_FAILURE);
    }
  }
  homedir = gethome();
  if (homedir == NULL)
    return 1;
  len = 0;
  if (sstrncat(directory, &len, 512, homedir, strlen(homedir)))
    return 1;
  if (sstrncat(directory, &len, 512, "/.tldrc/tldr-master/pages/",
               (sizeof("/.tldrc/tldr-master/pages/") - 1)))
    return 1;
  if (stat(directory, &sb) == 0 && S_ISDIR(sb.st_mode)) {
    construct_path(url, 1024, homedir, input, platform);
    if (stat(url, &sb) == 0 && S_ISREG(sb.st_mode)) {
      if (!get_file_content(url, &output, 0)) {
        parse_tldrpage(output);
        free(output);
        return 0;
      }
    } else {
      construct_path(url, 1024, homedir, input, "common");
      if (stat(url, &sb) == 0 && S_ISREG(sb.st_mode)) {
        if (!get_file_content(url, &output, 0)) {
          parse_tldrpage(output);
          free(output);
          return 0;
        }
      }
    }
  }
  construct_url(url, 1024, input, platform);
  output = NULL;
  download_content(url, &output, 0);
  if (output == NULL) {
    construct_url(url, 1024, input, "common");
    download_content(url, &output, 0);
    if (output == NULL)
      return 1;
  }
  parse_tldrpage(output);
  free(output);
  return 0;
}


x86 assembly (clang, -O0):
<print_tldrpage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1231 <print_tldrpage+0x31>
mov    $0x0,%al
call   10f0 <getplatform@plt>
mov    %rax,-0x428(%rbp)
jmp    1315 <print_tldrpage+0x115>
mov    -0x18(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rdi
lea    0xdb6(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1310 <print_tldrpage+0x110>
mov    -0x428(%rbp),%rdi
lea    0xd9f(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1310 <print_tldrpage+0x110>
mov    -0x428(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1310 <print_tldrpage+0x110>
mov    -0x428(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1310 <print_tldrpage+0x110>
mov    -0x428(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1310 <print_tldrpage+0x110>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    -0x428(%rbp),%rdx
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
lea    0xd47(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1315 <print_tldrpage+0x115>
mov    $0x0,%al
call   1120 <gethome@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
jne    133d <print_tldrpage+0x13d>
movl   $0x1,-0x4(%rbp)
jmp    15e9 <print_tldrpage+0x3e9>
movq   $0x0,-0x438(%rbp)
lea    -0x640(%rbp),%rax
mov    %rax,-0x658(%rbp)
mov    -0x430(%rbp),%rax
mov    %rax,-0x650(%rbp)
mov    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x658(%rbp),%rdi
mov    -0x650(%rbp),%rcx
mov    %eax,%r8d
lea    -0x438(%rbp),%rsi
mov    $0x200,%edx
call   1090 <sstrncat@plt>
cmp    $0x0,%rax
je     13a8 <print_tldrpage+0x1a8>
movl   $0x1,-0x4(%rbp)
jmp    15e9 <print_tldrpage+0x3e9>
lea    -0x640(%rbp),%rdi
lea    -0x438(%rbp),%rsi
mov    $0x200,%edx
lea    0xcbd(%rip),%rcx
mov    $0x1a,%r8d
call   1090 <sstrncat@plt>
cmp    $0x0,%rax
je     13e3 <print_tldrpage+0x1e3>
movl   $0x1,-0x4(%rbp)
jmp    15e9 <print_tldrpage+0x3e9>
lea    -0x640(%rbp),%rdi
lea    -0x648(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
jne    1545 <print_tldrpage+0x345>
mov    -0x648(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1545 <print_tldrpage+0x345>
lea    -0x420(%rbp),%rdi
mov    -0x430(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x428(%rbp),%r8
mov    $0x400,%esi
call   10e0 <construct_path@plt>
lea    -0x420(%rbp),%rdi
lea    -0x648(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
jne    14a8 <print_tldrpage+0x2a8>
mov    -0x648(%rbp),%edi
call   10d0 <S_ISREG@plt>
cmp    $0x0,%rax
je     14a8 <print_tldrpage+0x2a8>
lea    -0x420(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1060 <get_file_content@plt>
cmp    $0x0,%eax
jne    14a3 <print_tldrpage+0x2a3>
mov    -0x20(%rbp),%rdi
call   1040 <parse_tldrpage@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    15e9 <print_tldrpage+0x3e9>
jmp    1540 <print_tldrpage+0x340>
lea    -0x420(%rbp),%rdi
mov    -0x430(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x400,%esi
lea    0xb44(%rip),%r8
call   10e0 <construct_path@plt>
lea    -0x420(%rbp),%rdi
lea    -0x648(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
jne    153b <print_tldrpage+0x33b>
mov    -0x648(%rbp),%edi
call   10d0 <S_ISREG@plt>
cmp    $0x0,%rax
je     153b <print_tldrpage+0x33b>
lea    -0x420(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1060 <get_file_content@plt>
cmp    $0x0,%eax
jne    1536 <print_tldrpage+0x336>
mov    -0x20(%rbp),%rdi
call   1040 <parse_tldrpage@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    15e9 <print_tldrpage+0x3e9>
jmp    153b <print_tldrpage+0x33b>
jmp    1540 <print_tldrpage+0x340>
jmp    1545 <print_tldrpage+0x345>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x428(%rbp),%rcx
mov    $0x400,%esi
call   1110 <construct_url@plt>
movq   $0x0,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1050 <download_content@plt>
cmpq   $0x0,-0x20(%rbp)
jne    15d0 <print_tldrpage+0x3d0>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
lea    0xa6d(%rip),%rcx
call   1110 <construct_url@plt>
lea    -0x420(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1050 <download_content@plt>
cmpq   $0x0,-0x20(%rbp)
jne    15cb <print_tldrpage+0x3cb>
movl   $0x1,-0x4(%rbp)
jmp    15e9 <print_tldrpage+0x3e9>
jmp    15d0 <print_tldrpage+0x3d0>
mov    -0x20(%rbp),%rdi
call   1040 <parse_tldrpage@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_tldrpage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x620,%rsp
mov    %rdi,%r14
test   %rsi,%rsi
je     12c4 <print_tldrpage+0xc4>
mov    %rsi,%rbx
lea    0xddb(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12ce <print_tldrpage+0xce>
lea    0xdc9(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12ce <print_tldrpage+0xce>
lea    0xdb5(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12ce <print_tldrpage+0xce>
lea    0xda8(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12ce <print_tldrpage+0xce>
lea    0xd9a(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12ce <print_tldrpage+0xce>
mov    0x2d4f(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd84(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xd93(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
xor    %eax,%eax
call   10f0 <getplatform@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1120 <gethome@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     13e4 <print_tldrpage+0x1e4>
mov    %rax,%rbp
movq   $0x0,0x18(%rsp)
mov    %rax,%rdi
call   1070 <strlen@plt>
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    $0x200,%edx
mov    %rbp,%rcx
mov    %eax,%r8d
call   1090 <sstrncat@plt>
test   %rax,%rax
jne    13e4 <print_tldrpage+0x1e4>
lea    0xd5d(%rip),%rcx
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    $0x200,%edx
mov    $0x1a,%r8d
call   1090 <sstrncat@plt>
test   %rax,%rax
jne    13e4 <print_tldrpage+0x1e4>
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <stat@plt>
test   %rax,%rax
je     13f7 <print_tldrpage+0x1f7>
lea    0x220(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1110 <construct_url@plt>
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
xor    %edx,%edx
call   1050 <download_content@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
jne    13d2 <print_tldrpage+0x1d2>
lea    0xc69(%rip),%rcx
lea    0x220(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1110 <construct_url@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <download_content@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     13e4 <print_tldrpage+0x1e4>
call   1040 <parse_tldrpage@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x620,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     135d <print_tldrpage+0x15d>
lea    0x220(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
call   10e0 <construct_path@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   10c0 <stat@plt>
test   %rax,%rax
je     1484 <print_tldrpage+0x284>
lea    0xbca(%rip),%r8
lea    0x220(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
mov    %r14,%rcx
call   10e0 <construct_path@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   10c0 <stat@plt>
test   %rax,%rax
jne    135d <print_tldrpage+0x15d>
mov    0x8(%rsp),%edi
call   10d0 <S_ISREG@plt>
test   %rax,%rax
jne    1492 <print_tldrpage+0x292>
jmp    135d <print_tldrpage+0x15d>
mov    0x8(%rsp),%edi
call   10d0 <S_ISREG@plt>
test   %rax,%rax
je     1439 <print_tldrpage+0x239>
lea    0x220(%rsp),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1060 <get_file_content@plt>
test   %eax,%eax
jne    135d <print_tldrpage+0x15d>
mov    0x10(%rsp),%rdi
jmp    13d2 <print_tldrpage+0x1d2>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [6 x i8] c"linux\00"
@.str.1 = [4 x i8] c"osx\00"
@.str.2 = [7 x i8] c"common\00"
@.str.3 = [6 x i8] c"sunos\00"
@.str.4 = [8 x i8] c"windows\00"
@stderr = global i32 0
@.str.5 = [35 x i8] c"Error: platform %s is unsupported\0A\00"
@.str.6 = [61 x i8] c"Supported platforms: linux / osx / sunos / windows / common\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [27 x i8] c"/.tldrc/tldr-master/pages/\00"
define i32 @print_tldrpage(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [512 x i8]
%12 = alloca %struct.stat
store i8* %0, i8** %4
store i8* %1, i8** %5
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i8* (...) @getplatform()
store i8* %16, i8** %8
br label %47
17: ; preds = %2
%18 = load i8*, i8** %5
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %17
%23 = load i8*, i8** %8
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %46
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %26
%31 = load i8*, i8** %8
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %46
34: ; preds = %30
%35 = load i8*, i8** %8
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %8
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %34, %30, %26, %22, %17
br label %47
47: ; preds = %46, %15
%48 = call i8* (...) @gethome()
store i8* %48, i8** %9
%49 = load i8*, i8** %9
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 1, i32* %3
br label %147
52: ; preds = %47
store i64 0, i64* %10
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%54 = load i8*, i8** %9
%55 = load i8*, i8** %9
%56 = call i32 @strlen(i8* %55)
%57 = call i64 @sstrncat(i8* %53, i64* %10, i32 512, i8* %54, i32 %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %52
store i32 1, i32* %3
br label %147
60: ; preds = %52
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%62 = call i64 @sstrncat(i8* %61, i64* %10, i32 512, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 26)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 1, i32* %3
br label %147
65: ; preds = %60
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%67 = call i64 @stat(i8* %66, %struct.stat* %12)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %123
69: ; preds = %65
%70 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%71 = load i32, i32* %70
%72 = call i64 @S_ISDIR(i32 %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %123
74: ; preds = %69
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%76 = load i8*, i8** %9
%77 = load i8*, i8** %4
%78 = load i8*, i8** %8
%79 = call i32 @construct_path(i8* %75, i32 1024, i8* %76, i8* %77, i8* %78)
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%81 = call i64 @stat(i8* %80, %struct.stat* %12)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %98
83: ; preds = %74
%84 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%85 = load i32, i32* %84
%86 = call i64 @S_ISREG(i32 %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %98
88: ; preds = %83
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%90 = call i32 @get_file_content(i8* %89, i8** %6, i32 0)
%91 = icmp ne i32 %90, 0
br i1 %91, label %97, label %92
92: ; preds = %88
%93 = load i8*, i8** %6
%94 = call i32 @parse_tldrpage(i8* %93)
%95 = load i8*, i8** %6
%96 = call i32 @free(i8* %95)
store i32 0, i32* %3
br label %147
97: ; preds = %88
br label %122
98: ; preds = %83, %74
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%100 = load i8*, i8** %9
%101 = load i8*, i8** %4
%102 = call i32 @construct_path(i8* %99, i32 1024, i8* %100, i8* %101, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%104 = call i64 @stat(i8* %103, %struct.stat* %12)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %121
106: ; preds = %98
%107 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%108 = load i32, i32* %107
%109 = call i64 @S_ISREG(i32 %108)
%110 = icmp ne i64 %109, 0
br i1 %110, label %111, label %121
111: ; preds = %106
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%113 = call i32 @get_file_content(i8* %112, i8** %6, i32 0)
%114 = icmp ne i32 %113, 0
br i1 %114, label %120, label %115
115: ; preds = %111
%116 = load i8*, i8** %6
%117 = call i32 @parse_tldrpage(i8* %116)
%118 = load i8*, i8** %6
%119 = call i32 @free(i8* %118)
store i32 0, i32* %3
br label %147
120: ; preds = %111
br label %121
121: ; preds = %120, %106, %98
br label %122
122: ; preds = %121, %97
br label %123
123: ; preds = %122, %69, %65
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%125 = load i8*, i8** %4
%126 = load i8*, i8** %8
%127 = call i32 @construct_url(i8* %124, i32 1024, i8* %125, i8* %126)
store i8* null, i8** %6
%128 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%129 = call i32 @download_content(i8* %128, i8** %6, i32 0)
%130 = load i8*, i8** %6
%131 = icmp eq i8* %130, null
br i1 %131, label %132, label %142
132: ; preds = %123
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%134 = load i8*, i8** %4
%135 = call i32 @construct_url(i8* %133, i32 1024, i8* %134, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%136 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%137 = call i32 @download_content(i8* %136, i8** %6, i32 0)
%138 = load i8*, i8** %6
%139 = icmp eq i8* %138, null
br i1 %139, label %140, label %141
140: ; preds = %132
store i32 1, i32* %3
br label %147
141: ; preds = %132
br label %142
142: ; preds = %141, %123
%143 = load i8*, i8** %6
%144 = call i32 @parse_tldrpage(i8* %143)
%145 = load i8*, i8** %6
%146 = call i32 @free(i8* %145)
store i32 0, i32* %3
br label %147
147: ; preds = %142, %140, %115, %92, %64, %59, %51
%148 = load i32, i32* %3
ret i32 %148
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [6 x i8] c"linux\00"
@.str.1 = [4 x i8] c"osx\00"
@.str.2 = [7 x i8] c"common\00"
@.str.3 = [6 x i8] c"sunos\00"
@.str.4 = [8 x i8] c"windows\00"
@stderr = global i32 0
@.str.5 = [35 x i8] c"Error: platform %s is unsupported\0A\00"
@.str.6 = [61 x i8] c"Supported platforms: linux / osx / sunos / windows / common\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [27 x i8] c"/.tldrc/tldr-master/pages/\00"
define i32 @print_tldrpage(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca i64
%6 = alloca [512 x i8]
%7 = alloca %struct.stat
%8 = bitcast i8** %3 to i8*
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = bitcast i64* %5 to i8*
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = bitcast %struct.stat* %7 to i8*
%13 = icmp eq i8* %1, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i8* (...) @getplatform()
br label %38
16: ; preds = %2
%17 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %38, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %38, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %38, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %38, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %16, %19, %22, %25, %28, %14
%39 = phi i8* [ %15, %14 ], [ %1, %28 ], [ %1, %25 ], [ %1, %22 ], [ %1, %19 ], [ %1, %16 ]
%40 = tail call i8* (...) @gethome()
%41 = icmp eq i8* %40, null
br i1 %41, label %101, label %42
42: ; preds = %38
store i64 0, i64* %5
%43 = tail call i32 @strlen(i8* %40)
%44 = call i64 @sstrncat(i8* %11, i64* %5, i32 512, i8* %40, i32 %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %101
46: ; preds = %42
%47 = call i64 @sstrncat(i8* %11, i64* %5, i32 512, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 26)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %101
49: ; preds = %46
%50 = call i64 @stat(i8* %11, %struct.stat* %7)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %85
52: ; preds = %49
%53 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%54 = load i32, i32* %53
%55 = call i64 @S_ISDIR(i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %85, label %57
57: ; preds = %52
%58 = call i32 @construct_path(i8* %9, i32 1024, i8* %40, i8* %0, i8* %39)
%59 = call i64 @stat(i8* %9, %struct.stat* %7)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = load i32, i32* %53
%63 = call i64 @S_ISREG(i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %71, label %65
65: ; preds = %61
%66 = call i32 @get_file_content(i8* %9, i8** %3, i32 0)
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %85
68: ; preds = %65
%69 = load i8*, i8** %3
%70 = call i32 @parse_tldrpage(i8* %69)
br label %98
71: ; preds = %61, %57
%72 = call i32 @construct_path(i8* %9, i32 1024, i8* %40, i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%73 = call i64 @stat(i8* %9, %struct.stat* %7)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %85
75: ; preds = %71
%76 = load i32, i32* %53
%77 = call i64 @S_ISREG(i32 %76)
%78 = icmp eq i64 %77, 0
br i1 %78, label %85, label %79
79: ; preds = %75
%80 = call i32 @get_file_content(i8* %9, i8** %3, i32 0)
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i8*, i8** %3
%84 = call i32 @parse_tldrpage(i8* %83)
br label %98
85: ; preds = %65, %79, %75, %71, %52, %49
%86 = call i32 @construct_url(i8* %9, i32 1024, i8* %0, i8* %39)
store i8* null, i8** %3
%87 = call i32 @download_content(i8* %9, i8** %3, i32 0)
%88 = load i8*, i8** %3
%89 = icmp eq i8* %88, null
br i1 %89, label %90, label %95
90: ; preds = %85
%91 = call i32 @construct_url(i8* %9, i32 1024, i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%92 = call i32 @download_content(i8* %9, i8** %3, i32 0)
%93 = load i8*, i8** %3
%94 = icmp eq i8* %93, null
br i1 %94, label %101, label %95
95: ; preds = %90, %85
%96 = phi i8* [ %93, %90 ], [ %88, %85 ]
%97 = call i32 @parse_tldrpage(i8* %96)
br label %98
98: ; preds = %68, %82, %95
%99 = load i8*, i8** %3
%100 = call i32 @free(i8* %99)
br label %101
101: ; preds = %98, %90, %46, %42, %38
%102 = phi i32 [ 1, %38 ], [ 1, %42 ], [ 1, %46 ], [ 1, %90 ], [ 0, %98 ]
ret i32 %102
}