// File: WeihuaZhu[P]hpc_prog2/main.cpp
// Function: main
int main(int argc, char *argv[])
{
   // set up MPI
   MPI_Init(&argc, &argv);

   // get communicator size
   MPI_Comm comm = MPI_COMM_WORLD;
   int p;
   MPI_Comm_size(comm, &p);

   // Ax = b
   std::vector<double> A;
   std::vector<double> b;
   std::vector<double> x;


   /**********************************
    *  Parse command line arguments  *
    **********************************/
   bool write_output = false;
   std::string outfile_name;
   int n;
   bool rand_input = false;
   double difficulty = 0.5;
   std::string fileA;
   std::string fileB;
   if (argc < 3)
   {
      print_usage();
      exit(EXIT_FAILURE);
   }
   if (std::string(argv[1]) == "-n")
   {
      // randomly generate input
      n = atoi(argv[2]);
      if (!(n > 0))
      {
         print_usage();
         exit(EXIT_FAILURE);
      }
      if (argc == 5)
      {
         if (std::string(argv[3]) != "-d")
         {
            print_usage();
            exit(EXIT_FAILURE);
         }
         std::istringstream iss(argv[4]);
         iss >> difficulty;
      }
      rand_input = true;
   }
   else
   {
      if (argc != 4)
      {
         print_usage();
         exit(EXIT_FAILURE);
      }

      // get output filename
      outfile_name = std::string(argv[3]);
      write_output = true;
   }


   // start timer
   //   we omit the file loading and argument parsing from the runtime
   //   timings, we measure the time needed by the processor with rank 0
   struct timespec t_start, t_end;
   if (p > 1)
   {
      // get the dimensions
      int q = (int)sqrt(p);
      if (p != q*q)
      {
         throw std::runtime_error("The number of MPI processes must be a perfect square");
      }
      // create 2D cartesian grid for the processors (enable reordering)
      MPI_Comm grid_comm;
      int dims[2] = {q, q};
      int periods[2] = {0, 0};
      MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 1, &grid_comm);
      // get the rank of process with coordinates (0,0)
      int rank00;
      int myrank;
      int coords[2] = {0, 0};
      MPI_Cart_rank(grid_comm, coords, &rank00);
      MPI_Comm_rank(grid_comm, &myrank);

      // process (0,0) loads input
      if (myrank == rank00)
      {
         if (rand_input) {
            // generate random input of the given size
            A = diag_dom_rand(n, difficulty);
            b = randn(n);
         } else {
            // read input from file
            A = read_binary_file<double>(argv[1]);
            b = read_binary_file<double>(argv[2]);
            n = b.size();
            if (A.size() != n*(size_t)n)
            {
               throw std::runtime_error("The input dimensions are not matching");
            }
         }
      }
      MPI_Bcast(&n, 1, MPI_INT, rank00, grid_comm);

      // start timer
      clock_gettime(CLOCK_MONOTONIC,  &t_start);

      // allocate output and run the parallel jacobi implementation
      if (myrank == rank00)
         x = std::vector<double>(n);
      mpi_jacobi(n, &A[0], &b[0], &x[0], grid_comm);

      if (myrank == rank00)
      {
         // get time
         clock_gettime(CLOCK_MONOTONIC,  &t_end);
         // time in seconds
         double time_secs = (t_end.tv_sec - t_start.tv_sec)
            + (double) (t_end.tv_nsec - t_start.tv_nsec) * 1e-9;
         // output time
         std::cerr << time_secs << std::endl;
         // write output
         if (write_output)
         {
            write_binary_file(outfile_name.c_str(), x);
         }
      }
   }
   else
   {
      std::cerr << "[WARNING]: Running the sequential solver. Start with mpirun to execute the parallel version." << std::endl;

      // get input
      if (rand_input) {
         // generate random input of the given size
         A = diag_dom_rand(n, difficulty);
         b = randn(n);
      } else {
         // read input from file
         A = read_binary_file<double>(argv[1]);
         b = read_binary_file<double>(argv[2]);
         n = b.size();
         if (A.size() != n*(size_t)n)
         {
            throw std::runtime_error("The input dimensions are not matching");
         }
      }

      clock_gettime(CLOCK_MONOTONIC,  &t_start);
      // sequential jacobi
      x = std::vector<double>(n);
      jacobi(n, &A[0], &b[0], &x[0]);
      // get time
      clock_gettime(CLOCK_MONOTONIC,  &t_end);
      // time in seconds
      double time_secs = (t_end.tv_sec - t_start.tv_sec)
         + (double) (t_end.tv_nsec - t_start.tv_nsec) * 1e-9;
      // output time
      std::cerr << time_secs << std::endl;
      // write output
      if (write_output)
      {
         write_binary_file(outfile_name.c_str(), x);
      }
   }

   // finalize MPI
   MPI_Finalize();
   return 0;
}

