#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 */
scalar_t__ isalpha(unsigned char);
scalar_t__ isdigit(unsigned char);
int strlen(char *);
int printable(char *s) {
  int len = strlen(s);
  int i;
  for (i = 0; i < len; i++) {
    unsigned char c = s[i];
    if (isalpha(c) || isdigit(c) || c == '-')
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<printable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bb <printable+0x8b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
jne    119c <printable+0x6c>
movzbl -0x19(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    119c <printable+0x6c>
movzbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    11a8 <printable+0x78>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <printable+0x92>
jmp    11ad <printable+0x7d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114f <printable+0x1f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printable>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    117e <printable+0x4e>
mov    %eax,%r15d
xor    %ebp,%ebp
mov    $0x1,%r12d
nop
movzbl (%r14,%rbp,1),%eax
movzbl %al,%ebx
mov    %ebx,%edi
call   1050 <isalpha@plt>
test   %rax,%rax
jne    1181 <printable+0x51>
mov    %ebx,%edi
call   1030 <isdigit@plt>
cmp    $0x2d,%bl
je     1181 <printable+0x51>
test   %rax,%rax
jne    1181 <printable+0x51>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1150 <printable+0x20>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @printable(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %32, %1
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %35
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %6
%19 = load i8, i8* %6
%20 = call i64 @isalpha(i8 zeroext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %30, label %22
22: ; preds = %13
%23 = load i8, i8* %6
%24 = call i64 @isdigit(i8 zeroext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8, i8* %6
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 45
br i1 %29, label %30, label %31
30: ; preds = %26, %22, %13
store i32 1, i32* %2
br label %36
31: ; preds = %26
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %9
35: ; preds = %9
store i32 0, i32* %2
br label %36
36: ; preds = %35, %30
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @printable(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %8
6: ; preds = %14
%7 = icmp eq i64 %19, %5
br i1 %7, label %20, label %8
8: ; preds = %4, %6
%9 = phi i64 [ 0, %4 ], [ %19, %6 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i64 @isalpha(i8 zeroext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %8
%15 = tail call i64 @isdigit(i8 zeroext %11)
%16 = icmp ne i64 %15, 0
%17 = icmp eq i8 %11, 45
%18 = or i1 %17, %16
%19 = add nuw nsw i64 %9, 1
br i1 %18, label %20, label %6
20: ; preds = %8, %14, %6, %1
%21 = phi i32 [ 0, %1 ], [ 0, %6 ], [ 1, %14 ], [ 1, %8 ]
ret i32 %21
}