#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_frame(void *frame_addr, unsigned int frame_size) {
  unsigned int *pFrameAddr;
  unsigned long ulCount = 0;
  pFrameAddr = (unsigned int *)frame_addr;
  int i;
  frame_size /= 4;
  printf("Address = [%08x] \t    Size=[%d] \n", (unsigned int)frame_addr,
         frame_size);
  printf("********************** < Dump Start > ********************\n");
  printf(" %x ", (unsigned int)pFrameAddr);
  for (i = 0; i < frame_size; i++) {
    printf("%08X ", (unsigned int)*pFrameAddr);
    pFrameAddr++;
    ulCount++;
    if (ulCount == 8) {
      printf("\n %x ", (unsigned int)pFrameAddr);
    }
    if (ulCount > 15) {
      printf("\n %x ", (unsigned int)pFrameAddr);
      ulCount = 0;
    }
  }
  printf("\n*************************** < Dump End > "
         "**************************\n");
}


x86 assembly (clang, -O0):
<dump_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
shr    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%esi
mov    -0xc(%rbp),%edx
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1209 <dump_frame+0xf9>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x8,-0x20(%rbp)
jne    11cf <dump_frame+0xbf>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0xf,-0x20(%rbp)
jbe    11f6 <dump_frame+0xe6>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
jmp    11fb <dump_frame+0xeb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <dump_frame+0x68>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_frame>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r12
mov    %esi,%ebp
shr    $0x2,%ebp
lea    0xec3(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
lea    0xecd(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%r14d
jae    1186 <dump_frame+0x66>
lea    0xef6(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
cmp    $0x2,%ebp
mov    $0x1,%r13d
cmovae %ebp,%r13d
lea    0x4(%r12),%ebp
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11c2 <dump_frame+0xa2>
nop
lea    0xe81(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
add    $0x1,%rbx
add    $0x4,%ebp
mov    %rax,%r15
cmp    %ebx,%r13d
je     116c <dump_frame+0x4c>
mov    (%r12,%rbx,4),%esi
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%r15),%rax
mov    $0x8,%r14d
cmp    $0x8,%rax
je     11a0 <dump_frame+0x80>
cmp    $0xf,%r15
jb     11b3 <dump_frame+0x93>
xor    %r14d,%r14d
jmp    11a0 <dump_frame+0x80>

LLVM IR (-O0):
@.str = [34 x i8] c"Address = [%08x] \09 Size=[%d] \0A\00"
@.str.1 = [60 x i8] c"********************** < Dump Start > ********************\0A\00"
@.str.2 = [5 x i8] c" %x \00"
@.str.3 = [6 x i8] c"%08X \00"
@.str.4 = [6 x i8] c"\0A %x \00"
@.str.5 = [70 x i8] c"\0A*************************** < Dump End > **************************\0A\00"
define void @dump_frame(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i64 0, i64* %6
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %5
%10 = load i32, i32* %4
%11 = udiv i32 %10, 4
store i32 %11, i32* %4
%12 = load i8*, i8** %3
%13 = ptrtoint i8* %12 to i32
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32*, i32** %5
%18 = ptrtoint i32* %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %18)
store i32 0, i32* %7
br label %20
20: ; preds = %46, %2
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %49
24: ; preds = %20
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i32 1
store i32* %29, i32** %5
%30 = load i64, i64* %6
%31 = add i64 %30, 1
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = icmp eq i64 %32, 8
br i1 %33, label %34, label %38
34: ; preds = %24
%35 = load i32*, i32** %5
%36 = ptrtoint i32* %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %34, %24
%39 = load i64, i64* %6
%40 = icmp ugt i64 %39, 15
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32*, i32** %5
%43 = ptrtoint i32* %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %43)
store i64 0, i64* %6
br label %45
45: ; preds = %41, %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %20
49: ; preds = %20
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"Address = [%08x] \09 Size=[%d] \0A\00"
@.str.2 = [5 x i8] c" %x \00"
@.str.3 = [6 x i8] c"%08X \00"
@.str.4 = [6 x i8] c"\0A %x \00"
@str = [59 x i8] c"********************** < Dump Start > ********************\00"
@str.6 = [69 x i8] c"\0A*************************** < Dump End > **************************\00"
define void @dump_frame(i8* %0, i32 %1) {
%3 = lshr i32 %1, 2
%4 = ptrtoint i8* %0 to i64
%5 = trunc i64 %4 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %3)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%9 = icmp ult i32 %1, 4
br i1 %9, label %33, label %10
10: ; preds = %2
%11 = bitcast i8* %0 to i32*
%12 = call i32 @llvm.umax.i32(i32 %3, i32 1)
br label %13
13: ; preds = %10, %29
%14 = phi i32 [ %31, %29 ], [ 0, %10 ]
%15 = phi i64 [ %30, %29 ], [ 0, %10 ]
%16 = phi i32* [ %19, %29 ], [ %11, %10 ]
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i32, i32* %16, i64 1
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, 8
br i1 %21, label %24, label %22
22: ; preds = %13
%23 = icmp ugt i64 %15, 14
br i1 %23, label %24, label %29
24: ; preds = %22, %13
%25 = phi i64 [ 8, %13 ], [ 0, %22 ]
%26 = ptrtoint i32* %19 to i64
%27 = trunc i64 %26 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %24, %22
%30 = phi i64 [ %20, %22 ], [ %25, %24 ]
%31 = add nuw nsw i32 %14, 1
%32 = icmp eq i32 %31, %12
br i1 %32, label %33, label %13
33: ; preds = %29, %2
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.6, i64 0, i64 0))
ret void
}