#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 /*<<< orphan*/ get_path(char *, char *);
char *getenv(char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
int get_full_path(char *path, char *command) {
  char *tmp_path;
  char *tmp_command;
  char *homedir;
  homedir = malloc(2048 * sizeof(char));
  tmp_path = malloc(2048 * sizeof(char));
  tmp_command = malloc(2048 * sizeof(char));
  get_path(tmp_path, path);
  sprintf(homedir, "%s", getenv("HOME"));
  strcat(homedir, "/.local/share/secapp/");
  strcpy(tmp_command, command);
  get_path(tmp_command, command);
  strcat(homedir, tmp_command);
  strcpy(path, homedir);
  strtok(path, "\n");
}


x86 assembly (clang, -O0):
<get_full_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <get_path@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe3d(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rdx
lea    0xe27(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <get_path@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1070 <strtok@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_full_path>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <get_path@plt>
lea    0xe58(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <get_path@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe21(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1070 <strtok@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [22 x i8] c"/.local/share/secapp/\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @get_full_path(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = call i8* @malloc(i32 2048)
store i8* %9, i8** %8
%10 = call i8* @malloc(i32 2048)
store i8* %10, i8** %6
%11 = call i8* @malloc(i32 2048)
store i8* %11, i8** %7
%12 = load i8*, i8** %6
%13 = load i8*, i8** %4
%14 = call i32 @get_path(i8* %12, i8* %13)
%15 = load i8*, i8** %8
%16 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %8
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %7
%21 = load i8*, i8** %5
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %7
%24 = load i8*, i8** %5
%25 = call i32 @get_path(i8* %23, i8* %24)
%26 = load i8*, i8** %8
%27 = load i8*, i8** %7
%28 = call i32 @strcat(i8* %26, i8* %27)
%29 = load i8*, i8** %4
%30 = load i8*, i8** %8
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %4
%33 = call i32 @strtok(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [22 x i8] c"/.local/share/secapp/\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @get_full_path(i8* %0, i8* %1) {
%3 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%4 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%5 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%6 = tail call i32 @get_path(i8* %4, i8* %0)
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %3, i8* %7)
%9 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @strcpy(i8* %5, i8* %1)
%11 = tail call i32 @get_path(i8* %5, i8* %1)
%12 = tail call i32 @strcat(i8* %3, i8* %5)
%13 = tail call i32 @strcpy(i8* %0, i8* %3)
%14 = tail call i32 @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 undef
}