#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 */
size_t next_token(char path[], size_t curr_i) {
  size_t i = curr_i;
  while (path[i] != '\0' && path[i] != '/')
    i++;
  return path[i] == '\0' ? i : i + 1;
}


x86 assembly (clang, -O0):
<next_token>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1143 <next_token+0x43>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1153 <next_token+0x53>
jmp    1164 <next_token+0x64>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1114 <next_token+0x14>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1186 <next_token+0x86>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1192 <next_token+0x92>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_token>:
mov    %rsi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rdi,%rax,1),%ecx
test   %cl,%cl
je     1123 <next_token+0x23>
cmp    $0x2f,%cl
je     1123 <next_token+0x23>
add    $0x1,%rax
jmp    1110 <next_token+0x10>
cmp    $0x1,%cl
sbb    $0xffffffffffffffff,%rax
ret

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

LLVM IR (-O2):
define i64 @next_token(i8* nocapture %0, i64 %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i64 [ %1, %2 ], [ %8, %7 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %9
i8 47, label %9
]
7: ; preds = %3
%8 = add i64 %4, 1
br label %3
9: ; preds = %3, %3
%10 = icmp ne i8 %6, 0
%11 = zext i1 %10 to i64
%12 = add i64 %4, %11
ret i64 %12
}