#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void hexdump_32bit(const void *data, size_t length, size_t count) {
  const uint32_t *ptr = data;
  int i;
  length /= sizeof(uint32_t);
  count /= sizeof(uint32_t);
  for (i = 0; i < length; ++i) {
    printf("%08X ", *ptr++);
  }
  for (i = length; i < count; ++i) {
    printf("         ");
  }
}


x86 assembly (clang, -O0):
<hexdump_32bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x2,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1186 <hexdump_32bit+0x76>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114b <hexdump_32bit+0x3b>
mov    -0x10(%rbp),%rax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11b7 <hexdump_32bit+0xa7>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <hexdump_32bit+0x7d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump_32bit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
shr    $0x2,%r12
shr    $0x2,%r14
cmp    $0x4,%rsi
jb     1168 <hexdump_32bit+0x58>
mov    %rdi,%r13
cmp    $0x2,%r12
mov    $0x1,%ebx
cmovae %r12,%rbx
lea    0xeba(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <hexdump_32bit+0x40>
movslq %r12d,%rax
cmp    %rax,%r14
jbe    1193 <hexdump_32bit+0x83>
movslq %r12d,%rbx
lea    0xe8c(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
ja     1180 <hexdump_32bit+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%08X \00"
@.str.1 = [10 x i8] c" \00"
define void @hexdump_32bit(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %7
%11 = load i64, i64* %5
%12 = udiv i64 %11, 4
store i64 %12, i64* %5
%13 = load i64, i64* %6
%14 = udiv i64 %13, 4
store i64 %14, i64* %6
store i32 0, i32* %8
br label %15
15: ; preds = %25, %3
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = load i64, i64* %5
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = load i32*, i32** %7
%22 = getelementptr inbounds i32, i32* %21, i32 1
store i32* %22, i32** %7
%23 = load i32, i32* %21
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %15
28: ; preds = %15
%29 = load i64, i64* %5
%30 = trunc i64 %29 to i32
store i32 %30, i32* %8
br label %31
31: ; preds = %38, %28
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = load i64, i64* %6
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %31
41: ; preds = %31
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%08X \00"
@.str.1 = [10 x i8] c" \00"
define void @hexdump_32bit(i8* nocapture %0, i64 %1, i64 %2) {
%4 = lshr i64 %1, 2
%5 = lshr i64 %2, 2
%6 = icmp ult i64 %1, 4
br i1 %6, label %18, label %7
7: ; preds = %3
%8 = bitcast i8* %0 to i32*
%9 = call i64 @llvm.umax.i64(i64 %4, i64 1)
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %16, %10 ]
%12 = phi i32* [ %8, %7 ], [ %13, %10 ]
%13 = getelementptr inbounds i32, i32* %12, i64 1
%14 = load i32, i32* %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %10, %3
%19 = shl i64 %4, 32
%20 = ashr exact i64 %19, 32
%21 = icmp ugt i64 %5, %20
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = shl i64 %4, 32
%24 = ashr exact i64 %23, 32
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ %24, %22 ], [ %28, %25 ]
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%28 = add i64 %26, 1
%29 = icmp ugt i64 %5, %28
br i1 %29, label %25, label %30
30: ; preds = %25, %18
ret void
}