#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 *);
char *get_home_folder();
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *get_tr_folder() {
  char *path = NULL;
  char buf[MAXPATHLEN];
  char *home = NULL;
  if (!path) {
    home = get_home_folder();
    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    0x2e81(%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,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11dd <get_tr_folder+0x8d>
mov    $0x0,%al
call   1030 <get_home_folder@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1050 <am_strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <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   %r14
push   %rbx
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %eax,%eax
call   1030 <get_home_folder@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <am_strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <am_free@plt>
mov    %rbx,%rax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
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 = load i8*, i8** %1
%10 = icmp ne i8* %9, null
br i1 %10, label %19, label %11
11: ; preds = %0
%12 = call i8* (...) @get_home_folder()
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %8, i8* %13)
%15 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = call i8* @am_strdup(i8* %8)
store i8* %16, i8** %1
%17 = load i8*, i8** %4
%18 = call i32 @am_free(i8* %17)
br label %19
19: ; preds = %11, %0
%20 = load i8*, i8** %1
%21 = load i8*, i8** %2
ret i8* %20
}

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 = call i32 @strcpy(i8* %3, i8* %4)
%6 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i8* @am_strdup(i8* %3)
%8 = call i32 @am_free(i8* %4)
ret i8* %7
}