#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*/ printf(char *, ...);
void printBytes(unsigned int address, unsigned int size,
                const unsigned char *data) {
  unsigned int currentAddress = address & ~0xf;
  unsigned int i;
  printf("%u bytes of data at 0x%.8x\n\n"
         "         00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"
         "--------------------------------------------------------\n",
         size, address);
  for (i = 0; i < size;) {
    printf("%.8x ", currentAddress);
    do {
      if (currentAddress < address || i >= size)
        printf(".. ");
      else
        printf("%.2x ", data[i++]);
    } while ((++currentAddress % 16) != 0);
    printf("\n");
  }
  printf("--------------------------------------------------------\n");
}


x86 assembly (clang, -O0):
<printBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffff0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11de <printBytes+0xce>
mov    -0x14(%rbp),%esi
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jb     117b <printBytes+0x6b>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jb     118e <printBytes+0x7e>
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <printBytes+0xa1>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b6 <printBytes+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
and    $0xf,%eax
cmp    $0x0,%eax
jne    1163 <printBytes+0x53>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1146 <printBytes+0x36>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%ebp
lea    0xeb6(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
je     11d7 <printBytes+0xa7>
mov    %ebp,%ebx
and    $0xfffffff0,%ebx
lea    0xf31(%rip),%r12
xor    %r13d,%r13d
jmp    117f <printBytes+0x4f>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r15d,%r13d
jae    11d7 <printBytes+0xa7>
lea    0xf09(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b2 <printBytes+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
test   $0xf,%bl
je     1170 <printBytes+0x40>
cmp    %ebp,%ebx
jb     11a0 <printBytes+0x70>
cmp    %r15d,%r13d
jae    11a0 <printBytes+0x70>
mov    %r13d,%eax
add    $0x1,%r13d
movzbl (%r14,%rax,1),%esi
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11aa <printBytes+0x7a>
lea    0xec1(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [143 x i8] c"%u bytes of data at 0x%.8x\0A\0A 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\0A--------------------------------------------------------\0A\00"
@.str.1 = [6 x i8] c"%.8x \00"
@.str.2 = [4 x i8] c".. \00"
@.str.3 = [6 x i8] c"%.2x \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [58 x i8] c"--------------------------------------------------------\0A\00"
define void @printBytes(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* %4
%10 = and i32 %9, -16
store i32 %10, i32* %7
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
store i32 0, i32* %8
br label %14
14: ; preds = %46, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %48
18: ; preds = %14
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %41, %18
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = icmp ult i32 %22, %23
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i32, i32* %8
%27 = load i32, i32* %5
%28 = icmp uge i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25, %21
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %40
31: ; preds = %25
%32 = load i8*, i8** %6
%33 = load i32, i32* %8
%34 = add i32 %33, 1
store i32 %34, i32* %8
%35 = zext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %31, %29
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add i32 %42, 1
store i32 %43, i32* %7
%44 = urem i32 %43, 16
%45 = icmp ne i32 %44, 0
br i1 %45, label %21, label %46
46: ; preds = %41
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %14
48: ; preds = %14
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [143 x i8] c"%u bytes of data at 0x%.8x\0A\0A 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\0A--------------------------------------------------------\0A\00"
@.str.1 = [6 x i8] c"%.8x \00"
@.str.2 = [4 x i8] c".. \00"
@.str.3 = [6 x i8] c"%.2x \00"
@str = [57 x i8] c"--------------------------------------------------------\00"
define void @printBytes(i32 %0, i32 %1, i8* nocapture %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %0)
%5 = icmp eq i32 %1, 0
br i1 %5, label %35, label %6
6: ; preds = %3
%7 = and i32 %0, -16
br label %8
8: ; preds = %6, %32
%9 = phi i32 [ %28, %32 ], [ 0, %6 ]
%10 = phi i32 [ %29, %32 ], [ %7, %6 ]
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %27, %8
%13 = phi i32 [ %10, %8 ], [ %29, %27 ]
%14 = phi i32 [ %9, %8 ], [ %28, %27 ]
%15 = icmp uge i32 %13, %0
%16 = icmp ult i32 %14, %1
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %27
20: ; preds = %12
%21 = add nuw i32 %14, 1
%22 = zext i32 %14 to i64
%23 = getelementptr inbounds i8, i8* %2, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %18, %20
%28 = phi i32 [ %14, %18 ], [ %21, %20 ]
%29 = add i32 %13, 1
%30 = and i32 %29, 15
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %12
32: ; preds = %27
%33 = tail call i32 @putchar(i32 10)
%34 = icmp ult i32 %28, %1
br i1 %34, label %8, label %35
35: ; preds = %32, %3
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
ret void
}