#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*/ assert(int);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void dump_data_impl(const char *data, size_t size) {
  assert(data != NULL || size == 0);
  for (size_t i = 0; i < size; ++i) {
    if (isprint((unsigned char)data[i]))
      printf("%c", data[i]);
    else
      printf("\\x%02x", (unsigned char)data[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_data_impl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%al
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x19(%rbp)
jne    115b <dump_data_impl+0x2b>
cmpq   $0x0,-0x10(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e8 <dump_data_impl+0xb8>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     11b8 <dump_data_impl+0x88>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <dump_data_impl+0xa2>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d7 <dump_data_impl+0xa7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1170 <dump_data_impl+0x40>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_data_impl>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
test   %r14,%r14
je     11b2 <dump_data_impl+0x72>
lea    0xe90(%rip),%r15
xor    %ebx,%ebx
jmp    1197 <dump_data_impl+0x57>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %dil,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     11b2 <dump_data_impl+0x72>
movzbl (%r12,%rbx,1),%edi
call   1060 <isprint@plt>
movsbl (%r12,%rbx,1),%edi
test   %rax,%rax
je     1180 <dump_data_impl+0x40>
call   1030 <putchar@plt>
jmp    118e <dump_data_impl+0x4e>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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