// File: /workspace/github_c_makefile_star2_O2/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 0x495830
movq %rax, %r15
movb $0x0, (%rax)
movsd 0x10(%rbx), %xmm3
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm3
xorpd %xmm2, %xmm2
jne 0x402f9b
jnp 0x402ff6
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 0x402fd5
sqrtsd %xmm0, %xmm2
jmp 0x402ff6
movsd %xmm3, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
callq 0x46ae50
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm2
leaq 0x1359e3(%rip), %rdx    # 0x5389e0
leaq 0x20(%rsp), %r12
movl $0xc8, %esi
movq %r12, %rdi
movapd %xmm3, %xmm0
movb $0x3, %al
callq 0x474e90
movq %r15, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq $0x401, %rax            # imm = 0x401
jb 0x403049
movl $0x800, %r14d           # imm = 0x800
movl $0x800, %esi            # imm = 0x800
movq %r15, %rdi
callq 0x495ec0
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 0x40306b
jnp 0x40306f
movsd (%rbx), %xmm0
mulsd 0x135471(%rip), %xmm1   # 0x5384e8
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpq $0x4d0, %rax            # imm = 0x4D0
je 0x40309f
movsd 0x28(%rbx,%rax), %xmm3
addsd %xmm3, %xmm2
ucomisd %xmm1, %xmm2
jae 0x4030aa
addq $0x8, %rax
incq %rcx
jmp 0x40307e
movsd 0x8(%rbx), %xmm2
movapd %xmm2, %xmm1
jmp 0x403104
testq %rax, %rax
je 0x4030bf
movl %ecx, %ecx
leaq 0x135458(%rip), %rdx    # 0x538510
movsd (%rdx,%rcx,8), %xmm4
jmp 0x4030c3
xorpd %xmm4, %xmm4
leaq 0x135446(%rip), %rcx    # 0x538510
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 0x1358ff(%rip), %rdx    # 0x538a0a
leaq 0x20(%rsp), %r12
movl $0xc8, %esi
movq %r12, %rdi
movb $0x3, %al
callq 0x474e90
movq %r15, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq %rax, %r14
jae 0x40314b
addl %r14d, %r14d
movq %r15, %rdi
movq %r14, %rsi
callq 0x495ec0
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 0x403187
addl %r14d, %r14d
movq %r15, %rdi
movq %r14, %rsi
callq 0x495ec0
movq %rax, %r15
movq %r15, %rdi
callq 0x401100
movabsq $0xa2d2d2d2d2d2d, %rcx  # imm = 0xA2D2D2D2D2D2D
movq %rcx, 0x30(%r15,%rax)
movups 0x1358a9(%rip), %xmm0   # 0x538a4e
movups %xmm0, 0x20(%r15,%rax)
movups 0x13588c(%rip), %xmm0   # 0x538a3e
movups %xmm0, 0x10(%r15,%rax)
movups 0x13586f(%rip), %xmm0   # 0x538a2e
movups %xmm0, (%r15,%rax)
movsd 0x135324(%rip), %xmm0   # 0x5384f0
divsd 0x10(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm0, %xmm0
leaq 0x13532e(%rip), %rax    # 0x538510
xorl %r12d, %r12d
xorpd %xmm5, %xmm5
movq %rbx, 0x18(%rsp)
cmpq $0x9a, %r12
je 0x40331f
movsd 0x28(%rbx,%r12,8), %xmm2
ucomisd %xmm2, %xmm0
jae 0x403317
testq %r12, %r12
je 0x40321a
movsd -0x8(%rax,%r12,8), %xmm0
jmp 0x40321e
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 0x13580f(%rip), %rdx    # 0x538a66
movb $0x5, %al
callq 0x474e90
movq %r15, %rdi
callq 0x401100
movq %rax, %rbp
movq %rbx, %rdi
callq 0x401100
addq %rbp, %rax
cmpq %rax, %r14
jae 0x40328a
addq %r14, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x495ec0
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 0x135248(%rip), %xmm0   # 0x5384f8
addsd 0x135230(%rip), %xmm0   # 0x5384e8
cvttsd2si %xmm0, %ebp
movq %r15, %rdi
callq 0x401100
movslq %ebp, %rcx
addq %rcx, %rax
incq %rax
cmpq %rax, %r14
jae 0x4032e3
addq %r14, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x495ec0
movq %rax, %r15
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
movq %r15, %rdi
callq 0x401100
subl $0x1, %ebp
jb 0x403303
movw $0x23, (%r15,%rax)
jmp 0x4032ed
movw $0xa, (%r15,%rax)
xorpd %xmm0, %xmm0
movq %r13, %rax
movsd 0x10(%rsp), %xmm5
incq %r12
jmp 0x4031ee
movq %r15, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq