#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 *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
char *timlib_generate_password();
char *get_sys_string(char **generated_password, char *application_name,
                     char *login_host_name, char really_yn) {
  static char sys_string[2048];
  char execution_process[512];
  char sed_string[512];
  char testing_processes[1024];
  char grant_update_process[512];
  char flush_privileges_process[512];
  if (really_yn == 'y') {
    sprintf(grant_update_process,
            "echo \"grant update (execution_count ) on %s.process to %s;\" |"
            "sql.e '^'",
            application_name, login_host_name);
  } else {
    sprintf(grant_update_process,
            "echo \"grant update (execution_count) on %s.process to %s;\" |"
            "html_paragraph_wrapper.e | html_table.e 'Grant Update' '' '|'",
            application_name, login_host_name);
  }
  if (really_yn == 'y') {
    sprintf(flush_privileges_process, "echo \"flush privileges;\" |"
                                      "sql.e '^'");
  } else {
    sprintf(
        flush_privileges_process,
        "echo \"flush privileges;\" |"
        "html_paragraph_wrapper.e | html_table.e 'Flush Privileges' '' '|'");
  }
  if (really_yn == 'y') {
    strcpy(testing_processes, "cat");
    strcpy(execution_process, "sql.e");
    *generated_password = timlib_generate_password();
  } else {
    sprintf(testing_processes,
            "queue_top_bottom_lines.e 50			|"
            "html_table.e 'Grant Statements' '' '|'	 ");
    *generated_password = "**************************";
    strcpy(execution_process, "cat");
  }
  sprintf(sed_string, "sed \"s/.*/grant select on %s.& to %s;/\"",
          application_name, login_host_name);
  sprintf(
      sys_string,
      "(echo \"%s if exists %s;\"					;"
      "echo \"%s %s identified by '%s';\"				;"
      "application_folder_list.sh %s n				|"
      "grep -v '^null$'						|"
      "sed 's/^application$/%s_application/'				|"
      "%s								|"
      "sort -u)							|"
      "%s								|"
      "%s								|"
      "cat								;"
      "%s								;"
      "%s								 ",
      "drop user", login_host_name, "create user", login_host_name,
      *generated_password, application_name, application_name, sed_string,
      testing_processes, execution_process, grant_update_process,
      flush_privileges_process);
  return sys_string;
}


