// File: /workspace/github_c_makefile_star2_O1/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, %edi            # imm = 0x400
callq 0x4a7d10
movq %rax, %r14
movb $0x0, (%rax)
movsd 0x10(%rbx), %xmm3
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm3
xorpd %xmm1, %xmm1
jne 0x4038a4
jnp 0x4038ad
movsd 0x18(%rbx), %xmm1
divsd %xmm3, %xmm1
ucomisd %xmm2, %xmm3
jne 0x4038b5
jnp 0x40390b
movsd 0x18(%rbx), %xmm2
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 0x4038ea
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
jmp 0x40390b
movsd %xmm3, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
callq 0x47d330
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm2
leaq 0x1470be(%rip), %rdx    # 0x54a9d0
leaq 0x20(%rsp), %r15
movl $0xc8, %esi
movq %r15, %rdi
movapd %xmm3, %xmm0
movb $0x3, %al
callq 0x487370
movq %r14, %rdi
callq 0x401100
movq %rax, %r12
movq %r15, %rdi
callq 0x401100
addq %r12, %rax
movl $0x400, %r15d           # imm = 0x400
cmpq $0x401, %rax            # imm = 0x401
jb 0x403964
movl $0x800, %r15d           # imm = 0x800
movl $0x800, %esi            # imm = 0x800
movq %r14, %rdi
callq 0x4a83a0
movq %rax, %r14
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x401068
movsd 0x10(%rbx), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
xorpd %xmm0, %xmm0
jne 0x403986
jnp 0x40398a
movsd (%rbx), %xmm0
mulsd 0x146b56(%rip), %xmm1   # 0x54a4e8
movsd 0x28(%rbx), %xmm3
addsd %xmm3, %xmm2
xorl %ecx, %ecx
ucomisd %xmm1, %xmm3
jae 0x4039d2
cmpq $0x99, %rcx
je 0x403a42
movsd 0x30(%rbx,%rcx,8), %xmm3
addsd %xmm3, %xmm2
incq %rcx
ucomisd %xmm1, %xmm2
jb 0x4039a3
leaq -0x1(%rcx), %rax
cmpq $0x99, %rax
setae %al
jmp 0x4039d4
xorl %eax, %eax
testq %rcx, %rcx
je 0x4039ff
movq %rcx, %rdx
shlq $0x20, %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %rdx, %rsi
sarq $0x1d, %rsi
leaq 0x146b08(%rip), %rdx    # 0x54a500
movsd (%rsi,%rdx), %xmm4
jmp 0x403a03
xorpd %xmm4, %xmm4
leaq 0x146af6(%rip), %rdx    # 0x54a500
movsd (%rdx,%rcx,8), %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), %xmm2
maxsd %xmm5, %xmm2
movsd 0x8(%rbx), %xmm1
minsd %xmm2, %xmm1
jmp 0x403a44
movb $0x1, %al
testb %al, %al
je 0x403a4d
movsd 0x8(%rbx), %xmm1
movsd 0x8(%rbx), %xmm2
leaq 0x146fa1(%rip), %rdx    # 0x54a9fa
leaq 0x20(%rsp), %r12
movl $0xc8, %esi
movq %r12, %rdi
movb $0x3, %al
callq 0x487370
movq %r14, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq %rax, %r15
jae 0x403a99
addl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a83a0
movq %rax, %r14
leaq 0x20(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x401068
movq %r14, %rdi
callq 0x401100
movq %rax, %r13
movq %r12, %rdi
callq 0x401100
addq %r13, %rax
cmpq %rax, %r15
jae 0x403ad5
addl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a83a0
movq %rax, %r14
movq %r14, %rdi
callq 0x401100
movabsq $0xa2d2d2d2d2d2d, %rcx  # imm = 0xA2D2D2D2D2D2D
movq %rcx, 0x30(%r14,%rax)
movups 0x146f4b(%rip), %xmm0   # 0x54aa3e
movups %xmm0, 0x20(%r14,%rax)
movups 0x146f2e(%rip), %xmm0   # 0x54aa2e
movups %xmm0, 0x10(%r14,%rax)
movups 0x146f11(%rip), %xmm0   # 0x54aa1e
movups %xmm0, (%r14,%rax)
movsd 0x1469d6(%rip), %xmm0   # 0x54a4f0
divsd 0x10(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
leaq 0x1469cd(%rip), %rax    # 0x54a500
xorpd %xmm5, %xmm5
movq %rbx, 0x18(%rsp)
movsd 0x28(%rbx,%r12,8), %xmm2
ucomisd %xmm2, %xmm0
jae 0x403c57
testq %r12, %r12
je 0x403b5b
movsd -0x8(%rax,%r12,8), %xmm0
jmp 0x403b5f
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 0x146ebe(%rip), %rdx    # 0x54aa56
movb $0x5, %al
callq 0x487370
movq %r14, %rdi
callq 0x401100
movq %rax, %rbp
movq %rbx, %rdi
callq 0x401100
addq %rbp, %rax
cmpq %rax, %r15
jae 0x403bcb
addq %r15, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a83a0
movq %rax, %r14
movq 0x18(%rsp), %rbx
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x401068
movsd 0x28(%rbx,%r12,8), %xmm0
divsd 0x10(%rbx), %xmm0
mulsd 0x146907(%rip), %xmm0   # 0x54a4f8
addsd 0x1468ef(%rip), %xmm0   # 0x54a4e8
cvttsd2si %xmm0, %ebp
movq %r14, %rdi
callq 0x401100
movslq %ebp, %rcx
addq %rcx, %rax
incq %rax
cmpq %rax, %r15
jae 0x403c24
addq %r15, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a83a0
movq %rax, %r14
testl %ebp, %ebp
jle 0x403c3b
movq %r14, %rdi
callq 0x401100
movw $0x23, (%r14,%rax)
decl %ebp
jne 0x403c28
movq %r14, %rdi
callq 0x401100
movw $0xa, (%r14,%rax)
xorpd %xmm0, %xmm0
movq %r13, %rax
movsd 0x10(%rsp), %xmm5
incq %r12
cmpq $0x9a, %r12
jne 0x403b3c
movq %r14, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq