#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(int);
int /*<<< orphan*/ printf(char *, char);
void xt_core_show_memory(void *location, unsigned short length) {
  char *char_location;
  char c;
  unsigned short each_char;
  char_location = location;
  for (each_char = 0; each_char < length; each_char++) {
    c = *(char_location + each_char);
    if (isprint((int)c)) {
      printf("%c", c);
    } else {
      printf("[%d]", c);
    }
  }
}


x86 assembly (clang, -O0):
<xt_core_show_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movw   $0x0,-0x1c(%rbp)
movzwl -0x1c(%rbp),%eax
movzwl -0xa(%rbp),%ecx
cmp    %ecx,%eax
jge    11b0 <xt_core_show_memory+0x90>
mov    -0x18(%rbp),%rax
movzwl -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     118a <xt_core_show_memory+0x6a>
lea    0xe84(%rip),%rdi
movsbl -0x19(%rbp),%esi
call   1030 <printf@plt>
jmp    119a <xt_core_show_memory+0x7a>
lea    0xe72(%rip),%rdi
movsbl -0x19(%rbp),%esi
call   1030 <printf@plt>
jmp    119f <xt_core_show_memory+0x7f>
mov    -0x1c(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1c(%rbp)
jmp    1141 <xt_core_show_memory+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xt_core_show_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1176 <xt_core_show_memory+0x56>
mov    %rdi,%r14
movzwl %si,%r15d
xor    %ebx,%ebx
lea    0xec4(%rip),%r12
lea    0xeba(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%ebp
mov    %ebp,%edi
call   1040 <isprint@plt>
test   %rax,%rax
mov    %r13,%rdi
cmove  %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <xt_core_show_memory+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"[%d]\00"
define void @xt_core_show_memory(i8* nocapture %0, i16 zeroext %1) {
%3 = icmp eq i16 %1, 0
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = zext i16 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %15, %6 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = tail call i64 @isprint(i32 %10)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%14 = tail call i32 @printf(i8* %13, i8 signext %9)
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %17, label %6
17: ; preds = %6, %2
ret void
}