#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 int uint8_t;
typedef size_t uint32_t;

/* Variables and functions */
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, ...);
void dump_data(uint8_t *data, uint32_t len) {
  uint32_t cur;
  cur = 0;
  while (cur < len) {
    printf("%02x ", data[cur]);
    cur++;
  }
  printf(" ");
  cur = 0;
  while (cur < len) {
    if (isprint(data[cur]))
      printf("%c", data[cur]);
    else
      printf(".");
    cur++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1170 <dump_data+0x50>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <dump_data+0x18>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11eb <dump_data+0xcb>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     11cc <dump_data+0xac>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11da <dump_data+0xba>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1186 <dump_data+0x66>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_data>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11a7 <dump_data+0x77>
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeb6(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <dump_data+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
test   %r14,%r14
je     11b1 <dump_data+0x81>
xor    %ebx,%ebx
jmp    1192 <dump_data+0x62>
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     11b1 <dump_data+0x81>
mov    (%r12,%rbx,4),%edi
call   1050 <isprint@plt>
test   %rax,%rax
jne    1180 <dump_data+0x50>
mov    $0x2e,%edi
jmp    1184 <dump_data+0x54>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"%02x \00"
define void @dump_data(i32* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @putchar(i32 32)
br label %28
6: ; preds = %2, %6
%7 = phi i64 [ %11, %6 ], [ 0, %2 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = add nuw i64 %7, 1
%12 = icmp eq i64 %11, %1
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = tail call i32 @putchar(i32 32)
br i1 %3, label %28, label %15
15: ; preds = %13, %23
%16 = phi i64 [ %26, %23 ], [ 0, %13 ]
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = load i32, i32* %17
%19 = tail call i64 @isprint(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %15
%22 = load i32, i32* %17
br label %23
23: ; preds = %15, %21
%24 = phi i32 [ %22, %21 ], [ 46, %15 ]
%25 = tail call i32 @putchar(i32 %24)
%26 = add nuw i64 %16, 1
%27 = icmp eq i64 %26, %1
br i1 %27, label %28, label %15
28: ; preds = %23, %4, %13
%29 = tail call i32 @putchar(i32 10)
ret void
}