// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Utils/R3Segmentation.cpp
// Function: gaps::R3SegmentationCluster::Affinity(gaps::R3SegmentationCluster*) const
RNScalar R3SegmentationCluster::
Affinity(R3SegmentationCluster *cluster) const
{
  // Get convenient variables
  R3Segmentation *segmentation = cluster->segmentation;
  double max_pair_color_difference = (segmentation) ? segmentation->max_pair_color_difference : 0;
  double max_pair_timestamp_difference = (segmentation) ? segmentation->max_pair_timestamp_difference : 0;
  double max_pair_category_difference = (segmentation) ? segmentation->max_pair_category_difference : 0;
  double max_pair_centroid_distance = (segmentation) ? segmentation->max_pair_centroid_distance : 0;
  double max_pair_primitive_distance = (segmentation) ? segmentation->max_pair_primitive_distance : 0;
  double max_pair_normal_angle = (segmentation) ? segmentation->max_pair_normal_angle : 0;
  RNBoolean equalize_cluster_sizes = (segmentation) ? segmentation->equalize_cluster_sizes : FALSE;
  RNBoolean balance_cluster_sizes = (segmentation) ? segmentation->balance_cluster_sizes : FALSE;
  RNBoolean favor_convex_clusters = (segmentation) ? segmentation->favor_convex_clusters : FALSE;
  RNBoolean scale_tolerances_with_depth = (segmentation) ? segmentation->scale_tolerances_with_depth : FALSE;

  // Initialize affinity
  RNScalar affinity = 1;

  // Check color difference
  if (max_pair_color_difference > 0) {
    RNLength color_difference = 0;
    color_difference += fabs(color.R() - cluster->color.R());
    color_difference += fabs(color.G() - cluster->color.G());
    color_difference += fabs(color.B() - cluster->color.B());
    RNScalar color_difference_affinity = exp(color_difference * color_difference / (-2.0 * 0.25 * max_pair_color_difference * max_pair_color_difference));
    affinity *= color_difference_affinity;
    assert(affinity >= 0);
  }

  // Check timestamp difference
  if (max_pair_timestamp_difference > 0) {
    RNLength timestamp_difference = fabs(timestamp - cluster->timestamp);
    if (timestamp_difference > 0) {
      RNScalar timestamp_difference_affinity = exp(timestamp_difference * timestamp_difference / (-2.0 *  max_pair_timestamp_difference * max_pair_timestamp_difference));
      affinity *= timestamp_difference_affinity;
      assert(affinity >= 0);
    }
  }

  // Check category difference
  if (max_pair_category_difference > 0) {
    if (category_identifier != cluster->category_identifier) {
      RNScalar min_category_confidence = (category_confidence <  cluster->category_confidence) ? category_confidence : cluster->category_confidence;
      RNScalar category_difference_affinity = exp(min_category_confidence * min_category_confidence / (-2.0 * max_pair_category_difference * max_pair_category_difference));
      affinity *= category_difference_affinity;
    }
  }

  // Compute centroid distance
  if (max_pair_centroid_distance > 0) {
    RNLength centroid_distance = R3Distance(primitive.centroid, cluster->primitive.centroid);
    RNScalar centroid_distance_affinity = exp(centroid_distance * centroid_distance / (-2.0 * 0.25 * max_pair_centroid_distance * max_pair_centroid_distance));
    affinity *= centroid_distance_affinity;
    assert(affinity >= 0);
  }

  // Compute primitive distances
  if (max_pair_primitive_distance > 0) {
    // Compute point0-primitive1 distance
    RNLength primitive0_distance = primitive.Distance(cluster->primitive.centroid);
    if (seed_point && (seed_point->depth > 0) && scale_tolerances_with_depth) primitive0_distance  /= seed_point->depth;
    RNScalar primitive0_distance_affinity = exp(primitive0_distance * primitive0_distance / (-2.0 * 0.25 * max_pair_primitive_distance * max_pair_primitive_distance));
    affinity *= primitive0_distance_affinity;
    assert(affinity >= 0);

    // Compute point1-primitive0 distance
    RNLength primitive1_distance = cluster->primitive.Distance(primitive.centroid);
    if (seed_point && (seed_point->depth > 0) && scale_tolerances_with_depth) primitive1_distance  /= seed_point->depth;
    RNScalar primitive1_distance_affinity = exp(primitive1_distance * primitive1_distance / (-2.0 * 0.25 * max_pair_primitive_distance * max_pair_primitive_distance));
    affinity *= primitive1_distance_affinity;
    assert(affinity >= 0);
  }

  // Compute normal angle
  if (max_pair_normal_angle > 0) {
    if ((primitive.primitive_type == R3_SEGMENTATION_LINE_PRIMITIVE_TYPE) &&
      (cluster->primitive.primitive_type == R3_SEGMENTATION_LINE_PRIMITIVE_TYPE)) {
      RNScalar dot = fabs(primitive.line.Vector().Dot(cluster->primitive.line.Vector()));
      RNAngle normal_angle = (dot < 1) ? acos(dot) : 0;
      if (seed_point && (seed_point->depth > 0) && scale_tolerances_with_depth) normal_angle  /= seed_point->depth;
      RNScalar normal_angle_affinity = exp(normal_angle * normal_angle / (-2.0 * 0.25 * max_pair_normal_angle * max_pair_normal_angle));
      affinity *= normal_angle_affinity;
      assert(affinity >= 0);
    }
    else if ((primitive.primitive_type == R3_SEGMENTATION_PLANE_PRIMITIVE_TYPE) &&
      (cluster->primitive.primitive_type == R3_SEGMENTATION_LINE_PRIMITIVE_TYPE)) {
      RNScalar dot = fabs(primitive.plane.Normal().Dot(cluster->primitive.line.Vector()));
      RNAngle normal_angle = (dot < 1) ? RN_PI_OVER_TWO - acos(dot) : RN_PI_OVER_TWO;
      if (seed_point && (seed_point->depth > 0) && scale_tolerances_with_depth) normal_angle  /= seed_point->depth;
      RNScalar normal_angle_affinity = exp(normal_angle * normal_angle / (-2.0 * 0.25 * max_pair_normal_angle * max_pair_normal_angle));
      affinity *= normal_angle_affinity;
      assert(affinity >= 0);
    }
    else if ((primitive.primitive_type == R3_SEGMENTATION_LINE_PRIMITIVE_TYPE) &&
      (cluster->primitive.primitive_type == R3_SEGMENTATION_PLANE_PRIMITIVE_TYPE)) {
      RNScalar dot = fabs(primitive.line.Vector().Dot(cluster->primitive.plane.Normal()));
      RNAngle normal_angle = (dot < 1) ? RN_PI_OVER_TWO - acos(dot) : RN_PI_OVER_TWO;
      if (seed_point && (seed_point->depth > 0) && scale_tolerances_with_depth) normal_angle  /= seed_point->depth;
      RNScalar normal_angle_affinity = exp(normal_angle * normal_angle / (-2.0 * 0.25 * max_pair_normal_angle * max_pair_normal_angle));
      affinity *= normal_angle_affinity;
      assert(affinity >= 0);
    }
    else if ((primitive.primitive_type == R3_SEGMENTATION_PLANE_PRIMITIVE_TYPE) &&
      (cluster->primitive.primitive_type == R3_SEGMENTATION_PLANE_PRIMITIVE_TYPE)) {
      RNScalar dot = primitive.plane.Normal().Dot(cluster->primitive.plane.Normal());
      RNAngle normal_angle = (dot > -1) ? ((dot < 1) ? acos(dot) : 0) : RN_PI;
      if (seed_point && (seed_point->depth > 0) && scale_tolerances_with_depth) normal_angle  /= seed_point->depth;
      RNScalar normal_angle_affinity = exp(normal_angle * normal_angle / (-2.0 * 0.25 * max_pair_normal_angle * max_pair_normal_angle));
      affinity *= normal_angle_affinity;
      assert(affinity >= 0);
    }
  }

  // Compute fraction of points in smallest cluster
  if (equalize_cluster_sizes) {
    int segmentation_npoints = (segmentation) ? segmentation->points.NEntries() : 0;
    int segmentation_nclusters = (segmentation) ? segmentation->clusters.NEntries() : 0;
    if ((segmentation_npoints > 0) && (segmentation_nclusters > 0)) {
      int smaller_npoints = (points.NEntries() < cluster->points.NEntries()) ? points.NEntries() : cluster->points.NEntries();
      if (smaller_npoints == 0) return 0;
      RNScalar avg_points_per_cluster = (RNScalar) segmentation_npoints / (RNScalar) segmentation_nclusters;
      RNScalar balance_affinity =  avg_points_per_cluster / smaller_npoints;
      affinity *= balance_affinity;
      assert(affinity >= 0);
    }
  }
  
  // Compute relative sizes of clusters
  if (balance_cluster_sizes) {
    RNScalar balance_affinity = 1.0;
    if (points.NEntries() == 0) return 0;
    if (cluster->points.NEntries() == 0) return 0;
    if (points.NEntries() < cluster->points.NEntries()) balance_affinity = (RNScalar) points.NEntries() / (RNScalar) cluster->points.NEntries();
    else balance_affinity = (RNScalar) cluster->points.NEntries() / (RNScalar) points.NEntries();
    affinity *= balance_affinity;
    assert(affinity >= 0);
  }
  
  // Compute fraction of points in smallest cluster
  if (favor_convex_clusters) {
    RNScalar convexity_affinity = MergedConvexity(this, cluster);
    affinity *= convexity_affinity;
    assert(affinity >= 0);
  }
  
  // Just checking
  assert(affinity >= 0);

  // Return affinity
  return affinity;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x130(%rsi), %r12
xorpd %xmm6, %xmm6
xorpd %xmm1, %xmm1
testq %r12, %r12
je 0x2b986
movsd 0x98(%r12), %xmm1
testq %r12, %r12
je 0x2b995
movsd 0xa0(%r12), %xmm6
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
testq %r12, %r12
je 0x2b9ac
movsd 0xa8(%r12), %xmm5
testq %r12, %r12
je 0x2b9bb
movsd 0x80(%r12), %xmm4
xorpd %xmm0, %xmm0
xorpd %xmm2, %xmm2
testq %r12, %r12
je 0x2b9d2
movsd 0x88(%r12), %xmm2
testq %r12, %r12
je 0x2b9e1
movsd 0x90(%r12), %xmm0
movb $0x1, %r13b
movb $0x1, %bpl
testq %r12, %r12
je 0x2b9f9
cmpl $0x0, 0xc0(%r12)
sete %bpl
testq %r12, %r12
je 0x2ba0b
cmpl $0x0, 0xc4(%r12)
sete %r13b
testq %r12, %r12
je 0x2ba1f
cmpl $0x0, 0xc8(%r12)
sete %r15b
jmp 0x2ba22
movb $0x1, %r15b
testq %r12, %r12
je 0x2ba39
cmpl $0x0, 0xcc(%r12)
setne %al
movl %eax, 0x14(%rsp)
jmp 0x2ba41
movl $0x0, 0x14(%rsp)
xorpd %xmm7, %xmm7
ucomisd %xmm7, %xmm1
movsd %xmm0, 0x18(%rsp)
movsd %xmm2, 0x28(%rsp)
movsd %xmm4, 0x20(%rsp)
jbe 0x2bae9
movupd 0xf0(%r14), %xmm2
movupd 0xf0(%rbx), %xmm0
subpd %xmm0, %xmm2
movapd 0xdfaf2(%rip), %xmm3    # 0x10b570
andpd %xmm3, %xmm2
pshufd $0xee, %xmm2, %xmm4     # xmm4 = xmm2[2,3,2,3]
movsd 0x100(%r14), %xmm0
subsd 0x100(%rbx), %xmm0
addsd %xmm2, %xmm4
andpd %xmm3, %xmm0
addsd %xmm4, %xmm0
mulsd %xmm0, %xmm0
movsd 0xe0598(%rip), %xmm2    # 0x10c048
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm5, 0x30(%rsp)
movsd %xmm6, 0x8(%rsp)
callq 0x15b00
xorpd %xmm7, %xmm7
movsd 0x8(%rsp), %xmm6
movsd 0x30(%rsp), %xmm5
movsd 0x20(%rsp), %xmm4
movapd %xmm0, %xmm3
jmp 0x2baf1
movsd 0xdf55f(%rip), %xmm3    # 0x10b050
ucomisd %xmm7, %xmm6
jbe 0x2bb51
movsd 0x108(%r14), %xmm0
subsd 0x108(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
je 0x2bb51
mulsd %xmm0, %xmm0
movsd 0xe051a(%rip), %xmm1    # 0x10c038
mulsd %xmm6, %xmm1
mulsd %xmm6, %xmm1
divsd %xmm1, %xmm0
movsd %xmm3, 0x8(%rsp)
movsd %xmm5, 0x30(%rsp)
callq 0x15b00
movsd 0x30(%rsp), %xmm5
movsd 0x20(%rsp), %xmm4
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm5
jbe 0x2bbb2
movl 0x110(%r14), %eax
cmpl 0x110(%rbx), %eax
je 0x2bbb2
movsd 0x118(%r14), %xmm0
minsd 0x118(%rbx), %xmm0
mulsd %xmm0, %xmm0
movsd 0xe04b1(%rip), %xmm1    # 0x10c038
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
divsd %xmm1, %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x15b00
movsd 0x20(%rsp), %xmm4
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jbe 0x2bbfc
movl $0x80, %esi
leaq (%r14,%rsi), %rdi
addq %rbx, %rsi
movsd %xmm3, 0x8(%rsp)
callq 0x6a618
mulsd %xmm0, %xmm0
movsd 0xe046d(%rip), %xmm1    # 0x10c048
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x15b00
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
movsd 0x28(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2bcc8
movb %bpl, 0x20(%rsp)
movl %r13d, %ebp
movl %r15d, %r13d
movsd %xmm3, 0x8(%rsp)
leaq 0x40(%r14), %rdi
leaq 0x40(%rbx), %r15
leaq 0x80(%rbx), %rsi
callq 0x298b0
movq (%r14), %rax
testq %rax, %rax
je 0x2bc58
movsd (%rax), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
seta %al
andb 0x14(%rsp), %al
cmpb $0x1, %al
jne 0x2bc58
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
movsd 0xe03e4(%rip), %xmm2    # 0x10c048
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movsd %xmm2, 0x28(%rsp)
divsd %xmm2, %xmm0
callq 0x15b00
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
leaq 0x80(%r14), %rsi
movq %r15, %rdi
callq 0x298b0
movq (%r14), %rax
testq %rax, %rax
je 0x2bcd0
movsd (%rax), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
seta %al
andb 0x14(%rsp), %al
cmpb $0x1, %al
movl %r13d, %r15d
jne 0x2bcd3
divsd %xmm1, %xmm0
jmp 0x2bcd3
movsd 0x18(%rsp), %xmm0
jmp 0x2bcfe
movl %r13d, %r15d
mulsd %xmm0, %xmm0
divsd 0x28(%rsp), %xmm0
callq 0x15b00
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
movl %ebp, %r13d
movsd 0x18(%rsp), %xmm0
movb 0x20(%rsp), %bpl
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2bf18
movl 0x40(%r14), %eax
cmpl $0x2, %eax
jne 0x2bd83
cmpl $0x2, 0x40(%rbx)
jne 0x2bd83
movsd %xmm3, 0x8(%rsp)
movl $0xb0, %esi
leaq (%r14,%rsi), %rdi
addq %rbx, %rsi
callq 0xa01fe
andpd 0xdf83a(%rip), %xmm0    # 0x10b570
xorpd %xmm3, %xmm3
movsd 0xdf30e(%rip), %xmm1    # 0x10b050
ucomisd %xmm0, %xmm1
jbe 0x2bd51
callq 0x155b0
movapd %xmm0, %xmm3
movq (%r14), %rax
testq %rax, %rax
je 0x2beb1
movsd (%rax), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
andb 0x14(%rsp), %al
cmpb $0x1, %al
movsd 0x18(%rsp), %xmm2
je 0x2bee9
jmp 0x2beed
cmpl $0x3, %eax
jne 0x2bdf4
cmpl $0x2, 0x40(%rbx)
jne 0x2bdf4
movsd %xmm3, 0x8(%rsp)
leaq 0xc8(%r14), %rdi
leaq 0xb0(%rbx), %rsi
callq 0xa01fe
andpd 0xdf7c1(%rip), %xmm0    # 0x10b570
movsd 0xdf299(%rip), %xmm1    # 0x10b050
ucomisd %xmm0, %xmm1
leaq 0xe9df6(%rip), %rax     # 0x115bb8
movsd (%rax), %xmm3
jbe 0x2bddd
movsd %xmm3, 0x20(%rsp)
callq 0x155b0
movsd 0x20(%rsp), %xmm3
subsd %xmm0, %xmm3
movq (%r14), %rax
testq %rax, %rax
movsd 0x18(%rsp), %xmm2
jne 0x2bed2
jmp 0x2beed
cmpl $0x2, %eax
jne 0x2be54
cmpl $0x3, 0x40(%rbx)
jne 0x2be54
movsd %xmm3, 0x8(%rsp)
leaq 0xb0(%r14), %rdi
leaq 0xc8(%rbx), %rsi
callq 0xa01fe
andpd 0xdf750(%rip), %xmm0    # 0x10b570
movsd 0xdf228(%rip), %xmm1    # 0x10b050
ucomisd %xmm0, %xmm1
leaq 0xe9d85(%rip), %rax     # 0x115bb8
movsd (%rax), %xmm3
jbe 0x2bec4
movsd %xmm3, 0x20(%rsp)
callq 0x155b0
movsd 0x20(%rsp), %xmm3
subsd %xmm0, %xmm3
jmp 0x2bec4
cmpl $0x3, %eax
jne 0x2bf18
cmpl $0x3, 0x40(%rbx)
jne 0x2bf18
movsd %xmm3, 0x8(%rsp)
movl $0xc8, %esi
leaq (%r14,%rsi), %rdi
addq %rbx, %rsi
callq 0xa01fe
ucomisd 0xe01ca(%rip), %xmm0    # 0x10c050
jbe 0x2beb9
xorpd %xmm3, %xmm3
movsd 0xdf1bc(%rip), %xmm1    # 0x10b050
ucomisd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm2
jbe 0x2beca
callq 0x155b0
movsd 0x18(%rsp), %xmm2
movapd %xmm0, %xmm3
jmp 0x2beca
movsd 0x18(%rsp), %xmm2
jmp 0x2beed
leaq 0xe9ce8(%rip), %rax     # 0x115ba8
movsd (%rax), %xmm3
movsd 0x18(%rsp), %xmm2
movq (%r14), %rax
testq %rax, %rax
je 0x2beed
movsd (%rax), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
andb 0x14(%rsp), %al
cmpb $0x1, %al
jne 0x2beed
divsd %xmm0, %xmm3
mulsd %xmm3, %xmm3
movsd 0xe014f(%rip), %xmm0    # 0x10c048
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
divsd %xmm0, %xmm3
movapd %xmm3, %xmm0
callq 0x15b00
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
testb %bpl, %bpl
jne 0x2bf8b
xorl %eax, %eax
movl $0x0, %ecx
testq %r12, %r12
je 0x2bf2e
movl 0xc(%r12), %ecx
testq %r12, %r12
je 0x2bf38
movl 0x24(%r12), %eax
testl %ecx, %ecx
setle %sil
testl %eax, %eax
setle %dil
movb $0x1, %dl
orb %sil, %dil
jne 0x2bf7f
movl 0x14(%r14), %edx
movl 0x14(%rbx), %esi
cmpl %esi, %edx
cmovll %edx, %esi
testl %esi, %esi
setne %dl
je 0x2bf7f
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm3
xorpd %xmm0, %xmm0
testb %dl, %dl
je 0x2c159
testb %r13b, %r13b
jne 0x2bfd1
movl 0x14(%r14), %eax
testl %eax, %eax
je 0x2bfc3
movl 0x14(%rbx), %ecx
testl %ecx, %ecx
je 0x2bfc3
cmpl %ecx, %eax
movl %ecx, %edx
cmovll %eax, %edx
cmovgl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm3
movb $0x1, %al
jmp 0x2bfc5
xorl %eax, %eax
xorpd %xmm0, %xmm0
testb %al, %al
je 0x2c159
testb %r15b, %r15b
jne 0x2c155
movl 0x14(%r14), %esi
xorl %eax, %eax
movl $0x0, %ecx
movl $0x0, %edx
testl %esi, %esi
jle 0x2c062
movl %esi, %ecx
shrl $0xa, %ecx
cmpl $0x400, %esi            # imm = 0x400
movl $0x1, %edi
cmovael %ecx, %edi
movq 0x8(%r14), %r8
xorl %r9d, %r9d
xorl %edx, %edx
xorl %ecx, %ecx
movq (%r8,%r9,8), %r11
movslq 0xbc(%r11), %r10
testq %r10, %r10
jle 0x2c05a
movq 0xb0(%r11), %r11
xorl %r15d, %r15d
movq (%r11,%r15,8), %r12
movq 0xc0(%r12), %r12
xorl %ebp, %ebp
cmpq %r14, %r12
sete %bpl
setne %r13b
cmpq %rbx, %r12
sete %r12b
andb %r13b, %r12b
movzbl %r12b, %r12d
addl %r12d, %ecx
addl %ebp, %edx
incq %r15
cmpq %r15, %r10
jne 0x2c026
addq %rdi, %r9
cmpl %r9d, %esi
jg 0x2c00c
movl 0x14(%rbx), %esi
movl $0x0, %r8d
movl %esi, 0x8(%rsp)
testl %esi, %esi
jle 0x2c0ed
movl 0x8(%rsp), %esi
movl %esi, %eax
shrl $0xa, %eax
cmpl $0x400, %esi            # imm = 0x400
movl $0x1, %edi
cmovael %eax, %edi
movq 0x8(%rbx), %r9
xorl %r10d, %r10d
xorl %r8d, %r8d
xorl %eax, %eax
movq (%r9,%r10,8), %r15
movslq 0xbc(%r15), %r11
testq %r11, %r11
jle 0x2c0e3
movq 0xb0(%r15), %r15
xorl %r12d, %r12d
movq (%r15,%r12,8), %r13
movq 0xc0(%r13), %r13
xorl %ebp, %ebp
cmpq %rbx, %r13
sete %bpl
setne %sil
cmpq %r14, %r13
sete %r13b
andb %sil, %r13b
movzbl %r13b, %esi
addl %esi, %eax
addl %ebp, %r8d
incq %r12
cmpq %r12, %r11
jne 0x2c0b0
addq %rdi, %r10
cmpl %r10d, 0x8(%rsp)
jg 0x2c096
movd %r8d, %xmm0
movd %edx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd %eax, %xmm0
movd %ecx, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
paddd %xmm2, %xmm1
cvtdq2pd %xmm2, %xmm0
cvtdq2pd %xmm1, %xmm2
divpd %xmm2, %xmm0
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
xorpd %xmm2, %xmm2
pcmpgtd %xmm2, %xmm1
pand %xmm0, %xmm1
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2c140
sqrtsd %xmm0, %xmm0
jmp 0x2c151
movsd %xmm3, 0x8(%rsp)
callq 0x154d0
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm3, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq