#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 const);
int /*<<< orphan*/ putchar(char const);
void strdump(const void *buf, size_t len) {
  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),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1148 <strdump+0x28>
jmp    11b4 <strdump+0x94>
jmp    114d <strdump+0x2d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11b4 <strdump+0x94>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     118b <strdump+0x6b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <strdump+0x78>
mov    $0x2e,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <strdump+0x78>
mov    -0x1c(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114d <strdump+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strdump>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1169 <strdump+0x49>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    1156 <strdump+0x36>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r15,%rbx,1),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1169 <strdump+0x49>
movsbl (%r15,%rbx,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1140 <strdump+0x20>
mov    $0x2e,%al
jmp    1145 <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
store i8* %6, i8** %5
%7 = load i64, i64* %4
%8 = icmp ne i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
br label %31
10: ; preds = %2
br label %11
11: ; preds = %25, %10
%12 = load i64, i64* %4
%13 = add i64 %12, -1
store i64 %13, i64* %4
%14 = icmp ne i64 %12, 0
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = call i64 @isprint(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
br label %25
24: ; preds = %15
br label %25
25: ; preds = %24, %20
%26 = phi i32 [ %23, %20 ], [ 46, %24 ]
%27 = trunc i32 %26 to i8
%28 = call i32 @putchar(i8 signext %27)
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %5
br label %11
31: ; preds = %9, %11
ret void
}

LLVM IR (-O2):
define void @strdump(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %18, label %4
4: ; preds = %2, %13
%5 = phi i64 [ %7, %13 ], [ %1, %2 ]
%6 = phi i8* [ %16, %13 ], [ %0, %2 ]
%7 = add i64 %5, -1
%8 = load i8, i8* %6
%9 = tail call i64 @isprint(i8 signext %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 = tail call i32 @putchar(i8 signext %14)
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = icmp eq i64 %7, 0
br i1 %17, label %18, label %4
18: ; preds = %13, %2
ret void
}