#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*/ dump_row(long, int, int *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rows_eq(int *, int *);
int /*<<< orphan*/ stdout;
void dump_buffer_to_stdout(void *buf_v, int len, int hexmode) {
  unsigned char *buf = (unsigned char *)buf_v;
  long count = 0;
  int numinrow = 0;
  int chs[16];
  int oldchs[16];
  int showed_dots = 0;
  int i;
  if (hexmode) {
    for (i = 0; i < len; i++) {
      int ch = buf[i];
      if (numinrow == 16) {
        int i;
        if (rows_eq(oldchs, chs)) {
          if (!showed_dots) {
            showed_dots = 1;
            printf("          .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. "
                   "..\n");
          }
        } else {
          showed_dots = 0;
          dump_row(count, numinrow, chs);
        }
        for (i = 0; i < 16; i++)
          oldchs[i] = chs[i];
        numinrow = 0;
      }
      count++;
      chs[numinrow++] = ch;
    }
    dump_row(count, numinrow, chs);
    if (numinrow != 0)
      printf("%08lX:\n", count);
  } else {
    fwrite(buf, 1, len, stdout);
    printf("\n");
    fflush(NULL);
  }
}


x86 assembly (clang, -O0):
<dump_buffer_to_stdout>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     12d9 <dump_buffer_to_stdout+0x189>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a8 <dump_buffer_to_stdout+0x158>
mov    -0x18(%rbp),%rax
movslq -0xb8(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0xbc(%rbp)
cmpl   $0x10,-0x24(%rbp)
jne    1271 <dump_buffer_to_stdout+0x121>
lea    -0xb0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <rows_eq@plt>
cmp    $0x0,%rax
je     120c <dump_buffer_to_stdout+0xbc>
cmpl   $0x0,-0xb4(%rbp)
jne    1207 <dump_buffer_to_stdout+0xb7>
movl   $0x1,-0xb4(%rbp)
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1226 <dump_buffer_to_stdout+0xd6>
movl   $0x0,-0xb4(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x70(%rbp),%rdx
call   1030 <dump_row@plt>
movl   $0x0,-0xc0(%rbp)
cmpl   $0x10,-0xc0(%rbp)
jge    126a <dump_buffer_to_stdout+0x11a>
movslq -0xc0(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%ecx
movslq -0xc0(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    1230 <dump_buffer_to_stdout+0xe0>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0xbc(%rbp),%ecx
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    119a <dump_buffer_to_stdout+0x4a>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x70(%rbp),%rdx
call   1030 <dump_row@plt>
cmpl   $0x0,-0x24(%rbp)
je     12d4 <dump_buffer_to_stdout+0x184>
mov    -0x20(%rbp),%rsi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    130a <dump_buffer_to_stdout+0x1ba>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    0x2cf9(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_buffer_to_stdout>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %esi,%eax
mov    %rdi,%r15
test   %edx,%edx
je     1266 <dump_buffer_to_stdout+0xf6>
test   %eax,%eax
jle    12a0 <dump_buffer_to_stdout+0x130>
mov    %eax,%r13d
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
mov    %r13,0x8(%rsp)
jmp    1203 <dump_buffer_to_stdout+0x93>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %rbp,%rdx
call   1050 <dump_row@plt>
xor    %r13d,%r13d
movaps 0x10(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
movaps 0x30(%rsp),%xmm2
movaps 0x40(%rsp),%xmm3
movaps %xmm3,0x80(%rsp)
movaps %xmm2,0x70(%rsp)
movaps %xmm1,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
xor    %ebp,%ebp
mov    %r13d,%r14d
mov    0x8(%rsp),%r13
add    $0x1,%rbx
movslq %ebp,%rax
add    $0x1,%ebp
mov    %r12d,0x10(%rsp,%rax,4)
cmp    %rbx,%r13
je     1240 <dump_buffer_to_stdout+0xd0>
movzbl (%r15,%rbx,1),%r12d
cmp    $0x10,%ebp
jne    11ef <dump_buffer_to_stdout+0x7f>
lea    0x50(%rsp),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <rows_eq@plt>
test   %rax,%rax
je     11a7 <dump_buffer_to_stdout+0x37>
mov    $0x1,%r13d
test   %r14d,%r14d
jne    11ba <dump_buffer_to_stdout+0x4a>
lea    0xdd2(%rip),%rdi
call   1040 <puts@plt>
jmp    11ba <dump_buffer_to_stdout+0x4a>
lea    0x10(%rsp),%rdx
mov    %r13,%rdi
mov    %ebp,%esi
call   1050 <dump_row@plt>
test   %ebp,%ebp
je     12ae <dump_buffer_to_stdout+0x13e>
lea    0xda6(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12ae <dump_buffer_to_stdout+0x13e>
mov    0x2d73(%rip),%rcx
mov    (%rcx),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1090 <fwrite@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <fflush@plt>
lea    0x10(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1050 <dump_row@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%08lX:\0A\00"
@stdout = global i32 0
@str = [60 x i8] c" .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. ..\00"
define void @dump_buffer_to_stdout(i8* %0, i32 %1, i32 %2) {
%4 = alloca [16 x i32]
%5 = bitcast [16 x i32]* %4 to i8*
%6 = alloca [16 x i32]
%7 = bitcast [16 x i32]* %6 to i8*
%8 = icmp eq i32 %2, 0
br i1 %8, label %51, label %9
9: ; preds = %3
%10 = icmp sgt i32 %1, 0
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%13 = call i32 @dump_row(i64 0, i32 0, i32* %12)
br label %56
14: ; preds = %9
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%16 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%17 = zext i32 %1 to i64
br label %18
18: ; preds = %14, %37
%19 = phi i64 [ 0, %14 ], [ %40, %37 ]
%20 = phi i32 [ 0, %14 ], [ %39, %37 ]
%21 = phi i32 [ 0, %14 ], [ %41, %37 ]
%22 = getelementptr inbounds i8, i8* %0, i64 %19
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %21, 16
br i1 %25, label %26, label %37
26: ; preds = %18
%27 = call i64 @rows_eq(i32* %15, i32* %16)
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = icmp eq i32 %20, 0
br i1 %30, label %31, label %35
31: ; preds = %29
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
br label %35
33: ; preds = %26
%34 = call i32 @dump_row(i64 %19, i32 16, i32* %16)
br label %35
35: ; preds = %29, %31, %33
%36 = phi i32 [ 1, %29 ], [ 1, %31 ], [ 0, %33 ]
br label %37
37: ; preds = %35, %18
%38 = phi i32 [ %21, %18 ], [ 0, %35 ]
%39 = phi i32 [ %20, %18 ], [ %36, %35 ]
%40 = add nuw nsw i64 %19, 1
%41 = add nsw i32 %38, 1
%42 = sext i32 %38 to i64
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %42
store i32 %24, i32* %43
%44 = icmp eq i64 %40, %17
br i1 %44, label %45, label %18
45: ; preds = %37
%46 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%47 = call i32 @dump_row(i64 %17, i32 %41, i32* %46)
%48 = icmp eq i32 %41, 0
br i1 %48, label %56, label %49
49: ; preds = %45
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %56
51: ; preds = %3
%52 = load i32, i32* @stdout
%53 = tail call i32 @fwrite(i8* %0, i32 1, i32 %1, i32 %52)
%54 = tail call i32 @putchar(i32 10)
%55 = tail call i32 @fflush(i32* null)
br label %56
56: ; preds = %11, %45, %49, %51
ret void
}