#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 */
int /*<<< orphan*/ assert(void const *);
scalar_t__ isprint(char const);
int /*<<< orphan*/ putchar(char const);
void strdump(const void *buf, size_t len) {
  assert(buf);
  const uint8_t *str = buf;
  if (!len) {
    return;
  }
  while (len--) {
    putchar(isprint(*str) ? *str : '.');
    ++str;
  }
}


x86 assembly (clang, -O0):
<strdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1161 <strdump+0x31>
jmp    11cd <strdump+0x9d>
jmp    1166 <strdump+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11cd <strdump+0x9d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     11a4 <strdump+0x74>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11b1 <strdump+0x81>
mov    $0x2e,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b1 <strdump+0x81>
mov    -0x1c(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1166 <strdump+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strdump>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <assert@plt>
test   %r14,%r14
je     1179 <strdump+0x49>
xor    %ebx,%ebx
jmp    1166 <strdump+0x36>
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1179 <strdump+0x49>
movsbl (%r15,%rbx,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
jne    1150 <strdump+0x20>
mov    $0x2e,%al
jmp    1155 <strdump+0x25>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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