// File: /workspace/github_cpp_makefile_star2_O2/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 0x49fc1f(%rip), %al     # 0x4dbc70
testb %al, %al
je 0x3c260
movb 0x49fc61(%rip), %al     # 0x4dbcc0
testb %al, %al
je 0x3c324
xorl %r15d, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0x37b4a
addq $0x18, %r15
cmpq $0xc0, %r15
jne 0x3c06a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x24db6
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x3
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x2
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x4
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x5
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x7
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0xb0(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
leaq 0x8(%rsp), %r15
pushq $0x6
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x24db6
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x37e36
testb $0x2, %bl
jne 0x3c1d0
testb $0x1, %bl
je 0x3c24e
callq 0x21c38
xorl %ebx, %ebx
leaq 0x5dd15(%rip), %r14     # 0x99ec0
cmpq $0x40, %rbx
je 0x3c249
movslq (%rbx,%r14), %rax
imulq $0x18, %rax, %rax
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
callq 0xe130
addq $0x4, %rbx
jmp 0x3c1ab
leaq 0x5dc89(%rip), %r15     # 0x99e60
xorl %r12d, %r12d
leaq 0x49fa9f(%rip), %r13    # 0x4dbc80
cmpq $0x6, %r12
je 0x3c194
callq 0x21c40
testb $0x20, %bl
je 0x3c204
imulq $0x18, %r12, %rdi
leaq 0x49f9e4(%rip), %rax    # 0x4dbbe0
addq %rax, %rdi
callq 0xe6e0
movq %r13, %r14
xorl %ebp, %ebp
cmpq $0x4, %rbp
je 0x3c23b
btl $0x9, %ebx
jae 0x3c21d
movq %r14, %rdi
callq 0xe120
movslq (%r15,%rbp,4), %rax
imulq $0x18, %rax, %rax
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
callq 0xe130
incq %rbp
addq $0x10, %r14
jmp 0x3c209
callq 0xe5f0
incq %r12
addq $0x10, %r15
jmp 0x3c1e1
callq 0xe5f0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x49fa09(%rip), %r15    # 0x4dbc70
movq %r15, %rdi
callq 0xe840
testl %eax, %eax
je 0x3c059
leaq 0x49f962(%rip), %rdi    # 0x4dbbe0
movsd 0x56d9a(%rip), %xmm0    # 0x93020
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3830c
leaq 0x49f960(%rip), %rdi    # 0x4dbbf8
movsd 0x56d68(%rip), %xmm0    # 0x93008
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3830c
leaq 0x49f95e(%rip), %rdi    # 0x4dbc10
movsd 0x56d66(%rip), %xmm1    # 0x93020
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x3830c
leaq 0x49f95c(%rip), %rdi    # 0x4dbc28
movsd 0x56d34(%rip), %xmm1    # 0x93008
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x3830c
leaq 0x49f95a(%rip), %rdi    # 0x4dbc40
movsd 0x56d32(%rip), %xmm2    # 0x93020
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x3830c
leaq 0x49f958(%rip), %rdi    # 0x4dbc58
movsd 0x56d00(%rip), %xmm2    # 0x93008
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x3830c
leaq 0x49f956(%rip), %rdi    # 0x4dbc70
callq 0xe2f0
jmp 0x3c059
leaq 0x49f995(%rip), %r15    # 0x4dbcc0
movq %r15, %rdi
callq 0xe840
testl %eax, %eax
je 0x3c067
leaq 0x49f93e(%rip), %rdi    # 0x4dbc80
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x5f58c
leaq 0x49f93c(%rip), %rdi    # 0x4dbc90
movsd 0x56cac(%rip), %xmm0    # 0x93008
xorps %xmm1, %xmm1
callq 0x5f58c
leaq 0x49f935(%rip), %rdi    # 0x4dbca0
movsd 0x56c95(%rip), %xmm0    # 0x93008
movaps %xmm0, %xmm1
callq 0x5f58c
leaq 0x49f92e(%rip), %rdi    # 0x4dbcb0
movsd 0x56c7e(%rip), %xmm1    # 0x93008
xorps %xmm0, %xmm0
callq 0x5f58c
leaq 0x49f927(%rip), %rdi    # 0x4dbcc0
callq 0xe2f0
jmp 0x3c067
jmp 0x3c3a5
movq %rax, %rbx
movq %r15, %rdi
callq 0xe2e0
movq %rbx, %rdi
callq 0xe810