#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 *get_file_name(char *file_path) {
  int len = strlen(file_path);
  int i;
  for (i = len - 1; i >= 0; i--) {
    if (file_path[i] == '/' || file_path[i] == '\\')
      break;
  }
  return file_path + i + 1;
}


x86 assembly (clang, -O0):
<get_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     117d <get_file_name+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1165 <get_file_name+0x55>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    116a <get_file_name+0x5a>
jmp    117d <get_file_name+0x6d>
jmp    116f <get_file_name+0x5f>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1131 <get_file_name+0x21>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_name>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%edx
xor    %ecx,%ecx
test   %eax,%eax
cmovs  %eax,%ecx
add    $0xffffffff,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
test   %edx,%edx
jle    1148 <get_file_name+0x38>
add    $0xffffffffffffffff,%rdx
mov    %edx,%eax
movzbl (%rbx,%rax,1),%eax
cmp    $0x5c,%al
je     1146 <get_file_name+0x36>
cmp    $0x2f,%al
jne    1130 <get_file_name+0x20>
mov    %edx,%ecx
movslq %ecx,%rax
add    %rbx,%rax
add    $0x1,%rax
pop    %rbx
ret

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

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