// File: tomfunkhouser[P]gaps/apps/conf2conf/conf2conf.cpp
// Function: ComputeSurfaceTextures(gaps::RGBDConfiguration*)
static int
ComputeSurfaceTextures(RGBDConfiguration *configuration)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();
  if (print_verbose) {
    printf("Computing surface textures ...\n");
    fflush(stdout);
  }

  // Set texture directory 
  if (output_texture_directory) configuration->SetTextureDirectory(output_texture_directory);
  if (!configuration->TextureDirectory()) configuration->SetTextureDirectory("texture");

  // Create texture directory
  if (configuration->TextureDirectory()) {
    char cmd[4096];
    sprintf(cmd, "mkdir -p %s", configuration->TextureDirectory());
    system(cmd);
  }

  // Set texel spacing if specified on command line                       
  if (texel_spacing > 0) {
    for (int i = 0; i < configuration->NSurfaces(); i++) {
      RGBDSurface *surface = configuration->Surface(i);
      surface->SetWorldTexelSpacing(texel_spacing);
    }
  }

  // Compute surface textures
  if (!RGBDComputeSurfaceTextures(configuration)) return 0;

  // Print statistics
  if (print_verbose) {
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  Texture directory = %s\n", configuration->TextureDirectory());
    printf("  # Surfaces = %d\n", configuration->NSurfaces());
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x1048, %rsp           # imm = 0x1048
movq %rdi, 0x1038(%rsp)
leaq 0x1028(%rsp), %rdi
callq 0xdaa10
leaq 0x1028(%rsp), %rdi
callq 0x19c20
cmpl $0x0, 0x19a8b8(%rip)    # 0x1b1fe8
je 0x1774f
leaq 0x14ecc3(%rip), %rdi    # 0x1663fc
movb $0x0, %al
callq 0x12090
movq 0x199849(%rip), %rax    # 0x1b0f90
movq (%rax), %rdi
callq 0x12850
cmpq $0x0, 0x19a8c1(%rip)    # 0x1b2018
je 0x1776e
movq 0x1038(%rsp), %rdi
movq 0x19a8b0(%rip), %rsi    # 0x1b2018
movq (%rdi), %rax
callq *0x60(%rax)
movq 0x1038(%rsp), %rdi
callq 0x19f60
cmpq $0x0, %rax
jne 0x17796
movq 0x1038(%rsp), %rdi
movq (%rdi), %rax
leaq 0x14ec89(%rip), %rsi    # 0x16641c
callq *0x60(%rax)
movq 0x1038(%rsp), %rdi
callq 0x19f60
cmpq $0x0, %rax
je 0x177e0
leaq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x1038(%rsp), %rdi
callq 0x19f60
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0x14ec55(%rip), %rsi    # 0x166424
movb $0x0, %al
callq 0x12130
leaq 0x20(%rsp), %rdi
callq 0x125c0
movsd 0x19a840(%rip), %xmm0   # 0x1b2028
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x17853
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x1038(%rsp), %rdi
callq 0x19c60
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jge 0x17851
movq 0x1038(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x19f70
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movsd 0x19a7ed(%rip), %xmm0   # 0x1b2028
movq (%rdi), %rax
callq *0xd0(%rax)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x177f9
jmp 0x17853
movq 0x1038(%rsp), %rdi
callq 0x188a0
cmpl $0x0, %eax
jne 0x17872
movl $0x0, 0x1044(%rsp)
jmp 0x178eb
cmpl $0x0, 0x19a76f(%rip)    # 0x1b1fe8
je 0x178e0
leaq 0x1028(%rsp), %rdi
callq 0xdaad0
leaq 0x14ea63(%rip), %rdi    # 0x1662f2
movb $0x1, %al
callq 0x12090
movq 0x1038(%rsp), %rdi
callq 0x19f60
movq %rax, %rsi
leaq 0x14eb83(%rip), %rdi    # 0x166430
movb $0x0, %al
callq 0x12090
movq 0x1038(%rsp), %rdi
callq 0x19c60
movl %eax, %esi
leaq 0x14ea50(%rip), %rdi    # 0x16631a
movb $0x0, %al
callq 0x12090
movq 0x1996b8(%rip), %rax    # 0x1b0f90
movq (%rax), %rdi
callq 0x12850
movl $0x1, 0x1044(%rsp)
movl 0x1044(%rsp), %eax
addq $0x1048, %rsp           # imm = 0x1048
retq
nopw (%rax,%rax)