#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__ mapred_ischar_delim(char const);
size_t mapred_forward_token_len(const char *data, size_t size) {
  const char *ptr = data;
  while (size) {
    if (!*ptr)
      break;
    if (mapred_ischar_delim(*ptr))
      break;
    ptr++;
    size--;
  }
  return ptr - data;
}


x86 assembly (clang, -O0):
<mapred_forward_token_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117d <mapred_forward_token_len+0x6d>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1145 <mapred_forward_token_len+0x35>
jmp    117d <mapred_forward_token_len+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <mapred_ischar_delim@plt>
cmp    $0x0,%rax
je     1160 <mapred_forward_token_len+0x50>
jmp    117d <mapred_forward_token_len+0x6d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1128 <mapred_forward_token_len+0x18>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapred_forward_token_len>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
je     114e <mapred_forward_token_len+0x3e>
mov    %rsi,%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     114e <mapred_forward_token_len+0x3e>
movsbl %al,%edi
call   1030 <mapred_ischar_delim@plt>
test   %rax,%rax
jne    114e <mapred_forward_token_len+0x3e>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r15
jne    1130 <mapred_forward_token_len+0x20>
sub    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @mapred_forward_token_len(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %12
%5 = phi i8* [ %13, %12 ], [ %0, %2 ]
%6 = phi i64 [ %14, %12 ], [ %1, %2 ]
%7 = load i8, i8* %5
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %4
%10 = tail call i64 @mapred_ischar_delim(i8 signext %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %5, i64 1
%14 = add i64 %6, -1
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %4
16: ; preds = %12, %4, %9, %2
%17 = phi i8* [ %0, %2 ], [ %5, %9 ], [ %5, %4 ], [ %13, %12 ]
%18 = ptrtoint i8* %17 to i64
%19 = ptrtoint i8* %0 to i64
%20 = sub i64 %18, %19
ret i64 %20
}