// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelPointSet.cpp
// Function: gaps::R3SurfelPointSet::Draw(gaps::RNFlags) const
void R3SurfelPointSet::
Draw(RNFlags flags) const
{
  // Get convenient variables
  int c = flags[R3_SURFEL_COLOR_DRAW_FLAG];
  int n = flags[R3_SURFEL_NORMAL_DRAW_FLAG];
  int d = flags[R3_SURFEL_DISC_DRAW_FLAG];
  int id = flags[R3_SURFEL_IDENTIFIER_DRAW_FLAG];

  // Draw discs
  if (d) {
    const int nsides = 6;
    RNGrfxBegin(RN_GRFX_TRIANGLES);
    for (int i = 0; i < NPoints(); i++) {
      const R3SurfelPoint *point = Point(i);
      R3Point position = point->Position();
      R3Vector normal = point->Normal();
      R3Vector tangent1 = point->Tangent();
      R3Vector tangent2 = tangent1 % normal;
      double r1 = point->Radius(0);
      double r2 = point->Radius(1);
      if (r1 <= 0) r1 = 0.1;
      if (r2 <= 0) r2 = r1;
      if (c) RNLoadRgb(point->Color());
      if (id) RNLoadRgba(point->Identifier());
      else if (n) R3LoadNormal(normal);
      R3Point p[nsides];
      for (int j = 0; j < nsides; j++) {
        double angle = RN_TWO_PI*j/nsides;
        p[j] = position;
        p[j] += cos(angle) * r1 * tangent1;
        p[j] += sin(angle) * r2 * tangent2;
      }
      for (int j = 0; j < nsides; j++) {
        R3LoadPoint(position);
        R3LoadPoint(p[(j+1)%nsides]);
        R3LoadPoint(p[j]);
      }
    }
    RNGrfxEnd();
  }
  else {
    // Draw surfels with color
    RNGrfxBegin(RN_GRFX_POINTS);
    for (int i = 0; i < NPoints(); i++) {
      const R3SurfelPoint *point = Point(i);
      if (c) RNLoadRgb(point->Color());
      if (id) RNLoadRgba(point->Identifier());
      else if (n) R3LoadNormal(point->Normal());
      R3LoadPoint(point->Position());
    }
    RNGrfxEnd();
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdi, %rbx
movl %esi, %eax
shrl %eax
movl %eax, 0x8(%rsp)
movl %esi, %eax
shrl $0x2, %eax
movl %eax, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
testb $0x10, %sil
movq %rdi, 0x10(%rsp)
jne 0x34f97
xorl %edi, %edi
callq 0x13130
cmpl $0x0, 0x10(%rbx)
jle 0x35272
movq %rbx, %rcx
movl $0x8, %ebx
xorl %r14d, %r14d
leaq 0x60(%rsp), %r15
movq 0x8(%rcx), %r12
testb $0x1, 0x18(%rsp)
je 0x34ec2
movq (%r12,%rbx), %rdi
addq $0x2c, %rdi
callq 0x13660
testb $0x1, 0xc(%rsp)
jne 0x34f27
testb $0x1, 0x8(%rsp)
je 0x34f3a
movq (%r12,%rbx), %rax
movswl 0x10(%rax), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss 0xa9519(%rip), %xmm3    # 0xde400
mulss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
movswl 0x12(%rax), %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
movswl 0x14(%rax), %eax
xorps %xmm2, %xmm2
cvtsi2ss %eax, %xmm2
mulss %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
movq %r15, %rdi
callq 0x85816
movq %r15, %rdi
callq 0x13780
jmp 0x34f3a
movq (%r12,%rbx), %rax
movl 0x20(%rax), %eax
movl %eax, 0x60(%rsp)
movq %r15, %rdi
callq 0x13260
movq -0x8(%r12,%rbx), %rax
movq (%r12,%rbx), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rcx), %xmm0
addsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x4(%rcx), %xmm1
addsd 0x18(%rax), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x8(%rcx), %xmm2
addsd 0x20(%rax), %xmm2
movq %r15, %rdi
callq 0x84d7e
movq %r15, %rdi
callq 0x13150
incq %r14
movq 0x10(%rsp), %rcx
movslq 0x10(%rcx), %rax
addq $0x10, %rbx
cmpq %rax, %r14
jl 0x34eaa
jmp 0x35272
movl $0x4, %edi
callq 0x13130
cmpl $0x0, 0x10(%rbx)
jle 0x35272
leaq 0xb2856(%rip), %rax     # 0xe7808
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r14d, %r14d
leaq 0x140(%rsp), %r15
leaq 0x128(%rsp), %r13
leaq 0x110(%rsp), %rbp
leaq 0xf8(%rsp), %r12
movq 0x8(%rbx), %rbx
movq %r14, 0x28(%rsp)
shlq $0x4, %r14
movq (%rbx,%r14), %rax
movq 0x8(%rbx,%r14), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rcx), %xmm0
addsd 0x10(%rax), %xmm0
cvtss2sd 0x4(%rcx), %xmm1
addsd 0x18(%rax), %xmm1
cvtss2sd 0x8(%rcx), %xmm2
addsd 0x20(%rax), %xmm2
movq %r15, %rdi
callq 0x84d7e
movq 0x8(%rbx,%r14), %rax
movswl 0x10(%rax), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss 0xa93cb(%rip), %xmm3    # 0xde400
mulss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
movswl 0x12(%rax), %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
movswl 0x14(%rax), %eax
xorps %xmm2, %xmm2
cvtsi2ss %eax, %xmm2
mulss %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x48(%rsp), %rdi
callq 0x85816
movq 0x8(%rbx,%r14), %rax
movswl 0x16(%rax), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss 0xa937b(%rip), %xmm3    # 0xde400
mulss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
movswl 0x18(%rax), %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
movswl 0x1a(%rax), %eax
xorps %xmm2, %xmm2
cvtsi2ss %eax, %xmm2
mulss %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
movq %r13, %rdi
callq 0x85816
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x48(%rsp), %rdx
callq 0x8616a
movq 0x8(%rbx,%r14), %rdi
movd 0x1c(%rdi), %xmm0
xorps %xmm2, %xmm2
punpcklwd %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1],xmm0[2],xmm2[2],xmm0[3],xmm2[3]
cvtdq2ps %xmm0, %xmm0
mulps 0xa930a(%rip), %xmm0    # 0xde3f0
movaps %xmm0, %xmm1
cmpnleps %xmm2, %xmm1
unpcklps %xmm1, %xmm1            # xmm1 = xmm1[0,0,1,1]
movmskpd %xmm1, %eax
testb $0x1, %al
jne 0x35102
movsd 0xa9278(%rip), %xmm1    # 0xde378
jmp 0x35109
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
testb $0x2, %al
jne 0x35112
movaps %xmm1, %xmm0
jmp 0x3511a
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
testb $0x1, 0x18(%rsp)
movsd %xmm1, 0x40(%rsp)
je 0x35136
addq $0x2c, %rdi
callq 0x13660
testb $0x1, 0xc(%rsp)
jne 0x35150
testb $0x1, 0x8(%rsp)
je 0x35168
leaq 0x48(%rsp), %rdi
callq 0x13780
jmp 0x35168
addq %r14, %rbx
movq 0x8(%rbx), %rax
movl 0x20(%rax), %eax
movl %eax, 0x60(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x13260
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x60, %rdi
callq 0x84d7c
addq $0x18, %rbx
cmpq $0x90, %rbx
jne 0x3516a
leaq 0x60(%rsp), %rbx
xorl %r14d, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x30(%rsp), %xmm0
divsd 0xa91de(%rip), %xmm0    # 0xde380
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x850ec
movsd 0x20(%rsp), %xmm0
callq 0x13950
mulsd 0x40(%rsp), %xmm0
movq %r12, %rdi
movq %r13, %rsi
callq 0x861e6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x85166
movsd 0x20(%rsp), %xmm0
callq 0x13100
mulsd 0x38(%rsp), %xmm0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x861e6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x85166
incq %r14
addq $0x18, %rbx
cmpq $0x6, %r14
jne 0x3518c
movl $0x1, %r14d
leaq 0x60(%rsp), %rbx
movq %r15, %rdi
callq 0x13150
cmpq $0x6, %r14
movl $0x0, %eax
cmovneq %r14, %rax
leaq (%rax,%rax,2), %rax
leaq (%rsp,%rax,8), %rdi
addq $0x60, %rdi
callq 0x13150
movq %rbx, %rdi
callq 0x13150
addq $0x18, %rbx
incq %r14
cmpq $0x7, %r14
jne 0x3521d
movq 0x28(%rsp), %r14
incq %r14
movq 0x10(%rsp), %rbx
movslq 0x10(%rbx), %rax
cmpq %rax, %r14
jl 0x34fdf
callq 0x136a0
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop