#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__ strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void GetFileNameFromPath(char *Path, char *FileName) {
  int i;
  static char DirDelim[5] = {':', '/', '\\', ']', '\0'};
  for (i = (int)strlen(Path) - 1; i >= 0; i--)
    if (strchr(DirDelim, Path[i]))
      break;
  strcpy(FileName, Path + i + 1);
}


x86 assembly (clang, -O0):
<GetFileNameFromPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1193 <GetFileNameFromPath+0x63>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0x2ed0(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1180 <GetFileNameFromPath+0x50>
jmp    1193 <GetFileNameFromPath+0x63>
jmp    1185 <GetFileNameFromPath+0x55>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <GetFileNameFromPath+0x1f>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFileNameFromPath>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%ebx
add    $0xffffffff,%eax
cltq
lea    (%rax,%r12,1),%rcx
add    $0x1,%rcx
lea    0x2ede(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rcx,%r13
test   %ebx,%ebx
jle    1183 <GetFileNameFromPath+0x53>
add    $0xffffffffffffffff,%rbx
mov    %ebx,%eax
movsbl (%r12,%rax,1),%esi
mov    %r15,%rdi
call   1050 <strchr@plt>
lea    -0x1(%r13),%rcx
test   %rax,%rax
je     1160 <GetFileNameFromPath+0x30>
mov    %r14,%rdi
mov    %r13,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@GetFileNameFromPath.DirDelim = internal global [5 x i8] c":/\\]\00"
define void @GetFileNameFromPath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = trunc i64 %7 to i32
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %5
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call i64 @strchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @GetFileNameFromPath.DirDelim, i64 0, i64 0), i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %13
br label %26
22: ; preds = %13
br label %23
23: ; preds = %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, -1
store i32 %25, i32* %5
br label %10
26: ; preds = %21, %10
%27 = load i8*, i8** %4
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i32 @strcpy(i8* %27, i8* %32)
ret void
}

LLVM IR (-O2):
@GetFileNameFromPath.DirDelim = internal global [5 x i8] c":/\\]\00"
define void @GetFileNameFromPath(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = and i64 %3, 4294967295
br label %5
5: ; preds = %10, %2
%6 = phi i64 [ %7, %10 ], [ %4, %2 ]
%7 = add nsw i64 %6, -1
%8 = trunc i64 %6 to i32
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %5
%11 = and i64 %7, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i64 @strchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @GetFileNameFromPath.DirDelim, i64 0, i64 0), i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %5, label %16
16: ; preds = %10, %5
%17 = shl i64 %7, 32
%18 = ashr exact i64 %17, 32
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = tail call i32 @strcpy(i8* %1, i8* %20)
ret void
}