// File: /workspace/github_c_makefile_star2_O1/vlenhart[P]q3bsp/patch.cpp
// Function: PatchSurface::FillCurve(int, int, int, LightMapVertex*)
void PatchSurface::FillCurve(int numcp, int size, int stride,LightMapVertex *p)
{
  int step, halfstep, i, mid;
  LightMapVertex a,b;

  step = (size-1) / (numcp-1);

  while (step > 0)
  {
	  halfstep = step / 2;
  	for (i=0; i < size-1; i += step*2)
	  {
	    mid = (i+step)*stride;
      a.Lerp(p[i*stride],p[mid],0.5f);
      b.Lerp(p[mid],p[(i+step*2)*stride],0.5f);
      p[mid].Lerp(a,b,0.5f);

//	    vec_avg(p[i*stride], p[mid], a);
//	    vec_avg(p[mid], p[(i+step*2)*stride], b);
//	    vec_avg(a, b, p[mid]);

	    if (halfstep > 0)
	    {
		    p[(i+halfstep)*stride]   = a;
    		p[(i+3*halfstep)*stride] = b;
	    }
	  }
  	step /= 2;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, -0x48(%rbp)
movq %rdx, -0x50(%rbp)
leal -0x1(%rdx), %edi
decl %esi
movl %edi, %eax
cltd
idivl %esi
movq %rax, -0x30(%rbp)
testl %eax, %eax
jle 0x8519
movslq %edi, %rax
movq %rax, -0x68(%rbp)
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
shrl %eax
movq %rax, -0x30(%rbp)
cmpl $0x2, -0x50(%rbp)
jl 0x850f
movq -0x38(%rbp), %rdx
leal (%rdx,%rdx), %eax
movq -0x30(%rbp), %rcx
leal (%rcx,%rcx,2), %esi
movslq %eax, %rdi
movl %edx, %edx
movl %ecx, %ecx
movq -0x40(%rbp), %rax
imulq %rax, %rsi
addq $0x24, %rsi
movq %rsi, -0x60(%rbp)
movq %rax, %rsi
movq %rdi, -0x80(%rbp)
imulq %rdi, %rsi
movq %rsi, -0x70(%rbp)
imulq %rax, %rcx
addq $0x24, %rcx
movq %rcx, -0x58(%rbp)
imulq %rax, %rdx
movq %rdx, -0x78(%rbp)
movq -0x48(%rbp), %rbx
xorl %r13d, %r13d
movq -0x78(%rbp), %rax
leaq (%rbx,%rax), %r15
leaq -0xa8(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movss 0xa7d4(%rip), %xmm0     # 0x12bb8
callq 0x8584
movq -0x70(%rbp), %rax
leaq (%rbx,%rax), %r14
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movss 0xa7af(%rip), %xmm0     # 0x12bb8
callq 0x8584
movq %r15, %rdi
leaq -0xa8(%rbp), %rsi
movq %r12, %rdx
movss 0xa795(%rip), %xmm0     # 0x12bb8
callq 0x8584
cmpl $0x1, -0x38(%rbp)
je 0x84fe
movss -0xa8(%rbp), %xmm0
movq -0x58(%rbp), %rcx
movss %xmm0, -0x24(%rbx,%rcx)
movss -0xa4(%rbp), %xmm0
movss %xmm0, -0x20(%rbx,%rcx)
movss -0xa0(%rbp), %xmm0
movss %xmm0, -0x1c(%rbx,%rcx)
leaq -0x9c(%rbp), %rax
movups (%rax), %xmm0
movups %xmm0, -0x18(%rbx,%rcx)
movss -0x8c(%rbp), %xmm0
movss %xmm0, -0x8(%rbx,%rcx)
movss -0x88(%rbp), %xmm0
movss %xmm0, -0x4(%rbx,%rcx)
movss -0x84(%rbp), %xmm0
movss %xmm0, (%rbx,%rcx)
movss -0xd0(%rbp), %xmm0
movq -0x60(%rbp), %rcx
movss %xmm0, -0x24(%rbx,%rcx)
movss -0xcc(%rbp), %xmm0
movss %xmm0, -0x20(%rbx,%rcx)
movss -0xc8(%rbp), %xmm0
movss %xmm0, -0x1c(%rbx,%rcx)
leaq -0xc4(%rbp), %rax
movups (%rax), %xmm0
movups %xmm0, -0x18(%rbx,%rcx)
movss -0xb4(%rbp), %xmm0
movss %xmm0, -0x8(%rbx,%rcx)
movss -0xb0(%rbp), %xmm0
movss %xmm0, -0x4(%rbx,%rcx)
movss -0xac(%rbp), %xmm0
movss %xmm0, (%rbx,%rcx)
addq -0x80(%rbp), %r13
movq %r14, %rbx
cmpq -0x68(%rbp), %r13
jl 0x83c7
cmpl $0x2, -0x38(%rbp)
jae 0x835e
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop