#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 */
scalar_t__ ch_is_slash(char const);
char const *get_front_of_slashes(char const *const, char const *);
const char *find_last_row_of_slashes(const char *__attribute__((nonnull))
                                     const path,
                                     const char *__attribute__((nonnull))
                                     const end) {
  const char *iter = end - 1;
  const char *const rev_end = path - 1;
  for (; iter != rev_end; --iter) {
    if (ch_is_slash(*iter)) {
      return get_front_of_slashes(path, iter);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_last_row_of_slashes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1198 <find_last_row_of_slashes+0x78>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <ch_is_slash@plt>
cmp    $0x0,%rax
je     1182 <find_last_row_of_slashes+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <get_front_of_slashes@plt>
mov    %rax,-0x8(%rbp)
jmp    11a0 <find_last_row_of_slashes+0x80>
jmp    1187 <find_last_row_of_slashes+0x67>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1148 <find_last_row_of_slashes+0x28>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_last_row_of_slashes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
cmp    %r14,%rbx
je     1159 <find_last_row_of_slashes+0x39>
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1040 <ch_is_slash@plt>
test   %rax,%rax
je     1130 <find_last_row_of_slashes+0x10>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <get_front_of_slashes@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @find_last_row_of_slashes(i8* %0, i8* %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i8* [ %1, %2 ], [ %5, %7 ]
%5 = getelementptr inbounds i8, i8* %4, i64 -1
%6 = icmp eq i8* %4, %0
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = load i8, i8* %5
%9 = tail call i64 @ch_is_slash(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %3, label %11
11: ; preds = %7
%12 = tail call i8* @get_front_of_slashes(i8* %0, i8* %5)
br label %13
13: ; preds = %3, %11
%14 = phi i8* [ %12, %11 ], [ null, %3 ]
ret i8* %14
}