#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ strstrip(char *, char *);
char *fix_name(const char *filename) {
  char *stripped = ((char *)(calloc(strlen(filename), sizeof(char))));
  char new_filename[strlen(filename)];
  strcpy(new_filename, filename);
  int i = 0;
  for (i = 0; i < strlen(filename); i++) {
    if (((filename[i] > 0x60) && (filename[i] < 0x7b)) ||
        (filename[i] == 0x2e) || ((filename[i] > 47) && filename[i] < 58)) {
      continue;
    } else {
      if ((filename[i] > 0x40) && (filename[i] < 0x5a)) {
        new_filename[i] = filename[i] + 32;
        continue;
      } else {
        new_filename[i] = 0x5f;
      }
    }
  }
  strstrip(stripped, new_filename);
  return stripped;
}


x86 assembly (clang, -O0):
<fix_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    12a3 <fix_name+0x163>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x60,%eax
jle    11f0 <fix_name+0xb0>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7b,%eax
jl     122f <fix_name+0xef>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     122f <fix_name+0xef>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jle    1234 <fix_name+0xf4>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jge    1234 <fix_name+0xf4>
jmp    1295 <fix_name+0x155>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x40,%eax
jle    127f <fix_name+0x13f>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5a,%eax
jge    127f <fix_name+0x13f>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
add    $0x20,%ecx
mov    %cl,%dl
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1295 <fix_name+0x155>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    1290 <fix_name+0x150>
jmp    1295 <fix_name+0x155>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11aa <fix_name+0x6a>
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1060 <strstrip@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_name>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11f1 <fix_name+0xb1>
xor    %ebx,%ebx
mov    $0x5f,%r13d
jmp    11c3 <fix_name+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11f1 <fix_name+0xb1>
movzbl (%r12,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     11b0 <fix_name+0x70>
cmp    $0x2e,%al
je     11b0 <fix_name+0x70>
lea    -0x61(%rax),%ecx
cmp    $0x1a,%cl
jb     11b0 <fix_name+0x70>
lea    -0x41(%rax),%ecx
add    $0x20,%al
cmp    $0x19,%cl
movzbl %al,%eax
cmovae %r13d,%eax
mov    %al,(%r15,%rbx,1)
jmp    11b0 <fix_name+0x70>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strstrip@plt>
mov    %r14,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @fix_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = call i64 @calloc(i32 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %3
%11 = load i8*, i8** %2
%12 = call i32 @strlen(i8* %11)
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %4
%15 = alloca i8, i64 %13
store i64 %13, i64* %5
%16 = load i8*, i8** %2
%17 = call i32 @strcpy(i8* %15, i8* %16)
store i32 0, i32* %6
store i32 0, i32* %6
br label %18
18: ; preds = %98, %1
%19 = load i32, i32* %6
%20 = load i8*, i8** %2
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %101
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sgt i32 %29, 96
br i1 %30, label %31, label %39
31: ; preds = %23
%32 = load i8*, i8** %2
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp slt i32 %37, 123
br i1 %38, label %63, label %39
39: ; preds = %31, %23
%40 = load i8*, i8** %2
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 46
br i1 %46, label %63, label %47
47: ; preds = %39
%48 = load i8*, i8** %2
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp sgt i32 %53, 47
br i1 %54, label %55, label %64
55: ; preds = %47
%56 = load i8*, i8** %2
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp slt i32 %61, 58
br i1 %62, label %63, label %64
63: ; preds = %55, %39, %31
br label %98
64: ; preds = %55, %47
%65 = load i8*, i8** %2
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp sgt i32 %70, 64
br i1 %71, label %72, label %92
72: ; preds = %64
%73 = load i8*, i8** %2
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp slt i32 %78, 90
br i1 %79, label %80, label %92
80: ; preds = %72
%81 = load i8*, i8** %2
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = add nsw i32 %86, 32
%88 = trunc i32 %87 to i8
%89 = load i32, i32* %6
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %15, i64 %90
store i8 %88, i8* %91
br label %98
92: ; preds = %72, %64
%93 = load i32, i32* %6
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %15, i64 %94
store i8 95, i8* %95
br label %96
96: ; preds = %92
br label %97
97: ; preds = %96
br label %98
98: ; preds = %97, %80, %63
%99 = load i32, i32* %6
%100 = add nsw i32 %99, 1
store i32 %100, i32* %6
br label %18
101: ; preds = %18
%102 = load i8*, i8** %3
%103 = call i32 @strstrip(i8* %102, i8* %15)
%104 = load i8*, i8** %3
%105 = load i8*, i8** %4
ret i8* %104
}

LLVM IR (-O2):
define i8* @fix_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i64 @calloc(i32 %2, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @strlen(i8* %0)
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i32 @strcpy(i8* %7, i8* %0)
%9 = call i32 @strlen(i8* %0)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %1, %28
%12 = phi i64 [ %29, %28 ], [ 0, %1 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = add i8 %14, -97
%16 = icmp ult i8 %15, 26
%17 = icmp eq i8 %14, 46
%18 = or i1 %17, %16
%19 = add i8 %14, -48
%20 = icmp ult i8 %19, 10
%21 = or i1 %20, %18
br i1 %21, label %28, label %22
22: ; preds = %11
%23 = add i8 %14, -65
%24 = icmp ult i8 %23, 25
%25 = add nuw nsw i8 %14, 32
%26 = select i1 %24, i8 %25, i8 95
%27 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 %26, i8* %27
br label %28
28: ; preds = %22, %11
%29 = add nuw nsw i64 %12, 1
%30 = call i32 @strlen(i8* %0)
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %11, label %33
33: ; preds = %28, %1
%34 = call i32 @strstrip(i8* %4, i8* %7)
ret i8* %4
}