#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*/ free(char *);
char *os_shell_escape(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int i = 0;
  char *tmp;
  char buf[] = "/var/www/html/Testing This Interface$%^&*().txt";
  tmp = os_shell_escape(buf);
  char clean[] = "/var/www/html/index.html";
  printf("Sent: '%s'\n", buf);
  printf("Fixed: '%s'\n", tmp);
  free(tmp);
  tmp = os_shell_escape(clean);
  printf("Sent: '%s'\n", clean);
  printf("Fixed: '%s'\n", tmp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe98(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
lea    -0x50(%rbp),%rdi
call   1040 <os_shell_escape@plt>
mov    %rax,-0x20(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea2(%rip),%al
mov    %al,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    -0x70(%rbp),%rdi
call   1040 <os_shell_escape@plt>
mov    %rax,-0x20(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
movaps 0xede(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1040 <os_shell_escape@plt>
mov    %rax,%rbx
movups 0xec3(%rip),%xmm0
movups %xmm0,0x9(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xebc(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
lea    0xeb6(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rsp,%r12
mov    %r12,%rdi
call   1040 <os_shell_escape@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.buf = [48 x i8] c"/var/www/html/Testing This Interface$%^&*().txt\00"
@__const.main.clean = [25 x i8] c"/var/www/html/index.html\00"
@.str = [12 x i8] c"Sent: '%s'\0A\00"
@.str.1 = [13 x i8] c"Fixed: '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [48 x i8]
%9 = alloca [25 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = bitcast [48 x i8]* %8 to i8*
%11 = getelementptr inbounds [48 x i8], [48 x i8]* %8, i64 0, i64 0
%12 = call i8* @os_shell_escape(i8* %11)
store i8* %12, i8** %7
%13 = bitcast [25 x i8]* %9 to i8*
%14 = getelementptr inbounds [48 x i8], [48 x i8]* %8, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %7
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %7
%19 = call i32 @free(i8* %18)
%20 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%21 = call i8* @os_shell_escape(i8* %20)
store i8* %21, i8** %7
%22 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %7
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [48 x i8] c"/var/www/html/Testing This Interface$%^&*().txt\00"
@__const.main.clean = [25 x i8] c"/var/www/html/index.html\00"
@.str = [12 x i8] c"Sent: '%s'\0A\00"
@.str.1 = [13 x i8] c"Fixed: '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [48 x i8]
%4 = alloca [25 x i8]
%5 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%6 = call i8* @os_shell_escape(i8* %5)
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%10 = call i32 @free(i8* %6)
%11 = call i8* @os_shell_escape(i8* %7)
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11)
ret i32 0
}