#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 dump_hex(unsigned long long *data, int from, int to) {
  unsigned offset, print_offset = 1, col = 0;
  from /= 8;
  to = (to + 7) / 8;
  for (offset = from; offset < to; offset++) {
    if (print_offset) {
      printf("%04x: ", offset * 8);
      print_offset = 0;
    }
    printf("%016llx", data[offset]);
    col++;
    if ((col & 3) == 0) {
      printf("\n");
      print_offset = 1;
    } else {
      printf(" ");
    }
  }
  if (!print_offset)
    printf("\n");
}


x86 assembly (clang, -O0):
<dump_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11f2 <dump_hex+0xe2>
cmpl   $0x0,-0x18(%rbp)
je     1186 <dump_hex+0x76>
mov    -0x14(%rbp),%esi
shl    $0x3,%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    11d1 <dump_hex+0xc1>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    11df <dump_hex+0xcf>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <dump_hex+0xd4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <dump_hex+0x45>
cmpl   $0x0,-0x18(%rbp)
jne    120a <dump_hex+0xfa>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_hex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
lea    0x7(%rsi),%ebp
test   %esi,%esi
cmovns %esi,%ebp
sar    $0x3,%ebp
lea    0x7(%rbx),%eax
add    $0xe,%ebx
test   %eax,%eax
cmovns %eax,%ebx
sar    $0x3,%ebx
sub    %ebp,%ebx
jbe    11dc <dump_hex+0xbc>
mov    %ebp,%eax
lea    (%rdi,%rax,8),%r12
shl    $0x3,%ebp
mov    $0x1,%r14d
mov    $0xa,%r13d
xor    %r15d,%r15d
jmp    11a7 <dump_hex+0x87>
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r15,8),%rsi
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15
xor    %r14d,%r14d
test   $0x3,%r15b
sete   %r14b
mov    $0x20,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
add    $0x8,%ebp
cmp    %r15d,%ebx
je     11be <dump_hex+0x9e>
test   %r14d,%r14d
je     1170 <dump_hex+0x50>
lea    0xe4d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <dump_hex+0x50>
test   $0x3,%r15b
je     11dc <dump_hex+0xbc>
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 = [7 x i8] c"%04x: \00"
@.str.1 = [8 x i8] c"%016llx\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c" \00"
define void @dump_hex(i64* %0, i32 %1, i32 %2) {
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i64* %0, i64** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 1, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %5
%11 = sdiv i32 %10, 8
store i32 %11, i32* %5
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 7
%14 = sdiv i32 %13, 8
store i32 %14, i32* %6
%15 = load i32, i32* %5
store i32 %15, i32* %7
br label %16
16: ; preds = %44, %3
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %47
20: ; preds = %16
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %7
%25 = mul i32 %24, 8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %25)
store i32 0, i32* %8
br label %27
27: ; preds = %23, %20
%28 = load i64*, i64** %4
%29 = load i32, i32* %7
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i64, i64* %28, i64 %30
%32 = load i64, i64* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %32)
%34 = load i32, i32* %9
%35 = add i32 %34, 1
store i32 %35, i32* %9
%36 = load i32, i32* %9
%37 = and i32 %36, 3
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %8
br label %43
41: ; preds = %27
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %39
br label %44
44: ; preds = %43
%45 = load i32, i32* %7
%46 = add i32 %45, 1
store i32 %46, i32* %7
br label %16
47: ; preds = %16
%48 = load i32, i32* %8
%49 = icmp ne i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
ret void
}

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