#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ isprint(char);
int /*<<< orphan*/ stderr;
int str_isprint(char *str, int len) {
  int idx_str;
  if (!str || len <= 0) {
    fprintf(stderr, "error: str_isalpha(): Bad parameters\n");
    return 0;
  }
  for (idx_str = 0; idx_str < len; idx_str++) {
    if (!isprint(str[idx_str]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<str_isprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <str_isprint+0x24>
cmpl   $0x0,-0x14(%rbp)
jg     1165 <str_isprint+0x45>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <str_isprint+0x98>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b1 <str_isprint+0x91>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%eax
jne    119e <str_isprint+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <str_isprint+0x98>
jmp    11a3 <str_isprint+0x83>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <str_isprint+0x4c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_isprint>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     115f <str_isprint+0x3f>
test   %esi,%esi
jle    115f <str_isprint+0x3f>
mov    %rdi,%r12
mov    %esi,%r15d
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r12,%rbx,1),%edi
call   1040 <isprint@plt>
test   %eax,%eax
je     1177 <str_isprint+0x57>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <str_isprint+0x20>
mov    $0x1,%r14d
jmp    1177 <str_isprint+0x57>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1030 <fprintf@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"error: str_isalpha(): Bad parameters\0A\00"
define i32 @str_isprint(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9, %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %34
15: ; preds = %9
store i32 0, i32* %6
br label %16
16: ; preds = %30, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @isprint(i8 signext %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %20
store i32 0, i32* %3
br label %34
29: ; preds = %20
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %16
33: ; preds = %16
store i32 1, i32* %3
br label %34
34: ; preds = %33, %28, %12
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"error: str_isalpha(): Bad parameters\0A\00"
define i32 @str_isprint(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %20
11: ; preds = %13
%12 = icmp eq i64 %19, %7
br i1 %12, label %20, label %13
13: ; preds = %6, %11
%14 = phi i64 [ 0, %6 ], [ %19, %11 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = tail call i32 @isprint(i8 signext %16)
%18 = icmp eq i32 %17, 0
%19 = add nuw nsw i64 %14, 1
br i1 %18, label %20, label %11
20: ; preds = %13, %11, %8
%21 = phi i32 [ 0, %8 ], [ 0, %13 ], [ 1, %11 ]
ret i32 %21
}