#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 int32_t;

/* Variables and functions */
scalar_t__ utf8proc_is_space(int);
int 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 (uc == 0xFFFD)
      return size;
    else 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    119d <utf8proc_find_space+0x7d>
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)
cmpl   $0xfffd,-0x2c(%rbp)
jne    1174 <utf8proc_find_space+0x54>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <utf8proc_find_space+0x85>
mov    -0x2c(%rbp),%edi
call   1040 <utf8proc_is_space@plt>
cmp    $0x0,%rax
je     1193 <utf8proc_find_space+0x73>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <utf8proc_find_space+0x85>
jmp    1198 <utf8proc_find_space+0x78>
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    1167 <utf8proc_find_space+0x47>
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%r12
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <utf8proc_next@plt>
cmp    $0xfffd,%eax
je     1167 <utf8proc_find_space+0x47>
mov    %eax,%edi
call   1040 <utf8proc_is_space@plt>
test   %rax,%rax
jne    116a <utf8proc_find_space+0x4a>
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 = %29, %3
%11 = load i64, i64* %6
%12 = load i64, i64* %7
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %30
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 = icmp eq i32 %18, 65533
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = load i64, i64* %7
store i64 %21, i64* %4
br label %32
22: ; preds = %14
%23 = load i32, i32* %9
%24 = call i64 @utf8proc_is_space(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i64, i64* %8
store i64 %27, i64* %4
br label %32
28: ; preds = %22
br label %29
29: ; preds = %28
br label %10
30: ; preds = %10
%31 = load i64, i64* %7
store i64 %31, i64* %4
br label %32
32: ; preds = %30, %26, %20
%33 = load i64, i64* %4
ret i64 %33
}

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 %16
6: ; preds = %3, %13
%7 = phi i64 [ %14, %13 ], [ %1, %3 ]
%8 = call i32 @utf8proc_next(i32* %0, i64* %4)
%9 = icmp eq i32 %8, 65533
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = call i64 @utf8proc_is_space(i32 %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i64, i64* %4
%15 = icmp ult i64 %14, %2
br i1 %15, label %6, label %16
16: ; preds = %13, %6, %10, %3
%17 = phi i64 [ %2, %3 ], [ %2, %13 ], [ %2, %6 ], [ %7, %10 ]
ret i64 %17
}