#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 */
signed int unprintable_score(size_t size, char *chararray) {
  for (int i = 0; chararray[i] && i < size; i++) {
    unsigned char current = (unsigned)chararray[i];
    if (current <= 31 || current >= 127) {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<unprintable_score>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1e(%rbp)
je     113b <unprintable_score+0x3b>
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
setb   %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    114b <unprintable_score+0x4b>
jmp    1193 <unprintable_score+0x93>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
cmp    $0x1f,%eax
jle    1174 <unprintable_score+0x74>
movzbl -0x1d(%rbp),%eax
cmp    $0x7f,%eax
jl     1180 <unprintable_score+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <unprintable_score+0x9a>
jmp    1185 <unprintable_score+0x85>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1113 <unprintable_score+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unprintable_score>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rsi,%rax,1),%edx
test   %dl,%dl
setne  %r8b
cmp    %rdi,%rax
setb   %cl
and    %r8b,%cl
cmp    $0x1,%cl
jne    1134 <unprintable_score+0x34>
add    $0x81,%dl
add    $0x1,%rax
cmp    $0xa0,%dl
ja     1110 <unprintable_score+0x10>
movzbl %cl,%eax
neg    %eax
ret

LLVM IR (-O0):
define i32 @unprintable_score(i64 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %40, %2
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, 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 %21
16: ; preds = %8
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = load i64, i64* %4
%20 = icmp ult i64 %18, %19
br label %21
21: ; preds = %16, %8
%22 = phi i1 [ false, %8 ], [ %20, %16 ]
br i1 %22, label %23, label %43
23: ; preds = %21
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = trunc i32 %29 to i8
store i8 %30, i8* %7
%31 = load i8, i8* %7
%32 = zext i8 %31 to i32
%33 = icmp sle i32 %32, 31
br i1 %33, label %38, label %34
34: ; preds = %23
%35 = load i8, i8* %7
%36 = zext i8 %35 to i32
%37 = icmp sge i32 %36, 127
br i1 %37, label %38, label %39
38: ; preds = %34, %23
store i32 -1, i32* %3
br label %44
39: ; preds = %34
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %8
43: ; preds = %21
store i32 0, i32* %3
br label %44
44: ; preds = %43, %38
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @unprintable_score(i64 %0, i8* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ %14, %3 ], [ 0, %2 ]
%5 = getelementptr inbounds i8, i8* %1, i64 %4
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
%8 = icmp ult i64 %4, %0
%9 = select i1 %7, i1 %8, i1 false
%10 = xor i1 %9, true
%11 = add i8 %6, -127
%12 = icmp ult i8 %11, -95
%13 = select i1 %10, i1 true, i1 %12
%14 = add nuw i64 %4, 1
br i1 %13, label %15, label %3
15: ; preds = %3
%16 = sext i1 %9 to i32
ret i32 %16
}