#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 */
typedef char uint8_t;

/* Variables and functions */
scalar_t__ isprint(char);
int /*<<< orphan*/ tprintf(char *, ...);
void _ascii(uint8_t *ptr, size_t len) {
  if (!len)
    return;
  tprintf(" [ Chr ");
  for (; ptr && len-- > 0; ptr++)
    tprintf("%c", isprint(*ptr) ? *ptr : '.');
  tprintf(" ]\n");
}


x86 assembly (clang, -O0):
<_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1140 <_ascii+0x20>
jmp    11e9 <_ascii+0xc9>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <tprintf@plt>
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     1177 <_ascii+0x57>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
seta   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1187 <_ascii+0x67>
jmp    11db <_ascii+0xbb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     11ac <_ascii+0x8c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    11b9 <_ascii+0x99>
mov    $0x2e,%eax
mov    %eax,-0x18(%rbp)
jmp    11b9 <_ascii+0x99>
mov    -0x18(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <tprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114e <_ascii+0x2e>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <tprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ascii>:
test   %rsi,%rsi
je     11a7 <_ascii+0x87>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <tprintf@plt>
test   %r12,%r12
je     118e <_ascii+0x6e>
lea    0xeb7(%rip),%r15
xor    %ebx,%ebx
jmp    1178 <_ascii+0x58>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <tprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     118e <_ascii+0x6e>
movsbl (%r12,%rbx,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1160 <_ascii+0x40>
mov    $0x2e,%esi
jmp    1165 <_ascii+0x45>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <tprintf@plt>
ret

LLVM IR (-O0):
@.str = [8 x i8] c" [ Chr \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c" ]\0A\00"
define void @_ascii(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = icmp ne i64 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %2
br label %37
8: ; preds = %2
%9 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %32, %8
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* %4
%15 = add i64 %14, -1
store i64 %15, i64* %4
%16 = icmp ugt i64 %14, 0
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %19, label %35
19: ; preds = %17
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = call i64 @isprint(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
br label %29
28: ; preds = %19
br label %29
29: ; preds = %28, %24
%30 = phi i32 [ %27, %24 ], [ 46, %28 ]
%31 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %10
35: ; preds = %17
%36 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %7
ret void
}

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