const char *get_tmp_log_file(char *tool) {
  char *tmpDir = get_asf_tmp_dir();
  char *tmpLog =
      (char *)MALLOC(sizeof(char) * (strlen(tmpDir) + strlen(tool) + 20));
  sprintf(tmpLog, "%s%c%s%i.log", tmpDir, '/', tool, (int)getpid());
  return tmpLog;
}


x86 assembly (clang, -O0):
<get_tmp_log_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <get_asf_tmp_dir@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x14,%rdi
shl    $0x0,%rdi
mov    $0x0,%al
call   1060 <MALLOC@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%r8
mov    %eax,%r9d
lea    0xe30(%rip),%rsi
mov    $0x2f,%ecx
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tmp_log_file>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <get_asf_tmp_dir@plt>
movslq %eax,%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x14,%rdi
xor    %eax,%eax
call   1060 <MALLOC@plt>
movslq %eax,%rbx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    $0x2f,%ecx
mov    %r14,%r8
mov    %eax,%r9d
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"%s%c%s%i.log\00"
define i8* @get_tmp_log_file(i8* %0) {
%2 = tail call i32 (...) @get_asf_tmp_dir()
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = add i64 %5, 20
%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 (...) @getpid()
%13 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %4, i32 47, i8* %0, i32 %12)
ret i8* %11
}