#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 *calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *status_get_file_path() {
  char *path = NULL;
  char *env = NULL;
  env = getenv("HOME");
  if (env == NULL) {
    fprintf(stderr, "Failed to get env.\n");
    return NULL;
  }
  path = calloc(1, (strlen(env) + 12) * sizeof(char));
  if (path == NULL) {
    fprintf(stderr, "Malloc failed.\n");
    return NULL;
  }
  strcpy(path, env);
  strcat(path, "/.steel_dbs");
  return path;
}


x86 assembly (clang, -O0):
<status_get_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe81(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <status_get_file_path+0x55>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1070 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1229 <status_get_file_path+0xc9>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
add    $0xc,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
mov    $0x1,%edi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1204 <status_get_file_path+0xa4>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1070 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1229 <status_get_file_path+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_get_file_path>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b1 <status_get_file_path+0x51>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0xc(%rax),%esi
mov    $0x1,%edi
call   1060 <calloc@plt>
test   %rax,%rax
je     11c3 <status_get_file_path+0x63>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
jmp    11da <status_get_file_path+0x7a>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
jmp    11d3 <status_get_file_path+0x73>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1070 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Failed to get env.\0A\00"
@.str.2 = [16 x i8] c"Malloc failed.\0A\00"
@.str.3 = [12 x i8] c"/.steel_dbs\00"
define i8* @status_get_file_path() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
store i8* null, i8** %2
store i8* null, i8** %3
%4 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %1
br label %30
10: ; preds = %0
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %12, 12
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = call i8* @calloc(i32 1, i32 %16)
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %1
br label %30
23: ; preds = %10
%24 = load i8*, i8** %2
%25 = load i8*, i8** %3
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %2
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %2
store i8* %29, i8** %1
br label %30
30: ; preds = %23, %20, %7
%31 = load i8*, i8** %1
ret i8* %31
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Failed to get env.\0A\00"
@.str.2 = [16 x i8] c"Malloc failed.\0A\00"
@.str.3 = [12 x i8] c"/.steel_dbs\00"
define i8* @status_get_file_path() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %17
6: ; preds = %0
%7 = tail call i32 @strlen(i8* %1)
%8 = add nsw i32 %7, 12
%9 = tail call i8* @calloc(i32 1, i32 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %17
14: ; preds = %6
%15 = tail call i32 @strcpy(i8* %9, i8* %1)
%16 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %14, %11, %3
%18 = phi i8* [ null, %3 ], [ null, %11 ], [ %9, %14 ]
ret i8* %18
}