#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 */
char *strchr(char *, char);
char *strrchr(char *, char);
char *dirfname(char *pszFileName) {
  char *pch1, *pch2;
  if ((pch2 = strrchr(pszFileName, '\\')) == NULL)
    if ((pch2 = strchr(pszFileName, ':')) == NULL)
      return (pszFileName);
  pch2++;
  pch1 = pszFileName;
  while ((*pch2) != '\0') {
    (*pch1) = (*pch2);
    pch1++;
    pch2++;
  }
  (*pch1) = '\0';
  return (pszFileName);
}


x86 assembly (clang, -O0):
<dirfname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1176 <dirfname+0x56>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1171 <dirfname+0x51>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d2 <dirfname+0xb2>
jmp    1176 <dirfname+0x56>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c3 <dirfname+0xa3>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118a <dirfname+0x6a>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dirfname>:
push   %rbx
mov    %rdi,%rbx
mov    $0x5c,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
jne    1145 <dirfname+0x25>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1174 <dirfname+0x54>
mov    0x1(%rax),%cl
mov    %rbx,%rdx
test   %cl,%cl
je     1171 <dirfname+0x51>
add    $0x2,%rax
mov    %rbx,%rdx
cs nopw 0x0(%rax,%rax,1)
mov    %cl,(%rdx)
add    $0x1,%rdx
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1160 <dirfname+0x40>
movb   $0x0,(%rdx)
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @dirfname(i8* returned %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%6 = icmp eq i8* %5, null
br i1 %6, label %22, label %7
7: ; preds = %4, %1
%8 = phi i8* [ %5, %4 ], [ %2, %1 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %7, %12
%13 = phi i8 [ %18, %12 ], [ %10, %7 ]
%14 = phi i8* [ %17, %12 ], [ %9, %7 ]
%15 = phi i8* [ %16, %12 ], [ %0, %7 ]
store i8 %13, i8* %15
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %12, %7
%21 = phi i8* [ %0, %7 ], [ %16, %12 ]
store i8 0, i8* %21
br label %22
22: ; preds = %4, %20
ret i8* %0
}