#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__ isprint(char const);
int /*<<< orphan*/ printf(char *, char const);
void print_asc(const char *buf, int len) {
  int i;
  if (buf[len - 1] == 0)
    len--;
  for (i = 0; i < len; i++)
    printf("%c", isprint(buf[i]) ? buf[i] : '.');
}


x86 assembly (clang, -O0):
<print_asc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1152 <print_asc+0x32>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c1 <print_asc+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1194 <print_asc+0x74>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <print_asc+0x81>
mov    $0x2e,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <print_asc+0x81>
mov    -0x14(%rbp),%eax
lea    0xe55(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <print_asc+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_asc>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movslq %esi,%rax
cmpb   $0x0,-0x1(%rdi,%rax,1)
lea    -0x1(%rax),%rcx
cmove  %ecx,%eax
test   %eax,%eax
jle    117c <print_asc+0x5c>
mov    %rdi,%r12
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xeb6(%rip),%r14
jmp    1169 <print_asc+0x49>
nopl   0x0(%rax)
movzbl (%r12,%rbx,1),%eax
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     117c <print_asc+0x5c>
movsbl (%r12,%rbx,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1150 <print_asc+0x30>
mov    $0x2e,%al
jmp    1155 <print_asc+0x35>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @print_asc(i8* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = select i1 %7, i32 %3, i32 %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %20
%13 = phi i64 [ 0, %10 ], [ %23, %20 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = tail call i64 @isprint(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = load i8, i8* %14
br label %20
20: ; preds = %12, %18
%21 = phi i8 [ %19, %18 ], [ 46, %12 ]
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%23 = add nuw nsw i64 %13, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %12
25: ; preds = %20, %2
ret void
}