#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 */
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void show_char(void *buff, int len) {
  while (len--) {
    if (isprint(*(unsigned char *)buff)) {
      printf("%c", *(char *)(buff++));
    } else {
      printf(".");
      buff++;
    }
  }
}


x86 assembly (clang, -O0):
<show_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     119d <show_char+0x7d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     117e <show_char+0x5e>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <show_char+0x78>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112f <show_char+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_char>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
je     1169 <show_char+0x49>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
jmp    1153 <show_char+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %ebx,%r14d
je     1169 <show_char+0x49>
movzbl (%r15,%rbx,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1140 <show_char+0x20>
mov    $0x2e,%edi
jmp    1145 <show_char+0x25>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c".\00"
define void @show_char(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %24, %2
%6 = load i32, i32* %4
%7 = add nsw i32 %6, -1
store i32 %7, i32* %4
%8 = icmp ne i32 %6, 0
br i1 %8, label %9, label %25
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = call i64 @isprint(i8 zeroext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %24
20: ; preds = %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
br label %24
24: ; preds = %20, %14
br label %5
25: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @show_char(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %19, label %4
4: ; preds = %2, %14
%5 = phi i32 [ %7, %14 ], [ %1, %2 ]
%6 = phi i8* [ %17, %14 ], [ %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 %14, label %11
11: ; preds = %4
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
br label %14
14: ; preds = %4, %11
%15 = phi i32 [ %13, %11 ], [ 46, %4 ]
%16 = tail call i32 @putchar(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 = %14, %2
ret void
}