// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Circle::Draw(gaps::RNFlags) const
void R3Circle::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix (Zaxis -> ScaledNormal + OffsetToCenter)
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(center.Vector());
    matrix.Rotate(R3posz_vector, Normal());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	// Load normal
	if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) 
	    R3LoadNormal(R3posz_vector);

	// Draw circle in XY plane
	R3BeginPolygon();
	for (int i = 0; i < R3circle_npoints; i++) {
	    if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) 
		R3LoadTextureCoords(R3circle_texcoords[i]);
	    R3LoadPoint(R3circle_points[i] * radius);
	}
	R3EndPolygon();
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	R3BeginLoop();
	for (int i = 0; i < R3circle_npoints; i++) 
	    R3LoadPoint(R3circle_points[i] * radius);
	R3EndLoop();
    }

    // Pop matrix
    matrix.Pop();
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rsi, 0x110(%rsp)
movq %rdi, 0x108(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x101edd(%rip), %rsi    # 0x178c30
callq 0x51b60
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0x70(%rsp), %rdi
callq 0x36d10
leaq 0x88(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x534b0
movq 0x8(%rsp), %rdi
callq 0x78a80
movq %rax, %rdx
leaq 0x88(%rsp), %rdi
leaq 0x502867(%rip), %rsi    # 0x579600
callq 0x53ec0
leaq 0x88(%rsp), %rdi
callq 0x75ad0
leaq 0x68(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x68(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x76ea7
leaq 0x60(%rsp), %rdi
movl $0x20, %esi
callq 0x13d80
movq 0x60(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x76e07
leaq 0x5027fe(%rip), %rdi    # 0x579600
callq 0x38ea0
callq 0x38e90
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
leaq 0xbec69(%rip), %rcx     # 0x135a88
cmpl (%rcx), %eax
jge 0x76ea2
leaq 0x50(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x13d80
movq 0x50(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x76e61
movslq 0x5c(%rsp), %rax
leaq 0x50302b(%rip), %rdi    # 0x579e80
shlq $0x4, %rax
addq %rax, %rdi
callq 0x789f0
movq 0x8(%rsp), %rax
movslq 0x5c(%rsp), %rcx
leaq 0x502d0e(%rip), %rsi    # 0x579b80
imulq $0x18, %rcx, %rcx
addq %rcx, %rsi
movsd 0x20(%rax), %xmm0
leaq 0x38(%rsp), %rdi
callq 0x6fb80
leaq 0x38(%rsp), %rdi
callq 0x38e40
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x76e14
callq 0x38ec0
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x13d80
movq 0x30(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x76f2c
callq 0x78a60
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
leaq 0xbeba3(%rip), %rcx     # 0x135a88
cmpl (%rcx), %eax
jge 0x76f27
movq 0x8(%rsp), %rax
movslq 0x2c(%rsp), %rcx
leaq 0x502c86(%rip), %rsi    # 0x579b80
imulq $0x18, %rcx, %rcx
addq %rcx, %rsi
movsd 0x20(%rax), %xmm0
leaq 0x10(%rsp), %rdi
callq 0x6fb80
leaq 0x10(%rsp), %rdi
callq 0x38e40
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x76eda
callq 0x78a70
leaq 0x88(%rsp), %rdi
callq 0x75b00
addq $0x118, %rsp            # imm = 0x118
retq
nopw %cs:(%rax,%rax)