#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ appaserver_library_is_system_folder(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ strcmp(char *, char *);
void go_output2shell_script_header(FILE *output_file, char *application_name,
                                   char *folder_name,
                                   char dont_output_if_statement_yn) {
  fprintf(output_file, "#!/bin/sh\n");
  if (dont_output_if_statement_yn != 'y' &&
      !appaserver_library_is_system_folder(folder_name)) {
    fprintf(output_file, "if [ \"$application\" != %s ]\n", application_name);
    fprintf(output_file, "then\n");
    fprintf(output_file, "\texit 0\n");
    fprintf(output_file, "fi\n\n");
  }
  if (strcmp(folder_name, "application") == 0) {
    fprintf(output_file, "table_name=%s_application\n", application_name);
  } else {
    fprintf(output_file, "table_name=%s\n", folder_name);
  }
  fprintf(output_file, "(\nsql.e << all_done\n");
}


x86 assembly (clang, -O0):
<go_output2shell_script_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x79,%eax
je     11c6 <go_output2shell_script_header+0x96>
mov    -0x18(%rbp),%rdi
call   1030 <appaserver_library_is_system_folder@plt>
cmp    $0x0,%eax
jne    11c6 <go_output2shell_script_header+0x96>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fb <go_output2shell_script_header+0xcb>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1211 <go_output2shell_script_header+0xe1>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<go_output2shell_script_header>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea7(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
cmp    $0x79,%bpl
je     11dc <go_output2shell_script_header+0x9c>
mov    %r14,%rdi
call   1030 <appaserver_library_is_system_folder@plt>
test   %eax,%eax
jne    11dc <go_output2shell_script_header+0x9c>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe90(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xe7d(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xe6d(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xe59(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ff <go_output2shell_script_header+0xbf>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
jmp    120c <go_output2shell_script_header+0xcc>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe58(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fwrite@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"#!/bin/sh\0A\00"
@.str.1 = [29 x i8] c"if [ \22$application\22 != %s ]\0A\00"
@.str.2 = [6 x i8] c"then\0A\00"
@.str.3 = [9 x i8] c"\09exit 0\0A\00"
@.str.4 = [5 x i8] c"fi\0A\0A\00"
@.str.5 = [12 x i8] c"application\00"
@.str.6 = [27 x i8] c"table_name=%s_application\0A\00"
@.str.7 = [15 x i8] c"table_name=%s\0A\00"
@.str.8 = [21 x i8] c"(\0Asql.e << all_done\0A\00"
define void @go_output2shell_script_header(i32* %0, i8* %1, i8* %2, i8 signext %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8 %3, i8* %8
%9 = load i32*, i32** %5
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = load i8, i8* %8
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 121
br i1 %13, label %14, label %28
14: ; preds = %4
%15 = load i8*, i8** %7
%16 = call i32 @appaserver_library_is_system_folder(i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %14
%19 = load i32*, i32** %5
%20 = load i8*, i8** %6
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32*, i32** %5
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32*, i32** %5
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32*, i32** %5
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %18, %14, %4
%29 = load i8*, i8** %7
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32*, i32** %5
%34 = load i8*, i8** %6
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %34)
br label %40
36: ; preds = %28
%37 = load i32*, i32** %5
%38 = load i8*, i8** %7
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %36, %32
%41 = load i32*, i32** %5
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"#!/bin/sh\0A\00"
@.str.1 = [29 x i8] c"if [ \22$application\22 != %s ]\0A\00"
@.str.2 = [6 x i8] c"then\0A\00"
@.str.3 = [9 x i8] c"\09exit 0\0A\00"
@.str.4 = [5 x i8] c"fi\0A\0A\00"
@.str.5 = [12 x i8] c"application\00"
@.str.6 = [27 x i8] c"table_name=%s_application\0A\00"
@.str.7 = [15 x i8] c"table_name=%s\0A\00"
@.str.8 = [21 x i8] c"(\0Asql.e << all_done\0A\00"
define void @go_output2shell_script_header(i32* nocapture %0, i8* %1, i8* %2, i8 signext %3) {
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 10, i64 1, i32* %0)
%6 = icmp eq i8 %3, 121
br i1 %6, label %15, label %7
7: ; preds = %4
%8 = tail call i32 @appaserver_library_is_system_folder(i8* %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5, i64 1, i32* %0)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 8, i64 1, i32* %0)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %0)
br label %15
15: ; preds = %10, %7, %4
%16 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %1)
br label %22
20: ; preds = %15
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %2)
br label %22
22: ; preds = %20, %18
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i64 20, i64 1, i32* %0)
ret void
}