#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*/ sprintf(char *, char *, char *, char *, char *, char *);
char *strdup(char *);
char *folder_menu_get_filename(char *application_name, char *session,
                               char *appaserver_data_directory,
                               char *role_name) {
  char filename[1024];
  if (!appaserver_data_directory || !application_name || !role_name ||
      !session) {
    return (char *)0;
  }
  sprintf(filename, "%s/%s_%s_%s.txt", appaserver_data_directory,
          application_name, role_name, session);
  return strdup(filename);
}


x86 assembly (clang, -O0):
<folder_menu_get_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1167 <folder_menu_get_filename+0x47>
cmpq   $0x0,-0x10(%rbp)
je     1167 <folder_menu_get_filename+0x47>
cmpq   $0x0,-0x28(%rbp)
je     1167 <folder_menu_get_filename+0x47>
cmpq   $0x0,-0x18(%rbp)
jne    1174 <folder_menu_get_filename+0x54>
movq   $0x0,-0x8(%rbp)
jmp    11a7 <folder_menu_get_filename+0x87>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe6e(%rip),%rsi
call   1030 <sprintf@plt>
lea    -0x430(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<folder_menu_get_filename>:
xor    %eax,%eax
test   %rsi,%rsi
je     1169 <folder_menu_get_filename+0x49>
mov    %rcx,%r8
mov    %rdi,%rcx
test   %rdi,%rdi
je     1169 <folder_menu_get_filename+0x49>
test   %rdx,%rdx
je     1169 <folder_menu_get_filename+0x49>
test   %r8,%r8
je     1169 <folder_menu_get_filename+0x49>
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r9
lea    0xeb2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strdup@plt>
add    $0x400,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"%s/%s_%s_%s.txt\00"
define noalias i8* @folder_menu_get_filename(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = icmp ne i8* %2, null
%8 = icmp ne i8* %0, null
%9 = and i1 %8, %7
%10 = icmp ne i8* %3, null
%11 = and i1 %9, %10
%12 = icmp ne i8* %1, null
%13 = and i1 %12, %11
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %0, i8* %3, i8* %1)
%16 = call i8* @strdup(i8* %6)
br label %17
17: ; preds = %4, %14
%18 = phi i8* [ %16, %14 ], [ null, %4 ]
ret i8* %18
}