#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__ cwk_path_is_separator(char const *);
const char *cwk_path_find_previous_stop(const char *begin, const char *c) {
  while (c > begin && !cwk_path_is_separator(c)) {
    --c;
  }
  if (cwk_path_is_separator(c)) {
    return c + 1;
  } else {
    return c;
  }
}


x86 assembly (clang, -O0):
<cwk_path_find_previous_stop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    1148 <cwk_path_find_previous_stop+0x38>
mov    -0x18(%rbp),%rdi
call   1030 <cwk_path_is_separator@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1158 <cwk_path_find_previous_stop+0x48>
jmp    1169 <cwk_path_find_previous_stop+0x59>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <cwk_path_find_previous_stop+0x10>
mov    -0x18(%rbp),%rdi
call   1030 <cwk_path_is_separator@plt>
cmp    $0x0,%rax
je     118d <cwk_path_find_previous_stop+0x7d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1195 <cwk_path_find_previous_stop+0x85>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cwk_path_find_previous_stop>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    %rdi,%rsi
jbe    1136 <cwk_path_find_previous_stop+0x26>
mov    %rdi,%r14
nop
mov    %rbx,%rdi
call   1030 <cwk_path_is_separator@plt>
test   %rax,%rax
jne    1136 <cwk_path_find_previous_stop+0x26>
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
ja     1120 <cwk_path_find_previous_stop+0x10>
mov    %rbx,%rdi
call   1030 <cwk_path_is_separator@plt>
cmp    $0x1,%rax
sbb    $0xffffffffffffffff,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @cwk_path_find_previous_stop(i8* readnone %0, i8* %1) {
%3 = icmp ugt i8* %1, %0
br i1 %3, label %4, label %11
4: ; preds = %2, %8
%5 = phi i8* [ %9, %8 ], [ %1, %2 ]
%6 = tail call i64 @cwk_path_is_separator(i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %5, i64 -1
%10 = icmp ugt i8* %9, %0
br i1 %10, label %4, label %11
11: ; preds = %4, %8, %2
%12 = phi i8* [ %1, %2 ], [ %9, %8 ], [ %5, %4 ]
%13 = tail call i64 @cwk_path_is_separator(i8* %12)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i64
%16 = getelementptr i8, i8* %12, i64 %15
ret i8* %16
}