int next_path_part(char *path_part, char **path_ptr) {
  char ch;
  if (**path_ptr == '\0') {
    return 0;
  }
  while ((ch = *(*path_ptr)++) != '/' && ch != '\0') {
    *path_part++ = ch;
  }
  *path_part++ = '\0';
  if (ch == '/') {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<next_path_part>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    112b <next_path_part+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11bf <next_path_part+0xbf>
jmp    1130 <next_path_part+0x30>
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x1a(%rbp)
je     1164 <next_path_part+0x64>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    1174 <next_path_part+0x74>
jmp    118d <next_path_part+0x8d>
mov    -0x19(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1130 <next_path_part+0x30>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
movsbl -0x19(%rbp),%eax
cmp    $0x2f,%eax
jne    11b8 <next_path_part+0xb8>
movl   $0x1,-0x4(%rbp)
jmp    11bf <next_path_part+0xbf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_path_part>:
mov    (%rsi),%rax
cmpb   $0x0,(%rax)
je     113a <next_path_part+0x3a>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rax),%rcx
mov    %rcx,(%rsi)
movzbl (%rax),%ecx
test   %cl,%cl
je     112e <next_path_part+0x2e>
cmp    $0x2f,%cl
je     112e <next_path_part+0x2e>
mov    %cl,(%rdi)
add    $0x1,%rdi
mov    (%rsi),%rax
jmp    1110 <next_path_part+0x10>
movb   $0x0,(%rdi)
xor    %eax,%eax
cmp    $0x2f,%cl
sete   %al
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @next_path_part(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %39
13: ; preds = %2
br label %14
14: ; preds = %27, %13
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %15
%18 = load i8, i8* %16
store i8 %18, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 47
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = load i8, i8* %6
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br label %25
25: ; preds = %21, %14
%26 = phi i1 [ false, %14 ], [ %24, %21 ]
br i1 %26, label %27, label %31
27: ; preds = %25
%28 = load i8, i8* %6
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
store i8 %28, i8* %29
br label %14
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
store i8 0, i8* %32
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 47
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %3
br label %39
38: ; preds = %31
store i32 0, i32* %3
br label %39
39: ; preds = %38, %37, %12
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @next_path_part(i8* nocapture writeonly %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %2, %11
%7 = phi i8* [ %13, %11 ], [ %3, %2 ]
%8 = phi i8* [ %12, %11 ], [ %0, %2 ]
%9 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %9, i8** %1
%10 = load i8, i8* %7
switch i8 %10, label %11 [
i8 47, label %14
i8 0, label %14
]
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %10, i8* %8
%13 = load i8*, i8** %1
br label %6
14: ; preds = %6, %6
store i8 0, i8* %8
%15 = icmp eq i8 %10, 47
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %14, %2
%18 = phi i32 [ 0, %2 ], [ %16, %14 ]
ret i32 %18
}