// File: /workspace/github_cpp_makefile_star2_O1/mitchellsayer[P]FastPointCloudSegmentation/src/./point_cloud_segmenter.cc
// Function: PointCloudSegmenter::FindRuns(Scanline&)
void PointCloudSegmenter::FindRuns(Scanline& cur_scanline) {
  int i = 0;

  std::vector<Vec3>::iterator it;

  while (cur_scanline.points[i].label == -3) {
    i++;
  }

  if (i < cur_scanline.points.size() ) {
    cur_scanline.s_queue.push_back(i);

    if (i == cur_scanline.points.size() - 1){
      cur_scanline.e_queue.push_back(i);
      return;
    }

    i += 1;
  } else {
    return;
  }

  for (; i < cur_scanline.points.size(); i++) {
    Vec3* cur_p = &cur_scanline.points[i];
    Vec3* prev_p = &cur_scanline.points[i-1];

    if (cur_p->label != -3) {

      if (prev_p->label == -3) {
        //Start new run if immediately after gnd pt
        cur_scanline.s_queue.push_back(i);
        if (i == cur_scanline.points.size() - 1) {
          cur_scanline.e_queue.push_back(i);
        }
      } else {
        //check distance to prev point
        if ( (cur_scanline.points[i]).distance(cur_scanline.points[i-1]) > this->th_run ) {
          cur_scanline.e_queue.push_back(i - 1);
          cur_scanline.s_queue.push_back(i);
        }

        if (i == cur_scanline.points.size() - 1) {
            cur_scanline.e_queue.push_back(i);
        }
      }
    } else {
      //Current point is ground & previous point is not
      //then end that run
      if (prev_p->label != -3) {
        cur_scanline.e_queue.push_back(i-1);
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x48(%rsi), %rcx
leaq 0x18(%rcx), %rdx
movq $-0x1, %rax
movss 0x46fc(%rip), %xmm3     # 0x8080
movss (%rdx), %xmm0
incq %rax
addq $0x1c, %rdx
ucomiss %xmm3, %xmm0
jne 0x3996
jnp 0x3984
movl %eax, -0x2c(%rbp)
movq 0x50(%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
movabsq $0x6db6db6db6db6db7, %r13 # imm = 0x6DB6DB6DB6DB6DB7
imulq %r13, %rdx
cmpq %rax, %rdx
jbe 0x3bfe
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x39d1
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x39e5
leaq -0x2c(%rbp), %rdx
movq %rbx, %rdi
callq 0x62d2
movss 0x469b(%rip), %xmm3     # 0x8080
movslq -0x2c(%rbp), %rax
movq 0x50(%rbx), %rcx
subq 0x48(%rbx), %rcx
sarq $0x2, %rcx
imulq %r13, %rcx
decq %rcx
cmpq %rax, %rcx
jne 0x3a1e
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x3bee
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x3bfe
movslq -0x2c(%rbp), %rax
leaq 0x1(%rax), %rcx
movl %ecx, -0x2c(%rbp)
movq 0x48(%rbx), %rdx
movq 0x50(%rbx), %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
imulq %r13, %rsi
cmpq %rcx, %rsi
jbe 0x3bfe
leaq 0x18(%rbx), %r15
leaq -0x2c(%rbp), %r12
leaq (%rcx,%rcx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rcx, %rsi
movslq %eax, %r8
leaq (%r8,%r8,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %r8, %rdi
movss 0x18(%rdx,%rsi), %xmm0
ucomiss %xmm3, %xmm0
movss 0x18(%rdx,%rdi), %xmm0
jne 0x3a79
jnp 0x3a95
ucomiss %xmm3, %xmm0
jne 0x3ac2
jp 0x3ac2
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3b6b
movl %ecx, (%rsi)
jmp 0x3b61
ucomiss %xmm3, %xmm0
jne 0x3aa0
jnp 0x3bc3
movl %eax, -0x30(%rbp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
jne 0x3ba4
movq %r15, %rdi
leaq -0x30(%rbp), %rdx
callq 0x61b0
jmp 0x3bbb
addq %rdx, %rsi
addq %rdx, %rdi
movss (%rsi), %xmm1
movss 0x4(%rsi), %xmm2
subss (%rdi), %xmm1
subss 0x4(%rdi), %xmm2
movss 0x8(%rsi), %xmm0
subss 0x8(%rdi), %xmm0
mulss %xmm2, %xmm2
mulss %xmm1, %xmm1
addss %xmm2, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
ucomiss 0x4579(%rip), %xmm0     # 0x8078
jb 0x3b07
sqrtss %xmm0, %xmm0
jmp 0x3b14
callq 0x22d0
movss 0x456c(%rip), %xmm3     # 0x8080
cvtss2sd %xmm0, %xmm0
ucomisd 0x70(%r14), %xmm0
jbe 0x3b7e
movl -0x2c(%rbp), %eax
decl %eax
movl %eax, -0x34(%rbp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x3b3e
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x3b52
movq %r15, %rdi
leaq -0x34(%rbp), %rdx
callq 0x61b0
movss 0x452e(%rip), %xmm3     # 0x8080
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3b6b
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x3b7e
movq %rbx, %rdi
movq %r12, %rdx
callq 0x62d2
movss 0x4502(%rip), %xmm3     # 0x8080
movslq -0x2c(%rbp), %rax
movq 0x50(%rbx), %rcx
subq 0x48(%rbx), %rcx
sarq $0x2, %rcx
imulq %r13, %rcx
decq %rcx
cmpq %rax, %rcx
jne 0x3bc3
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x3bb0
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x3bc3
movq %r15, %rdi
movq %r12, %rdx
callq 0x62d2
movss 0x44bd(%rip), %xmm3     # 0x8080
movslq -0x2c(%rbp), %rax
movq %rax, %rcx
incq %rcx
movl %ecx, -0x2c(%rbp)
movq 0x48(%rbx), %rdx
movq 0x50(%rbx), %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
imulq %r13, %rsi
cmpq %rcx, %rsi
ja 0x3a4d
jmp 0x3bfe
addq $0x18, %rbx
leaq -0x2c(%rbp), %rdx
movq %rbx, %rdi
callq 0x62d2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop