#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*/ isprint(char);
int /*<<< orphan*/ isspace(char);
int util_checkprintspace(char *str) {
  while (*str) {
    if (!isprint(*str) && !isspace(*str))
      return -1;
    str++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<util_checkprintspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1180 <util_checkprintspace+0x60>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%eax
jne    116f <util_checkprintspace+0x4f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    116f <util_checkprintspace+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1187 <util_checkprintspace+0x67>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <util_checkprintspace+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_checkprintspace>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
xor    %ebp,%ebp
test   %al,%al
je     1169 <util_checkprintspace+0x49>
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    114b <util_checkprintspace+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1169 <util_checkprintspace+0x49>
movsbl %al,%edi
call   1040 <isprint@plt>
test   %eax,%eax
jne    1140 <util_checkprintspace+0x20>
movsbl -0x1(%rbx),%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1140 <util_checkprintspace+0x20>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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