#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;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_bytes(uint8_t *image, int offset, int uniqcount) {
  int i;
  printf("### %d unique bytes at offset 0x%.8x :\n", uniqcount, offset);
  for (i = 0; i < uniqcount; i++) {
    if (!(i % 16)) {
      printf("0x%.8x :  ", offset + i);
    }
    printf("%.2x ", image[i]);
    if ((i % 16) == 7) {
      printf(" ");
    }
    if ((i % 16) == 15) {
      printf("\n");
    }
  }
  if (uniqcount % 16) {
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e1 <dump_bytes+0xd1>
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1171 <dump_bytes+0x61>
mov    -0xc(%rbp),%esi
add    -0x14(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    11ac <dump_bytes+0x9c>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11ce <dump_bytes+0xbe>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <dump_bytes+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <dump_bytes+0x2d>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1203 <dump_bytes+0xf3>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xec6(%rip),%rdi
mov    %edx,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    11dc <dump_bytes+0xbc>
mov    0x4(%rsp),%ebp
mov    %r15d,%r13d
lea    0xed3(%rip),%r12
xor    %r14d,%r14d
jmp    1199 <dump_bytes+0x79>
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%r13,1),%esi
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx,%r14,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
je     11dc <dump_bytes+0xbc>
mov    %r14d,%r15d
and    $0xf,%r15d
je     1170 <dump_bytes+0x50>
mov    (%rbx,%r14,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xf,%r15d
je     11d0 <dump_bytes+0xb0>
cmp    $0x7,%r15d
jne    1190 <dump_bytes+0x70>
mov    $0x20,%edi
jmp    11d5 <dump_bytes+0xb5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1190 <dump_bytes+0x70>
testb  $0xf,0x4(%rsp)
je     11fb <dump_bytes+0xdb>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"### %d unique bytes at offset 0x%.8x :\0A\00"
@.str.1 = [11 x i8] c"0x%.8x : \00"
@.str.2 = [6 x i8] c"%.2x \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @dump_bytes(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %43, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %46
15: ; preds = %11
%16 = load i32, i32* %7
%17 = srem i32 %16, 16
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i32, i32* %5
%21 = load i32, i32* %7
%22 = add nsw i32 %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %19, %15
%25 = load i32*, i32** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %7
%32 = srem i32 %31, 16
%33 = icmp eq i32 %32, 7
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %24
%37 = load i32, i32* %7
%38 = srem i32 %37, 16
%39 = icmp eq i32 %38, 15
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %11
46: ; preds = %11
%47 = load i32, i32* %6
%48 = srem i32 %47, 16
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"### %d unique bytes at offset 0x%.8x :\0A\00"
@.str.1 = [11 x i8] c"0x%.8x : \00"
@.str.2 = [6 x i8] c"%.2x \00"
define void @dump_bytes(i32* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %1)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %30
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %27
%9 = phi i64 [ 0, %6 ], [ %28, %27 ]
%10 = trunc i64 %9 to i32
%11 = and i32 %10, 15
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = add nsw i32 %10, %1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i32, i32* %0, i64 %9
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %27
19: ; preds = %8
%20 = getelementptr inbounds i32, i32* %0, i64 %9
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %21)
switch i32 %11, label %27 [
i32 7, label %23
i32 15, label %25
]
23: ; preds = %19
%24 = tail call i32 @putchar(i32 32)
br label %27
25: ; preds = %19
%26 = tail call i32 @putchar(i32 10)
br label %27
27: ; preds = %13, %23, %19, %25
%28 = add nuw nsw i64 %9, 1
%29 = icmp eq i64 %28, %7
br i1 %29, label %30, label %8
30: ; preds = %27, %3
%31 = and i32 %2, 15
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 @putchar(i32 10)
br label %35
35: ; preds = %33, %30
ret void
}