#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 strlen(char *);
char *fix_file_name(char *name) {
  int len;
  for (len = strlen(name); len > 0; len--) {
    switch (name[len]) {
    case '/':
    case '\\':
    case ':':
      return &name[len + 1];
    }
  }
  return name;
}


x86 assembly (clang, -O0):
<fix_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    119d <fix_file_name+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2f,%eax
je     1171 <fix_file_name+0x61>
jmp    114f <fix_file_name+0x3f>
mov    -0x18(%rbp),%eax
sub    $0x3a,%eax
je     1171 <fix_file_name+0x61>
jmp    1160 <fix_file_name+0x50>
mov    -0x18(%rbp),%eax
sub    $0x5c,%eax
jne    118a <fix_file_name+0x7a>
jmp    1171 <fix_file_name+0x61>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <fix_file_name+0x95>
jmp    118f <fix_file_name+0x7f>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1128 <fix_file_name+0x18>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_file_name>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1152 <fix_file_name+0x42>
mov    %eax,%eax
add    $0x1,%rax
movabs $0x200000000801,%rcx
jmp    113a <fix_file_name+0x2a>
nop
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
jle    1152 <fix_file_name+0x42>
movsbl -0x1(%rbx,%rax,1),%edx
add    $0xffffffd1,%edx
cmp    $0x2d,%edx
ja     1130 <fix_file_name+0x20>
bt     %rdx,%rcx
jae    1130 <fix_file_name+0x20>
mov    %eax,%eax
add    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @fix_file_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
br label %7
7: ; preds = %24, %1
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %23 [
i32 47, label %17
i32 92, label %17
i32 58, label %17
]
17: ; preds = %10, %10, %10
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
store i8* %22, i8** %2
br label %29
23: ; preds = %10
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, -1
store i32 %26, i32* %4
br label %7
27: ; preds = %7
%28 = load i8*, i8** %3
store i8* %28, i8** %2
br label %29
29: ; preds = %27, %17
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
define i8* @fix_file_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ %5, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %15 [
i32 47, label %11
i32 92, label %11
i32 58, label %11
]
11: ; preds = %6, %6, %6
%12 = add nuw nsw i64 %7, 1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds i8, i8* %0, i64 %13
br label %18
15: ; preds = %6
%16 = add nsw i64 %7, -1
%17 = icmp sgt i64 %7, 1
br i1 %17, label %6, label %18
18: ; preds = %15, %1, %11
%19 = phi i8* [ %14, %11 ], [ %0, %1 ], [ %0, %15 ]
ret i8* %19
}