#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 *application_first_relative_source_directory(char *);
char *basename_get_filename(char *);
char *right_trim_session(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ system(char *);
void upload_source_file(char *application_name,
                        char *source_filename_directory_session,
                        char *appaserver_mount_point) {
  char *full_filename_directory;
  char *filename;
  char tmp_buffer[256];
  char destination_directory[256];
  char sys_string[1024];
  strcpy(tmp_buffer, source_filename_directory_session);
  full_filename_directory = right_trim_session(tmp_buffer);
  filename = basename_get_filename(full_filename_directory);
  sprintf(destination_directory, "%s/%s", appaserver_mount_point,
          application_first_relative_source_directory(application_name));
  sprintf(sys_string, "cp %s %s/%s", source_filename_directory_session,
          destination_directory, filename);
  if (system(sys_string)) {
  };
  sprintf(sys_string, "chmod g+w %s/%s", destination_directory, filename);
  sprintf(sys_string, "chmod -x %s/%s", destination_directory, filename);
  if (system(sys_string)) {
  };
}


x86 assembly (clang, -O0):
<upload_source_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x640,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x130(%rbp),%rdi
call   1060 <right_trim_session@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <basename_get_filename@plt>
mov    %rax,-0x28(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x640(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x638(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <application_first_relative_source_directory@plt>
mov    -0x640(%rbp),%rdi
mov    -0x638(%rbp),%rdx
mov    %rax,%rcx
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x630(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x230(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x630(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%rax
je     1224 <upload_source_file+0xc4>
jmp    1224 <upload_source_file+0xc4>
lea    -0x630(%rbp),%rdi
lea    -0x230(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x630(%rbp),%rdi
lea    -0x230(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x630(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%rax
je     127f <upload_source_file+0x11f>
jmp    127f <upload_source_file+0x11f>
add    $0x640,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upload_source_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x608,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <right_trim_session@plt>
mov    %rax,%rdi
call   1080 <basename_get_filename@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <application_first_relative_source_directory@plt>
lea    0xe5d(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe3d(%rip),%rsi
lea    0x200(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %r12,%rdi
call   1050 <system@plt>
lea    0xe1f(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe18(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %r12,%rdi
call   1050 <system@plt>
add    $0x608,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [12 x i8] c"cp %s %s/%s\00"
@.str.2 = [16 x i8] c"chmod g+w %s/%s\00"
@.str.3 = [15 x i8] c"chmod -x %s/%s\00"
define void @upload_source_file(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca [1024 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%16 = call i8* @right_trim_session(i8* %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i8* @basename_get_filename(i8* %17)
store i8* %18, i8** %8
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = load i8*, i8** %4
%22 = call i8* @application_first_relative_source_directory(i8* %21)
%23 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%25 = load i8*, i8** %5
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%27 = load i8*, i8** %8
%28 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26, i8* %27)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%30 = call i64 @system(i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %3
br label %33
33: ; preds = %32, %3
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%36 = load i8*, i8** %8
%37 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %36)
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%40 = load i8*, i8** %8
%41 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %39, i8* %40)
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%43 = call i64 @system(i8* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %33
br label %46
46: ; preds = %45, %33
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [12 x i8] c"cp %s %s/%s\00"
@.str.2 = [16 x i8] c"chmod g+w %s/%s\00"
@.str.3 = [15 x i8] c"chmod -x %s/%s\00"
define void @upload_source_file(i8* %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = call i32 @strcpy(i8* %7, i8* %1)
%11 = call i8* @right_trim_session(i8* %7)
%12 = call i8* @basename_get_filename(i8* %11)
%13 = call i8* @application_first_relative_source_directory(i8* %0)
%14 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %13)
%15 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %8, i8* %12)
%16 = call i64 @system(i8* %9)
%17 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %12)
%18 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %8, i8* %12)
%19 = call i64 @system(i8* %9)
ret void
}