#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 next_dark(char *buffer, size_t len, size_t i) {
  for (; i < len; ++i) {
    switch (buffer[i]) {
    case ' ':
    case '\t':
    case '\r':
    case '\n':
      break;
    default:
      return i;
    }
  }
  return len;
}


x86 assembly (clang, -O0):
<next_dark>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1187 <next_dark+0x87>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
add    $0xfffffff7,%eax
sub    $0x2,%eax
jb     1160 <next_dark+0x60>
jmp    113e <next_dark+0x3e>
mov    -0x24(%rbp),%eax
sub    $0xd,%eax
je     1160 <next_dark+0x60>
jmp    114f <next_dark+0x4f>
mov    -0x24(%rbp),%eax
sub    $0x20,%eax
jne    1165 <next_dark+0x65>
jmp    1160 <next_dark+0x60>
jmp    1171 <next_dark+0x71>
mov    -0x20(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    118e <next_dark+0x8e>
jmp    1176 <next_dark+0x76>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1110 <next_dark+0x10>
mov    -0x18(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_dark>:
cmp    %rsi,%rdx
jae    1138 <next_dark+0x38>
mov    %rdx,%rax
movabs $0x100002600,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rdi,%rax,1),%edx
cmp    $0x20,%edx
ja     113b <next_dark+0x3b>
bt     %rdx,%rcx
jae    113b <next_dark+0x3b>
add    $0x1,%rax
cmp    %rax,%rsi
jne    1120 <next_dark+0x20>
mov    %rsi,%rax
ret

LLVM IR (-O0):
define i32 @next_dark(i8* %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
br label %8
8: ; preds = %23, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = load i64, i64* %7
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %19 [
i32 32, label %18
i32 9, label %18
i32 13, label %18
i32 10, label %18
]
18: ; preds = %12, %12, %12, %12
br label %22
19: ; preds = %12
%20 = load i64, i64* %7
%21 = trunc i64 %20 to i32
store i32 %21, i32* %4
br label %29
22: ; preds = %18
br label %23
23: ; preds = %22
%24 = load i64, i64* %7
%25 = add i64 %24, 1
store i64 %25, i64* %7
br label %8
26: ; preds = %8
%27 = load i64, i64* %6
%28 = trunc i64 %27 to i32
store i32 %28, i32* %4
br label %29
29: ; preds = %26, %19
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @next_dark(i8* nocapture %0, i64 %1, i64 %2) {
%4 = icmp ult i64 %2, %1
br i1 %4, label %5, label %13
5: ; preds = %3, %10
%6 = phi i64 [ %11, %10 ], [ %2, %3 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %13 [
i32 32, label %10
i32 9, label %10
i32 13, label %10
i32 10, label %10
]
10: ; preds = %5, %5, %5, %5
%11 = add i64 %6, 1
%12 = icmp eq i64 %11, %1
br i1 %12, label %13, label %5
13: ; preds = %5, %10, %3
%14 = phi i64 [ %1, %3 ], [ %1, %10 ], [ %6, %5 ]
%15 = trunc i64 %14 to i32
ret i32 %15
}