#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*/ uint8_t;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void disassemble_data(int32_t *data, int32_t data_size) {
  uint8_t *p, *lim;
  for (p = (uint8_t *)data, lim = (uint8_t *)data + data_size; p < lim;) {
    printf("(%p) ", p);
    printf("%x\n", *(int32_t *)p);
    p += sizeof(int32_t);
  }
}


x86 assembly (clang, -O0):
<disassemble_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117d <disassemble_data+0x6d>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
jmp    113a <disassemble_data+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disassemble_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1160 <disassemble_data+0x50>
mov    %rdi,%rbx
movslq %esi,%rax
lea    (%rdi,%rax,4),%r12
lea    0xed3(%rip),%r14
lea    0xed2(%rip),%r15
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    (%rbx),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x10,%rbx
add    $0x10,%ebp
cmp    %r12,%rbx
jb     1140 <disassemble_data+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"(%p) \00"
@.str.1 = [4 x i8] c"%x\0A\00"
define void @disassemble_data(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
store i32* %7, i32** %5
%8 = load i32*, i32** %3
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
store i32* %11, i32** %6
br label %12
12: ; preds = %16, %2
%13 = load i32*, i32** %5
%14 = load i32*, i32** %6
%15 = icmp ult i32* %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32*, i32** %5
%18 = ptrtoint i32* %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %5
%24 = getelementptr inbounds i32, i32* %23, i64 4
store i32* %24, i32** %5
br label %12
25: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"(%p) \00"
@.str.1 = [4 x i8] c"%x\0A\00"
define void @disassemble_data(i32* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %15
6: ; preds = %2, %6
%7 = phi i32* [ %13, %6 ], [ %0, %2 ]
%8 = ptrtoint i32* %7 to i64
%9 = trunc i64 %8 to i32
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %7
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i32, i32* %7, i64 4
%14 = icmp ult i32* %13, %4
br i1 %14, label %6, label %15
15: ; preds = %6, %2
ret void
}