#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*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ stderr;
void dump_data(unsigned char *data, int len) {
  int i;
  for (i = 0; i < len; i++) {
    if (isprint(data[i]))
      fprintf(stderr, "%c", data[i]);
    else
      fprintf(stderr, "0x%02x ", (int)data[i]);
  }
}


x86 assembly (clang, -O0):
<dump_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <dump_data+0x97>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1183 <dump_data+0x63>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11a4 <dump_data+0x84>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe64(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11a9 <dump_data+0x89>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <dump_data+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    117b <dump_data+0x5b>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
mov    0x2ea2(%rip),%r12
lea    0xebe(%rip),%r13
lea    0xeb4(%rip),%rbp
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
mov    (%r12),%edi
movzbl (%r15,%rbx,1),%edx
mov    %rbp,%rsi
cmove  %r13,%rsi
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <dump_data+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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