int share_file_exists(const char *filename) {
  char *full_name;
  const char *share_dir;
  share_dir = get_asf_share_dir();
  full_name = (char *)MALLOC(sizeof(char) *
                             (strlen(filename) + strlen(share_dir) + 10));
  sprintf(full_name, "%s%c%s", share_dir, '/', filename);
  int exists = fileExists(full_name);
  free(full_name);
  return exists;
}


x86 assembly (clang, -O0):
<share_file_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <get_asf_share_dir@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0xa,%rdi
shl    $0x0,%rdi
mov    $0x0,%al
call   1070 <MALLOC@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%r8
lea    0xe42(%rip),%rsi
mov    $0x2f,%ecx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <fileExists@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<share_file_exists>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <get_asf_share_dir@plt>
movslq %eax,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0xa,%rdi
xor    %eax,%eax
call   1070 <MALLOC@plt>
movslq %eax,%rbx
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    $0x2f,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fileExists@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s%c%s\00"
define i32 @share_file_exists(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 (...) @get_asf_share_dir()
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %4
%9 = load i8*, i8** %2
%10 = call i64 @strlen(i8* %9)
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
%13 = add i64 %10, %12
%14 = add i64 %13, 10
%15 = mul i64 1, %14
%16 = call i32 (i64, ...) bitcast (i32 (...)* @MALLOC to i32 (i64, ...)*)(i64 %15)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = load i8*, i8** %2
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %20, i32 47, i8* %21)
%23 = load i8*, i8** %3
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @fileExists to i32 (i8*, ...)*)(i8* %23)
store i32 %24, i32* %5
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s%c%s\00"
define i32 @share_file_exists(i8* %0) {
%2 = tail call i32 (...) @get_asf_share_dir()
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%7 = add i64 %5, 10
%8 = add i64 %7, %6
%9 = tail call i32 (i64, ...) bitcast (i32 (...)* @MALLOC to i32 (i64, ...)*)(i64 %8)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4, i32 47, i8* %0)
%13 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fileExists to i32 (i8*, ...)*)(i8* %11)
tail call void @free(i8* %11)
ret i32 %13
}