// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/histogram.c
// Function: histogram_to_string
char* histogram_to_string(Histogram* hist_) {
  size_t r_size = 1024;
  char* r = malloc(sizeof(char) * 1024);
  strcpy(r, "");
  char buf[200];
  snprintf(buf, sizeof(buf),
            "Count: %.0f  Average: %.4f  StdDiv: %.2f\n",
            hist_->num_, average(hist_), standard_deviation(hist_));
  if (r_size < strlen(r) + strlen(buf)) {
    r = realloc(r, r_size * 2);
    r_size *= 2;
  }
  strcat(r, buf);
  snprintf(buf, sizeof(buf),
            "Min: %.4f  Median: %.4f  Max: %.4f\n",
            (hist_->num_ == 0.0 ? 0.0 : hist_->min_),
            median(hist_), hist_->max_);
  if (r_size < strlen(r) + strlen(buf)) {
    r = realloc(r, r_size * 2);
    r_size *= 2;
  }
  strcat(r, buf);
  if (r_size < strlen(r) + strlen(buf)) {
    r = realloc(r, r_size * 2);
    r_size *= 2;
  }
  strcat(r, "------------------------------------------------------\n");
  const double mult = 100.0 / hist_->num_;
  double sum = 0;
  for (int b = 0; b < kNumBuckets; b++) {
    if (hist_->buckets_[b] <= 0.0) continue;
    sum += hist_->buckets_[b];
    snprintf(buf, sizeof(buf),
              "[ %7.0f, %7.0f ) %7.0f %7.3f%% %7.3f%%",
              ((b == 0) ? 0.0 : bucket_limit[b - 1]),
              bucket_limit[b],
              hist_->buckets_[b],
              mult * hist_->buckets_[b],
              mult * sum);
    if (r_size < strlen(r) + strlen(buf)) {
      r = realloc(r, r_size * 2);
      r_size *= 2;
    }
    strcat(r, buf);

    /* Add hash marks based on percentage; 20 marks for 100%. */
    int marks = (int)(20 * (hist_->buckets_[b] / hist_->num_) + 0.5);
    if (r_size < strlen(r) + marks + 1) {
      r = realloc(r, r_size * 2);
      r_size *= 2;
    }
    for (int i = 0; i < marks; i++)
      strcat(r, "#");
    strcat(r, "\n");
  }
  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq $0x400, -0x10(%rbp)     # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x4d4850
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x19c72d(%rip), %rsi    # 0x59ff0d
callq 0x401020
leaq -0xe0(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x118(%rbp)
movq -0x8(%rbp), %rdi
callq 0x403cb0
movsd %xmm0, -0x120(%rbp)
movq -0x8(%rbp), %rdi
callq 0x403d00
movq -0x128(%rbp), %rdi
movsd -0x120(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x118(%rbp), %xmm0
movl $0xc8, %esi
leaq 0x1741dc(%rip), %rdx    # 0x577a20
movb $0x3, %al
callq 0x4b4180
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4010f8
movq %rax, -0x110(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4010f8
movq -0x110(%rbp), %rcx
movq %rax, %rdx
movq -0x108(%rbp), %rax
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x4038aa
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
shlq %rsi
callq 0x4d4ee0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
shlq %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x401060
leaq -0xe0(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4038e9
jp 0x4038e9
xorps %xmm0, %xmm0
movsd %xmm0, -0x138(%rbp)
jmp 0x4038f9
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x138(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
movq -0x8(%rbp), %rdi
callq 0x403db0
movq -0x130(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x150(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm2
movl $0xc8, %esi
leaq 0x174111(%rip), %rdx    # 0x577a4a
movb $0x3, %al
callq 0x4b4180
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4010f8
movq %rax, -0x148(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4010f8
movq -0x148(%rbp), %rcx
movq %rax, %rdx
movq -0x140(%rbp), %rax
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x40399f
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
shlq %rsi
callq 0x4d4ee0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
shlq %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x401060
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4010f8
movq %rax, -0x160(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4010f8
movq -0x160(%rbp), %rcx
movq %rax, %rdx
movq -0x158(%rbp), %rax
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x403a0e
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
shlq %rsi
callq 0x4d4ee0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
shlq %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x174055(%rip), %rsi    # 0x577a6e
callq 0x401060
movq -0x8(%rbp), %rax
movsd 0x173afe(%rip), %xmm0   # 0x577528
divsd 0x10(%rax), %xmm0
movsd %xmm0, -0xe8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xf0(%rbp)
movl $0x0, -0xf4(%rbp)
cmpl $0x9a, -0xf4(%rbp)
jge 0x403ca3
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd 0x28(%rax,%rcx,8), %xmm0
jb 0x403a77
jmp 0x403c8f
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movsd 0x28(%rax,%rcx,8), %xmm0
addsd -0xf0(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x168(%rbp)
cmpl $0x0, -0xf4(%rbp)
jne 0x403abc
xorps %xmm0, %xmm0
movsd %xmm0, -0x170(%rbp)
jmp 0x403adc
movl -0xf4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x173a81(%rip), %rax    # 0x577550
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x170(%rbp)
movq -0x168(%rbp), %rdi
movsd -0x170(%rbp), %xmm0
movslq -0xf4(%rbp), %rcx
leaq 0x173a57(%rip), %rax    # 0x577550
movsd (%rax,%rcx,8), %xmm1
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movsd 0x28(%rax,%rcx,8), %xmm2
movsd -0xe8(%rbp), %xmm3
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
mulsd 0x28(%rax,%rcx,8), %xmm3
movsd -0xe8(%rbp), %xmm4
mulsd -0xf0(%rbp), %xmm4
movl $0xc8, %esi
leaq 0x173f62(%rip), %rdx    # 0x577aa6
movb $0x5, %al
callq 0x4b4180
movq -0x10(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4010f8
movq %rax, -0x180(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4010f8
movq -0x180(%rbp), %rcx
movq %rax, %rdx
movq -0x178(%rbp), %rax
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x403baa
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
shlq %rsi
callq 0x4d4ee0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
shlq %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x401060
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movsd 0x28(%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
divsd 0x10(%rax), %xmm0
movsd 0x173954(%rip), %xmm1   # 0x577530
mulsd %xmm1, %xmm0
movsd 0x173950(%rip), %xmm1   # 0x577538
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4010f8
movq %rax, %rcx
movq -0x188(%rbp), %rax
movslq -0xf8(%rbp), %rdx
addq %rdx, %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x403c46
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
shlq %rsi
callq 0x4d4ee0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
shlq %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0xf8(%rbp), %eax
jge 0x403c7f
movq -0x18(%rbp), %rdi
leaq 0x173e64(%rip), %rsi    # 0x577acd
callq 0x401060
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x403c50
movq -0x18(%rbp), %rdi
leaq 0x17f440(%rip), %rsi    # 0x5830ca
callq 0x401060
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x403a4c
movq -0x18(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq