// File: blackle[P]LZMA-Vizualizer/LzmaSpec.cpp
// Function: output_console(CLzmaDecoder&, double)
static int output_console(CLzmaDecoder& lzmaDecoder, double maxPerplexity) {
  ColorGradient grad;
  if (options.jet) {
    grad.createDefaultHeatMapGradient();
  } else {
    grad.createViridisHeatMapGradient();
  }

  int colWidth = 64;
  int scaleFreq = 16;
  float minForCol = 1.;
  float maxForCol = 0;
  float avgForCol = 0;

  for (int j = 0; j < lzmaDecoder.OutWindow.OutStream.Data.size(); j++) {
    if (j % colWidth == 0 && (j / colWidth)%scaleFreq == 0) {
      std::cout << grad.printScale(colWidth) << std::endl;
    }
    bool literal = lzmaDecoder.Literals[j];
    float heat = sqrt(lzmaDecoder.Perplexities[j]/maxPerplexity);
    avgForCol += heat;
    maxForCol = std::max(maxForCol, heat);
    minForCol = std::min(minForCol, heat);
    if (options.literals) heat = literal ? 1. : 0.;

    char byte = lzmaDecoder.OutWindow.OutStream.Data[j];
    if (!std::isprint(byte)) {
      byte = '.';
    }
    std::cout
      << grad.get(heat)
      // << std::setfill('0')
      // << std::setw(2)
      // << std::right
      // << std::hex
      << byte
      << realcolor::reset;
    // if (j % 16 == 16-1) {
    //   std::cout << " ";
    // }
    if (j % colWidth == colWidth-1) {
      std::cout << " "
        << grad.get(minForCol) << " "
        << grad.get(avgForCol/colWidth) << " "
        << grad.get(maxForCol) << " "
        << realcolor::reset << std::endl;
      minForCol = 1;
      maxForCol = 0;
      avgForCol = 0;
    }
  }
  std::cout << std::endl;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x6350
testb $0x1, 0xcb5d(%rip)      # 0x101c1
je 0x3684
leaq -0x28(%rbp), %rdi
callq 0x63a0
jmp 0x3671
jmp 0x3691
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3b8d
leaq -0x28(%rbp), %rdi
callq 0x64a0
jmp 0x368f
jmp 0x3691
movl $0x40, -0x38(%rbp)
movl $0x10, -0x3c(%rbp)
movss 0x795d(%rip), %xmm0     # 0xb004
movss %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
addq $0x18, %rdi
callq 0x5970
movq %rax, %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
jae 0x3b64
movl -0x4c(%rbp), %eax
cltd
idivl -0x38(%rbp)
cmpl $0x0, %edx
jne 0x3773
movl -0x4c(%rbp), %eax
cltd
idivl -0x38(%rbp)
cltd
idivl -0x3c(%rbp)
cmpl $0x0, %edx
jne 0x3773
movl -0x38(%rbp), %edx
leaq -0x70(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x65a0
jmp 0x3720
movq 0xc8a9(%rip), %rdi      # 0xffd0
leaq -0x70(%rbp), %rsi
callq 0x2130
movq %rax, -0x120(%rbp)
jmp 0x3739
movq -0x120(%rbp), %rdi
movq 0xc871(%rip), %rsi      # 0xffb8
callq 0x2190
jmp 0x374e
leaq -0x70(%rbp), %rdi
callq 0x20c0
jmp 0x3773
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x20c0
jmp 0x3b8d
movq -0x8(%rbp), %rdi
addq $0x60, %rdi
movslq -0x4c(%rbp), %rsi
callq 0x6760
movq %rdx, -0x130(%rbp)
movq %rax, -0x128(%rbp)
jmp 0x3794
movq -0x130(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x67c0
movb %al, -0x71(%rbp)
movq -0x8(%rbp), %rdi
addq $0x48, %rdi
movslq -0x4c(%rbp), %rsi
callq 0x6310
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2100
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8c(%rbp)
movss -0x8c(%rbp), %xmm1
movss -0x48(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x48(%rbp)
leaq -0x44(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x67f0
movq %rax, -0x138(%rbp)
jmp 0x381e
movq -0x138(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x44(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x6830
movq %rax, -0x140(%rbp)
jmp 0x3847
movq -0x140(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x40(%rbp)
testb $0x1, 0xc964(%rip)      # 0x101c2
je 0x38a6
movb -0x71(%rbp), %al
movsd 0x77fd(%rip), %xmm0     # 0xb068
xorps %xmm1, %xmm1
movsd %xmm1, -0x150(%rbp)
testb $0x1, %al
movsd %xmm0, -0x148(%rbp)
jne 0x3892
movsd -0x150(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
movsd -0x148(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
addq $0x18, %rdi
movslq -0x4c(%rbp), %rsi
callq 0x6330
movb (%rax), %al
movb %al, -0x8d(%rbp)
movsbl -0x8d(%rbp), %edi
callq 0x2280
cmpl $0x0, %eax
jne 0x38db
movb $0x2e, -0x8d(%rbp)
movss -0x8c(%rbp), %xmm0
leaq -0xb0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6870
jmp 0x38f5
movq 0xc6d4(%rip), %rdi      # 0xffd0
leaq -0xb0(%rbp), %rsi
callq 0x2130
movq %rax, -0x158(%rbp)
jmp 0x3911
movq -0x158(%rbp), %rdi
movsbl -0x8d(%rbp), %esi
callq 0x21a0
movq %rax, -0x160(%rbp)
jmp 0x392d
movq -0x160(%rbp), %rdi
leaq 0x30d5(%rip), %rsi      # 0x6a10
callq 0x2190
jmp 0x3942
leaq -0xb0(%rbp), %rdi
callq 0x20c0
movl -0x4c(%rbp), %eax
cltd
idivl -0x38(%rbp)
movl -0x38(%rbp), %eax
subl $0x1, %eax
cmpl %eax, %edx
jne 0x3b54
movq 0xc666(%rip), %rdi      # 0xffd0
leaq 0x783c(%rip), %rsi      # 0xb1ad
callq 0x2150
movq %rax, -0x168(%rbp)
jmp 0x397f
movss -0x40(%rbp), %xmm0
leaq -0xd0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6870
jmp 0x3996
movq -0x168(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2130
movq %rax, -0x170(%rbp)
jmp 0x39b2
movq -0x170(%rbp), %rdi
leaq 0x77ed(%rip), %rsi      # 0xb1ad
callq 0x2150
movq %rax, -0x178(%rbp)
jmp 0x39ce
movss -0x48(%rbp), %xmm0
cvtsi2ssl -0x38(%rbp), %xmm1
divss %xmm1, %xmm0
leaq -0xf0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6870
jmp 0x39ee
movq -0x178(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2130
movq %rax, -0x180(%rbp)
jmp 0x3a0a
movq -0x180(%rbp), %rdi
leaq 0x7795(%rip), %rsi      # 0xb1ad
callq 0x2150
movq %rax, -0x188(%rbp)
jmp 0x3a26
movss -0x44(%rbp), %xmm0
leaq -0x110(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6870
jmp 0x3a3d
movq -0x188(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x2130
movq %rax, -0x190(%rbp)
jmp 0x3a59
movq -0x190(%rbp), %rdi
leaq 0x7746(%rip), %rsi      # 0xb1ad
callq 0x2150
movq %rax, -0x198(%rbp)
jmp 0x3a75
movq -0x198(%rbp), %rdi
leaq 0x2f8d(%rip), %rsi      # 0x6a10
callq 0x2190
movq %rax, -0x1a0(%rbp)
jmp 0x3a91
movq -0x1a0(%rbp), %rdi
movq 0xc519(%rip), %rsi      # 0xffb8
callq 0x2190
jmp 0x3aa6
leaq -0x110(%rbp), %rdi
callq 0x20c0
leaq -0xf0(%rbp), %rdi
callq 0x20c0
leaq -0xd0(%rbp), %rdi
callq 0x20c0
movss 0x7532(%rip), %xmm0     # 0xb004
movss %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x48(%rbp)
jmp 0x3b54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x20c0
jmp 0x3b8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3b46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3b3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x20c0
leaq -0xf0(%rbp), %rdi
callq 0x20c0
leaq -0xd0(%rbp), %rdi
callq 0x20c0
jmp 0x3b8d
jmp 0x3b56
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x36c3
movq 0xc465(%rip), %rdi      # 0xffd0
movq 0xc446(%rip), %rsi      # 0xffb8
callq 0x2190
jmp 0x3b79
leaq -0x28(%rbp), %rdi
callq 0x6a40
xorl %eax, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x6a40
movq -0x30(%rbp), %rdi
callq 0x2270
nop