// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
movl $0x400, %r14d           # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x4a7390
movq %rax, %r15
movb $0x0, (%rax)
movsd 0x10(%rbx), %xmm3
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm3
xorpd %xmm2, %xmm2
jne 0x4038d1
jnp 0x40392f
movsd 0x18(%rbx), %xmm2
movapd %xmm2, %xmm1
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm2
movsd 0x20(%rbx), %xmm0
mulsd %xmm3, %xmm0
subsd %xmm2, %xmm0
movapd %xmm3, %xmm2
mulsd %xmm3, %xmm2
divsd %xmm2, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jb 0x40390e
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
jmp 0x40392f
movsd %xmm3, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
callq 0x47c9b0
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm2
leaq 0x1470aa(%rip), %rdx    # 0x54a9e0
leaq 0x20(%rsp), %r12
movl $0xc8, %esi
movq %r12, %rdi
movapd %xmm3, %xmm0
movb $0x3, %al
callq 0x4869f0
movq %r15, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq $0x401, %rax            # imm = 0x401
jb 0x403982
movl $0x800, %r14d           # imm = 0x800
movl $0x800, %esi            # imm = 0x800
movq %r15, %rdi
callq 0x4a7a20
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x401068
movsd 0x10(%rbx), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
xorpd %xmm0, %xmm0
jne 0x4039a4
jnp 0x4039a8
movsd (%rbx), %xmm0
mulsd 0x146b38(%rip), %xmm1   # 0x54a4e8
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movsd 0x28(%rbx,%rax), %xmm3
addsd %xmm3, %xmm2
ucomisd %xmm1, %xmm2
jae 0x4039e1
addq $0x8, %rax
incq %rcx
cmpq $0x4d0, %rax            # imm = 0x4D0
jne 0x4039b7
movsd 0x8(%rbx), %xmm2
movapd %xmm2, %xmm1
jmp 0x403a3b
testq %rax, %rax
je 0x4039f6
movl %ecx, %ecx
leaq 0x146b21(%rip), %rdx    # 0x54a510
movsd (%rdx,%rcx,8), %xmm4
jmp 0x4039fa
xorpd %xmm4, %xmm4
leaq 0x146b0f(%rip), %rcx    # 0x54a510
movsd (%rax,%rcx), %xmm5
movapd %xmm2, %xmm6
subsd %xmm3, %xmm6
subsd %xmm6, %xmm1
subsd %xmm6, %xmm2
divsd %xmm2, %xmm1
subsd %xmm4, %xmm5
mulsd %xmm1, %xmm5
addsd %xmm4, %xmm5
movsd (%rbx), %xmm3
maxsd %xmm5, %xmm3
movsd 0x8(%rbx), %xmm2
movapd %xmm2, %xmm1
minsd %xmm3, %xmm1
leaq 0x146fc8(%rip), %rdx    # 0x54aa0a
leaq 0x20(%rsp), %r12
movl $0xc8, %esi
movq %r12, %rdi
movb $0x3, %al
callq 0x4869f0
movq %r15, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq %rax, %r14
jae 0x403a82
addl %r14d, %r14d
movq %r15, %rdi
movq %r14, %rsi
callq 0x4a7a20
movq %rax, %r15
leaq 0x20(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x401068
movq %r15, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq %rax, %r14
jae 0x403abe
addl %r14d, %r14d
movq %r15, %rdi
movq %r14, %rsi
callq 0x4a7a20
movq %rax, %r15
movq %r15, %rdi
callq 0x401100
movabsq $0xa2d2d2d2d2d2d, %rcx  # imm = 0xA2D2D2D2D2D2D
movq %rcx, 0x30(%r15,%rax)
movups 0x146f72(%rip), %xmm0   # 0x54aa4e
movups %xmm0, 0x20(%r15,%rax)
movups 0x146f55(%rip), %xmm0   # 0x54aa3e
movups %xmm0, 0x10(%r15,%rax)
movups 0x146f38(%rip), %xmm0   # 0x54aa2e
movups %xmm0, (%r15,%rax)
movsd 0x1469ed(%rip), %xmm0   # 0x54a4f0
divsd 0x10(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
leaq 0x1469f4(%rip), %rax    # 0x54a510
xorpd %xmm5, %xmm5
movq %rbx, 0x18(%rsp)
movsd 0x28(%rbx,%r12,8), %xmm2
ucomisd %xmm2, %xmm0
jae 0x403c40
testq %r12, %r12
je 0x403b44
movsd -0x8(%rax,%r12,8), %xmm0
jmp 0x403b48
xorpd %xmm0, %xmm0
addsd %xmm2, %xmm5
movq %rax, %r13
movsd (%rax,%r12,8), %xmm1
movsd 0x8(%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd %xmm2, %xmm3
movsd %xmm5, 0x10(%rsp)
mulsd %xmm5, %xmm4
movl $0xc8, %esi
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x146ee5(%rip), %rdx    # 0x54aa66
movb $0x5, %al
callq 0x4869f0
movq %r15, %rdi
callq 0x401100
movq %rax, %rbp
movq %rbx, %rdi
callq 0x401100
addq %rbp, %rax
cmpq %rax, %r14
jae 0x403bb4
addq %r14, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x4a7a20
movq %rax, %r15
movq 0x18(%rsp), %rbx
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
callq 0x401068
movsd 0x28(%rbx,%r12,8), %xmm0
divsd 0x10(%rbx), %xmm0
mulsd 0x14691e(%rip), %xmm0   # 0x54a4f8
addsd 0x146906(%rip), %xmm0   # 0x54a4e8
cvttsd2si %xmm0, %ebp
movq %r15, %rdi
callq 0x401100
movslq %ebp, %rcx
addq %rcx, %rax
incq %rax
cmpq %rax, %r14
jae 0x403c0d
addq %r14, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x4a7a20
movq %rax, %r15
testl %ebp, %ebp
jle 0x403c24
movq %r15, %rdi
callq 0x401100
movw $0x23, (%r15,%rax)
decl %ebp
jne 0x403c11
movq %r15, %rdi
callq 0x401100
movw $0xa, (%r15,%rax)
xorpd %xmm0, %xmm0
movq %r13, %rax
movsd 0x10(%rsp), %xmm5
incq %r12
cmpq $0x9a, %r12
jne 0x403b25
movq %r15, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)