// File: tomfunkhouser[P]gaps/apps/scninfo/scninfo.cpp
// Function: PrintBrdf(gaps::R3Brdf*, int, int)
static int
PrintBrdf(R3Brdf *brdf, int index, int level)
{
  // Construct indent
  char indent[4096] = { '\0' };
  for (int i = 0; i < level; i++) {
    strcat(indent, "  ");
  }

  // Print brdf
  const char *name = brdf->Name();
  const RNRgb& ambient = brdf->Ambient();
  const RNRgb& diffuse = brdf->Diffuse();
  const RNRgb& specular = brdf->Specular();
  const RNRgb& transmission = brdf->Transmission();
  const RNRgb& emission = brdf->Emission();
  printf("%sBrdf %d\n", indent, index);
  if (name) printf("%s  Name = %s\n", indent, name);
  if (!ambient.IsBlack()) printf("%s  Ambient = %g %g %g\n", indent, ambient.R(), ambient.G(), ambient.B());
  if (!diffuse.IsBlack()) printf("%s  Diffuse = %g %g %g\n", indent, diffuse.R(), diffuse.G(), diffuse.B());
  if (!specular.IsBlack()) printf("%s  Specular = %g %g %g\n", indent, specular.R(), specular.G(), specular.B());
  if (!transmission.IsBlack()) printf("%s  Transmission = %g %g %g\n", indent, transmission.R(), transmission.G(), transmission.B());
  if (!emission.IsBlack()) printf("%s  Emission = %g %g %g\n", indent, emission.R(), emission.G(), emission.B());
  if (brdf->Shininess() != 0) printf("%s  Shininess = %g\n", indent, brdf->Shininess());
  if (brdf->IndexOfRefraction() != 1) printf("%s  Index of refraction = %g\n", indent, brdf->IndexOfRefraction());
  printf("\n");

  // Return success
  return 1;
}

// Assembly:
subq $0x10d8, %rsp           # imm = 0x10D8
movq %rdi, 0x10d0(%rsp)
movl %esi, 0x10cc(%rsp)
movl %edx, 0x10c8(%rsp)
leaq 0xc0(%rsp), %rdi
xorl %esi, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x224b0
movl $0x0, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
cmpl 0x10c8(%rsp), %eax
jge 0x289a3
leaq 0xc0(%rsp), %rdi
leaq 0x166ed6(%rip), %rsi    # 0x18f861
callq 0x23230
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0x2896c
movq 0x10d0(%rsp), %rdi
callq 0x2ac40
movq %rax, 0xb0(%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ac50
movq %rax, 0xa8(%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ab50
movq %rax, 0xa0(%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ac60
movq %rax, 0x98(%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ac70
movq %rax, 0x90(%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ac80
movq %rax, 0x88(%rsp)
leaq 0xc0(%rsp), %rsi
movl 0x10cc(%rsp), %edx
leaq 0x163a99(%rip), %rdi    # 0x18c4d0
movb $0x0, %al
callq 0x22090
cmpq $0x0, 0xb0(%rsp)
je 0x28a67
leaq 0xc0(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq 0x1639ea(%rip), %rdi    # 0x18c44a
movb $0x0, %al
callq 0x22090
movq 0xa8(%rsp), %rdi
callq 0x2aca0
cmpl $0x0, %eax
jne 0x28ae1
leaq 0xc0(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x2ab70
movsd %xmm0, 0x80(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x2ab80
movsd %xmm0, 0x78(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x2ab90
movq 0x70(%rsp), %rsi
movsd 0x78(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x80(%rsp), %xmm0
leaq 0x163a01(%rip), %rdi    # 0x18c4db
movb $0x3, %al
callq 0x22090
movq 0xa0(%rsp), %rdi
callq 0x2aca0
cmpl $0x0, %eax
jne 0x28b55
leaq 0xc0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x2ab70
movsd %xmm0, 0x68(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x2ab80
movsd %xmm0, 0x60(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x2ab90
movq 0x58(%rsp), %rsi
movsd 0x60(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x68(%rsp), %xmm0
leaq 0x1639a5(%rip), %rdi    # 0x18c4f3
movb $0x3, %al
callq 0x22090
movq 0x98(%rsp), %rdi
callq 0x2aca0
cmpl $0x0, %eax
jne 0x28bc9
leaq 0xc0(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x98(%rsp), %rdi
callq 0x2ab70
movsd %xmm0, 0x50(%rsp)
movq 0x98(%rsp), %rdi
callq 0x2ab80
movsd %xmm0, 0x48(%rsp)
movq 0x98(%rsp), %rdi
callq 0x2ab90
movq 0x40(%rsp), %rsi
movsd 0x48(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x50(%rsp), %xmm0
leaq 0x163949(%rip), %rdi    # 0x18c50b
movb $0x3, %al
callq 0x22090
movq 0x90(%rsp), %rdi
callq 0x2aca0
cmpl $0x0, %eax
jne 0x28c3d
leaq 0xc0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x90(%rsp), %rdi
callq 0x2ab70
movsd %xmm0, 0x38(%rsp)
movq 0x90(%rsp), %rdi
callq 0x2ab80
movsd %xmm0, 0x30(%rsp)
movq 0x90(%rsp), %rdi
callq 0x2ab90
movq 0x28(%rsp), %rsi
movsd 0x30(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x38(%rsp), %xmm0
leaq 0x1638ee(%rip), %rdi    # 0x18c524
movb $0x3, %al
callq 0x22090
movq 0x88(%rsp), %rdi
callq 0x2aca0
cmpl $0x0, %eax
jne 0x28cb1
leaq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x88(%rsp), %rdi
callq 0x2ab70
movsd %xmm0, 0x20(%rsp)
movq 0x88(%rsp), %rdi
callq 0x2ab80
movsd %xmm0, 0x18(%rsp)
movq 0x88(%rsp), %rdi
callq 0x2ab90
movq 0x10(%rsp), %rsi
movsd 0x18(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x20(%rsp), %xmm0
leaq 0x163897(%rip), %rdi    # 0x18c541
movb $0x3, %al
callq 0x22090
movq 0x10d0(%rsp), %rdi
callq 0x2ad10
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x28ccb
jp 0x28ccb
jmp 0x28cf8
leaq 0xc0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ad10
movq 0x8(%rsp), %rsi
leaq 0x163869(%rip), %rdi    # 0x18c55a
movb $0x1, %al
callq 0x22090
movq 0x10d0(%rsp), %rdi
callq 0x2ad30
movsd 0x1632fb(%rip), %xmm1   # 0x18c008
ucomisd %xmm1, %xmm0
jne 0x28d17
jp 0x28d17
jmp 0x28d42
leaq 0xc0(%rsp), %rax
movq %rax, (%rsp)
movq 0x10d0(%rsp), %rdi
callq 0x2ad30
movq (%rsp), %rsi
leaq 0x163833(%rip), %rdi    # 0x18c56e
movb $0x1, %al
callq 0x22090
leaq 0x16a9b9(%rip), %rdi    # 0x193702
movb $0x0, %al
callq 0x22090
movl $0x1, %eax
addq $0x10d8, %rsp           # imm = 0x10D8
retq
nopl (%rax)