#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 *strdup(char *);
scalar_t__ timlib_file_exists(char *);
char *get_existing_tar_file(char *appaserver_home_directory) {
  char existing_tar_file[256];
  sprintf(existing_tar_file, "%s/template/mysqldump_template.sql.gz",
          appaserver_home_directory);
  if (timlib_file_exists(existing_tar_file))
    return strdup(existing_tar_file);
  else
    return (char *)0;
}


x86 assembly (clang, -O0):
<get_existing_tar_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeaf(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <timlib_file_exists@plt>
cmp    $0x0,%rax
je     1181 <get_existing_tar_file+0x51>
lea    -0x110(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1189 <get_existing_tar_file+0x59>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_existing_tar_file>:
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rdx
lea    0xebe(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <timlib_file_exists@plt>
test   %rax,%rax
je     1164 <get_existing_tar_file+0x34>
mov    %rsp,%rdi
call   1050 <strdup@plt>
jmp    1166 <get_existing_tar_file+0x36>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"%s/template/mysqldump_template.sql.gz\00"
define i8* @get_existing_tar_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [256 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %3
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = call i64 @timlib_file_exists(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %2
br label %15
14: ; preds = %1
store i8* null, i8** %2
br label %15
15: ; preds = %14, %11
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@.str = [38 x i8] c"%s/template/mysqldump_template.sql.gz\00"
define noalias i8* @get_existing_tar_file(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i64 @timlib_file_exists(i8* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i8* @strdup(i8* %3)
br label %9
9: ; preds = %1, %7
%10 = phi i8* [ %8, %7 ], [ null, %1 ]
ret i8* %10
}