// File: /workspace/github_c_makefile_star2_O2/sharpyfox[P]citrusleaf-client/src/cf_hist.c
// Function: cf_histogram_dump_new
void 
cf_histogram_dump_new( cf_histogram *h, char *outbuff, size_t outbuff_len)
{
  char printbuf[256];
  int pos = 0; // location to print from
  printbuf[0] = '\0';

  sprintf(printbuf, "histogram dump: %s (%zu total)",h->name, h->n_counts);
  if (outbuff) {
    strncat(outbuff, printbuf, outbuff_len - strlen(outbuff) - 1);
            strncat(outbuff, "  |", outbuff_len - strlen(outbuff) - 1);
  } else {
    cf_debug("%s", printbuf);
  }

  int i, j;
  int k = 0;
  for (j=CF_N_HIST_COUNTS-1 ; j >= 0 ; j-- ) if (h->count[j]) break;
  for (i=0;i<CF_N_HIST_COUNTS;i++) if (h->count[i]) break;
  for (; i<=j;i++) {
    if (h->count[i] > 0) { // print only non zero columns
      int bytes =
        sprintf((char *) (printbuf + pos), " (%02d: %010zu) ", i, h->count[i]);
      if (bytes <= 0) {
        cf_debug("histogram printing error. (bytes < 0 ) Bailing ...");
        return;
      }
      pos += bytes;
      if (k % 4 == 3){
        if (outbuff) {
          strncat(outbuff, printbuf, outbuff_len - strlen(outbuff) - 1);
          strncat(outbuff, "   ", outbuff_len - strlen(outbuff) - 1);
        } else {
          cf_debug("%s", (char *) printbuf);
        }
        pos = 0;
        printbuf[0] = '\0';
      }
      k++;
    }
  } // end for each
  if (pos > 0) {
    if (outbuff) {
      strncat(outbuff, printbuf, outbuff_len - strlen(outbuff) - 1);
    } else {
      cf_debug("%s", (char *) printbuf);
    }
  } // end if pos > 0
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %r15
leaq 0x10(%rsp), %rdi
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x527b(%rip), %rsi      # 0x143a0
xorl %eax, %eax
movb $0x0, (%rdi)
movq %r15, %rdx
movq 0x40(%r15), %rcx
callq 0x6aa0
testq %r14, %r14
je 0xf177
movq %r14, %rdi
callq 0x6280
notq %rax
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
leaq (%rax,%rbx), %rdx
callq 0x6450
movq %r14, %rdi
callq 0x6280
notq %rax
leaq 0x5256(%rip), %rsi      # 0x143bf
movq %r14, %rdi
leaq (%rax,%rbx), %rdx
callq 0x6450
jmp 0xf1a2
movq 0xae4a(%rip), %rax      # 0x19fc8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0xf1a2
movq 0xae14(%rip), %rax      # 0x19fa0
leaq 0x539b(%rip), %rsi      # 0x1452e
movq (%rax), %rcx
pushq $0x3
popq %rdi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq *%rcx
pushq $0x3f
popq %rcx
pushq $-0x1
popq %rax
testl %ecx, %ecx
js 0xf1bc
movl %ecx, %edx
cmpq $0x0, 0x48(%r15,%rdx,8)
jne 0xf1ba
decl %ecx
jmp 0xf1a8
movl %ecx, %eax
xorl %r12d, %r12d
cmpq $0x40, %r12
je 0xf1d2
cmpq $0x0, 0x48(%r15,%r12,8)
jne 0xf1d2
incq %r12
jmp 0xf1bf
movq %rbx, 0x8(%rsp)
movslq %eax, %rbp
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpq %rbp, %r12
jg 0xf2af
cmpq $0x0, 0x48(%r15,%r12,8)
je 0xf2a7
movq 0x48(%r15,%r12,8), %rcx
movl %r13d, %eax
leaq 0x51c0(%rip), %rsi      # 0x143c3
movl %r12d, %edx
leaq 0x10(%rsp,%rax), %rdi
xorl %eax, %eax
callq 0x6aa0
testl %eax, %eax
jle 0xf2db
movl %ebx, %ecx
andl $0x80000003, %ecx       # imm = 0x80000003
cmpl $0x3, %ecx
jne 0xf26d
testq %r14, %r14
je 0xf272
movq %r14, %rdi
callq 0x6280
movq 0x8(%rsp), %r13
notq %rax
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
leaq (%rax,%r13), %rdx
callq 0x6450
movq %r14, %rdi
callq 0x6280
notq %rax
movq %r14, %rdi
leaq 0x51a5(%rip), %rsi      # 0x14407
leaq (%rax,%r13), %rdx
callq 0x6450
jmp 0xf29d
addl %eax, %r13d
jmp 0xf2a5
movq 0xad4f(%rip), %rax      # 0x19fc8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0xf29d
movq 0xad19(%rip), %rax      # 0x19fa0
movq (%rax), %rcx
pushq $0x3
popq %rdi
leaq 0x529a(%rip), %rsi      # 0x1452e
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq *%rcx
xorl %r13d, %r13d
movb $0x0, 0x10(%rsp)
incl %ebx
incq %r12
jmp 0xf1df
testl %r13d, %r13d
jle 0xf32e
testq %r14, %r14
je 0xf303
movq %r14, %rdi
callq 0x6280
movq 0x8(%rsp), %rdx
notq %rax
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
addq %rax, %rdx
callq 0x6450
jmp 0xf32e
movq 0xace6(%rip), %rax      # 0x19fc8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0xf32e
movq 0xacb0(%rip), %rax      # 0x19fa0
leaq 0x50dd(%rip), %rsi      # 0x143d4
movq (%rax), %rcx
pushq $0x3
popq %rdi
xorl %eax, %eax
callq *%rcx
jmp 0xf32e
movq 0xacbe(%rip), %rax      # 0x19fc8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0xf32e
movq 0xac88(%rip), %rax      # 0x19fa0
leaq 0x520f(%rip), %rsi      # 0x1452e
movq (%rax), %rcx
pushq $0x3
popq %rdi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq *%rcx
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq