// File: /workspace/github_cpp_makefile_star2_O3/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 0x4a5827(%rip), %al     # 0x4e6c60
testb %al, %al
je 0x41653
movb 0x4a5869(%rip), %al     # 0x4e6cb0
testb %al, %al
je 0x41717
xorl %r15d, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0x3c530
addq $0x18, %r15
cmpq $0xc0, %r15
jne 0x41452
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x27552
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x27552
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq 0x27552
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x27552
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x27552
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0x27552
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x7, %edx
callq 0x27552
leaq 0xb0(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x6, %edx
callq 0x27552
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x3c89a
testb $0x2, %bl
je 0x41605
leaq 0x6791f(%rip), %r15     # 0xa8eb0
xorl %r12d, %r12d
leaq 0x4a56d5(%rip), %r13    # 0x4e6c70
movl $0x9, %edi
callq 0xe110
testb $0x20, %bl
je 0x415be
leaq (%r12,%r12,2), %rax
leaq 0x4a561b(%rip), %rcx    # 0x4e6bd0
leaq (%rcx,%rax,8), %rdi
callq 0xe6b0
movq %r13, %r14
xorl %ebp, %ebp
btl $0x9, %ebx
jae 0x415d1
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 0x415c3
callq 0xe5d0
incq %r12
addq $0x10, %r15
cmpq $0x6, %r12
jne 0x4159b
testb $0x1, %bl
je 0x41641
movl $0x3, %edi
callq 0xe110
xorl %ebx, %ebx
leaq 0x678f3(%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 0x4161d
callq 0xe5d0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a5606(%rip), %r15    # 0x4e6c60
movq %r15, %rdi
callq 0xe810
testl %eax, %eax
je 0x41441
leaq 0x4a555f(%rip), %rdi    # 0x4e6bd0
movsd 0x609cf(%rip), %xmm0    # 0xa2048
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3cfc6
leaq 0x4a555d(%rip), %rdi    # 0x4e6be8
movsd 0x609a5(%rip), %xmm0    # 0xa2038
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3cfc6
leaq 0x4a555b(%rip), %rdi    # 0x4e6c00
movsd 0x6099b(%rip), %xmm1    # 0xa2048
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x3cfc6
leaq 0x4a5559(%rip), %rdi    # 0x4e6c18
movsd 0x60971(%rip), %xmm1    # 0xa2038
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x3cfc6
leaq 0x4a5557(%rip), %rdi    # 0x4e6c30
movsd 0x60967(%rip), %xmm2    # 0xa2048
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x3cfc6
leaq 0x4a5555(%rip), %rdi    # 0x4e6c48
movsd 0x6093d(%rip), %xmm2    # 0xa2038
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x3cfc6
leaq 0x4a5553(%rip), %rdi    # 0x4e6c60
callq 0xe2e0
jmp 0x41441
leaq 0x4a5592(%rip), %r15    # 0x4e6cb0
movq %r15, %rdi
callq 0xe810
testl %eax, %eax
je 0x4144f
leaq 0x4a553b(%rip), %rdi    # 0x4e6c70
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x680a6
leaq 0x4a5539(%rip), %rdi    # 0x4e6c80
movsd 0x608e9(%rip), %xmm0    # 0xa2038
xorps %xmm1, %xmm1
callq 0x680a6
leaq 0x4a5532(%rip), %rdi    # 0x4e6c90
movsd 0x608d2(%rip), %xmm0    # 0xa2038
movaps %xmm0, %xmm1
callq 0x680a6
leaq 0x4a552b(%rip), %rdi    # 0x4e6ca0
movsd 0x608bb(%rip), %xmm1    # 0xa2038
xorps %xmm0, %xmm0
callq 0x680a6
leaq 0x4a5524(%rip), %rdi    # 0x4e6cb0
callq 0xe2e0
jmp 0x4144f
jmp 0x41798
movq %rax, %rbx
movq %r15, %rdi
callq 0xe2d0
movq %rbx, %rdi
callq 0xe7e0
nop