#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 *, unsigned char const);
void print_ascii_rendering(const unsigned char *data, size_t nbytes,
                           char nonascii) {
  for (int i = 0; i < nbytes; ++i) {
    if (data[i] >= 32 && data[i] < 127)
      printf("%c", data[i]);
    else
      printf("%c", nonascii);
  }
}


x86 assembly (clang, -O0):
<print_ascii_rendering>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a4 <print_ascii_rendering+0x94>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     1181 <print_ascii_rendering+0x71>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
jge    1181 <print_ascii_rendering+0x71>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
lea    0xe8d(%rip),%rdi
movzbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
jmp    1191 <print_ascii_rendering+0x81>
lea    0xe78(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1030 <printf@plt>
jmp    1196 <print_ascii_rendering+0x86>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <print_ascii_rendering+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ascii_rendering>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rsi,%rsi
je     1152 <print_ascii_rendering+0x42>
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebx,%ebx
movzbl %dl,%ebp
lea    0xed1(%rip),%r15
nop
movzbl (%r14,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <print_ascii_rendering+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @print_ascii_rendering(i8* nocapture %0, i64 %1, i8 signext %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %5, label %6
5: ; preds = %6, %3
ret void
6: ; preds = %3, %6
%7 = phi i64 [ %14, %6 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = add i8 %9, -32
%11 = icmp ult i8 %10, 95
%12 = select i1 %11, i8 %9, i8 %2
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %12)
%14 = add nuw i64 %7, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %5, label %6
}