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


x86 assembly (clang, -O0):
<print_asc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a3 <print_asc+0x83>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     117a <print_asc+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
jmp    1187 <print_asc+0x67>
mov    $0x2e,%eax
mov    %eax,-0x20(%rbp)
jmp    1187 <print_asc+0x67>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%eax
movslq %eax,%rsi
call   1030 <DEBUG@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <print_asc+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_asc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    116a <print_asc+0x4a>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %edx,%r15d
xor    %ebp,%ebp
jmp    1155 <print_asc+0x35>
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%rbp,1),%esi
mov    %r14d,%edi
call   1030 <DEBUG@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     116a <print_asc+0x4a>
movzbl (%rbx,%rbp,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1140 <print_asc+0x20>
mov    $0x2e,%esi
jmp    1144 <print_asc+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @print_asc(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %34, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%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 = call i64 @isprint(i8 zeroext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %12
%22 = load i8*, i8** %5
%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
br label %29
28: ; preds = %12
br label %29
29: ; preds = %28, %21
%30 = phi i32 [ %27, %21 ], [ 46, %28 ]
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
%33 = call i32 @DEBUG(i32 %13, i8* %32)
br label %34
34: ; preds = %29
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %8
37: ; preds = %8
ret void
}

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