#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*/ fputc(char, int /*<<< orphan*/);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ stdout;
void dump_text(void *in, int len) {
  unsigned char *p = (unsigned char *)in;
  while (len--) {
    fputc(isprint(*p) ? *p : '.', stdout);
    p++;
  }
  fputc('\n', stdout);
}


x86 assembly (clang, -O0):
<dump_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11a2 <dump_text+0x82>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1170 <dump_text+0x50>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <dump_text+0x5d>
mov    $0x2e,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <dump_text+0x5d>
mov    -0x1c(%rbp),%eax
mov    0x2e59(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <dump_text+0x17>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_text>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     116d <dump_text+0x4d>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
mov    0x2ea5(%rip),%r12
jmp    115a <dump_text+0x3a>
nopl   (%rax)
movzbl (%r15,%rbx,1),%eax
mov    (%r12),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
add    $0x1,%rbx
cmp    %ebx,%r14d
je     116d <dump_text+0x4d>
movzbl (%r15,%rbx,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1140 <dump_text+0x20>
mov    $0x2e,%al
jmp    1145 <dump_text+0x25>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>

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

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