#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_buff(const uint8_t *payload, unsigned payload_len,
               unsigned display_len) {
  unsigned byte;
  if ((display_len == 0) || (display_len > payload_len))
    display_len = payload_len;
  printf("---[ Len: %d  Displaying: %d "
         "]------------------------------------------\n",
         payload_len, display_len);
  for (byte = 0; byte < display_len; ++byte) {
    if (byte % 32 == 0) {
      printf("%04x: ", byte);
    }
    printf("%02x ", payload[byte]);
    if (byte % 8 == 7) {
      printf(" - ");
    }
    if (byte % 32 == 31) {
      printf("\n");
    }
  }
  if (display_len < payload_len) {
    printf("[");
    for (; (byte < display_len + 3) && (byte < payload_len); ++byte) {
      printf("%02x ", payload[byte]);
      if (byte % 32 == 31) {
        printf("\n");
      }
    }
    printf("... ]");
  }
  printf("\n------------------------------------------------------------\n");
}


x86 assembly (clang, -O0):
<dump_buff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1138 <dump_buff+0x28>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jbe    113e <dump_buff+0x2e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11ea <dump_buff+0xda>
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
cmp    $0x0,%eax
jne    1185 <dump_buff+0x75>
mov    -0x14(%rbp),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    11ba <dump_buff+0xaa>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
cmp    $0x1f,%eax
jne    11d7 <dump_buff+0xc7>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <dump_buff+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <dump_buff+0x49>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    128c <dump_buff+0x17c>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%edx
add    $0x3,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jae    1226 <dump_buff+0x116>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
setb   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1236 <dump_buff+0x126>
jmp    127e <dump_buff+0x16e>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
cmp    $0x1f,%eax
jne    126b <dump_buff+0x15b>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <dump_buff+0x160>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1204 <dump_buff+0xf4>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_buff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rdi,%rbx
lea    -0x1(%r14),%eax
cmp    %esi,%eax
cmovae %esi,%r14d
lea    0xeae(%rip),%rdi
mov    %esi,0x4(%rsp)
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
je     11da <dump_buff+0xaa>
mov    %r14d,%r12d
lea    0xee2(%rip),%rbp
xor    %r15d,%r15d
jmp    1189 <dump_buff+0x59>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
cmp    %r15,%r12
je     11da <dump_buff+0xaa>
mov    %r15d,%r13d
and    $0x1f,%r13d
jne    11a3 <dump_buff+0x73>
lea    0xeb1(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r15,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15d,%eax
not    %eax
test   $0x7,%al
jne    11c8 <dump_buff+0x98>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1f,%r13d
jne    1180 <dump_buff+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1180 <dump_buff+0x50>
mov    0x4(%rsp),%r15d
cmp    %r15d,%r14d
jae    124b <dump_buff+0x11b>
mov    $0x5b,%edi
call   1030 <putchar@plt>
cmp    $0xfffffffc,%r14d
ja     123d <dump_buff+0x10d>
mov    %r14d,%ebp
add    $0x3,%r14d
mov    %r15d,%r12d
lea    0xe4c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x1f,%al
jne    122f <dump_buff+0xff>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
jae    123d <dump_buff+0x10d>
cmp    %r12,%rbp
jb     1210 <dump_buff+0xe0>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [74 x i8] c"---[ Len: %d Displaying: %d ]------------------------------------------\0A\00"
@.str.1 = [7 x i8] c"%04x: \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c" - \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c"[\00"
@.str.6 = [6 x i8] c"... ]\00"
@.str.7 = [63 x i8] c"\0A------------------------------------------------------------\0A\00"
define void @dump_buff(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = icmp ugt i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10, %3
%15 = load i32, i32* %5
store i32 %15, i32* %6
br label %16
16: ; preds = %14, %10
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
store i32 0, i32* %7
br label %20
20: ; preds = %50, %16
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %53
24: ; preds = %20
%25 = load i32, i32* %7
%26 = urem i32 %25, 32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %24
%32 = load i32*, i32** %4
%33 = load i32, i32* %7
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %7
%39 = urem i32 %38, 8
%40 = icmp eq i32 %39, 7
br i1 %40, label %41, label %43
41: ; preds = %31
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %31
%44 = load i32, i32* %7
%45 = urem i32 %44, 32
%46 = icmp eq i32 %45, 31
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add i32 %51, 1
store i32 %52, i32* %7
br label %20
53: ; preds = %20
%54 = load i32, i32* %6
%55 = load i32, i32* %5
%56 = icmp ult i32 %54, %55
br i1 %56, label %57, label %88
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %83, %57
%60 = load i32, i32* %7
%61 = load i32, i32* %6
%62 = add i32 %61, 3
%63 = icmp ult i32 %60, %62
br i1 %63, label %64, label %68
64: ; preds = %59
%65 = load i32, i32* %7
%66 = load i32, i32* %5
%67 = icmp ult i32 %65, %66
br label %68
68: ; preds = %64, %59
%69 = phi i1 [ false, %59 ], [ %67, %64 ]
br i1 %69, label %70, label %86
70: ; preds = %68
%71 = load i32*, i32** %4
%72 = load i32, i32* %7
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %71, i64 %73
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = load i32, i32* %7
%78 = urem i32 %77, 32
%79 = icmp eq i32 %78, 31
br i1 %79, label %80, label %82
80: ; preds = %70
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %70
br label %83
83: ; preds = %82
%84 = load i32, i32* %7
%85 = add i32 %84, 1
store i32 %85, i32* %7
br label %59
86: ; preds = %68
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %88
88: ; preds = %86, %53
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [74 x i8] c"---[ Len: %d Displaying: %d ]------------------------------------------\0A\00"
@.str.1 = [7 x i8] c"%04x: \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c" - \00"
@.str.6 = [6 x i8] c"... ]\00"
@str = [62 x i8] c"\0A------------------------------------------------------------\00"
define void @dump_buff(i32* nocapture %0, i32 %1, i32 %2) {
%4 = add i32 %2, -1
%5 = icmp ult i32 %4, %1
%6 = select i1 %5, i32 %2, i32 %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %6)
%8 = icmp eq i32 %6, 0
br i1 %8, label %33, label %9
9: ; preds = %3
%10 = zext i32 %6 to i64
br label %11
11: ; preds = %9, %30
%12 = phi i64 [ 0, %9 ], [ %31, %30 ]
%13 = trunc i64 %12 to i32
%14 = and i32 %13, 31
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %18
18: ; preds = %16, %11
%19 = getelementptr inbounds i32, i32* %0, i64 %12
%20 = load i32, i32* %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = and i32 %13, 7
%23 = icmp eq i32 %22, 7
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %18
%27 = icmp eq i32 %14, 31
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call i32 @putchar(i32 10)
br label %30
30: ; preds = %26, %28
%31 = add nuw nsw i64 %12, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %33, label %11
33: ; preds = %30, %3
%34 = icmp ult i32 %6, %1
br i1 %34, label %35, label %59
35: ; preds = %33
%36 = tail call i32 @putchar(i32 91)
%37 = icmp ult i32 %6, -3
br i1 %37, label %38, label %57
38: ; preds = %35
%39 = add i32 %6, 3
%40 = zext i32 %6 to i64
%41 = zext i32 %1 to i64
%42 = zext i32 %39 to i64
br label %43
43: ; preds = %38, %52
%44 = phi i64 [ %40, %38 ], [ %53, %52 ]
%45 = getelementptr inbounds i32, i32* %0, i64 %44
%46 = load i32, i32* %45
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = and i64 %44, 31
%49 = icmp eq i64 %48, 31
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = tail call i32 @putchar(i32 10)
br label %52
52: ; preds = %43, %50
%53 = add nuw nsw i64 %44, 1
%54 = icmp ult i64 %53, %42
%55 = icmp ult i64 %53, %41
%56 = and i1 %54, %55
br i1 %56, label %43, label %57
57: ; preds = %52, %35
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %59
59: ; preds = %57, %33
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
ret void
}