// File: mitchellsayer[P]FastPointCloudSegmentation/src/main.cc
// Function: main
int main() {

  int n_iters = 3;
  int n_lpr = 20;
  int n_segs = 3;
  double seed_thresh = 0.4; //meters
  double dist_thresh = 0.2; //meters

  double th_run = 0.5;
  double th_merge = 1.0;
  int x_max = 30;
  int y_max = 15;
  int n_scanlines = 50;

  std::vector<Vec3> input_cloud;
  std::vector<Vec3> predicted_ground;
  std::vector<Vec3> predicted_not_ground;
  std::vector<Vec3> predicted_clusters;

  PointCloudSegmenter segmenter(x_max, y_max, n_iters, n_lpr, n_segs, seed_thresh, dist_thresh, n_scanlines, th_run, th_merge);

  parseInput(input_cloud, segmenter);
  std::cout << "Input size: " << input_cloud.size() << std::endl;

  segmenter.GroundPlaneFitting(input_cloud);

  predicted_ground = segmenter.GetGroundPoints();
  predicted_not_ground = segmenter.GetNonGroundPoints();

  predicted_clusters = segmenter.ScanLineRun(segmenter.p_all);
  generateOutput(predicted_clusters, "predicted_clusters.txt");

  return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movl $0x0, -0x4(%rbp)
movl $0x3, -0x8(%rbp)
movl $0x14, -0xc(%rbp)
movl $0x3, -0x10(%rbp)
movabsq $0x3fd999999999999a, %rax # imm = 0x3FD999999999999A
movq %rax, -0x18(%rbp)
movabsq $0x3fc999999999999a, %rax # imm = 0x3FC999999999999A
movq %rax, -0x20(%rbp)
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, -0x28(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x30(%rbp)
movl $0x1e, -0x34(%rbp)
movl $0xf, -0x38(%rbp)
movl $0x32, -0x3c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x57b0
leaq -0x70(%rbp), %rdi
callq 0x57b0
leaq -0x88(%rbp), %rdi
callq 0x57b0
leaq -0xa0(%rbp), %rdi
callq 0x57b0
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x8(%rbp), %ecx
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movl -0x3c(%rbp), %edi
movsd -0x28(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq %rsp, %rax
movl %edi, (%rax)
leaq -0x170(%rbp), %rdi
callq 0x6eb0
jmp 0x5019
leaq -0x250(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x6fa0
jmp 0x502e
leaq -0x58(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x52e0
jmp 0x5040
leaq -0x250(%rbp), %rdi
callq 0x7110
movq 0x14f6d(%rip), %rdi     # 0x19fc0
leaq 0xd099(%rip), %rsi      # 0x120f3
callq 0x21d0
movq %rax, -0x2c8(%rbp)
jmp 0x5068
leaq -0x58(%rbp), %rdi
callq 0x5780
movq -0x2c8(%rbp), %rdi
movq %rax, %rsi
callq 0x2040
movq %rax, -0x2d0(%rbp)
jmp 0x5089
movq -0x2d0(%rbp), %rdi
movq 0x14f09(%rip), %rsi     # 0x19fa0
callq 0x2200
jmp 0x509e
leaq -0x170(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2660
jmp 0x50b0
leaq -0x268(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x7180
jmp 0x50c5
leaq -0x70(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movq %rsi, -0x2d8(%rbp)
callq 0x5fe0
movq -0x2d8(%rbp), %rdi
callq 0x5d70
leaq -0x280(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x71b0
jmp 0x50fd
leaq -0x88(%rbp), %rdi
leaq -0x280(%rbp), %rsi
movq %rsi, -0x2e0(%rbp)
callq 0x5fe0
movq -0x2e0(%rbp), %rdi
callq 0x5d70
leaq -0x140(%rbp), %rdx
leaq -0x298(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x38a0
jmp 0x513f
leaq -0xa0(%rbp), %rdi
leaq -0x298(%rbp), %rsi
movq %rsi, -0x2f0(%rbp)
callq 0x5fe0
movq -0x2f0(%rbp), %rdi
callq 0x5d70
leaq -0x2b9(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x2380
movq -0x2e8(%rbp), %rdx
leaq 0xcf7a(%rip), %rsi      # 0x12100
leaq -0x2b8(%rbp), %rdi
callq 0x71e0
jmp 0x5194
leaq -0xa0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x5520
jmp 0x51a9
leaq -0x2b8(%rbp), %rdi
callq 0x20f0
leaq -0x2b9(%rbp), %rdi
callq 0x2220
movl $0x0, -0x4(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x7110
leaq -0xa0(%rbp), %rdi
callq 0x5d70
leaq -0x88(%rbp), %rdi
callq 0x5d70
leaq -0x70(%rbp), %rdi
callq 0x5d70
leaq -0x58(%rbp), %rdi
callq 0x5d70
movl -0x4(%rbp), %eax
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x178(%rbp)
movl %eax, -0x17c(%rbp)
jmp 0x529c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x178(%rbp)
movl %eax, -0x17c(%rbp)
jmp 0x5290
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x178(%rbp)
movl %eax, -0x17c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x7110
jmp 0x5290
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x178(%rbp)
movl %eax, -0x17c(%rbp)
jmp 0x5284
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x178(%rbp)
movl %eax, -0x17c(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x20f0
leaq -0x2b9(%rbp), %rdi
callq 0x2220
leaq -0x170(%rbp), %rdi
callq 0x7110
leaq -0xa0(%rbp), %rdi
callq 0x5d70
leaq -0x88(%rbp), %rdi
callq 0x5d70
leaq -0x70(%rbp), %rdi
callq 0x5d70
leaq -0x58(%rbp), %rdi
callq 0x5d70
movq -0x178(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)