#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 getpid();
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, ...);
void post2dictionary_get_spool_filename(char *spool_filename,
                                        char *appaserver_data_directory,
                                        char *base_filename, char *session) {
  if (appaserver_data_directory && session) {
    sprintf(spool_filename, "%s/%s_%s", appaserver_data_directory,
            base_filename, session);
  } else {
    sprintf(spool_filename, "%s/%s_%d", "/tmp", base_filename, getpid());
  }
}


x86 assembly (clang, -O0):
<post2dictionary_get_spool_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1171 <post2dictionary_get_spool_filename+0x51>
cmpq   $0x0,-0x20(%rbp)
je     1171 <post2dictionary_get_spool_filename+0x51>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11a8 <post2dictionary_get_spool_filename+0x88>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    %eax,%r8d
lea    0xe6f(%rip),%rsi
lea    0xe71(%rip),%rdx
mov    $0x0,%al
call   1040 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<post2dictionary_get_spool_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
je     1155 <post2dictionary_get_spool_filename+0x35>
mov    %rcx,%r8
test   %rcx,%rcx
je     1155 <post2dictionary_get_spool_filename+0x35>
mov    %rsi,%rdx
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sprintf@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea6(%rip),%rsi
lea    0xea8(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
mov    %eax,%r8d
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s/%s_%s\00"
@.str.1 = [9 x i8] c"%s/%s_%d\00"
@.str.2 = [5 x i8] c"/tmp\00"
define void @post2dictionary_get_spool_filename(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %20
11: ; preds = %4
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %18)
br label %25
20: ; preds = %11, %4
%21 = load i8*, i8** %5
%22 = load i8*, i8** %7
%23 = call i32 (...) @getpid()
%24 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %23)
br label %25
25: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s/%s_%s\00"
@.str.1 = [9 x i8] c"%s/%s_%d\00"
@.str.2 = [5 x i8] c"/tmp\00"
define void @post2dictionary_get_spool_filename(i8* nocapture writeonly %0, i8* %1, i8* %2, i8* %3) {
%5 = icmp ne i8* %1, null
%6 = icmp ne i8* %3, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %3)
br label %13
10: ; preds = %4
%11 = tail call i32 (...) @getpid()
%12 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %11)
br label %13
13: ; preds = %10, %8
ret void
}