// File: tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::WritePrincetonMaterial(gaps::R3Scene const*, gaps::R3Material const*, _IO_FILE*)
static int
WritePrincetonMaterial(const R3Scene *scene, const R3Material *material, FILE *fp)
{
  // Write material
  const R3Brdf *brdf = material->Brdf();
  const R2Texture *texture = material->Texture();
  RNRgb ambient = (brdf) ? brdf->Ambient() : RNblack_rgb;
  RNRgb diffuse = (brdf) ? brdf->Diffuse() : RNblack_rgb;
  RNRgb specular = (brdf) ? brdf->Specular() : RNblack_rgb;
  RNRgb transmission = (brdf) ? brdf->Transmission() : RNblack_rgb;
  RNRgb emission = (brdf) ? brdf->Emission() : RNblack_rgb;
  RNScalar shininess = brdf->Shininess();
  RNScalar indexofref = brdf->IndexOfRefraction();
  const char *texture_name = (texture && texture->Filename()) ? texture->Filename() : "0";
  fprintf(fp, "material %g %g %g  %g %g %g  %g %g %g  %g %g %g  %g %g %g  %g %g %s\n",
    ambient.R(), ambient.G(), ambient.B(),
    diffuse.R(), diffuse.G(), diffuse.B(),
    specular.R(), specular.G(), specular.B(),
    transmission.R(), transmission.G(), transmission.B(),
    emission.R(), emission.G(), emission.B(),
    shininess, indexofref, texture_name);

  // Return success
  return 1;
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1b0(%rsp)
movq %rsi, 0x1a8(%rsp)
movq %rdx, 0x1a0(%rsp)
movq 0x1a8(%rsp), %rdi
callq 0x2be70
movq %rax, 0x198(%rsp)
movq 0x1a8(%rsp), %rdi
callq 0x48b20
movq %rax, 0x190(%rsp)
cmpq $0x0, 0x198(%rsp)
je 0x3d93b
movq 0x198(%rsp), %rdi
callq 0x488e0
movq %rax, 0xf8(%rsp)
jmp 0x3d94c
leaq 0x1c2246(%rip), %rax    # 0x1ffb88
movq %rax, 0xf8(%rsp)
jmp 0x3d94c
movq 0xf8(%rsp), %rsi
leaq 0x178(%rsp), %rdi
callq 0xef300
cmpq $0x0, 0x198(%rsp)
je 0x3d983
movq 0x198(%rsp), %rdi
callq 0x48930
movq %rax, 0xf0(%rsp)
jmp 0x3d994
leaq 0x1c21fe(%rip), %rax    # 0x1ffb88
movq %rax, 0xf0(%rsp)
jmp 0x3d994
movq 0xf0(%rsp), %rsi
leaq 0x160(%rsp), %rdi
callq 0xef300
cmpq $0x0, 0x198(%rsp)
je 0x3d9cb
movq 0x198(%rsp), %rdi
callq 0x48980
movq %rax, 0xe8(%rsp)
jmp 0x3d9dc
leaq 0x1c21b6(%rip), %rax    # 0x1ffb88
movq %rax, 0xe8(%rsp)
jmp 0x3d9dc
movq 0xe8(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0xef300
cmpq $0x0, 0x198(%rsp)
je 0x3da13
movq 0x198(%rsp), %rdi
callq 0x48a10
movq %rax, 0xe0(%rsp)
jmp 0x3da24
leaq 0x1c216e(%rip), %rax    # 0x1ffb88
movq %rax, 0xe0(%rsp)
jmp 0x3da24
movq 0xe0(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0xef300
cmpq $0x0, 0x198(%rsp)
je 0x3da5b
movq 0x198(%rsp), %rdi
callq 0x2bea0
movq %rax, 0xd8(%rsp)
jmp 0x3da6c
leaq 0x1c2126(%rip), %rax    # 0x1ffb88
movq %rax, 0xd8(%rsp)
jmp 0x3da6c
movq 0xd8(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0xef300
movq 0x198(%rsp), %rdi
callq 0x48ae0
movsd %xmm0, 0x110(%rsp)
movq 0x198(%rsp), %rdi
callq 0x48b00
movsd %xmm0, 0x108(%rsp)
cmpq $0x0, 0x190(%rsp)
je 0x3dae2
movq 0x190(%rsp), %rdi
callq 0x48b30
cmpq $0x0, %rax
je 0x3dae2
movq 0x190(%rsp), %rdi
callq 0x48b30
movq %rax, 0xd0(%rsp)
jmp 0x3daf3
leaq 0x1585be(%rip), %rax    # 0x1960a7
movq %rax, 0xd0(%rsp)
jmp 0x3daf3
movq 0xd0(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x2b4a0
movsd %xmm0, 0xc0(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x2b4b0
movsd %xmm0, 0x58(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x2b4c0
movsd %xmm0, 0x60(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x2b4a0
movsd %xmm0, 0x68(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x2b4b0
movsd %xmm0, 0x70(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x2b4c0
movsd %xmm0, 0x78(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x2b4a0
movsd %xmm0, 0x80(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x2b4b0
movsd %xmm0, 0x88(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x2b4c0
movsd %xmm0, 0x90(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x2b4a0
movsd %xmm0, 0x98(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x2b4b0
movsd %xmm0, 0xa0(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x2b4c0
movsd %xmm0, 0xa8(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x2b4a0
movsd %xmm0, 0xb0(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x2b4b0
movsd %xmm0, 0xb8(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x2b4c0
movq 0x50(%rsp), %rdi
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movsd 0x68(%rsp), %xmm3
movsd 0x70(%rsp), %xmm4
movsd 0x78(%rsp), %xmm5
movsd 0x80(%rsp), %xmm6
movsd 0x88(%rsp), %xmm7
movsd 0x90(%rsp), %xmm8
movsd 0x98(%rsp), %xmm15
movsd 0xa0(%rsp), %xmm14
movsd 0xa8(%rsp), %xmm13
movsd 0xb0(%rsp), %xmm12
movsd 0xb8(%rsp), %xmm11
movaps %xmm0, %xmm10
movsd 0x110(%rsp), %xmm9
movsd 0x108(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0xc0(%rsp), %xmm0
movq 0x100(%rsp), %rdx
leaq 0x151b28(%rip), %rsi    # 0x18f813
movsd %xmm8, (%rsp)
movsd 0xc8(%rsp), %xmm8
movsd %xmm15, 0x8(%rsp)
movsd %xmm14, 0x10(%rsp)
movsd %xmm13, 0x18(%rsp)
movsd %xmm12, 0x20(%rsp)
movsd %xmm11, 0x28(%rsp)
movsd %xmm10, 0x30(%rsp)
movsd %xmm9, 0x38(%rsp)
movsd %xmm8, 0x40(%rsp)
movb $0x8, %al
callq 0x22f30
movl $0x1, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
retq
nopw (%rax,%rax)