// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Box::Draw(gaps::RNFlags) const
void R3Box::
Draw(const R3DrawFlags draw_flags) const
{
    static R3Vector normals[6] = {
	R3Vector(-1.0, 0.0, 0.0),
	R3Vector(1.0, 0.0, 0.0),
	R3Vector(0.0, -1.0, 0.0),
	R3Vector(0.0, 1.0, 0.0),
	R3Vector(0.0, 0.0, -1.0),
	R3Vector(0.0, 0.0, 1.0)
    };
    static R2Point texcoords[4] = {
	R2Point(0.0, 0.0),
	R2Point(1.0, 0.0),
	R2Point(1.0, 1.0),
	R2Point(0.0, 1.0)
    };
    static int surface_paths[6][4] = {
	{ 3, 0, 1, 2 },
	{ 4, 7, 6, 5 },
	{ 0, 4, 5, 1 },
	{ 7, 3, 2, 6 },
	{ 3, 7, 4, 0 },
        { 1, 5, 6, 2 }
    };
    static int outline_path[16] = {
	0, 1, 2, 3,
	0, 4, 5, 6,
	7, 4, 5, 1,
	2, 6, 7, 3
    };

    /* Get box corner points */
    R3Point corners[8];
    corners[0] = Corner(RN_NNN_OCTANT);
    corners[1] = Corner(RN_NNP_OCTANT);
    corners[2] = Corner(RN_NPP_OCTANT);
    corners[3] = Corner(RN_NPN_OCTANT);
    corners[4] = Corner(RN_PNN_OCTANT);
    corners[5] = Corner(RN_PNP_OCTANT);
    corners[6] = Corner(RN_PPP_OCTANT);
    corners[7] = Corner(RN_PPN_OCTANT);

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	for (int i = 0; i < 6; i++) {
	    R3BeginPolygon();
	    if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) 
		R3LoadNormal(normals[i]);
	    for (int j = 0; j < 4; j++) {
		if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) 
		    R3LoadTextureCoords(texcoords[j]);
		R3LoadPoint(corners[surface_paths[i][j]]);
	    }
	    R3EndPolygon();
	}
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	R3BeginLine();
	for (int i = 0; i < 16; i++)
	    R3LoadPoint(corners[outline_path[i]]);
	R3EndLine();
    }    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movb 0x4a52cb(%rip), %al     # 0x4e6c60
testb %al, %al
je 0x41baf
movb 0x4a530d(%rip), %al     # 0x4e6cb0
testb %al, %al
je 0x41c73
xorl %r15d, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0x3ca24
addq $0x18, %r15
cmpq $0xc0, %r15
jne 0x419ae
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2777e
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x2777e
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq 0x2777e
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x2777e
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x2777e
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0x2777e
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x7, %edx
callq 0x2777e
leaq 0xb0(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x6, %edx
callq 0x2777e
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x3cd94
testb $0x2, %bl
je 0x41b61
leaq 0x673c3(%rip), %r15     # 0xa8eb0
xorl %r12d, %r12d
leaq 0x4a5179(%rip), %r13    # 0x4e6c70
movl $0x9, %edi
callq 0xe110
testb $0x20, %bl
je 0x41b1a
leaq (%r12,%r12,2), %rax
leaq 0x4a50bf(%rip), %rcx    # 0x4e6bd0
leaq (%rcx,%rax,8), %rdi
callq 0xe6b0
movq %r13, %r14
xorl %ebp, %ebp
btl $0x9, %ebx
jae 0x41b2d
movq %r14, %rdi
callq 0xe120
movslq (%r15,%rbp,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rsp,%rax,8), %rdi
addq $0x20, %rdi
callq 0xe130
incq %rbp
addq $0x10, %r14
cmpq $0x4, %rbp
jne 0x41b1f
callq 0xe5d0
incq %r12
addq $0x10, %r15
cmpq $0x6, %r12
jne 0x41af7
testb $0x1, %bl
je 0x41b9d
movl $0x3, %edi
callq 0xe110
xorl %ebx, %ebx
leaq 0x67397(%rip), %r14     # 0xa8f10
movslq (%rbx,%r14), %rax
leaq (%rax,%rax,2), %rax
leaq (%rsp,%rax,8), %rdi
addq $0x20, %rdi
callq 0xe130
addq $0x4, %rbx
cmpq $0x40, %rbx
jne 0x41b79
callq 0xe5d0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a50aa(%rip), %r15    # 0x4e6c60
movq %r15, %rdi
callq 0xe810
testl %eax, %eax
je 0x4199d
leaq 0x4a5003(%rip), %rdi    # 0x4e6bd0
movsd 0x60473(%rip), %xmm0    # 0xa2048
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3d4be
leaq 0x4a5001(%rip), %rdi    # 0x4e6be8
movsd 0x60449(%rip), %xmm0    # 0xa2038
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3d4be
leaq 0x4a4fff(%rip), %rdi    # 0x4e6c00
movsd 0x6043f(%rip), %xmm1    # 0xa2048
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x3d4be
leaq 0x4a4ffd(%rip), %rdi    # 0x4e6c18
movsd 0x60415(%rip), %xmm1    # 0xa2038
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x3d4be
leaq 0x4a4ffb(%rip), %rdi    # 0x4e6c30
movsd 0x6040b(%rip), %xmm2    # 0xa2048
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x3d4be
leaq 0x4a4ff9(%rip), %rdi    # 0x4e6c48
movsd 0x603e1(%rip), %xmm2    # 0xa2038
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x3d4be
leaq 0x4a4ff7(%rip), %rdi    # 0x4e6c60
callq 0xe2e0
jmp 0x4199d
leaq 0x4a5036(%rip), %r15    # 0x4e6cb0
movq %r15, %rdi
callq 0xe810
testl %eax, %eax
je 0x419ab
leaq 0x4a4fdf(%rip), %rdi    # 0x4e6c70
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x68e2e
leaq 0x4a4fdd(%rip), %rdi    # 0x4e6c80
movsd 0x6038d(%rip), %xmm0    # 0xa2038
xorps %xmm1, %xmm1
callq 0x68e2e
leaq 0x4a4fd6(%rip), %rdi    # 0x4e6c90
movsd 0x60376(%rip), %xmm0    # 0xa2038
movaps %xmm0, %xmm1
callq 0x68e2e
leaq 0x4a4fcf(%rip), %rdi    # 0x4e6ca0
movsd 0x6035f(%rip), %xmm1    # 0xa2038
xorps %xmm0, %xmm0
callq 0x68e2e
leaq 0x4a4fc8(%rip), %rdi    # 0x4e6cb0
callq 0xe2e0
jmp 0x419ab
jmp 0x41cf4
movq %rax, %rbx
movq %r15, %rdi
callq 0xe2d0
movq %rbx, %rdi
callq 0xe7e0
nop