#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*/ free(char *);
scalar_t__ loadfile(unsigned char *, int /*<<< orphan*/ *);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
scalar_t__ strlen(char const *);
char const **vec_from_str(char const *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *);
const char **xmldir_toks(const char *xmldir) {
  char *fname = malloc(strlen(xmldir) + 16);
  static const char *txt[2];
  sprintf(fname, "%s/search.txt", xmldir);
  txt[0] = (char *)loadfile((unsigned char *)fname, NULL);
  txt[1] = NULL;
  free(fname);
  return vec_from_str(txt[0], NULL, NULL);
}


x86 assembly (clang, -O0):
<xmldir_toks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x10,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe6c(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <loadfile@plt>
mov    %rax,0x2eb3(%rip)
movq   $0x0,0x2eb0(%rip)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e98(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <vec_from_str@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmldir_toks>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0x10(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%r15
lea    0xe80(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1080 <sprintf@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <loadfile@plt>
mov    %rax,%rbx
mov    %rax,0x2ec1(%rip)
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <vec_from_str@plt>

LLVM IR (-O0):
@xmldir_toks.txt = internal global [2 x i8*] zeroinitializer
@.str = [14 x i8] c"%s/search.txt\00"
define i8** @xmldir_toks(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 16
%7 = call i8* @malloc(i64 %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = load i8*, i8** %2
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %3
%12 = call i64 @loadfile(i8* %11, i32* null)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @xmldir_toks.txt, i64 0, i64 0)
store i8* null, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @xmldir_toks.txt, i64 0, i64 1)
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
%16 = load i8*, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @xmldir_toks.txt, i64 0, i64 0)
%17 = call i8** @vec_from_str(i8* %16, i32* null, i32* null)
ret i8** %17
}

LLVM IR (-O2):
@xmldir_toks.txt.0 = internal unnamed_addr global i8* null
@.str = [14 x i8] c"%s/search.txt\00"
define i8** @xmldir_toks(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 16
%4 = tail call i8* @malloc(i64 %3)
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i64 @loadfile(i8* %4, i32* null)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** @xmldir_toks.txt.0
%8 = tail call i32 @free(i8* %4)
%9 = tail call i8** @vec_from_str(i8* %7, i32* null, i32* null)
ret i8** %9
}