// Assembly:
subq $0x588, %rsp            # imm = 0x588
movl $0x0, 0x584(%rsp)
movl %edi, 0x580(%rsp)
movq %rsi, 0x578(%rsp)
leaq 0x580(%rsp), %rdi
leaq 0x578(%rsp), %rsi
callq 0x9a30
movq 0xf933(%rip), %rax      # 0x19fa0
movq %rax, 0x570(%rsp)
movq 0x570(%rsp), %rdi
leaq 0x56c(%rsp), %rsi
callq 0x9810
leaq 0x550(%rsp), %rdi
callq 0xbd20
leaq 0x538(%rsp), %rdi
callq 0xbd20
leaq 0x520(%rsp), %rdi
callq 0xbd20
movb $0x0, 0x51f(%rsp)
leaq 0x4f8(%rsp), %rdi
callq 0x99d0
movb $0x0, 0x4f3(%rsp)
movsd 0x9952(%rip), %xmm0     # 0x14028
movsd %xmm0, 0x4e8(%rsp)
leaq 0x4c8(%rsp), %rdi
callq 0x99d0
leaq 0x4a8(%rsp), %rdi
callq 0x99d0
cmpl $0x3, 0x580(%rsp)
jge 0xa72d
callq 0xa530
jmp 0xa70a
movl $0x1, %edi
callq 0x9860
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
jmp 0xb49b
movq 0x578(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x108(%rsp)
leaq 0x477(%rsp), %rdi
movq %rdi, 0x110(%rsp)
callq 0x9cd0
movq 0x108(%rsp), %rsi
movq 0x110(%rsp), %rdx
leaq 0x478(%rsp), %rdi
callq 0xbd60
jmp 0xa775
leaq 0x9a93(%rip), %rsi      # 0x1420f
leaq 0x478(%rsp), %rdi
callq 0xbd30
movb %al, 0x107(%rsp)
jmp 0xa792
leaq 0x478(%rsp), %rdi
callq 0x93e0
leaq 0x477(%rsp), %rdi
callq 0x9770
movb 0x107(%rsp), %al
testb $0x1, %al
jne 0xa7bc
jmp 0xaa4c
movq 0x578(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x9b10
movl %eax, 0x4f4(%rsp)
cmpl $0x0, 0x4f4(%rsp)
jg 0xa838
callq 0xa530
jmp 0xa7e5
movl $0x1, %edi
callq 0x9860
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
jmp 0xa826
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x478(%rsp), %rdi
callq 0x93e0
leaq 0x477(%rsp), %rdi
callq 0x9770
jmp 0xb49b
cmpl $0x5, 0x580(%rsp)
jne 0xaa3f
movq 0x578(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0xf0(%rsp)
leaq 0x44f(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0x9cd0
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
leaq 0x450(%rsp), %rdi
callq 0xbd60
jmp 0xa88e
leaq 0x997d(%rip), %rsi      # 0x14212
leaq 0x450(%rsp), %rdi
callq 0xbe20
movb %al, 0xef(%rsp)
jmp 0xa8ab
leaq 0x450(%rsp), %rdi
callq 0x93e0
leaq 0x44f(%rsp), %rdi
callq 0x9770
movb 0xef(%rsp), %al
testb $0x1, %al
jne 0xa8d2
jmp 0xa92c
callq 0xa530
jmp 0xa8d9
movl $0x1, %edi
callq 0x9860
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
jmp 0xa91a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x450(%rsp), %rdi
callq 0x93e0
leaq 0x44f(%rsp), %rdi
callq 0x9770
jmp 0xb49b
movq 0x578(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0xd8(%rsp)
leaq 0x2a7(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x9cd0
movq 0xd8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
leaq 0x2a8(%rsp), %rdi
callq 0xbd60
jmp 0xa974
leaq 0x2c8(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
movl $0x8, %edx
callq 0x9c10
jmp 0xa990
leaq 0x2a8(%rsp), %rdi
callq 0x93e0
leaq 0x2a7(%rsp), %rdi
callq 0x9770
leaq 0x2c8(%rsp), %rdi
leaq 0x4e8(%rsp), %rsi
callq 0x95a0
jmp 0xa9c1
leaq 0x2c8(%rsp), %rdi
callq 0x92b0
jmp 0xaa3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
jmp 0xaa07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x93e0
leaq 0x2a7(%rsp), %rdi
callq 0x9770
jmp 0xb49b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0x92b0
jmp 0xb49b
movb $0x1, 0x4f3(%rsp)
jmp 0xab0e
cmpl $0x4, 0x580(%rsp)
je 0xaa67
callq 0xa530
jmp 0xaa5d
movl $0x1, %edi
callq 0x9860
movq 0x578(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0xc8(%rsp)
leaq 0x27f(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x9cd0
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0x280(%rsp), %rdi
callq 0xbd60
jmp 0xaaaf
leaq 0x4f8(%rsp), %rdi
leaq 0x280(%rsp), %rsi
callq 0x9870
leaq 0x280(%rsp), %rdi
callq 0x93e0
leaq 0x27f(%rsp), %rdi
callq 0x9770
movb $0x1, 0x51f(%rsp)
jmp 0xab0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x27f(%rsp), %rdi
callq 0x9770
jmp 0xb49b
cmpl $0x1, 0x56c(%rsp)
jle 0xb07f
cvtsi2sdl 0x56c(%rsp), %xmm0
callq 0x9520
cvttsd2si %xmm0, %eax
movl %eax, 0x254(%rsp)
movl 0x56c(%rsp), %eax
movl 0x254(%rsp), %ecx
imull 0x254(%rsp), %ecx
cmpl %ecx, %eax
je 0xabbb
movl $0x10, %edi
callq 0x92c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xc0(%rsp)
leaq 0x96a7(%rip), %rsi      # 0x14215
callq 0x9220
jmp 0xab75
movq 0xc0(%rsp), %rdi
movq 0xf46c(%rip), %rsi      # 0x19ff0
movq 0xf42d(%rip), %rdx      # 0x19fb8
callq 0x9c70
jmp 0xb4f6
movq 0xc0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
callq 0x9480
jmp 0xb49b
movl 0x254(%rsp), %eax
movl %eax, 0x240(%rsp)
movl 0x254(%rsp), %eax
movl %eax, 0x244(%rsp)
movq $0x0, 0x238(%rsp)
movq 0xf3b6(%rip), %rdi      # 0x19fa0
movl $0x2, %esi
leaq 0x240(%rsp), %rdx
leaq 0x238(%rsp), %rcx
movl $0x1, %r8d
leaq 0x248(%rsp), %r9
callq 0x9080
jmp 0xac14
movq $0x0, 0x228(%rsp)
movq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rsi
leaq 0x234(%rsp), %rdx
callq 0x9cf0
jmp 0xac3f
movq 0x248(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x9a20
jmp 0xac56
movl 0x230(%rsp), %eax
cmpl 0x234(%rsp), %eax
jne 0xae35
testb $0x1, 0x4f3(%rsp)
je 0xad09
movl 0x4f4(%rsp), %esi
movsd 0x4e8(%rsp), %xmm0
leaq 0x210(%rsp), %rdi
callq 0xa2e0
jmp 0xac97
leaq 0x550(%rsp), %rdi
leaq 0x210(%rsp), %rsi
movq %rsi, 0xb8(%rsp)
callq 0xbe50
movq 0xb8(%rsp), %rdi
callq 0xbcc0
movl 0x4f4(%rsp), %esi
leaq 0x1f8(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x9355(%rip), %xmm1     # 0x14030
callq 0xa1e0
jmp 0xace2
leaq 0x538(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0xbe50
leaq 0x1f8(%rsp), %rdi
callq 0xbcc0
jmp 0xae33
movq 0x578(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0xbe90
jmp 0xad24
leaq 0x550(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
movq %rsi, 0xb0(%rsp)
callq 0xbe50
movq 0xb0(%rsp), %rdi
callq 0xbcc0
movq 0x578(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x1c8(%rsp), %rdi
callq 0xbe90
jmp 0xad69
leaq 0x538(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0xbe50
leaq 0x1c8(%rsp), %rdi
callq 0xbcc0
leaq 0x538(%rsp), %rdi
callq 0xc200
movl %eax, 0x4f4(%rsp)
leaq 0x550(%rsp), %rdi
callq 0xc200
movslq 0x4f4(%rsp), %rcx
movslq 0x4f4(%rsp), %rdx
imulq %rdx, %rcx
cmpq %rcx, %rax
je 0xae31
movl $0x10, %edi
callq 0x92c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xa8(%rsp)
leaq 0x9466(%rip), %rsi      # 0x1424a
callq 0x9220
jmp 0xadeb
movq 0xa8(%rsp), %rdi
movq 0xf1f6(%rip), %rsi      # 0x19ff0
movq 0xf1b7(%rip), %rdx      # 0x19fb8
callq 0x9c70
jmp 0xb4f6
movq 0xa8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
callq 0x9480
jmp 0xb49b
jmp 0xae33
jmp 0xae35
movl 0x234(%rsp), %ecx
movq 0x248(%rsp), %r8
movq 0xf17d(%rip), %rdx      # 0x19fc8
leaq 0x4f4(%rsp), %rdi
movl $0x1, %esi
callq 0x90d0
jmp 0xae5f
movl $0x1, %edi
leaq 0x268(%rsp), %rsi
callq 0x9650
movl 0x230(%rsp), %eax
cmpl 0x234(%rsp), %eax
jne 0xaf20
movslq 0x4f4(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x1af(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xbc00
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x1b0(%rsp), %rdi
callq 0xbc10
jmp 0xaec9
leaq 0x520(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0xbe50
leaq 0x1b0(%rsp), %rdi
callq 0xbcc0
leaq 0x1af(%rsp), %rdi
callq 0xbc90
jmp 0xaf20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x1af(%rsp), %rdi
callq 0xbc90
jmp 0xb49b
movl 0x4f4(%rsp), %eax
movl %eax, 0x84(%rsp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0x78(%rsp)
leaq 0x550(%rsp), %rdi
callq 0xbca0
movq 0x78(%rsp), %rsi
movq %rax, 0x88(%rsp)
leaq 0x538(%rsp), %rdi
callq 0xbca0
movq 0x78(%rsp), %rsi
movq %rax, 0x90(%rsp)
leaq 0x520(%rsp), %rdi
callq 0xbca0
movl 0x84(%rsp), %edi
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %rax, %rcx
movq 0x248(%rsp), %r8
movl $0x64, %r9d
movsd 0x9090(%rip), %xmm0     # 0x14038
callq 0x131f0
jmp 0xafaf
movl 0x230(%rsp), %eax
cmpl 0x234(%rsp), %eax
jne 0xb07a
movl $0x1, %edi
leaq 0x258(%rsp), %rsi
callq 0x9650
movq 0x258(%rsp), %rdx
movq 0x260(%rsp), %rax
movq 0x268(%rsp), %rsi
movq 0x270(%rsp), %rcx
subq %rsi, %rdx
cvtsi2sd %rdx, %xmm1
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0x9033(%rip), %xmm2     # 0x14040
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1a0(%rsp)
movsd 0x1a0(%rsp), %xmm0
movq 0xefba(%rip), %rdi      # 0x19fe8
callq 0x9db0
movq %rax, 0x70(%rsp)
jmp 0xb03a
movq 0x70(%rsp), %rdi
movq 0xef52(%rip), %rsi      # 0x19f98
callq 0x9700
jmp 0xb04d
testb $0x1, 0x51f(%rsp)
je 0xb078
leaq 0x4f8(%rsp), %rdi
callq 0x9240
movq %rax, %rdi
leaq 0x520(%rsp), %rsi
callq 0xc220
jmp 0xb076
jmp 0xb078
jmp 0xb07a
jmp 0xb42c
movq 0xef62(%rip), %rdi      # 0x19fe8
leaq 0x91e3(%rip), %rsi      # 0x14270
callq 0x96c0
movq %rax, 0x68(%rsp)
jmp 0xb099
movq 0x68(%rsp), %rdi
movq 0xeef3(%rip), %rsi      # 0x19f98
callq 0x9700
jmp 0xb0ac
testb $0x1, 0x4f3(%rsp)
je 0xb145
movl 0x4f4(%rsp), %esi
movsd 0x4e8(%rsp), %xmm0
leaq 0x188(%rsp), %rdi
callq 0xa2e0
jmp 0xb0d9
leaq 0x550(%rsp), %rdi
leaq 0x188(%rsp), %rsi
movq %rsi, 0x60(%rsp)
callq 0xbe50
movq 0x60(%rsp), %rdi
callq 0xbcc0
movl 0x4f4(%rsp), %esi
leaq 0x170(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x8f19(%rip), %xmm1     # 0x14030
callq 0xa1e0
jmp 0xb11e
leaq 0x538(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0xbe50
leaq 0x170(%rsp), %rdi
callq 0xbcc0
jmp 0xb260
movq 0x578(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x158(%rsp), %rdi
callq 0xbe90
jmp 0xb160
leaq 0x550(%rsp), %rdi
leaq 0x158(%rsp), %rsi
movq %rsi, 0x58(%rsp)
callq 0xbe50
movq 0x58(%rsp), %rdi
callq 0xbcc0
movq 0x578(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x140(%rsp), %rdi
callq 0xbe90
jmp 0xb19f
leaq 0x538(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0xbe50
leaq 0x140(%rsp), %rdi
callq 0xbcc0
leaq 0x538(%rsp), %rdi
callq 0xc200
movl %eax, 0x4f4(%rsp)
leaq 0x550(%rsp), %rdi
callq 0xc200
movslq 0x4f4(%rsp), %rcx
movslq 0x4f4(%rsp), %rdx
imulq %rdx, %rcx
cmpq %rcx, %rax
je 0xb25e
movl $0x10, %edi
callq 0x92c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
leaq 0x9033(%rip), %rsi      # 0x1424a
callq 0x9220
jmp 0xb21e
movq 0x50(%rsp), %rdi
movq 0xedc6(%rip), %rsi      # 0x19ff0
movq 0xed87(%rip), %rdx      # 0x19fb8
callq 0x9c70
jmp 0xb4f6
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
callq 0x9480
jmp 0xb49b
jmp 0xb260
movl $0x1, %edi
leaq 0x268(%rsp), %rsi
callq 0x9650
movslq 0x4f4(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x127(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xbc00
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x128(%rsp), %rdi
callq 0xbc10
jmp 0xb2aa
leaq 0x520(%rsp), %rdi
movq %rdi, 0x18(%rsp)
leaq 0x128(%rsp), %rsi
movq %rsi, 0x10(%rsp)
callq 0xbe50
movq 0x10(%rsp), %rdi
callq 0xbcc0
leaq 0x127(%rsp), %rdi
callq 0xbc90
movl 0x4f4(%rsp), %eax
movl %eax, 0x2c(%rsp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0x20(%rsp)
leaq 0x550(%rsp), %rdi
callq 0xbca0
movq 0x20(%rsp), %rsi
movq %rax, 0x30(%rsp)
leaq 0x538(%rsp), %rdi
callq 0xbca0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rax, 0x38(%rsp)
callq 0xbca0
movl 0x2c(%rsp), %edi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rax, %rcx
movl $0x64, %r8d
movsd 0x8ced(%rip), %xmm0     # 0x14038
callq 0x11a00
jmp 0xb352
movl $0x1, %edi
leaq 0x258(%rsp), %rsi
callq 0x9650
movq 0x258(%rsp), %rdx
movq 0x260(%rsp), %rax
movq 0x268(%rsp), %rsi
movq 0x270(%rsp), %rcx
subq %rsi, %rdx
cvtsi2sd %rdx, %xmm1
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0x8ca4(%rip), %xmm2     # 0x14040
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x118(%rsp), %xmm0
movq 0xec2b(%rip), %rdi      # 0x19fe8
callq 0x9db0
movq %rax, 0x8(%rsp)
jmp 0xb3c9
movq 0x8(%rsp), %rdi
movq 0xebc3(%rip), %rsi      # 0x19f98
callq 0x9700
jmp 0xb3dc
testb $0x1, 0x51f(%rsp)
je 0xb42a
leaq 0x4f8(%rsp), %rdi
callq 0x9240
movq %rax, %rdi
leaq 0x520(%rsp), %rsi
callq 0xc220
jmp 0xb405
jmp 0xb42a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4a0(%rsp)
movl %eax, 0x49c(%rsp)
leaq 0x127(%rsp), %rdi
callq 0xbc90
jmp 0xb49b
jmp 0xb42c
callq 0x9500
jmp 0xb433
movl $0x0, 0x584(%rsp)
leaq 0x4a8(%rsp), %rdi
callq 0x93e0
leaq 0x4c8(%rsp), %rdi
callq 0x93e0
leaq 0x4f8(%rsp), %rdi
callq 0x93e0
leaq 0x520(%rsp), %rdi
callq 0xbcc0
leaq 0x538(%rsp), %rdi
callq 0xbcc0
leaq 0x550(%rsp), %rdi
callq 0xbcc0
movl 0x584(%rsp), %eax
addq $0x588, %rsp            # imm = 0x588
retq
leaq 0x4a8(%rsp), %rdi
callq 0x93e0
leaq 0x4c8(%rsp), %rdi
callq 0x93e0
leaq 0x4f8(%rsp), %rdi
callq 0x93e0
leaq 0x520(%rsp), %rdi
callq 0xbcc0
leaq 0x538(%rsp), %rdi
callq 0xbcc0
leaq 0x550(%rsp), %rdi
callq 0xbcc0
movq 0x4a0(%rsp), %rdi
callq 0x9cc0
nopw %cs:(%rax,%rax)