#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 *FilePart(char *fnam) {
  char *p = fnam;
  char *q = fnam + strlen(fnam);
  for (; q != p; --q) {
    if (*q == ':' || *q == '/') {
      q++;
      break;
    }
  }
  return q;
}


x86 assembly (clang, -O0):
<FilePart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     119a <FilePart+0x8a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     1173 <FilePart+0x63>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1184 <FilePart+0x74>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119a <FilePart+0x8a>
jmp    1189 <FilePart+0x79>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1145 <FilePart+0x35>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FilePart>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
test   %eax,%eax
je     1136 <FilePart+0x26>
nop
movzbl (%rbx,%rax,1),%ecx
cmp    $0x3a,%cl
je     113b <FilePart+0x2b>
cmp    $0x2f,%cl
je     113b <FilePart+0x2b>
add    $0xffffffffffffffff,%rax
jne    1120 <FilePart+0x10>
jmp    1142 <FilePart+0x32>
add    %rax,%rbx
jmp    1142 <FilePart+0x32>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @FilePart(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = icmp eq i32 %2, 0
br i1 %5, label %14, label %6
6: ; preds = %1, %11
%7 = phi i8* [ %12, %11 ], [ %4, %1 ]
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 58, label %9
i8 47, label %9
]
9: ; preds = %6, %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %14
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %7, i64 -1
%13 = icmp eq i8* %12, %0
br i1 %13, label %14, label %6
14: ; preds = %11, %1, %9
%15 = phi i8* [ %10, %9 ], [ %4, %1 ], [ %0, %11 ]
ret i8* %15
}