#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 *pdc_file_strip_dirs(const char *pathname) {
  const char *scan = pathname + strlen(pathname);
  while (pathname <= --scan) {
    if (*scan == "/"[0] || *scan == "\\"[0])
      return scan + 1;
  }
  return pathname;
}


x86 assembly (clang, -O0):
<pdc_file_strip_dirs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    %rcx,%rax
ja     1198 <pdc_file_strip_dirs+0x88>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movsbl 0xe9c(%rip),%ecx
cmp    %ecx,%eax
je     1182 <pdc_file_strip_dirs+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movsbl 0xe88(%rip),%ecx
cmp    %ecx,%eax
jne    1193 <pdc_file_strip_dirs+0x83>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <pdc_file_strip_dirs+0x90>
jmp    113d <pdc_file_strip_dirs+0x2d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdc_file_strip_dirs>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %rbx,%rax
jb     114d <pdc_file_strip_dirs+0x3d>
movzbl (%rax),%ecx
add    $0xffffffffffffffff,%rax
cmp    $0x5c,%cl
je     1146 <pdc_file_strip_dirs+0x36>
cmp    $0x2f,%cl
jne    1130 <pdc_file_strip_dirs+0x20>
add    $0x2,%rax
mov    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c"\\\00"
define i8* @pdc_file_strip_dirs(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %4
br label %10
10: ; preds = %32, %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 -1
store i8* %13, i8** %4
%14 = icmp ule i8* %11, %13
br i1 %14, label %15, label %33
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %18, %20
br i1 %21, label %29, label %22
22: ; preds = %15
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %32
29: ; preds = %22, %15
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %2
br label %35
32: ; preds = %22
br label %10
33: ; preds = %10
%34 = load i8*, i8** %3
store i8* %34, i8** %2
br label %35
35: ; preds = %33, %29
%36 = load i8*, i8** %2
ret i8* %36
}

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