#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(uint8_t *buffer, int sz) {
  int i, j;
  for (i = 0; i < sz; i++) {
    printf("%02X ", buffer[i]);
    if (i % 16 == 15) {
      for (j = 0; j < 16; j++) {
        char c = buffer[i / 16 * 16 + j];
        if (c >= 32 && c < 127) {
          printf("%c", c);
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120b <dump+0xfb>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11f8 <dump+0xe8>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11ea <dump+0xda>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
shl    $0x4,%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x20,%eax
jl     11c9 <dump+0xb9>
movsbl -0x15(%rbp),%eax
cmp    $0x7f,%eax
jge    11c9 <dump+0xb9>
movsbl -0x15(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d7 <dump+0xc7>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <dump+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <dump+0x56>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <dump+0xed>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <dump+0x16>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11cf <dump+0xaf>
mov    %rdi,%r12
mov    %esi,%r15d
lea    0xec0(%rip),%r14
mov    $0x2e,%ebp
xor    %ebx,%ebx
mov    %r15,(%rsp)
jmp    1159 <dump+0x39>
nopl   (%rax)
add    $0x1,%rbx
cmp    %r15,%rbx
je     11cf <dump+0xaf>
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1150 <dump+0x30>
mov    %r14,%r15
mov    %rbx,%rax
movabs $0x3ffffffffffffff0,%rcx
ff ff 3f
and    %rcx,%rax
mov    %r12,%r13
lea    (%r12,%rax,4),%r12
xor    %r14d,%r14d
nopl   0x0(%rax)
movzbl (%r12,%r14,4),%edi
mov    %edi,%eax
shl    $0x18,%eax
cmp    $0x7f000000,%eax
cmove  %ebp,%edi
cmp    $0x1f000001,%eax
cmovl  %ebp,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    $0x10,%r14
jne    1190 <dump+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%r14
mov    (%rsp),%r15
mov    %r13,%r12
jmp    1150 <dump+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"%02X \00"
define void @dump(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %34
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %31
%7 = phi i64 [ 0, %4 ], [ %32, %31 ]
%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 = and i64 %7, 15
%12 = icmp eq i64 %11, 15
br i1 %12, label %13, label %31
13: ; preds = %6
%14 = and i64 %7, 2147483632
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %27, %15 ]
%17 = add nuw nsw i64 %16, %14
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = shl i32 %19, 24
%21 = icmp sgt i32 %20, 520093696
%22 = icmp ne i32 %20, 2130706432
%23 = and i1 %21, %22
%24 = and i32 %19, 255
%25 = select i1 %23, i32 %24, i32 46
%26 = tail call i32 @putchar(i32 %25)
%27 = add nuw nsw i64 %16, 1
%28 = icmp eq i64 %27, 16
br i1 %28, label %29, label %15
29: ; preds = %15
%30 = tail call i32 @putchar(i32 10)
br label %31
31: ; preds = %6, %29
%32 = add nuw nsw i64 %7, 1
%33 = icmp eq i64 %32, %5
br i1 %33, label %34, label %6
34: ; preds = %31, %2
%35 = tail call i32 @putchar(i32 10)
ret void
}