#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 /*<<< orphan*/ ch_is_slash(char const);
const char *get_front_of_slashes(const char *__attribute__((nonnull))
                                 const begin,
                                 const char *__attribute__((nonnull)) iter) {
  const char *const rev_end = begin - 1;
  for (--iter; iter != rev_end; --iter) {
    if (!ch_is_slash(*iter)) {
      break;
    }
  }
  return (iter + 1);
}


x86 assembly (clang, -O0):
<get_front_of_slashes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     1176 <get_front_of_slashes+0x66>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <ch_is_slash@plt>
cmp    $0x0,%eax
jne    1160 <get_front_of_slashes+0x50>
jmp    1176 <get_front_of_slashes+0x66>
jmp    1165 <get_front_of_slashes+0x55>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <get_front_of_slashes+0x28>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_front_of_slashes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
cmp    %r14,%rbx
je     113d <get_front_of_slashes+0x2d>
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1030 <ch_is_slash@plt>
test   %eax,%eax
jne    1120 <get_front_of_slashes+0x10>
add    $0x1,%rbx
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @get_front_of_slashes(i8* readnone %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 %11, label %7
7: ; preds = %3
%8 = load i8, i8* %5
%9 = tail call i32 @ch_is_slash(i8 signext %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %3
11: ; preds = %7, %3
%12 = phi i8* [ %4, %7 ], [ %0, %3 ]
ret i8* %12
}