#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 htonl(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void dump_buffer_32(void *buf, unsigned int len32) {
  unsigned int *ptr;
  unsigned int j = 0;
  printf("0x");
  for (ptr = (unsigned int *)buf; len32 > 0; len32--, ptr++) {
    printf("%08X", htonl(*ptr));
    if (++j == 10) {
      j = 0;
      printf("\n");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_buffer_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jbe    11b7 <dump_buffer_32+0x97>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0xa,%eax
jne    1198 <dump_buffer_32+0x78>
movl   $0x0,-0x1c(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119d <dump_buffer_32+0x7d>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    114c <dump_buffer_32+0x2c>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_buffer_32>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     1194 <dump_buffer_32+0x64>
mov    %ebp,%r12d
lea    0xeaa(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1169 <dump_buffer_32+0x39>
nop
add    $0x1,%rbx
cmp    %ebx,%r12d
je     1194 <dump_buffer_32+0x64>
mov    (%r15,%rbx,4),%edi
call   1050 <htonl@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    1160 <dump_buffer_32+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1160 <dump_buffer_32+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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