// File: tomfunkhouser[P]gaps/apps/msh2pts/msh2pts.cpp
// Function: WritePoints(gaps::R3Mesh*, gaps::RNArray<Point*> const&, char const*)
RNBoolean 
WritePoints(R3Mesh *mesh, const RNArray<Point *>& points, const char *filename)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .ply)\n", filename);
    return 0;
  }

  // Check file type
  if (!strcmp(extension, ".pid")) {
    // Open file
    FILE *fp = stdout;
    if (filename) {
      fp = fopen(filename, "w");
      if (!fp) {
        RNFail("Unable to open output file %s\n", filename);
        return FALSE;
      }
    }

    // Write vertex ids
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points[i];
      if (!point->vertex) { RNFail("Incompatible output type: pid\n"); return 0; }
      int vertex_id = (point->vertex) ? mesh->VertexID(point->vertex) : -1;
      fprintf(fp, "%d\n", vertex_id);
    }

    // Close file
    if (filename) fclose(fp);
  }
  else if (!strcmp(extension, ".vts")) {
    // Open file
    FILE *fp = stdout;
    if (filename) {
      fp = fopen(filename, "w");
      if (!fp) {
        RNFail("Unable to open output file %s\n", filename);
        return FALSE;
      }
    }

    // Write points
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points[i];
      int vertex_id = (point->vertex) ? mesh->VertexID(point->vertex) : -1;
      const R3Point& position = point->position;
      fprintf(fp, "%d %g %g %g\n", vertex_id, position.X(), position.Y(), position.Z());
    }

    // Close file
    if (filename) fclose(fp);
  }
  else if (!strcmp(extension, ".xyzn")) {
    // Open file
    FILE *fp = stdout;
    if (filename) {
      fp = fopen(filename, "w");
      if (!fp) {
        RNFail("Unable to open output file %s\n", filename);
        return FALSE;
      }
    }

    // Write points
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points[i];
      fprintf(fp, "%g %g %g   %g %g %g\n", 
        point->position.X(), point->position.Y(), point->position.Z(),
        point->normal.X(), point->normal.Y(), point->normal.Z());
    }

    // Close file
    if (filename) fclose(fp);
  }
  else if (!strcmp(extension, ".xyz")) {
    // Open file
    FILE *fp = stdout;
    if (filename) {
      fp = fopen(filename, "w");
      if (!fp) {
        RNFail("Unable to open output file %s\n", filename);
        return FALSE;
      }
    }

    // Write points
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points[i];
      fprintf(fp, "%g %g %g\n", point->position.X(), point->position.Y(), point->position.Z());
    }

    // Close file
    if (filename) fclose(fp);
  }
  else if (!strcmp(extension, ".pts")) {
    // Open file
    FILE *fp = stdout;
    if (filename) {
      fp = fopen(filename, "wb");
      if (!fp) {
        RNFail("Unable to open output file %s\n", filename);
        return FALSE;
      }
    }

    // Write points
    float coordinates[6];
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points[i];
      coordinates[0] = point->position.X();
      coordinates[1] = point->position.Y();
      coordinates[2] = point->position.Z();
      coordinates[3] = point->normal.X();
      coordinates[4] = point->normal.Y();
      coordinates[5] = point->normal.Z();
      if (fwrite(coordinates, sizeof(float), 6, fp) != (unsigned int) 6) {
        RNFail("Unable to write point to output file %s\n", filename);
        return FALSE;
      }
    }

    // Close file
    if (filename) fclose(fp);
  }
  else if (!strcmp(extension, ".sdf")) {
    // Open binary file
    FILE *fp = fopen(filename, "wb");
    if (!fp) {
      RNFail("Unable to open output file %s\n", filename);
      return 0;
    }

    // Write points
    float values[4];
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points.Kth(i);
      values[0] = point->position.X();
      values[1] = point->position.Y();
      values[2] = point->position.Z();
      values[3] = point->sdf;
      if (fwrite(values, sizeof(float), 4, fp) != (unsigned int) 4) {
        RNFail("Unable to write point to output file %s\n", filename);
        return 0;
      }
    }
  }
  else {
    // Create mesh
    R3Mesh mesh;
    for (int i = 0; i < points.NEntries(); i++) {
      Point *point = points[i];
      mesh.CreateVertex(point->position, point->normal);
    }

    // Write mesh file
    if (!mesh.WriteFile(filename)) return FALSE;
  }

  // Print message
  if (print_verbose) {
    fprintf(stdout, "Wrote points to %s ...\n", (filename) ? filename : "stdout");
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    fflush(stdout);
  }

  // Return success
  return TRUE;
}

