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


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

x86 assembly (clang, -O2):
<pdc_file_strip_name>:
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     114a <pdc_file_strip_name+0x3a>
movzbl (%rax),%ecx
add    $0xffffffffffffffff,%rax
cmp    $0x5c,%cl
je     1146 <pdc_file_strip_name+0x36>
cmp    $0x2f,%cl
jne    1130 <pdc_file_strip_name+0x20>
movb   $0x0,0x1(%rax)
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_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
store i8* %8, i8** %3
br label %9
9: ; preds = %30, %1
%10 = load i8*, i8** %2
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 -1
store i8* %12, i8** %3
%13 = icmp ule i8* %10, %12
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %17, %19
br i1 %20, label %28, label %21
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %24, %26
br i1 %27, label %28, label %30
28: ; preds = %21, %14
%29 = load i8*, i8** %3
store i8 0, i8* %29
br label %31
30: ; preds = %21
br label %9
31: ; preds = %28, %9
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
define i8* @pdc_file_strip_name(i8* returned %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 %12, 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 = %9, %9
store i8 0, i8* %7
br label %12
12: ; preds = %5, %11
ret i8* %0
}