#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*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ isprint(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ stderr;
void prv_output_buffer(uint8_t *buffer, int length) {
  int i;
  uint8_t array[16];
  i = 0;
  while (i < length) {
    int j;
    fprintf(stderr, "  ");
    memcpy(array, buffer + i, 16);
    for (j = 0; j < 16 && i + j < length; j++) {
      fprintf(stderr, "%02X ", array[j]);
    }
    while (j < 16) {
      fprintf(stderr, "   ");
      j++;
    }
    fprintf(stderr, "  ");
    for (j = 0; j < 16 && i + j < length; j++) {
      if (isprint(array[j]))
        fprintf(stderr, "%c ", array[j]);
      else
        fprintf(stderr, ". ");
    }
    fprintf(stderr, "\n");
    i += 16;
  }
}


x86 assembly (clang, -O0):
<prv_output_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f2 <prv_output_buffer+0x1c2>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x54(%rbp)
mov    %al,-0x55(%rbp)
jge    11ab <prv_output_buffer+0x7b>
mov    -0x10(%rbp),%eax
add    -0x54(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    11bb <prv_output_buffer+0x8b>
jmp    11e8 <prv_output_buffer+0xb8>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    118d <prv_output_buffer+0x5d>
jmp    11ed <prv_output_buffer+0xbd>
cmpl   $0x10,-0x54(%rbp)
jge    121c <prv_output_buffer+0xec>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ed <prv_output_buffer+0xbd>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x54(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x54(%rbp)
mov    %al,-0x56(%rbp)
jge    1258 <prv_output_buffer+0x128>
mov    -0x10(%rbp),%eax
add    -0x54(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x56(%rbp)
mov    -0x56(%rbp),%al
test   $0x1,%al
jne    1268 <prv_output_buffer+0x138>
jmp    12cd <prv_output_buffer+0x19d>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     12a3 <prv_output_buffer+0x173>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ba <prv_output_buffer+0x18a>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12bf <prv_output_buffer+0x18f>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    123a <prv_output_buffer+0x10a>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <prv_output_buffer+0x16>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prv_output_buffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdi,0x10(%rsp)
mov    %esi,0xc(%rsp)
test   %esi,%esi
jle    12bc <prv_output_buffer+0x18c>
movslq 0xc(%rsp),%r15
mov    $0x1,%r13d
mov    0x2e7f(%rip),%r12
lea    0xe9f(%rip),%r14
lea    0xe91(%rip),%rbx
xor    %ebp,%ebp
jmp    11a9 <prv_output_buffer+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edi
lea    0xe86(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x18(%rsp),%rbp
add    $0x10,%rbp
add    $0x10,%r13
cmp    0xc(%rsp),%ebp
jge    12bc <prv_output_buffer+0x18c>
mov    (%r12),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x10(%rsp),%rax
mov    %rbp,0x18(%rsp)
lea    (%rax,%rbp,4),%rsi
lea    0x20(%rsp),%rdi
mov    $0x10,%edx
call   1040 <memcpy@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rbp
mov    (%r12),%edi
mov    0x20(%rsp,%rax,4),%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x1(%rbp),%rax
cmp    $0xe,%rbp
ja     120a <prv_output_buffer+0xda>
mov    %r13,%rcx
add    %rbp,%rcx
cmp    %r15,%rcx
jl     11e0 <prv_output_buffer+0xb0>
cmp    $0xf,%eax
lea    0xdf2(%rip),%rbx
ja     1234 <prv_output_buffer+0x104>
mov    $0xf,%r14d
sub    %ebp,%r14d
nop
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0xffffffff,%r14d
jne    1220 <prv_output_buffer+0xf0>
mov    (%r12),%edi
lea    0xdc8(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %ebp,%ebp
lea    0xdae(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x20(%rsp,%rbp,4),%edi
call   1050 <isprint@plt>
mov    (%r12),%edi
test   %rax,%rax
je     1290 <prv_output_buffer+0x160>
mov    0x20(%rsp,%rbp,4),%edx
lea    0xd8d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    $0xe,%rbp
jbe    12a8 <prv_output_buffer+0x178>
jmp    1180 <prv_output_buffer+0x50>
nop
lea    0xd77(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    $0xe,%rbp
ja     1180 <prv_output_buffer+0x50>
mov    %r13,%rax
add    %rbp,%rax
add    $0x1,%rbp
cmp    %r15,%rax
jl     1260 <prv_output_buffer+0x130>
jmp    1180 <prv_output_buffer+0x50>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [3 x i8] c" \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [4 x i8] c"%c \00"
@.str.4 = [3 x i8] c". \00"
@.str.5 = [2 x i8] c"\0A\00"
define void @prv_output_buffer(i32* %0, i32 %1) {
%3 = alloca [16 x i32]
%4 = bitcast [16 x i32]* %3 to i8*
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %63
6: ; preds = %2
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%8 = sext i32 %1 to i64
%9 = sext i32 %1 to i64
br label %10
10: ; preds = %57, %6
%11 = phi i64 [ 0, %6 ], [ %60, %57 ]
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds i32, i32* %0, i64 %11
%15 = call i32 @memcpy(i32* %7, i32* %14, i32 16)
br label %19
16: ; preds = %19
%17 = trunc i64 %25 to i32
%18 = icmp ult i32 %17, 16
br i1 %18, label %30, label %36
19: ; preds = %10, %19
%20 = phi i64 [ 0, %10 ], [ %25, %19 ]
%21 = load i32, i32* @stderr
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %20
%23 = load i32, i32* %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %20, 1
%26 = icmp ult i64 %20, 15
%27 = add nuw nsw i64 %25, %11
%28 = icmp slt i64 %27, %8
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %19, label %16
30: ; preds = %16, %30
%31 = phi i32 [ %34, %30 ], [ %17, %16 ]
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%34 = add nuw nsw i32 %31, 1
%35 = icmp eq i32 %34, 16
br i1 %35, label %36, label %30
36: ; preds = %30, %16
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %36, %51
%40 = phi i64 [ 0, %36 ], [ %52, %51 ]
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i64 @isprint(i32 %42)
%44 = icmp eq i64 %43, 0
%45 = load i32, i32* @stderr
br i1 %44, label %49, label %46
46: ; preds = %39
%47 = load i32, i32* %41
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %51
49: ; preds = %39
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %46, %49
%52 = add nuw nsw i64 %40, 1
%53 = icmp ult i64 %40, 15
%54 = add nuw nsw i64 %52, %11
%55 = icmp slt i64 %54, %9
%56 = select i1 %53, i1 %55, i1 false
br i1 %56, label %39, label %57
57: ; preds = %51
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%60 = add nuw i64 %11, 16
%61 = trunc i64 %60 to i32
%62 = icmp slt i32 %61, %1
br i1 %62, label %10, label %63
63: ; preds = %57, %2
ret void
}