#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 *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strlen(char *);
char *simias_get_user_profile_dir_path(char *dest_path) {
  char *home_dir;
  char dot_local_path[1024];
  char dot_local_share_path[1024];
  char dot_local_share_simias_path[1024];
  home_dir = getenv("HOME");
  if (home_dir == NULL || strlen(home_dir) <= 0) {
    do {
    } while (0);
    return NULL;
  }
  sprintf(dot_local_share_simias_path, "%s%s", home_dir,
          "/.local/share/simias");
  sprintf(dest_path, dot_local_share_simias_path);
  return dest_path;
}


x86 assembly (clang, -O0):
<simias_get_user_profile_dir_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116d <simias_get_user_profile_dir_path+0x3d>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jg     1184 <simias_get_user_profile_dir_path+0x54>
jmp    1172 <simias_get_user_profile_dir_path+0x42>
jmp    1177 <simias_get_user_profile_dir_path+0x47>
movq   $0x0,-0x8(%rbp)
jmp    11be <simias_get_user_profile_dir_path+0x8e>
lea    -0xc20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe6f(%rip),%rsi
lea    0xe6d(%rip),%rcx
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0xc20(%rbp),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simias_get_user_profile_dir_path>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r14
lea    0xeba(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     118d <simias_get_user_profile_dir_path+0x5d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    118d <simias_get_user_profile_dir_path+0x5d>
lea    0xe9e(%rip),%rsi
lea    0xe9c(%rip),%rcx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1190 <simias_get_user_profile_dir_path+0x60>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [21 x i8] c"/.local/share/simias\00"
define i8* @simias_get_user_profile_dir_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i8* %0, i8** %3
%8 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = icmp sle i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11, %1
br label %16
16: ; preds = %15
br label %17
17: ; preds = %16
store i8* null, i8** %2
br label %26
18: ; preds = %11
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%20 = load i8*, i8** %4
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8*, i8** %3
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* %23)
%25 = load i8*, i8** %3
store i8* %25, i8** %2
br label %26
26: ; preds = %18, %17
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [21 x i8] c"/.local/share/simias\00"
define i8* @simias_get_user_profile_dir_path(i8* writeonly %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = tail call i64 @strlen(i8* %4)
%8 = icmp slt i64 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* %3)
br label %12
12: ; preds = %6, %1, %9
%13 = phi i8* [ %0, %9 ], [ null, %1 ], [ null, %6 ]
ret i8* %13
}