// File: tomfunkhouser[P]gaps/apps/msh2df/msh2df.cpp
// Function: EstimateSign(gaps::R3Grid*, gaps::R3Mesh*)
static int
EstimateSign(R3Grid *grid, R3Mesh *mesh)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();


  // Check sign estimation method
  if (sign_estimation_method == 0) {
    if (!EstimateSignUsingNormals(grid, mesh)) return 0;
  }
  else if (sign_estimation_method == 1) {
    if (!EstimateSignUsingFloodFill(grid, mesh)) return 0;
  }
  else {
    RNFail("Unrecognized sign estimation method: %d\n", sign_estimation_method);
    return 0;
  }

  // Print statistics
  if (print_verbose) {
    printf("Estimated sign ...\n");
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  Resolution = %d %d %d\n", grid->XResolution(), grid->YResolution(), grid->ZResolution());
    printf("  Spacing = %g\n", grid->GridToWorldScaleFactor());
    printf("  Cardinality = %d\n", grid->Cardinality());
    printf("  Volume = %g\n", grid->Volume());
    RNInterval grid_range = grid->Range();
    printf("  Minimum = %g\n", grid_range.Min());
    printf("  Maximum = %g\n", grid_range.Max());
    printf("  L1Norm = %g\n", grid->L1Norm());
    printf("  L2Norm = %g\n", grid->L2Norm());
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
leaq 0x20(%rsp), %rdi
callq 0xddf30
leaq 0x20(%rsp), %rdi
callq 0x17860
cmpl $0x0, 0x169717(%rip)    # 0x17d500
jne 0x13e0e
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x16110
cmpl $0x0, %eax
jne 0x13e0c
movl $0x0, 0x44(%rsp)
jmp 0x13f9e
jmp 0x13e5d
cmpl $0x1, 0x1696eb(%rip)    # 0x17d500
jne 0x13e3a
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x16bb0
cmpl $0x0, %eax
jne 0x13e38
movl $0x0, 0x44(%rsp)
jmp 0x13f9e
jmp 0x13e5b
movl 0x1696c0(%rip), %esi    # 0x17d500
leaq 0x12c535(%rip), %rdi    # 0x14037c
movb $0x0, %al
callq 0xe2150
movl $0x0, 0x44(%rsp)
jmp 0x13f9e
jmp 0x13e5d
cmpl $0x0, 0x172794(%rip)    # 0x1865f8
je 0x13f96
leaq 0x12c534(%rip), %rdi    # 0x1403a5
movb $0x0, %al
callq 0xf070
leaq 0x20(%rsp), %rdi
callq 0xddff0
leaq 0x12c39a(%rip), %rdi    # 0x140223
movb $0x1, %al
callq 0xf070
movq 0x38(%rsp), %rdi
callq 0x17b40
movl %eax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
callq 0x17b60
movl %eax, 0xc(%rsp)
movq 0x38(%rsp), %rdi
callq 0x17b80
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movl %eax, %ecx
leaq 0x12c3c9(%rip), %rdi    # 0x140290
movb $0x0, %al
callq 0xf070
movq 0x38(%rsp), %rdi
callq 0x17b20
leaq 0x12c3ca(%rip), %rdi    # 0x1402a9
movb $0x1, %al
callq 0xf070
movq 0x38(%rsp), %rdi
callq 0x7b1f0
movl %eax, %esi
leaq 0x12c3c0(%rip), %rdi    # 0x1402b9
movb $0x0, %al
callq 0xf070
movq 0x38(%rsp), %rdi
callq 0x17ba0
leaq 0x12c3bc(%rip), %rdi    # 0x1402cd
movb $0x1, %al
callq 0xf070
movq 0x38(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x7aff0
leaq 0x10(%rsp), %rdi
callq 0x17be0
leaq 0x12c3a4(%rip), %rdi    # 0x1402dc
movb $0x1, %al
callq 0xf070
leaq 0x10(%rsp), %rdi
callq 0x17bf0
leaq 0x12c39c(%rip), %rdi    # 0x1402ec
movb $0x1, %al
callq 0xf070
movq 0x38(%rsp), %rdi
callq 0x7b0e0
leaq 0x12c394(%rip), %rdi    # 0x1402fc
movb $0x1, %al
callq 0xf070
movq 0x38(%rsp), %rdi
callq 0x17c00
leaq 0x12c38b(%rip), %rdi    # 0x14030b
movb $0x1, %al
callq 0xf070
movq 0x169002(%rip), %rax    # 0x17cf90
movq (%rax), %rdi
callq 0xf5d0
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw (%rax,%rax)