#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 MAXPATHLEN;
int /*<<< orphan*/ am_free(char *);
char *am_strdup(char *);
int /*<<< orphan*/ assert(int);
char *get_home_folder();
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *get_tr_folder() {
  char *path = NULL;
  char buf[MAXPATHLEN];
  char *home = NULL;
  home = get_home_folder();
  assert(home && *home && ((strlen(home) + 20) < MAXPATHLEN));
  strcpy(buf, home);
  strcat(buf, "/.config/transmission");
  path = am_strdup(buf);
  am_free(home);
  return path;
}


x86 assembly (clang, -O0):
<get_tr_folder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <get_home_folder@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     11ff <get_tr_folder+0x8f>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     11ff <get_tr_folder+0x8f>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x14,%eax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1050 <am_strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <am_free@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tr_folder>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e66(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <get_home_folder@plt>
mov    %rax,%r14
test   %rax,%rax
je     11c5 <get_tr_folder+0x55>
cmpb   $0x0,(%r14)
je     11c5 <get_tr_folder+0x55>
mov    %r14,%rdi
call   1060 <strlen@plt>
add    $0x14,%eax
xor    %r15d,%r15d
cmp    (%r12),%eax
setl   %r15b
mov    %r15d,%edi
call   1070 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1050 <am_strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1080 <am_free@plt>
mov    %rbx,%rax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@.str = [22 x i8] c"/.config/transmission\00"
define i8* @get_tr_folder() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* null, i8** %1
%5 = load i32, i32* @MAXPATHLEN
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %2
%8 = alloca i8, i64 %6
store i64 %6, i64* %3
store i8* null, i8** %4
%9 = call i8* (...) @get_home_folder()
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %23
12: ; preds = %0
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 20
%21 = load i32, i32* @MAXPATHLEN
%22 = icmp slt i32 %20, %21
br label %23
23: ; preds = %17, %12, %0
%24 = phi i1 [ false, %12 ], [ false, %0 ], [ %22, %17 ]
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i8*, i8** %4
%28 = call i32 @strcpy(i8* %8, i8* %27)
%29 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%30 = call i8* @am_strdup(i8* %8)
store i8* %30, i8** %1
%31 = load i8*, i8** %4
%32 = call i32 @am_free(i8* %31)
%33 = load i8*, i8** %1
%34 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
@.str = [22 x i8] c"/.config/transmission\00"
define i8* @get_tr_folder() {
%1 = load i32, i32* @MAXPATHLEN
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i8* (...) @get_home_folder()
%5 = icmp eq i8* %4, null
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %4)
%11 = add nsw i32 %10, 20
%12 = load i32, i32* @MAXPATHLEN
%13 = icmp slt i32 %11, %12
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %9, %6, %0
%16 = phi i32 [ 0, %6 ], [ 0, %0 ], [ %14, %9 ]
%17 = tail call i32 @assert(i32 %16)
%18 = call i32 @strcpy(i8* %3, i8* %4)
%19 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%20 = call i8* @am_strdup(i8* %3)
%21 = call i32 @am_free(i8* %4)
ret i8* %20
}