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


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

x86 assembly (clang, -O2):
<pszTraceGetFileBaseName>:
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 <pszTraceGetFileBaseName+0x3a>
movzbl -0x1(%rbx,%rcx,1),%eax
add    $0xffffffffffffffff,%rcx
cmp    $0x5c,%al
je     1145 <pszTraceGetFileBaseName+0x35>
cmp    $0x2f,%al
jne    1130 <pszTraceGetFileBaseName+0x20>
add    $0x1,%ecx
mov    %ecx,%edx
movslq %edx,%rax
add    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @pszTraceGetFileBaseName(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* %4
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
store i32 %8, i32* %3
br label %9
9: ; preds = %30, %1
%10 = load i32, i32* %3
%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* %3
%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, 92
br i1 %19, label %28, label %20
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%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, 47
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* %3
%32 = add nsw i32 %31, -1
store i32 %32, i32* %3
br label %9
33: ; preds = %28, %9
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
%36 = load i8*, i8** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
ret i8* %39
}

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