#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_word(unsigned long ka, char *base, unsigned long size) {
  int i;
  unsigned int *p = (unsigned int *)base;
  for (i = 0; i < (size / 4); i++) {
    if (i % 8 == 0) {
      printf("\n");
      printf("0x%08x: ", ka + i * 4);
    }
    printf("%08X ", p[i]);
  }
  printf("\n\n");
}


x86 assembly (clang, -O0):
<dump_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
jae    11ae <dump_word+0x9e>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1187 <dump_word+0x77>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
cltq
add    %rax,%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <dump_word+0x23>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x4,%rdx
jae    115b <dump_word+0x2b>
lea    0xec7(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
shr    $0x2,%rbx
lea    0xe91(%rip),%r12
lea    0xe93(%rip),%r13
xor    %ebp,%ebp
jmp    1197 <dump_word+0x67>
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbp,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
je     1141 <dump_word+0x11>
test   $0x7,%bpl
jne    1180 <dump_word+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x0(,%rbp,4),%esi
add    %r15,%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1180 <dump_word+0x50>

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

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