// File: tomfunkhouser[P]gaps/pkgs/R3Graphics/R3AreaLight.cpp
// Function: gaps::R3AreaLight::Draw(int) const
void R3AreaLight::
Draw(int i) const
{
    // Draw light
    GLenum index = (GLenum) (GL_LIGHT0 + i);
    if (index > GL_LIGHT7) return;
    GLfloat buffer[4];
    buffer[0] = Intensity() * Color().R();
    buffer[1] = Intensity() * Color().G();
    buffer[2] = Intensity() * Color().B();
    buffer[3] = 1.0;
    glLightfv(index, GL_DIFFUSE, buffer);
    glLightfv(index, GL_SPECULAR, buffer);
    buffer[0] = Position().X();
    buffer[1] = Position().Y();
    buffer[2] = Position().Z();
    buffer[3] = 1.0;
    glLightfv(index, GL_POSITION, buffer);
    buffer[0] = 90.0;
    glLightf(index, GL_SPOT_CUTOFF, buffer[0]);
    glEnable(index);
    buffer[0] = ConstantAttenuation();
    buffer[1] = LinearAttenuation();
    buffer[2] = QuadraticAttenuation();
    glLightf(index, GL_CONSTANT_ATTENUATION, buffer[0]);
    glLightf(index, GL_LINEAR_ATTENUATION, buffer[1]);
    glLightf(index, GL_QUADRATIC_ATTENUATION, buffer[2]);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x3c(%rsp), %eax
addl $0x4000, %eax           # imm = 0x4000
movl %eax, 0x38(%rsp)
cmpl $0x4007, 0x38(%rsp)     # imm = 0x4007
jbe 0x606e3
jmp 0x608d8
movq 0x18(%rsp), %rdi
callq 0x60980
movq 0x18(%rsp), %rdi
movsd %xmm0, (%rsp)
callq 0x2ba40
movq %rax, %rdi
callq 0x2b4a0
movq 0x18(%rsp), %rdi
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
callq 0x60980
movq 0x18(%rsp), %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x2ba40
movq %rax, %rdi
callq 0x2b4b0
movq 0x18(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rsp)
callq 0x60980
movq 0x18(%rsp), %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x2ba40
movq %rax, %rdi
callq 0x2b4c0
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x12d8f4(%rip), %xmm0   # 0x18e088
movss %xmm0, 0x2c(%rsp)
movl 0x38(%rsp), %edi
leaq 0x20(%rsp), %rdx
movl $0x1201, %esi           # imm = 0x1201
callq 0x23270
movl 0x38(%rsp), %edi
leaq 0x20(%rsp), %rdx
movl $0x1202, %esi           # imm = 0x1202
callq 0x23270
movq 0x18(%rsp), %rdi
callq 0x4e6e0
movq %rax, %rdi
callq 0x2b820
movq 0x18(%rsp), %rdi
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
callq 0x4e6e0
movq %rax, %rdi
callq 0x2b830
movq 0x18(%rsp), %rdi
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rsp)
callq 0x4e6e0
movq %rax, %rdi
callq 0x2b840
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x12d86c(%rip), %xmm0   # 0x18e088
movss %xmm0, 0x2c(%rsp)
movl 0x38(%rsp), %edi
leaq 0x20(%rsp), %rdx
movl $0x1203, %esi           # imm = 0x1203
callq 0x23270
movss 0x12f4f3(%rip), %xmm0   # 0x18fd30
movss %xmm0, 0x20(%rsp)
movl 0x38(%rsp), %edi
movss 0x20(%rsp), %xmm0
movl $0x1206, %esi           # imm = 0x1206
callq 0x221e0
movl 0x38(%rsp), %edi
callq 0x22910
movq 0x18(%rsp), %rdi
callq 0x4e740
movq 0x18(%rsp), %rdi
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
callq 0x4e760
movq 0x18(%rsp), %rdi
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rsp)
callq 0x4e780
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movl 0x38(%rsp), %edi
movss 0x20(%rsp), %xmm0
movl $0x1207, %esi           # imm = 0x1207
callq 0x221e0
movl 0x38(%rsp), %edi
movss 0x24(%rsp), %xmm0
movl $0x1208, %esi           # imm = 0x1208
callq 0x221e0
movl 0x38(%rsp), %edi
movss 0x28(%rsp), %xmm0
movl $0x1209, %esi           # imm = 0x1209
callq 0x221e0
addq $0x48, %rsp
retq
nopl (%rax)