#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int htonl(int);
int /*<<< orphan*/ stdout;
void DumpBuffer(char *buf, int len, int to_dump) {
  int i, j;
  int *ptr;
  i = ((to_dump) < ((len >> 2)) ? (to_dump) : ((len >> 2)));
  j = 0;
  {
    fprintf(stdout, "\tDUMP %d first bytes... (len=%d/dump=%d)\n\t",
            i * sizeof(int), len, to_dump);
    fflush(stdout);
  }
  for (ptr = (int *)buf; i > 0; i--, ptr++) {
    {
      fprintf(stdout, "%08x ", htonl(*ptr));
      fflush(stdout);
    };
    if (++j == 8) {
      j = 0;
      {
        fprintf(stdout, "\n\t");
        fflush(stdout);
      }
    }
  }
  {
    fprintf(stdout, "\n");
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<DumpBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    $0x2,%ecx
cmp    %ecx,%eax
jge    115e <DumpBuffer+0x2e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <DumpBuffer+0x37>
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rdx
shl    $0x2,%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    124f <DumpBuffer+0x11f>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%edx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x8,%eax
jne    1230 <DumpBuffer+0x100>
movl   $0x0,-0x18(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    1235 <DumpBuffer+0x105>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    11b0 <DumpBuffer+0x80>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DumpBuffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r8d
mov    %esi,%ecx
mov    %rdi,%r13
mov    %esi,%ebx
sar    $0x2,%ebx
cmp    %edx,%ebx
cmovg  %edx,%ebx
mov    0x2e8c(%rip),%r12
mov    (%r12),%edi
movslq %ebx,%rbp
lea    0x0(,%rbp,4),%rdx
lea    0xe96(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
test   %ebp,%ebp
jle    11ea <DumpBuffer+0xba>
add    $0x1,%ebx
lea    0xea3(%rip),%r14
xor    %r15d,%r15d
jmp    119c <DumpBuffer+0x6c>
nopl   (%rax)
add    $0x4,%r13
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jle    11ea <DumpBuffer+0xba>
mov    (%r12),%ebp
mov    0x0(%r13),%edi
call   1030 <htonl@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
add    $0x1,%r15d
cmp    $0x8,%r15d
jne    1190 <DumpBuffer+0x60>
mov    (%r12),%edi
xor    %r15d,%r15d
lea    0xe50(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
jmp    1190 <DumpBuffer+0x60>
mov    (%r12),%edi
lea    0xe3c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [43 x i8] c"\09DUMP %d first bytes... (len=%d/dump=%d)\0A\09\00"
@.str.1 = [6 x i8] c"%08x \00"
@.str.2 = [3 x i8] c"\0A\09\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @DumpBuffer(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* %5
%12 = ashr i32 %11, 2
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i32, i32* %6
br label %19
16: ; preds = %3
%17 = load i32, i32* %5
%18 = ashr i32 %17, 2
br label %19
19: ; preds = %16, %14
%20 = phi i32 [ %15, %14 ], [ %18, %16 ]
store i32 %20, i32* %7
store i32 0, i32* %8
%21 = load i32, i32* @stdout
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %24, i32 %25, i32 %26)
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = load i8*, i8** %4
%31 = bitcast i8* %30 to i32*
store i32* %31, i32** %9
br label %32
32: ; preds = %52, %19
%33 = load i32, i32* %7
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %57
35: ; preds = %32
%36 = load i32, i32* @stdout
%37 = load i32*, i32** %9
%38 = load i32, i32* %37
%39 = call i32 @htonl(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @stdout
%42 = call i32 @fflush(i32 %41)
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
%45 = icmp eq i32 %44, 8
br i1 %45, label %46, label %51
46: ; preds = %35
store i32 0, i32* %8
%47 = load i32, i32* @stdout
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* @stdout
%50 = call i32 @fflush(i32 %49)
br label %51
51: ; preds = %46, %35
br label %52
52: ; preds = %51
%53 = load i32, i32* %7
%54 = add nsw i32 %53, -1
store i32 %54, i32* %7
%55 = load i32*, i32** %9
%56 = getelementptr inbounds i32, i32* %55, i32 1
store i32* %56, i32** %9
br label %32
57: ; preds = %32
%58 = load i32, i32* @stdout
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = load i32, i32* @stdout
%61 = call i32 @fflush(i32 %60)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [43 x i8] c"\09DUMP %d first bytes... (len=%d/dump=%d)\0A\09\00"
@.str.1 = [6 x i8] c"%08x \00"
@.str.2 = [3 x i8] c"\0A\09\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @DumpBuffer(i8* nocapture %0, i32 %1, i32 %2) {
%4 = ashr i32 %1, 2
%5 = icmp sgt i32 %4, %2
%6 = select i1 %5, i32 %2, i32 %4
%7 = load i32, i32* @stdout
%8 = sext i32 %6 to i64
%9 = shl nsw i64 %8, 2
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %9, i32 %1, i32 %2)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
%13 = icmp sgt i32 %6, 0
br i1 %13, label %14, label %38
14: ; preds = %3
%15 = bitcast i8* %0 to i32*
br label %16
16: ; preds = %14, %33
%17 = phi i32* [ %36, %33 ], [ %15, %14 ]
%18 = phi i32 [ %34, %33 ], [ 0, %14 ]
%19 = phi i32 [ %35, %33 ], [ %6, %14 ]
%20 = load i32, i32* @stdout
%21 = load i32, i32* %17
%22 = tail call i32 @htonl(i32 %21)
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @stdout
%25 = tail call i32 @fflush(i32 %24)
%26 = add nsw i32 %18, 1
%27 = icmp eq i32 %26, 8
br i1 %27, label %28, label %33
28: ; preds = %16
%29 = load i32, i32* @stdout
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = tail call i32 @fflush(i32 %31)
br label %33
33: ; preds = %16, %28
%34 = phi i32 [ 0, %28 ], [ %26, %16 ]
%35 = add nsw i32 %19, -1
%36 = getelementptr inbounds i32, i32* %17, i64 1
%37 = icmp sgt i32 %19, 1
br i1 %37, label %16, label %38
38: ; preds = %33, %3
%39 = load i32, i32* @stdout
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* @stdout
%42 = tail call i32 @fflush(i32 %41)
ret void
}