// File: tomfunkhouser[P]gaps/apps/msh2prp/msh2prp.cpp
// Function: ReadMTurkProperties(gaps::R3Mesh*, char const*, char const*, char const*)
static R3MeshPropertySet *
ReadMTurkProperties(R3Mesh *mesh, const char *segmentation_filename,
  const char *annotation_filename, const char *label_mapping_filename)
{                   
  // Allocate property set
  R3MeshPropertySet *properties = new R3MeshPropertySet(mesh);
  if (!properties) {
    RNFail("Unable to allocate property set.\n");
    return NULL;
  }

  // Read segmentation and annotation properties
  if (segmentation_filename) {
    R3MeshPropertySet *segmentation_properties = ReadMTurkSegmentationProperties(mesh, segmentation_filename);
    if (!segmentation_properties) return NULL;
    properties->Insert(segmentation_properties);
    delete segmentation_properties;
    if (input_mturk_annotation_name && input_mturk_label_mapping_name) {
      R3MeshProperty *segmentation_property = properties->Property("Segment");
      if (segmentation_property) {
        RNSymbolTable<MTurkLabel *> label_mapping;
        if (ReadMTurkLabelMapping(label_mapping, label_mapping_filename)) {
          R3MeshPropertySet *annotation_properties = ReadMTurkAnnotationProperties(mesh, segmentation_property, &label_mapping, annotation_filename);
          if (!annotation_properties) return NULL;
          properties->Insert(annotation_properties);
          delete annotation_properties;
        }
      }
    }
  }

  // Transfer properties to faces
  if (!TransferMTurkPropertiesToFaces(mesh, properties)) return NULL;

  // Return properties
  return properties;
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
movq %rcx, 0x70(%rsp)
movl $0x18, %edi
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq 0x88(%rsp), %rsi
callq 0x24ce0
jmp 0x1b195
movq 0x28(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x68(%rsp)
jne 0x1b1e8
leaq 0x1590a8(%rip), %rdi    # 0x174256
movb $0x0, %al
callq 0xedb00
movq $0x0, 0x90(%rsp)
jmp 0x1b3c8
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
movl $0x18, %esi
callq 0x11690
jmp 0x1b3d8
cmpq $0x0, 0x80(%rsp)
je 0x1b396
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x1d560
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
jne 0x1b22a
movq $0x0, 0x90(%rsp)
jmp 0x1b3c8
movq 0x68(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x1f310
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x1b262
movq 0x20(%rsp), %rdi
callq 0x24e50
movq 0x20(%rsp), %rdi
movl $0x18, %esi
callq 0x11690
cmpq $0x0, 0x1af516(%rip)    # 0x1ca780
je 0x1b394
cmpq $0x0, 0x1af510(%rip)    # 0x1ca788
je 0x1b394
movq 0x68(%rsp), %rdi
leaq 0x1593bb(%rip), %rsi    # 0x174645
callq 0x200e0
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x1b392
leaq 0x40(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x20140
movq 0x10(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1dba0
movl %eax, 0x1c(%rsp)
jmp 0x1b2c4
movl 0x1c(%rsp), %eax
cmpl $0x0, %eax
je 0x1b372
movq 0x88(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x78(%rsp), %rcx
leaq 0x40(%rsp), %rdx
callq 0x1e210
movq %rax, 0x8(%rsp)
jmp 0x1b2f4
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x1b339
movq $0x0, 0x90(%rsp)
movl $0x1, 0x34(%rsp)
jmp 0x1b37a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x20150
jmp 0x1b3d8
movq 0x68(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x1f310
jmp 0x1b34a
movq 0x38(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x1b370
movq (%rsp), %rdi
callq 0x24e50
movq (%rsp), %rdi
movl $0x18, %esi
callq 0x11690
jmp 0x1b372
movl $0x0, 0x34(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x20150
movl 0x34(%rsp), %eax
testl %eax, %eax
je 0x1b390
jmp 0x1b38e
jmp 0x1b3c8
jmp 0x1b392
jmp 0x1b394
jmp 0x1b396
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x1ed00
cmpl $0x0, %eax
jne 0x1b3bb
movq $0x0, 0x90(%rsp)
jmp 0x1b3c8
movq 0x68(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
addq $0x98, %rsp
retq
movq 0x60(%rsp), %rdi
callq 0x11bb0
nopw %cs:(%rax,%rax)