#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 */
char *getenv(char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char const *);
int strlen(char const *);
char *get_tcell_files_path(void) {
  char *home_path = getenv("HOME");
  char *tcell_files_path =
      malloc(sizeof(char) * (strlen(((const char *)"sipd/tcell/files")) +
                             strlen(home_path) + 2));
  sprintf(tcell_files_path, "%s/%s", home_path,
          ((const char *)"sipd/tcell/files"));
  return tcell_files_path;
}


x86 assembly (clang, -O0):
<get_tcell_files_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
lea    0xea6(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe7c(%rip),%rsi
lea    0xe64(%rip),%rcx
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tcell_files_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r12
lea    0xea7(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe8f(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
call   1060 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [17 x i8] c"sipd/tcell/files\00"
@.str.2 = [6 x i8] c"%s/%s\00"
define i8* @get_tcell_files_path() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = load i8*, i8** %1
%6 = call i32 @strlen(i8* %5)
%7 = add nsw i32 %4, %6
%8 = add nsw i32 %7, 2
%9 = sext i32 %8 to i64
%10 = mul i64 1, %9
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = load i8*, i8** %1
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [17 x i8] c"sipd/tcell/files\00"
@.str.2 = [6 x i8] c"%s/%s\00"
define noalias i8* @get_tcell_files_path() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* %1)
%4 = add i32 %2, 2
%5 = add i32 %4, %3
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
ret i8* %6
}