// Assembly:
subq $0x338, %rsp            # imm = 0x338
movq %rdi, 0x328(%rsp)
movq %rsi, 0x320(%rsp)
movq %rdx, 0x318(%rsp)
leaq 0x308(%rsp), %rdi
callq 0xe7be0
leaq 0x308(%rsp), %rdi
callq 0x1b2d0
movq 0x318(%rsp), %rdi
movl $0x2e, %esi
callq 0xf590
movq %rax, 0x300(%rsp)
cmpq $0x0, %rax
jne 0x125af
movq 0x318(%rsp), %rsi
leaq 0x137ae8(%rip), %rdi    # 0x14a080
movb $0x0, %al
callq 0xf070
movl $0x0, 0x334(%rsp)
jmp 0x13206
movq 0x300(%rsp), %rdi
leaq 0x137aed(%rip), %rsi    # 0x14a0ab
callq 0xf710
cmpl $0x0, %eax
jne 0x12752
movq 0x1759bd(%rip), %rax    # 0x187f90
movq (%rax), %rax
movq %rax, 0x2f8(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x12638
movq 0x318(%rsp), %rdi
leaq 0x13946b(%rip), %rsi    # 0x14ba63
callq 0xf5f0
movq %rax, 0x2f8(%rsp)
cmpq $0x0, 0x2f8(%rsp)
jne 0x12636
movq 0x318(%rsp), %rsi
leaq 0x137a91(%rip), %rdi    # 0x14a0b0
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x12638
movl $0x0, 0x2f4(%rsp)
movl 0x2f4(%rsp), %eax
movl %eax, 0xc0(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, %ecx
movl 0xc0(%rsp), %eax
cmpl %ecx, %eax
jge 0x12735
movq 0x320(%rsp), %rdi
movl 0x2f4(%rsp), %esi
callq 0x1b300
movq %rax, 0x2e8(%rsp)
movq 0x2e8(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x126b7
leaq 0x137a2f(%rip), %rdi    # 0x14a0cf
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
movq 0x2e8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x126e6
movq 0x328(%rsp), %rdi
movq 0x2e8(%rsp), %rax
movq (%rax), %rsi
callq 0x1b320
movl %eax, 0xbc(%rsp)
jmp 0x126f4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xbc(%rsp)
jmp 0x126f4
movl 0xbc(%rsp), %eax
movl %eax, 0x2e4(%rsp)
movq 0x2f8(%rsp), %rdi
movl 0x2e4(%rsp), %edx
leaq 0x138dbf(%rip), %rsi    # 0x14b4d7
movb $0x0, %al
callq 0xf740
movl 0x2f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2f4(%rsp)
jmp 0x12643
cmpq $0x0, 0x318(%rsp)
je 0x1274d
movq 0x2f8(%rsp), %rdi
callq 0xf4c0
jmp 0x13179
movq 0x300(%rsp), %rdi
leaq 0x13798d(%rip), %rsi    # 0x14a0ee
callq 0xf710
cmpl $0x0, %eax
jne 0x12949
movq 0x17581a(%rip), %rax    # 0x187f90
movq (%rax), %rax
movq %rax, 0x2d8(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x127db
movq 0x318(%rsp), %rdi
leaq 0x1392c8(%rip), %rsi    # 0x14ba63
callq 0xf5f0
movq %rax, 0x2d8(%rsp)
cmpq $0x0, 0x2d8(%rsp)
jne 0x127d9
movq 0x318(%rsp), %rsi
leaq 0x1378ee(%rip), %rdi    # 0x14a0b0
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x127db
movl $0x0, 0x2d4(%rsp)
movl 0x2d4(%rsp), %eax
movl %eax, 0xb8(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, %ecx
movl 0xb8(%rsp), %eax
cmpl %ecx, %eax
jge 0x1292c
movq 0x320(%rsp), %rdi
movl 0x2d4(%rsp), %esi
callq 0x1b300
movq %rax, 0x2c8(%rsp)
movq 0x2c8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1285d
movq 0x328(%rsp), %rdi
movq 0x2c8(%rsp), %rax
movq (%rax), %rsi
callq 0x1b320
movl %eax, 0xb4(%rsp)
jmp 0x1286b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xb4(%rsp)
jmp 0x1286b
movl 0xb4(%rsp), %eax
movl %eax, 0x2c4(%rsp)
movq 0x2c8(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x2b8(%rsp)
movq 0x2d8(%rsp), %rax
movq %rax, 0x90(%rsp)
movl 0x2c4(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0x2b8(%rsp), %rdi
callq 0x1b340
movsd %xmm0, 0xa8(%rsp)
movq 0x2b8(%rsp), %rdi
callq 0x1b350
movsd %xmm0, 0xa0(%rsp)
movq 0x2b8(%rsp), %rdi
callq 0x1b360
movq 0x90(%rsp), %rdi
movl 0x9c(%rsp), %edx
movsd 0xa0(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xa8(%rsp), %xmm0
leaq 0x1377e4(%rip), %rsi    # 0x14a0f3
movb $0x3, %al
callq 0xf740
movl 0x2d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2d4(%rsp)
jmp 0x127e6
cmpq $0x0, 0x318(%rsp)
je 0x12944
movq 0x2d8(%rsp), %rdi
callq 0xf4c0
jmp 0x13177
movq 0x300(%rsp), %rdi
leaq 0x1377a8(%rip), %rsi    # 0x14a100
callq 0xf710
cmpl $0x0, %eax
jne 0x12b23
movq 0x175623(%rip), %rax    # 0x187f90
movq (%rax), %rax
movq %rax, 0x2b0(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x129d2
movq 0x318(%rsp), %rdi
leaq 0x1390d1(%rip), %rsi    # 0x14ba63
callq 0xf5f0
movq %rax, 0x2b0(%rsp)
cmpq $0x0, 0x2b0(%rsp)
jne 0x129d0
movq 0x318(%rsp), %rsi
leaq 0x1376f7(%rip), %rdi    # 0x14a0b0
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x129d2
movl $0x0, 0x2ac(%rsp)
movl 0x2ac(%rsp), %eax
movl %eax, 0x8c(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, %ecx
movl 0x8c(%rsp), %eax
cmpl %ecx, %eax
jge 0x12b06
movq 0x320(%rsp), %rdi
movl 0x2ac(%rsp), %esi
callq 0x1b300
movq %rax, 0x2a0(%rsp)
movq 0x2b0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b340
movsd %xmm0, 0x80(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b350
movsd %xmm0, 0x60(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b360
movsd %xmm0, 0x68(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x28, %rdi
callq 0x1b370
movsd %xmm0, 0x70(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x28, %rdi
callq 0x1b380
movsd %xmm0, 0x78(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x28, %rdi
callq 0x1b390
movq 0x58(%rsp), %rdi
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movsd 0x70(%rsp), %xmm3
movsd 0x78(%rsp), %xmm4
movaps %xmm0, %xmm5
movsd 0x80(%rsp), %xmm0
leaq 0x13761d(%rip), %rsi    # 0x14a106
movb $0x6, %al
callq 0xf740
movl 0x2ac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2ac(%rsp)
jmp 0x129dd
cmpq $0x0, 0x318(%rsp)
je 0x12b1e
movq 0x2b0(%rsp), %rdi
callq 0xf4c0
jmp 0x13175
movq 0x300(%rsp), %rdi
leaq 0x1375e9(%rip), %rsi    # 0x14a11b
callq 0xf710
cmpl $0x0, %eax
jne 0x12c9a
movq 0x175449(%rip), %rax    # 0x187f90
movq (%rax), %rax
movq %rax, 0x298(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x12bac
movq 0x318(%rsp), %rdi
leaq 0x138ef7(%rip), %rsi    # 0x14ba63
callq 0xf5f0
movq %rax, 0x298(%rsp)
cmpq $0x0, 0x298(%rsp)
jne 0x12baa
movq 0x318(%rsp), %rsi
leaq 0x13751d(%rip), %rdi    # 0x14a0b0
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x12bac
movl $0x0, 0x294(%rsp)
movl 0x294(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, %ecx
movl 0x54(%rsp), %eax
cmpl %ecx, %eax
jge 0x12c7d
movq 0x320(%rsp), %rdi
movl 0x294(%rsp), %esi
callq 0x1b300
movq %rax, 0x288(%rsp)
movq 0x298(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x288(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b340
movsd %xmm0, 0x48(%rsp)
movq 0x288(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b350
movsd %xmm0, 0x40(%rsp)
movq 0x288(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b360
movq 0x38(%rsp), %rdi
movsd 0x40(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x48(%rsp), %xmm0
leaq 0x1374b1(%rip), %rsi    # 0x14a111
movb $0x3, %al
callq 0xf740
movl 0x294(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x294(%rsp)
jmp 0x12bb7
cmpq $0x0, 0x318(%rsp)
je 0x12c95
movq 0x298(%rsp), %rdi
callq 0xf4c0
jmp 0x13173
movq 0x300(%rsp), %rdi
leaq 0x137477(%rip), %rsi    # 0x14a120
callq 0xf710
cmpl $0x0, %eax
jne 0x12ea4
movq 0x1752d2(%rip), %rax    # 0x187f90
movq (%rax), %rax
movq %rax, 0x280(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x12d23
movq 0x318(%rsp), %rdi
leaq 0x137442(%rip), %rsi    # 0x14a125
callq 0xf5f0
movq %rax, 0x280(%rsp)
cmpq $0x0, 0x280(%rsp)
jne 0x12d21
movq 0x318(%rsp), %rsi
leaq 0x1373a6(%rip), %rdi    # 0x14a0b0
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x12d23
movl $0x0, 0x25c(%rsp)
movl 0x25c(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, %ecx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jge 0x12e87
movq 0x320(%rsp), %rdi
movl 0x25c(%rsp), %esi
callq 0x1b300
movq %rax, 0x250(%rsp)
movq 0x250(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b340
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x260(%rsp)
movq 0x250(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b350
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x264(%rsp)
movq 0x250(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b360
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x268(%rsp)
movq 0x250(%rsp), %rdi
addq $0x28, %rdi
callq 0x1b370
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x26c(%rsp)
movq 0x250(%rsp), %rdi
addq $0x28, %rdi
callq 0x1b380
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x270(%rsp)
movq 0x250(%rsp), %rdi
addq $0x28, %rdi
callq 0x1b390
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x274(%rsp)
leaq 0x260(%rsp), %rdi
movq 0x280(%rsp), %rcx
movl $0x4, %esi
movl $0x6, %edx
callq 0xf990
cmpq $0x6, %rax
je 0x12e6f
movq 0x318(%rsp), %rsi
leaq 0x1372d0(%rip), %rdi    # 0x14a128
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x12e71
movl 0x25c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25c(%rsp)
jmp 0x12d2e
cmpq $0x0, 0x318(%rsp)
je 0x12e9f
movq 0x280(%rsp), %rdi
callq 0xf4c0
jmp 0x13171
movq 0x300(%rsp), %rdi
leaq 0x13729e(%rip), %rsi    # 0x14a151
callq 0xf710
cmpl $0x0, %eax
jne 0x13035
movq 0x318(%rsp), %rdi
leaq 0x137255(%rip), %rsi    # 0x14a125
callq 0xf5f0
movq %rax, 0x248(%rsp)
cmpq $0x0, 0x248(%rsp)
jne 0x12f0e
movq 0x318(%rsp), %rsi
leaq 0x1371b9(%rip), %rdi    # 0x14a0b0
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
movl $0x0, 0x22c(%rsp)
movl 0x22c(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, %ecx
movl 0x30(%rsp), %eax
cmpl %ecx, %eax
jge 0x13030
movq 0x320(%rsp), %rdi
movl 0x22c(%rsp), %esi
callq 0x1b3a0
movq %rax, 0x220(%rsp)
movq 0x220(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b340
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x230(%rsp)
movq 0x220(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b350
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x234(%rsp)
movq 0x220(%rsp), %rdi
addq $0x10, %rdi
callq 0x1b360
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x238(%rsp)
movq 0x220(%rsp), %rax
movsd 0x40(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x23c(%rsp)
leaq 0x230(%rsp), %rdi
movq 0x248(%rsp), %rcx
movl $0x4, %edx
movq %rdx, %rsi
callq 0xf990
cmpq $0x4, %rax
je 0x13018
movq 0x318(%rsp), %rsi
leaq 0x137127(%rip), %rdi    # 0x14a128
movb $0x0, %al
callq 0xebe00
movl $0x0, 0x334(%rsp)
jmp 0x13206
jmp 0x1301a
movl 0x22c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x22c(%rsp)
jmp 0x12f19
jmp 0x1316f
leaq 0xe8(%rsp), %rdi
callq 0x40710
movl $0x0, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1b2f0
movl %eax, 0x2c(%rsp)
jmp 0x1306b
movl 0x28(%rsp), %eax
movl 0x2c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x13107
movq 0x320(%rsp), %rdi
movl 0xe4(%rsp), %esi
callq 0x1b300
movq %rax, 0x20(%rsp)
jmp 0x13096
movq 0x20(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rdx
movq %rdx, %rsi
addq $0x10, %rsi
addq $0x28, %rdx
xorl %eax, %eax
movl %eax, %ecx
leaq 0xe8(%rsp), %rdi
callq 0x46df0
jmp 0x130c9
jmp 0x130cb
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0x1304d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x41610
jmp 0x13215
movq 0x318(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x603f0
movl %eax, 0x1c(%rsp)
jmp 0x13122
movl 0x1c(%rsp), %eax
cmpl $0x0, %eax
jne 0x13143
movl $0x0, 0x334(%rsp)
movl $0x1, 0xc4(%rsp)
jmp 0x1314e
movl $0x0, 0xc4(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x41610
movl 0xc4(%rsp), %eax
testl %eax, %eax
je 0x1316d
jmp 0x13168
jmp 0x13206
jmp 0x1316f
jmp 0x13171
jmp 0x13173
jmp 0x13175
jmp 0x13177
jmp 0x13179
cmpl $0x0, 0x17e450(%rip)    # 0x1915d0
je 0x131fb
movq 0x174e07(%rip), %rax    # 0x187f90
movq (%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x131ab
movq 0x318(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x131b9
leaq 0x136fbc(%rip), %rax    # 0x14a16e
movq %rax, 0x8(%rsp)
jmp 0x131b9
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x136f8c(%rip), %rsi    # 0x14a156
movb $0x0, %al
callq 0xf740
leaq 0x308(%rsp), %rdi
callq 0xe7ca0
leaq 0x136f90(%rip), %rdi    # 0x14a175
movb $0x1, %al
callq 0xf070
movq 0x174d9d(%rip), %rax    # 0x187f90
movq (%rax), %rdi
callq 0xf5e0
movl $0x1, 0x334(%rsp)
movl 0x334(%rsp), %eax
addq $0x338, %rsp            # imm = 0x338
retq
movq 0xd8(%rsp), %rdi
callq 0xf8a0
nopw %cs:(%rax,%rax)