text: /*******************************************************************************
   HAW
   Elective Project
   6th Semester
  
   ********************************************************************************
   Project Name:	Side Channel Analysis
   Author: Mahmoud Jadaan
   ********************************************************************************/
  /*Importing the required libraries*/
  #include <stdio.h>
  #include <stdlib.h>
  #include "flint.h"
  
  CLINT * X_MirroredPoint(CLINT point1[], CLINT point2[], CLINT s, CLINT prime)
  {/*Genrating the x coordinate of the mirrored point(x3, y3):
   x3 = (s^2-(x1+x2)) mod p	*/
  
      CLINT sSquared, sumX;
      static CLINT x_mirroredPoint;
      sqr_l(s, sSquared);
      add_l(point1[0], point2[0], sumX);
      if (cmp_l(sSquared, sumX) == 1)
      {
          sub_l(sSquared, sumX, x_mirroredPoint);
          mod_l(x_mirroredPoint, prime, x_mirroredPoint);
      }
      else
      { //s^2 < (x1+x2)==> factor out the minus sign
          sub_l(sumX, sSquared, x_mirroredPoint);
          smod(x_mirroredPoint, -1, prime, x_mirroredPoint);
      }
  
      return &x_mirroredPoint;
  }
  