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

/* Variables and functions */
int /*<<< orphan*/ isspace(int /*<<< orphan*/);
void scan_spaces_safe(const uint8_t **bufptr, const uint8_t *end) {
  const uint8_t *ptr = *bufptr;
  uint_fast8_t ch;
  while (ptr != end) {
    ch = *ptr;
    if (!isspace(ch)) {
      break;
    }
    ptr++;
  }
  *bufptr = ptr;
}


x86 assembly (clang, -O0):
<scan_spaces_safe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1169 <scan_spaces_safe+0x59>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    1158 <scan_spaces_safe+0x48>
jmp    1169 <scan_spaces_safe+0x59>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    112b <scan_spaces_safe+0x1b>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_spaces_safe>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rdi),%rbx
cmp    %rsi,%rbx
je     1149 <scan_spaces_safe+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%edi
call   1030 <isspace@plt>
test   %eax,%eax
je     1146 <scan_spaces_safe+0x36>
add    $0x4,%rbx
cmp    %r15,%rbx
jne    1130 <scan_spaces_safe+0x20>
jmp    1149 <scan_spaces_safe+0x39>
mov    %rbx,%r15
mov    %r15,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @scan_spaces_safe(i32** nocapture %0, i32* readnone %1) {
%3 = load i32*, i32** %0
%4 = icmp eq i32* %3, %1
br i1 %4, label %13, label %5
5: ; preds = %2, %10
%6 = phi i32* [ %11, %10 ], [ %3, %2 ]
%7 = load i32, i32* %6
%8 = tail call i32 @isspace(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = getelementptr inbounds i32, i32* %6, i64 1
%12 = icmp eq i32* %11, %1
br i1 %12, label %13, label %5
13: ; preds = %10, %5, %2
%14 = phi i32* [ %1, %2 ], [ %6, %5 ], [ %1, %10 ]
store i32* %14, i32** %0
ret void
}