#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 *, ...);
scalar_t__ system(char *);
char *spool_from_table(char *application_name, char *select_statement_title,
                       char *select_statement_login_name, char *session,
                       char *appaserver_data_directory) {
  static char input_filename[128];
  char sys_string[1024];
  char where[256];
  sprintf(input_filename, "%s/%s_execute_select_statement_%s.sql",
          appaserver_data_directory, application_name, session);
  sprintf(where, "select_statement_title = '%s' and login_name = '%s'",
          select_statement_title, select_statement_login_name);
  sprintf(sys_string,
          "get_folder_data	application=%s		  "
          "			select=select_statement	  "
          "			folder=select_statement	  "
          "			where=\"%s\"		| "
          "cat > %s					  ",
          application_name, where, input_filename);
  if (system(sys_string)) {
  };
  return input_filename;
}


x86 assembly (clang, -O0):
<spool_from_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0x2eee(%rip),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x530(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x430(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    -0x530(%rbp),%rcx
lea    0xec4(%rip),%rsi
lea    0x2ea3(%rip),%r8
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x430(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     11bf <spool_from_table+0x9f>
jmp    11bf <spool_from_table+0x9f>
lea    0x2e7a(%rip),%rax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spool_from_table>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x500,%rsp
mov    %rcx,%rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0x2efd(%rip),%r14
lea    0xeb6(%rip),%rsi
mov    %r14,%rdi
mov    %r8,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xec2(%rip),%rsi
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xedc(%rip),%rsi
lea    0x100(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %r15,%rdi
call   1030 <system@plt>
mov    %r14,%rax
add    $0x500,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@spool_from_table.input_filename = internal global [128 x i8] zeroinitializer
@.str = [38 x i8] c"%s/%s_execute_select_statement_%s.sql\00"
@.str.1 = [52 x i8] c"select_statement_title = '%s' and login_name = '%s'\00"
@.str.2 = [125 x i8] c"get_folder_data\09application=%s\09\09 \09\09\09select=select_statement\09 \09\09\09folder=select_statement\09 \09\09\09where=\22%s\22\09\09| cat > %s\09\09\09\09\09 \00"
define i8* @spool_from_table(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [1024 x i8]
%12 = alloca [256 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%13 = load i8*, i8** %10
%14 = load i8*, i8** %6
%15 = load i8*, i8** %9
%16 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @spool_from_table.input_filename, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14, i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%18 = load i8*, i8** %7
%19 = load i8*, i8** %8
%20 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %17, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%24 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @spool_from_table.input_filename, i64 0, i64 0))
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%26 = call i64 @system(i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %5
br label %29
29: ; preds = %28, %5
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @spool_from_table.input_filename, i64 0, i64 0)
}

LLVM IR (-O2):
@spool_from_table.input_filename = internal global [128 x i8] zeroinitializer
@.str = [38 x i8] c"%s/%s_execute_select_statement_%s.sql\00"
@.str.1 = [52 x i8] c"select_statement_title = '%s' and login_name = '%s'\00"
@.str.2 = [125 x i8] c"get_folder_data\09application=%s\09\09 \09\09\09select=select_statement\09 \09\09\09folder=select_statement\09 \09\09\09where=\22%s\22\09\09| cat > %s\09\09\09\09\09 \00"
define i8* @spool_from_table(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [1024 x i8]
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%10 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @spool_from_table.input_filename, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %0, i8* %3)
%11 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
%12 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([125 x i8], [125 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %9, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @spool_from_table.input_filename, i64 0, i64 0))
%13 = call i64 @system(i8* %8)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @spool_from_table.input_filename, i64 0, i64 0)
}