#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*/ strcpy(char *, char *);
int strlen(char *);
char *CleanFileName(char *OriginalFileName, char *CleanFileName) {
  strcpy(CleanFileName, OriginalFileName);
  if ((CleanFileName[0] == '\'' || CleanFileName[0] == '\"') &&
      CleanFileName[0] == CleanFileName[strlen(CleanFileName) - 1]) {
    strcpy(CleanFileName, &CleanFileName[1]);
    CleanFileName[strlen(CleanFileName) - 1] = '\0';
  }
  return (CleanFileName);
}


x86 assembly (clang, -O0):
<CleanFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     115d <CleanFileName+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11c5 <CleanFileName+0xa5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,%edx
mov    -0x14(%rbp),%eax
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11c5 <CleanFileName+0xa5>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CleanFileName>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    (%rbx),%bpl
cmp    $0x27,%bpl
je     1140 <CleanFileName+0x20>
cmp    $0x22,%bpl
jne    116c <CleanFileName+0x4c>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    -0x1(%rax,%rbx,1),%bpl
jne    116c <CleanFileName+0x4c>
lea    0x1(%rbx),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @CleanFileName(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @strcpy(i8* %5, i8* %6)
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 39
br i1 %12, label %19, label %13
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 34
br i1 %18, label %19, label %44
19: ; preds = %13, %2
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i8*, i8** %4
%25 = load i8*, i8** %4
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %24, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %23, %31
br i1 %32, label %33, label %44
33: ; preds = %19
%34 = load i8*, i8** %4
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = call i32 @strcpy(i8* %34, i8* %36)
%38 = load i8*, i8** %4
%39 = load i8*, i8** %4
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
store i8 0, i8* %43
br label %44
44: ; preds = %33, %19, %13
%45 = load i8*, i8** %4
ret i8* %45
}

LLVM IR (-O2):
define i8* @CleanFileName(i8* %0, i8* returned %1) {
%3 = tail call i32 @strcpy(i8* %1, i8* %0)
%4 = load i8, i8* %1
switch i8 %4, label %19 [
i8 39, label %5
i8 34, label %5
]
5: ; preds = %2, %2
%6 = tail call i32 @strlen(i8* %1)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %4, %10
br i1 %11, label %12, label %19
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %1, i64 1
%14 = tail call i32 @strcpy(i8* %1, i8* %13)
%15 = tail call i32 @strlen(i8* %1)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 0, i8* %18
br label %19
19: ; preds = %2, %12, %5
ret i8* %1
}