#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*/ putchar(char);
void dump_ascii(const void *buf, size_t bytes) {
  const char *s = (const char *)buf;
  while (bytes--) {
    char c = *s++;
    putchar((0x20 <= c && c < 0x7F) ? c : '.');
  }
}


x86 assembly (clang, -O0):
<dump_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     119c <dump_ascii+0x8c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jg     117f <dump_ascii+0x6f>
movsbl -0x19(%rbp),%eax
cmp    $0x7f,%eax
jge    117f <dump_ascii+0x6f>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    118c <dump_ascii+0x7c>
mov    $0x2e,%eax
mov    %eax,-0x20(%rbp)
jmp    118c <dump_ascii+0x7c>
mov    -0x20(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1128 <dump_ascii+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_ascii>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     114f <dump_ascii+0x3f>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
mov    $0x2e,%ebp
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <dump_ascii+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dump_ascii(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %27, %2
%9 = load i64, i64* %4
%10 = add i64 %9, -1
store i64 %10, i64* %4
%11 = icmp ne i64 %9, 0
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load i8, i8* %13
store i8 %15, i8* %6
%16 = load i8, i8* %6
%17 = sext i8 %16 to i32
%18 = icmp sle i32 32, %17
br i1 %18, label %19, label %26
19: ; preds = %12
%20 = load i8, i8* %6
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %21, 127
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8, i8* %6
%25 = sext i8 %24 to i32
br label %27
26: ; preds = %19, %12
br label %27
27: ; preds = %26, %23
%28 = phi i32 [ %25, %23 ], [ 46, %26 ]
%29 = trunc i32 %28 to i8
%30 = call i32 @putchar(i8 signext %29)
br label %8
31: ; preds = %8
ret void
}

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