x86 assembly (clang, -O0):
<get_sys_string>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc68,%rsp
mov    %cl,%al
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %al,-0x41(%rbp)
movsbl -0x41(%rbp),%eax
cmp    $0x79,%eax
jne    1184 <get_sys_string+0x54>
lea    -0xa50(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11a1 <get_sys_string+0x71>
lea    -0xa50(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movsbl -0x41(%rbp),%eax
cmp    $0x79,%eax
jne    11c8 <get_sys_string+0x98>
lea    -0xc50(%rbp),%rdi
lea    0xf05(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11dd <get_sys_string+0xad>
lea    -0xc50(%rbp),%rdi
lea    0xf0f(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movsbl -0x41(%rbp),%eax
cmp    $0x79,%eax
jne    1226 <get_sys_string+0xf6>
lea    -0x850(%rbp),%rdi
lea    0xf49(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x250(%rbp),%rdi
lea    0xf3a(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x0,%al
call   1040 <timlib_generate_password@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
jmp    125c <get_sys_string+0x12c>
lea    -0x850(%rbp),%rdi
lea    0xf17(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x30(%rbp),%rax
lea    0xf4d(%rip),%rcx
mov    %rcx,(%rax)
lea    -0x250(%rbp),%rdi
lea    0xeea(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x450(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xf3c(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x40(%rbp),%rcx
mov    -0x40(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    (%rax),%r13
mov    -0x38(%rbp),%r12
mov    -0x38(%rbp),%r15
lea    -0x450(%rbp),%r14
lea    -0x850(%rbp),%rbx
lea    -0x250(%rbp),%r11
lea    -0xa50(%rbp),%r10
lea    -0xc50(%rbp),%rax
lea    0x2d96(%rip),%rdi
lea    0xf15(%rip),%rsi
lea    0x100a(%rip),%rdx
lea    0x100d(%rip),%r8
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    0x2d4c(%rip),%rax
add    $0xc68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sys_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc08,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
cmp    $0x79,%cl
jne    11c5 <get_sys_string+0x95>
lea    0xeaa(%rip),%rsi
lea    0x600(%rsp),%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
movups 0xf4f(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xf54(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x275e27,0x20(%rsp)
lea    0xfb0(%rip),%rsi
lea    0x200(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xfa0(%rip),%rsi
lea    0x800(%rsp),%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1040 <timlib_generate_password@plt>
mov    %rbp,%r14
mov    %rax,0x0(%rbp)
jmp    1298 <get_sys_string+0x168>
lea    0xe7b(%rip),%rsi
lea    0x600(%rsp),%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
movups 0xefd(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xf02(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xf06(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xf0a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movups 0xf0e(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0xf0e(%rip),%xmm0
movups %xmm0,0x4c(%rsp)
movabs $0x2009277c272027,%rax
mov    %rax,0x240(%rsp)
movups 0xf0a(%rip),%xmm0
movaps %xmm0,0x200(%rsp)
movups 0xf0b(%rip),%xmm0
movaps %xmm0,0x210(%rsp)
movups 0xf0c(%rip),%xmm0
movaps %xmm0,0x220(%rsp)
movups 0xf0d(%rip),%xmm0
movaps %xmm0,0x230(%rsp)
lea    0xf16(%rip),%rax
mov    %rbp,%r14
mov    %rax,0x0(%rbp)
lea    0xeb6(%rip),%rsi
lea    0x800(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xf0f(%rip),%rsi
lea    0xa00(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rsp,%r10
lea    0x600(%rsp),%r11
lea    0x800(%rsp),%rbp
lea    0x2d7f(%rip),%r13
lea    0xefe(%rip),%rsi
lea    0xff3(%rip),%rdx
lea    0xff6(%rip),%r8
mov    %r13,%rdi
mov    %rbx,%rcx
mov    %rbx,%r9
mov    $0x0,%eax
push   %r10
push   %r11
push   %rbp
lea    0x218(%rsp),%rbp
push   %rbp
push   %r12
push   %r15
push   %r15
push   (%r14)
call   1050 <sprintf@plt>
add    $0x40,%rsp
mov    %r13,%rax
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_sys_string.sys_string = internal global [2048 x i8] zeroinitializer
@.str = [71 x i8] c"echo \22grant update (execution_count ) on %s.process to %s;\22 |sql.e '^'\00"
@.str.1 = [122 x i8] c"echo \22grant update (execution_count) on %s.process to %s;\22 |html_paragraph_wrapper.e | html_table.e 'Grant Update' '' '|'\00"
@.str.2 = [36 x i8] c"echo \22flush privileges;\22 |sql.e '^'\00"
@.str.3 = [92 x i8] c"echo \22flush privileges;\22 |html_paragraph_wrapper.e | html_table.e 'Flush Privileges' '' '|'\00"
@.str.4 = [4 x i8] c"cat\00"
@.str.5 = [6 x i8] c"sql.e\00"
@.str.6 = [72 x i8] c"queue_top_bottom_lines.e 50\09\09\09|html_table.e 'Grant Statements' '' '|'\09 \00"
@.str.7 = [27 x i8] c"**************************\00"
@.str.8 = [40 x i8] c"sed \22s/.*/grant select on %s.& to %s;/\22\00"
@.str.9 = [252 x i8] c"(echo \22%s if exists %s;\22\09\09\09\09\09;echo \22%s %s identified by '%s';\22\09\09\09\09;application_folder_list.sh %s n\09\09\09\09|grep -v '^null$'\09\09\09\09\09\09|sed 's/^application$/%s_application/'\09\09\09\09|%s\09\09\09\09\09\09\09\09|sort -u)\09\09\09\09\09\09\09|%s\09\09\09\09\09\09\09\09|%s\09\09\09\09\09\09\09\09|cat\09\09\09\09\09\09\09\09;%s\09\09\09\09\09\09\09\09;%s\09\09\09\09\09\09\09\09 \00"
@.str.10 = [10 x i8] c"drop user\00"
@.str.11 = [12 x i8] c"create user\00"
define i8* @get_sys_string(i8** %0, i8* %1, i8* %2, i8 signext %3) {
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca [1024 x i8]
%12 = alloca [512 x i8]
%13 = alloca [512 x i8]
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8 %3, i8* %8
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 121
br i1 %16, label %17, label %22
17: ; preds = %4
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %27
22: ; preds = %4
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str.1, i64 0, i64 0), i8* %24, i8* %25)
br label %27
27: ; preds = %22, %17
%28 = load i8, i8* %8
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 121
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %37
34: ; preds = %27
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %34, %31
%38 = load i8, i8* %8
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 121
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%43 = call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%45 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%46 = call i8* (...) @timlib_generate_password()
%47 = load i8**, i8*** %5
store i8* %46, i8** %47
br label %54
48: ; preds = %37
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %49, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.6, i64 0, i64 0))
%51 = load i8**, i8*** %5
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8** %51
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%53 = call i32 @strcpy(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %48, %41
%55 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%56 = load i8*, i8** %6
%57 = load i8*, i8** %7
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %55, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %56, i8* %57)
%59 = load i8*, i8** %7
%60 = load i8*, i8** %7
%61 = load i8**, i8*** %5
%62 = load i8*, i8** %61
%63 = load i8*, i8** %6
%64 = load i8*, i8** %6
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%69 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_sys_string.sys_string, i64 0, i64 0), i8* getelementptr inbounds ([252 x i8], [252 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %59, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* %60, i8* %62, i8* %63, i8* %64, i8* %65, i8* %66, i8* %67, i8* %68, i8* %69)
ret i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_sys_string.sys_string, i64 0, i64 0)
}

LLVM IR (-O2):
@get_sys_string.sys_string = internal global [2048 x i8] zeroinitializer
@.str = [71 x i8] c"echo \22grant update (execution_count ) on %s.process to %s;\22 |sql.e '^'\00"
@.str.1 = [122 x i8] c"echo \22grant update (execution_count) on %s.process to %s;\22 |html_paragraph_wrapper.e | html_table.e 'Grant Update' '' '|'\00"
@.str.2 = [36 x i8] c"echo \22flush privileges;\22 |sql.e '^'\00"
@.str.3 = [92 x i8] c"echo \22flush privileges;\22 |html_paragraph_wrapper.e | html_table.e 'Flush Privileges' '' '|'\00"
@.str.4 = [4 x i8] c"cat\00"
@.str.5 = [6 x i8] c"sql.e\00"
@.str.6 = [72 x i8] c"queue_top_bottom_lines.e 50\09\09\09|html_table.e 'Grant Statements' '' '|'\09 \00"
@.str.7 = [27 x i8] c"**************************\00"
@.str.8 = [40 x i8] c"sed \22s/.*/grant select on %s.& to %s;/\22\00"
@.str.9 = [252 x i8] c"(echo \22%s if exists %s;\22\09\09\09\09\09;echo \22%s %s identified by '%s';\22\09\09\09\09;application_folder_list.sh %s n\09\09\09\09|grep -v '^null$'\09\09\09\09\09\09|sed 's/^application$/%s_application/'\09\09\09\09|%s\09\09\09\09\09\09\09\09|sort -u)\09\09\09\09\09\09\09|%s\09\09\09\09\09\09\09\09|%s\09\09\09\09\09\09\09\09|cat\09\09\09\09\09\09\09\09;%s\09\09\09\09\09\09\09\09;%s\09\09\09\09\09\09\09\09 \00"
@.str.10 = [10 x i8] c"drop user\00"
@.str.11 = [12 x i8] c"create user\00"
define i8* @get_sys_string(i8** nocapture %0, i8* %1, i8* %2, i8 signext %3) {
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%15 = icmp eq i8 %3, 121
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%18 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%20 = call i8* (...) @timlib_generate_password()
store i8* %20, i8** %0
br label %24
21: ; preds = %4
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([122 x i8], [122 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8** %0
%23 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %21, %16
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %1, i8* %2)
%26 = load i8*, i8** %0
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_sys_string.sys_string, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([252 x i8], [252 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* %2, i8* %26, i8* %1, i8* %1, i8* %11, i8* %12, i8* %10, i8* %13, i8* %14)
ret i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_sys_string.sys_string, i64 0, i64 0)
}