#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 *concat(char *, char *);
int /*<<< orphan*/ free(char *);
char *get_xdg_data_home();
char *getenv(char *);
scalar_t__ malloc(int);
char *strdup(char *);
char **get_search_paths() {
  char *suffix = "/horddays/";
  int dirs_num = 5;
  char **path = (char **)malloc(sizeof(char *) * (dirs_num + 1));
  path[0] = strdup("");
  char *s;
  s = get_xdg_data_home();
  path[1] = concat(s, suffix);
  free(s);
  path[2] = concat(getenv("HOME"), "/.horddays/");
  path[3] = strdup("/usr/local/share/horddays/");
  path[4] = strdup("/usr/share/horddays/");
  path[dirs_num] = NULL;
  return path;
}


x86 assembly (clang, -O0):
<get_search_paths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe78(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1080 <get_xdg_data_home@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <concat@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
lea    0xe26(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
lea    0xe1c(%rip),%rsi
call   1050 <concat@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
lea    0xe11(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
lea    0xe15(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_search_paths>:
push   %r14
push   %rbx
push   %rax
mov    $0x30,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe98(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,(%rbx)
xor    %eax,%eax
call   1080 <get_xdg_data_home@plt>
mov    %rax,%r14
lea    0xe90(%rip),%rsi
mov    %rax,%rdi
call   1050 <concat@plt>
mov    %rax,0x8(%rbx)
mov    %r14,%rdi
call   1040 <free@plt>
lea    0xe54(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe4d(%rip),%rsi
mov    %rax,%rdi
call   1050 <concat@plt>
mov    %rax,0x10(%rbx)
lea    0xe46(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,0x18(%rbx)
lea    0xe51(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,0x20(%rbx)
movq   $0x0,0x28(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/horddays/\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [12 x i8] c"/.horddays/\00"
@.str.4 = [27 x i8] c"/usr/local/share/horddays/\00"
@.str.5 = [21 x i8] c"/usr/share/horddays/\00"
define i8** @get_search_paths() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i8*
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1
store i32 5, i32* %2
%5 = load i32, i32* %2
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8**
store i8** %11, i8*** %3
%12 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8**, i8*** %3
%14 = getelementptr inbounds i8*, i8** %13, i64 0
store i8* %12, i8** %14
%15 = call i8* (...) @get_xdg_data_home()
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = load i8*, i8** %1
%18 = call i8* @concat(i8* %16, i8* %17)
%19 = load i8**, i8*** %3
%20 = getelementptr inbounds i8*, i8** %19, i64 1
store i8* %18, i8** %20
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
%23 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%24 = call i8* @concat(i8* %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i64 2
store i8* %24, i8** %26
%27 = call i8* @strdup(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%28 = load i8**, i8*** %3
%29 = getelementptr inbounds i8*, i8** %28, i64 3
store i8* %27, i8** %29
%30 = call i8* @strdup(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%31 = load i8**, i8*** %3
%32 = getelementptr inbounds i8*, i8** %31, i64 4
store i8* %30, i8** %32
%33 = load i8**, i8*** %3
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
store i8* null, i8** %36
%37 = load i8**, i8*** %3
ret i8** %37
}

LLVM IR (-O2):
@.str = [11 x i8] c"/horddays/\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [12 x i8] c"/.horddays/\00"
@.str.4 = [27 x i8] c"/usr/local/share/horddays/\00"
@.str.5 = [21 x i8] c"/usr/share/horddays/\00"
define i8** @get_search_paths() {
%1 = tail call i64 @malloc(i32 48)
%2 = inttoptr i64 %1 to i8**
%3 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %3, i8** %2
%4 = tail call i8* (...) @get_xdg_data_home()
%5 = tail call i8* @concat(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* %5, i8** %6
%7 = tail call i32 @free(i8* %4)
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i8* @concat(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %2, i64 2
store i8* %9, i8** %10
%11 = tail call dereferenceable_or_null(27) i8* @strdup(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %2, i64 3
store i8* %11, i8** %12
%13 = tail call dereferenceable_or_null(21) i8* @strdup(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %2, i64 4
store i8* %13, i8** %14
%15 = getelementptr inbounds i8*, i8** %2, i64 5
store i8* null, i8** %15
ret i8** %2
}