#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 const *);
const char *FindName(const char *Path) {
  int Len = strlen(Path);
  while (Len > 0 && Path[Len - 1] != '\\' && Path[Len - 1] != '/') {
    --Len;
  }
  return Path + Len;
}


x86 assembly (clang, -O0):
<FindName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jle    1170 <FindName+0x60>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0xd(%rbp)
je     1170 <FindName+0x60>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1180 <FindName+0x70>
jmp    118e <FindName+0x7e>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <FindName+0x18>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindName>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %edx,%edx
test   %eax,%eax
cmovs  %eax,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ecx,%ecx
jle    114a <FindName+0x3a>
movzbl -0x1(%rbx,%rcx,1),%eax
add    $0xffffffffffffffff,%rcx
cmp    $0x5c,%al
je     1145 <FindName+0x35>
cmp    $0x2f,%al
jne    1130 <FindName+0x20>
add    $0x1,%ecx
mov    %ecx,%edx
movslq %edx,%rax
add    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @FindName(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)
br label %5
5: ; preds = %9, %1
%6 = phi i64 [ %10, %9 ], [ %3, %1 ]
%7 = trunc i64 %6 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = add nsw i64 %6, -1
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %5 [
i8 92, label %13
i8 47, label %13
]
13: ; preds = %9, %9
%14 = trunc i64 %6 to i32
br label %15
15: ; preds = %5, %13
%16 = phi i32 [ %14, %13 ], [ %4, %5 ]
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
ret i8* %18
}