#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 */
char *get_error_filename(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ system(char *);
void make_appaserver_error_file(char *destination_application,
                                char *appaserver_error_directory,
                                char really_yn) {
  char sys_string[1024];
  char *error_filename;
  error_filename =
      get_error_filename(appaserver_error_directory, destination_application);
  if (really_yn == 'y') {
    sprintf(sys_string, "echo '' > %s", error_filename);
    if (system(sys_string)) {
    };
    sprintf(sys_string, "chmod g+rw %s", error_filename);
    if (system(sys_string)) {
    };
    sprintf(sys_string, "chmod o-r %s", error_filename);
    if (system(sys_string)) {
    };
  } else {
    printf("<p>Will create %s.\n", error_filename);
  }
}


x86 assembly (clang, -O0):
<make_appaserver_error_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <get_error_filename@plt>
mov    %rax,-0x428(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
jne    121d <make_appaserver_error_file+0xdd>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
lea    0xe72(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     11ae <make_appaserver_error_file+0x6e>
jmp    11ae <make_appaserver_error_file+0x6e>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
lea    0xe4a(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     11e3 <make_appaserver_error_file+0xa3>
jmp    11e3 <make_appaserver_error_file+0xa3>
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
lea    0xe23(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     1218 <make_appaserver_error_file+0xd8>
jmp    1218 <make_appaserver_error_file+0xd8>
jmp    1230 <make_appaserver_error_file+0xf0>
mov    -0x428(%rbp),%rsi
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_appaserver_error_file>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %edx,%ebp
mov    %rdi,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1050 <get_error_filename@plt>
mov    %rax,%rbx
cmp    $0x79,%bpl
jne    11bd <make_appaserver_error_file+0x7d>
lea    0xe97(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <system@plt>
lea    0xe87(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <system@plt>
lea    0xe7b(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <system@plt>
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe64(%rip),%rdi
mov    %rbx,%rsi
add    $0x408,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"echo '' > %s\00"
@.str.1 = [14 x i8] c"chmod g+rw %s\00"
@.str.2 = [13 x i8] c"chmod o-r %s\00"
@.str.3 = [20 x i8] c"<p>Will create %s.\0A\00"
define void @make_appaserver_error_file(i8* %0, i8* %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca [1024 x i8]
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = call i8* @get_error_filename(i8* %9, i8* %10)
store i8* %11, i8** %8
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 121
br i1 %14, label %15, label %40
15: ; preds = %3
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = load i8*, i8** %8
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%20 = call i64 @system(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
br label %23
23: ; preds = %22, %15
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%25 = load i8*, i8** %8
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%28 = call i64 @system(i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
br label %31
31: ; preds = %30, %23
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%33 = load i8*, i8** %8
%34 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%36 = call i64 @system(i8* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %31
br label %39
39: ; preds = %38, %31
br label %43
40: ; preds = %3
%41 = load i8*, i8** %8
%42 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %39
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"echo '' > %s\00"
@.str.1 = [14 x i8] c"chmod g+rw %s\00"
@.str.2 = [13 x i8] c"chmod o-r %s\00"
@.str.3 = [20 x i8] c"<p>Will create %s.\0A\00"
define void @make_appaserver_error_file(i8* %0, i8* %1, i8 signext %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @get_error_filename(i8* %1, i8* %0)
%7 = icmp eq i8 %2, 121
br i1 %7, label %8, label %15
8: ; preds = %3
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6)
%10 = call i64 @system(i8* %5)
%11 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%12 = call i64 @system(i8* %5)
%13 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%14 = call i64 @system(i8* %5)
br label %17
15: ; preds = %3
%16 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %17
17: ; preds = %15, %8
ret void
}