#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 */
int /*<<< orphan*/ isspace(unsigned char);
size_t non_white_space_length(const char *str) {
  size_t i = 0;
  if (!str) {
    return 0;
  }
  while (str[i] && !isspace((unsigned char)str[i])) {
    i++;
  }
  return i;
}


x86 assembly (clang, -O0):
<non_white_space_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113c <non_white_space_length+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    11a0 <non_white_space_length+0x90>
jmp    1141 <non_white_space_length+0x31>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1177 <non_white_space_length+0x67>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1187 <non_white_space_length+0x77>
jmp    1198 <non_white_space_length+0x88>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <non_white_space_length+0x31>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<non_white_space_length>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     114c <non_white_space_length+0x3c>
mov    %rdi,%r14
mov    (%rdi),%al
xor    %ebx,%ebx
test   %al,%al
je     114e <non_white_space_length+0x3e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %al,%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    114e <non_white_space_length+0x3e>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <non_white_space_length+0x20>
jmp    114e <non_white_space_length+0x3e>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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