#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 */
scalar_t__ sstrncat(char *, size_t *, size_t, char const *, int);
int strlen(char const *);
int construct_path(char *buf, size_t buflen, char const *home,
                   char const *input, char const *platform) {
  size_t len;
  len = 0;
  if (sstrncat(buf, &len, buflen, home, strlen(home)))
    return 1;
  if (sstrncat(buf, &len, buflen, "/.tldrc/tldr-master/pages/",
               (sizeof("/.tldrc/tldr-master/pages/") - 1)))
    return 1;
  if (sstrncat(buf, &len, buflen, platform, strlen(platform)))
    return 1;
  if (sstrncat(buf, &len, buflen, "/", 1))
    return 1;
  if (sstrncat(buf, &len, buflen, input, strlen(input)))
    return 1;
  if (sstrncat(buf, &len, buflen, ".md", 3))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<construct_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    %eax,%r8d
lea    -0x38(%rbp),%rsi
call   1040 <sstrncat@plt>
cmp    $0x0,%rax
je     1196 <construct_path+0x76>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <construct_path+0x1b7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rsi
lea    0xe57(%rip),%rcx
mov    $0x1a,%r8d
call   1040 <sstrncat@plt>
cmp    $0x0,%rax
je     11ca <construct_path+0xaa>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <construct_path+0x1b7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    %eax,%r8d
lea    -0x38(%rbp),%rsi
call   1040 <sstrncat@plt>
cmp    $0x0,%rax
je     1219 <construct_path+0xf9>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <construct_path+0x1b7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rsi
lea    0xded(%rip),%rcx
mov    $0x1,%r8d
call   1040 <sstrncat@plt>
cmp    $0x0,%rax
je     124d <construct_path+0x12d>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <construct_path+0x1b7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    -0x70(%rbp),%rcx
mov    %eax,%r8d
lea    -0x38(%rbp),%rsi
call   1040 <sstrncat@plt>
cmp    $0x0,%rax
je     129c <construct_path+0x17c>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <construct_path+0x1b7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rsi
lea    0xd6c(%rip),%rcx
mov    $0x3,%r8d
call   1040 <sstrncat@plt>
cmp    $0x0,%rax
je     12d0 <construct_path+0x1b0>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <construct_path+0x1b7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<construct_path>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r12
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
mov    %rdx,%rdi
call   1030 <strlen@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
mov    %eax,%r8d
call   1040 <sstrncat@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1229 <construct_path+0x109>
lea    0xe89(%rip),%rcx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    $0x1a,%r8d
call   1040 <sstrncat@plt>
test   %rax,%rax
jne    1229 <construct_path+0x109>
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %eax,%r8d
call   1040 <sstrncat@plt>
test   %rax,%rax
jne    1229 <construct_path+0x109>
lea    0xe59(%rip),%rcx
lea    0x8(%rsp),%rsi
mov    $0x1,%ebp
mov    %rbx,%rdi
mov    %r14,%rdx
mov    $0x1,%r8d
call   1040 <sstrncat@plt>
test   %rax,%rax
jne    1229 <construct_path+0x109>
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %eax,%r8d
call   1040 <sstrncat@plt>
test   %rax,%rax
jne    1229 <construct_path+0x109>
lea    0xe11(%rip),%rcx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    $0x3,%r8d
call   1040 <sstrncat@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"/.tldrc/tldr-master/pages/\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [4 x i8] c".md\00"
define i32 @construct_path(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i64 0, i64* %12
%13 = load i8*, i8** %7
%14 = load i64, i64* %8
%15 = load i8*, i8** %9
%16 = load i8*, i8** %9
%17 = call i32 @strlen(i8* %16)
%18 = call i64 @sstrncat(i8* %13, i64* %12, i64 %14, i8* %15, i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %5
store i32 1, i32* %6
br label %58
21: ; preds = %5
%22 = load i8*, i8** %7
%23 = load i64, i64* %8
%24 = call i64 @sstrncat(i8* %22, i64* %12, i64 %23, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %6
br label %58
27: ; preds = %21
%28 = load i8*, i8** %7
%29 = load i64, i64* %8
%30 = load i8*, i8** %11
%31 = load i8*, i8** %11
%32 = call i32 @strlen(i8* %31)
%33 = call i64 @sstrncat(i8* %28, i64* %12, i64 %29, i8* %30, i32 %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %27
store i32 1, i32* %6
br label %58
36: ; preds = %27
%37 = load i8*, i8** %7
%38 = load i64, i64* %8
%39 = call i64 @sstrncat(i8* %37, i64* %12, i64 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 1, i32* %6
br label %58
42: ; preds = %36
%43 = load i8*, i8** %7
%44 = load i64, i64* %8
%45 = load i8*, i8** %10
%46 = load i8*, i8** %10
%47 = call i32 @strlen(i8* %46)
%48 = call i64 @sstrncat(i8* %43, i64* %12, i64 %44, i8* %45, i32 %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %42
store i32 1, i32* %6
br label %58
51: ; preds = %42
%52 = load i8*, i8** %7
%53 = load i64, i64* %8
%54 = call i64 @sstrncat(i8* %52, i64* %12, i64 %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %51
store i32 1, i32* %6
br label %58
57: ; preds = %51
store i32 0, i32* %6
br label %58
58: ; preds = %57, %56, %50, %41, %35, %26, %20
%59 = load i32, i32* %6
ret i32 %59
}

LLVM IR (-O2):
@.str = [27 x i8] c"/.tldrc/tldr-master/pages/\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [4 x i8] c".md\00"
define i32 @construct_path(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i64
%7 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%8 = tail call i32 @strlen(i8* %2)
%9 = call i64 @sstrncat(i8* %0, i64* %6, i64 %1, i8* %2, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %5
%12 = call i64 @sstrncat(i8* %0, i64* %6, i64 %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = call i32 @strlen(i8* %4)
%16 = call i64 @sstrncat(i8* %0, i64* %6, i64 %1, i8* %4, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = call i64 @sstrncat(i8* %0, i64* %6, i64 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = call i32 @strlen(i8* %3)
%23 = call i64 @sstrncat(i8* %0, i64* %6, i64 %1, i8* %3, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = call i64 @sstrncat(i8* %0, i64* %6, i64 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%27 = icmp ne i64 %26, 0
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %25, %21, %18, %14, %11, %5
%30 = phi i32 [ 1, %5 ], [ 1, %11 ], [ 1, %14 ], [ 1, %18 ], [ 1, %21 ], [ %28, %25 ]
ret i32 %30
}