#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(void *p, long count, unsigned long offset) {
  unsigned *d = p;
  int i;
  while (count > 0) {
    printf("%08lx:", offset);
    for (i = 0; i < 4 && count--; i++)
      printf(" %08x", *d++);
    printf("\n");
    offset += 16;
  }
}


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    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11d4 <dump_word+0xc4>
mov    -0x18(%rbp),%rsi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x4,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jge    1178 <dump_word+0x68>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1188 <dump_word+0x78>
jmp    11b5 <dump_word+0xa5>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <dump_word+0x40>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <dump_word+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %rsi,%rsi
jle    11d6 <dump_word+0xb6>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    -0x3(%rsi),%rax
mov    %rax,0x8(%rsp)
lea    -0x2(%rsi),%rax
mov    %rax,0x10(%rsp)
lea    -0x1(%rsi),%rbp
lea    0xeaa(%rip),%r13
xor    %r12d,%r12d
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15,%r12,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,%rbp
je     11e5 <dump_word+0xc5>
mov    0x4(%r15,%r12,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x10(%rsp)
je     11e5 <dump_word+0xc5>
mov    0x8(%r15,%r12,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x8(%rsp)
je     11e5 <dump_word+0xc5>
mov    0xc(%r15,%r12,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rbx
add    $0x4,%r12
cmp    %r12,%r14
jne    1160 <dump_word+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%08lx:\00"
@.str.1 = [6 x i8] c" %08x\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_word(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
br label %11
11: ; preds = %34, %3
%12 = load i64, i64* %5
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load i64, i64* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %15)
store i32 0, i32* %8
br label %17
17: ; preds = %31, %14
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i64, i64* %5
%22 = add nsw i64 %21, -1
store i64 %22, i64* %5
%23 = icmp ne i64 %21, 0
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %34
26: ; preds = %24
%27 = load i32*, i32** %7
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %7
%29 = load i32, i32* %27
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %26
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %17
34: ; preds = %24
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = load i64, i64* %6
%37 = add i64 %36, 16
store i64 %37, i64* %6
br label %11
38: ; preds = %11
ret void
}

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