#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*/ printf(char *);
int protectedEcho(char c) {
  if (c == 127 || c == 8) {
    printf("\b \b");
  } else {
    if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9') {
      printf("*");
    } else {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<protectedEcho>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x7f,%eax
je     1138 <protectedEcho+0x28>
movsbl -0x5(%rbp),%eax
cmp    $0x8,%eax
jne    1149 <protectedEcho+0x39>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <protectedEcho+0xa9>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1163 <protectedEcho+0x53>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jle    1197 <protectedEcho+0x87>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     117d <protectedEcho+0x6d>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jle    1197 <protectedEcho+0x87>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     11a8 <protectedEcho+0x98>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     11a8 <protectedEcho+0x98>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <protectedEcho+0xa4>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <protectedEcho+0xb0>
jmp    11b9 <protectedEcho+0xa9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<protectedEcho>:
push   %rax
cmp    $0x7f,%dil
je     112d <protectedEcho+0xd>
cmp    $0x8,%dil
jne    113b <protectedEcho+0x1b>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
jmp    115e <protectedEcho+0x3e>
lea    -0x30(%rdi),%eax
cmp    $0xa,%al
jb     1154 <protectedEcho+0x34>
and    $0xdf,%dil
add    $0xbf,%dil
xor    %eax,%eax
cmp    $0x19,%dil
jbe    1154 <protectedEcho+0x34>
pop    %rcx
ret
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\08 \08\00"
@.str.1 = [2 x i8] c"*\00"
define i32 @protectedEcho(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 127
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 8
br i1 %10, label %11, label %13
11: ; preds = %7, %1
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %41
13: ; preds = %7
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp sge i32 %15, 65
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = icmp sle i32 %19, 90
br i1 %20, label %37, label %21
21: ; preds = %17, %13
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 97
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp sle i32 %27, 122
br i1 %28, label %37, label %29
29: ; preds = %25, %21
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = icmp sge i32 %31, 48
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
%36 = icmp sle i32 %35, 57
br i1 %36, label %37, label %39
37: ; preds = %33, %25, %17
%38 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
39: ; preds = %33, %29
store i32 0, i32* %2
br label %42
40: ; preds = %37
br label %41
41: ; preds = %40, %11
store i32 1, i32* %2
br label %42
42: ; preds = %41, %39
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@.str = [4 x i8] c"\08 \08\00"
define i32 @protectedEcho(i8 signext %0) {
switch i8 %0, label %4 [
i8 127, label %2
i8 8, label %2
]
2: ; preds = %1, %1
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %13
4: ; preds = %1
%5 = and i8 %0, -33
%6 = add i8 %5, -65
%7 = icmp ult i8 %6, 26
%8 = add i8 %0, -48
%9 = icmp ult i8 %8, 10
%10 = or i1 %9, %7
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @putchar(i32 42)
br label %13
13: ; preds = %2, %11, %4
%14 = phi i32 [ 0, %4 ], [ 1, %11 ], [ 1, %2 ]
ret i32 %14
}