// File: Luthaf[P]zeopp/ray.cc
// Function: reportHistogram(std::ostream&, double, int, std::vector<ray, std::allocator<ray>>&)
void reportHistogram(ostream& output,const double binSize,const int maxBins, vector<ray>& rays)
{
  assert(binSize > threshold);
  int bins[maxBins];
  for (int i=0; i<maxBins; i++)
    {
      bins[i] = 0;
    }
  
  //Assemble Hitsogram
  int bin;
  for (unsigned int i=0; i<rays.size(); i++)
    {
      bin = rays[i].vector.magnitude()/binSize;
      if (bin >= maxBins) 
	{
	  bin = maxBins - 1;
	}
      bins[bin]++;
    }
  
  //Output Histogram
  output << "Ray Histogram - Bin Size = " << binSize << " Number of Bins: " << maxBins << "From: 0 To: " << binSize * 1.0 * maxBins<< endl;
  for (int i=0; i<maxBins; i++)
    {
      output << bins[i] << endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0x165f43(%rip), %xmm1   # 0x1f7398
ucomisd %xmm1, %xmm0
jbe 0x9145d
jmp 0x9147c
leaq 0x1662f1(%rip), %rdi    # 0x1f7755
leaq 0x165fc3(%rip), %rsi    # 0x1f742e
movl $0x57b, %edx            # imm = 0x57B
leaq 0x1662f2(%rip), %rcx    # 0x1f7769
callq 0x5320
movl -0x14(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x914cc
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x914aa
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x92090
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jae 0x91542
movq -0x20(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %esi
callq 0x92100
movq %rax, %rdi
addq $0x18, %rdi
callq 0xe9fb0
divsd -0x10(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x91526
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x914d3
movq -0x8(%rbp), %rdi
leaq 0x166264(%rip), %rsi    # 0x1f77b1
callq 0x5540
movq %rax, %rdi
movsd -0x10(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x166264(%rip), %rsi    # 0x1f77cd
callq 0x5540
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x58d0
movq %rax, %rdi
leaq 0x16625c(%rip), %rsi    # 0x1f77df
callq 0x5540
movq %rax, %rdi
movsd 0x160abd(%rip), %xmm0   # 0x1f2050
mulsd -0x10(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x5980
movq %rax, %rdi
movq 0x1e19e8(%rip), %rsi    # 0x272f98
callq 0x55b0
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x915f2
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rdi
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x58d0
movq %rax, %rdi
movq 0x1e19b6(%rip), %rsi    # 0x272f98
callq 0x55b0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x915bc
movq -0x28(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop