#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__ get_end_of_slashes(char *const);
char *get_next_path_component_slash(char *__attribute__((nonnull)) const path) {
  char *iter = (char *)get_end_of_slashes(path);
  if (iter == NULL) {
    return NULL;
  }
  char ch = '\0';
  do {
    ch = *(++iter);
    if (ch == '\0') {
      return NULL;
    }
  } while (ch != '/');
  return iter;
}


x86 assembly (clang, -O0):
<get_next_path_component_slash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <get_end_of_slashes@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1141 <get_next_path_component_slash+0x31>
movq   $0x0,-0x8(%rbp)
jmp    118e <get_next_path_component_slash+0x7e>
movb   $0x0,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    0x1(%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    1174 <get_next_path_component_slash+0x64>
movq   $0x0,-0x8(%rbp)
jmp    118e <get_next_path_component_slash+0x7e>
jmp    1179 <get_next_path_component_slash+0x69>
movsbl -0x19(%rbp),%eax
cmp    $0x2f,%eax
jne    1145 <get_next_path_component_slash+0x35>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_path_component_slash>:
push   %rax
call   1030 <get_end_of_slashes@plt>
test   %rax,%rax
je     1131 <get_next_path_component_slash+0x21>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0x2f,%cl
je     1133 <get_next_path_component_slash+0x23>
test   %cl,%cl
jne    1120 <get_next_path_component_slash+0x10>
xor    %eax,%eax
pop    %rcx
ret

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

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