#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__ isspace(unsigned char);
const char *get_next_word_boundary(const char *ptr, size_t len) {
  while (len > 0) {
    if (isspace((unsigned char)*ptr))
      break;
    ptr++;
    len--;
  }
  while (len > 0) {
    if (!isspace((unsigned char)*ptr))
      return ptr;
    ptr++;
    len--;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_next_word_boundary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    1163 <get_next_word_boundary+0x53>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1146 <get_next_word_boundary+0x36>
jmp    1163 <get_next_word_boundary+0x53>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <get_next_word_boundary+0x10>
jmp    1168 <get_next_word_boundary+0x58>
cmpq   $0x0,-0x18(%rbp)
jbe    11b3 <get_next_word_boundary+0xa3>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    1196 <get_next_word_boundary+0x86>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <get_next_word_boundary+0xab>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <get_next_word_boundary+0x58>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_word_boundary>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1149 <get_next_word_boundary+0x39>
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    114e <get_next_word_boundary+0x3e>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r15
jne    1130 <get_next_word_boundary+0x20>
jmp    1180 <get_next_word_boundary+0x70>
xor    %r14d,%r14d
jmp    1180 <get_next_word_boundary+0x70>
xor    %r14d,%r14d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx,%r12,1),%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     117a <get_next_word_boundary+0x6a>
add    $0x1,%r12
cmp    %r12,%r15
jne    1160 <get_next_word_boundary+0x50>
jmp    1180 <get_next_word_boundary+0x70>
add    %r12,%rbx
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @get_next_word_boundary(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %24, label %4
4: ; preds = %2, %10
%5 = phi i64 [ %12, %10 ], [ %1, %2 ]
%6 = phi i8* [ %11, %10 ], [ %0, %2 ]
%7 = load i8, i8* %6
%8 = tail call i64 @isspace(i8 zeroext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %6, i64 1
%12 = add i64 %5, -1
%13 = icmp eq i64 %12, 0
br i1 %13, label %24, label %4
14: ; preds = %4, %20
%15 = phi i64 [ %22, %20 ], [ %5, %4 ]
%16 = phi i8* [ %21, %20 ], [ %6, %4 ]
%17 = load i8, i8* %16
%18 = tail call i64 @isspace(i8 zeroext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = getelementptr inbounds i8, i8* %16, i64 1
%22 = add i64 %15, -1
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %14
24: ; preds = %10, %14, %20, %2
%25 = phi i8* [ null, %2 ], [ null, %20 ], [ %16, %14 ], [ null, %10 ]
ret i8* %25
}