#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
scalar_t__ utf8proc_is_space(int /*<<< orphan*/);
int /*<<< orphan*/ utf8proc_next(int /*<<< orphan*/ const *, size_t *);
size_t utf8proc_find_space(const uint8_t *str, size_t pos, size_t size) {
  while (pos < size) {
    const size_t last = pos;
    int32_t uc = utf8proc_next(str, &pos);
    if (utf8proc_is_space(uc))
      return last;
  }
  return size;
}


x86 assembly (clang, -O0):
<utf8proc_find_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117e <utf8proc_find_space+0x5e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <utf8proc_next@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <utf8proc_is_space@plt>
cmp    $0x0,%rax
je     1179 <utf8proc_find_space+0x59>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <utf8proc_find_space+0x66>
jmp    1134 <utf8proc_find_space+0x14>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8proc_find_space>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,(%rsp)
cmp    %rdx,%rsi
jae    1160 <utf8proc_find_space+0x40>
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%r12
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <utf8proc_next@plt>
mov    %eax,%edi
call   1040 <utf8proc_is_space@plt>
test   %rax,%rax
jne    1163 <utf8proc_find_space+0x43>
mov    (%rsp),%rbx
cmp    %r14,%rbx
jb     1140 <utf8proc_find_space+0x20>
mov    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @utf8proc_find_space(i32* %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
br label %10
10: ; preds = %23, %3
%11 = load i64, i64* %6
%12 = load i64, i64* %7
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i64, i64* %6
store i64 %15, i64* %8
%16 = load i32*, i32** %5
%17 = call i32 @utf8proc_next(i32* %16, i64* %6)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = call i64 @utf8proc_is_space(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = load i64, i64* %8
store i64 %22, i64* %4
br label %26
23: ; preds = %14
br label %10
24: ; preds = %10
%25 = load i64, i64* %7
store i64 %25, i64* %4
br label %26
26: ; preds = %24, %21
%27 = load i64, i64* %4
ret i64 %27
}

LLVM IR (-O2):
define i64 @utf8proc_find_space(i32* %0, i64 %1, i64 %2) {
%4 = alloca i64
store i64 %1, i64* %4
%5 = icmp ult i64 %1, %2
br i1 %5, label %6, label %14
6: ; preds = %3, %11
%7 = phi i64 [ %12, %11 ], [ %1, %3 ]
%8 = call i32 @utf8proc_next(i32* %0, i64* %4)
%9 = call i64 @utf8proc_is_space(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i64, i64* %4
%13 = icmp ult i64 %12, %2
br i1 %13, label %6, label %14
14: ; preds = %11, %6, %3
%15 = phi i64 [ %2, %3 ], [ %2, %11 ], [ %7, %6 ]
ret i64 %15
}