# 0 "./pre-field.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "./pre-field.c"
typedef __int128 uint128_t;
# 14 "./pre-field.c"
# 1 "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/stdint.h" 1 3 4
# 9 "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/stdint.h" 3 4
# 1 "/usr/include/stdint.h" 1 3 4
# 26 "/usr/include/stdint.h" 3 4
# 1 "/usr/include/bits/libc-header-start.h" 1 3 4
# 33 "/usr/include/bits/libc-header-start.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 393 "/usr/include/features.h" 3 4
# 1 "/usr/include/features-time64.h" 1 3 4
# 20 "/usr/include/features-time64.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 21 "/usr/include/features-time64.h" 2 3 4
# 1 "/usr/include/bits/timesize.h" 1 3 4
# 19 "/usr/include/bits/timesize.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 20 "/usr/include/bits/timesize.h" 2 3 4
# 22 "/usr/include/features-time64.h" 2 3 4
# 394 "/usr/include/features.h" 2 3 4
# 491 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 559 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 560 "/usr/include/sys/cdefs.h" 2 3 4
# 1 "/usr/include/bits/long-double.h" 1 3 4
# 561 "/usr/include/sys/cdefs.h" 2 3 4
# 492 "/usr/include/features.h" 2 3 4
# 515 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 10 "/usr/include/gnu/stubs.h" 3 4
# 1 "/usr/include/gnu/stubs-64.h" 1 3 4
# 11 "/usr/include/gnu/stubs.h" 2 3 4
# 516 "/usr/include/features.h" 2 3 4
# 34 "/usr/include/bits/libc-header-start.h" 2 3 4
# 27 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/bits/types.h" 1 3 4
# 27 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 28 "/usr/include/bits/types.h" 2 3 4
# 1 "/usr/include/bits/timesize.h" 1 3 4
# 19 "/usr/include/bits/timesize.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 20 "/usr/include/bits/timesize.h" 2 3 4
# 29 "/usr/include/bits/types.h" 2 3 4



# 31 "/usr/include/bits/types.h" 3 4
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;


typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;

typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;






typedef __int8_t __int_least8_t;
typedef __uint8_t __uint_least8_t;
typedef __int16_t __int_least16_t;
typedef __uint16_t __uint_least16_t;
typedef __int32_t __int_least32_t;
typedef __uint32_t __uint_least32_t;
typedef __int64_t __int_least64_t;
typedef __uint64_t __uint_least64_t;



typedef long int __quad_t;
typedef unsigned long int __u_quad_t;







typedef long int __intmax_t;
typedef unsigned long int __uintmax_t;
# 141 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/typesizes.h" 1 3 4
# 142 "/usr/include/bits/types.h" 2 3 4
# 1 "/usr/include/bits/time64.h" 1 3 4
# 143 "/usr/include/bits/types.h" 2 3 4


typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;
typedef long int __suseconds64_t;

typedef int __daddr_t;
typedef int __key_t;


typedef int __clockid_t;


typedef void * __timer_t;


typedef long int __blksize_t;




typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;


typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;


typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;


typedef long int __fsword_t;

typedef long int __ssize_t;


typedef long int __syscall_slong_t;

typedef unsigned long int __syscall_ulong_t;



typedef __off64_t __loff_t;
typedef char *__caddr_t;


typedef long int __intptr_t;


typedef unsigned int __socklen_t;




typedef int __sig_atomic_t;
# 28 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/bits/wchar.h" 1 3 4
# 29 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 30 "/usr/include/stdint.h" 2 3 4




# 1 "/usr/include/bits/stdint-intn.h" 1 3 4
# 24 "/usr/include/bits/stdint-intn.h" 3 4
typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;
# 35 "/usr/include/stdint.h" 2 3 4


# 1 "/usr/include/bits/stdint-uintn.h" 1 3 4
# 24 "/usr/include/bits/stdint-uintn.h" 3 4
typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;
# 38 "/usr/include/stdint.h" 2 3 4





typedef __int_least8_t int_least8_t;
typedef __int_least16_t int_least16_t;
typedef __int_least32_t int_least32_t;
typedef __int_least64_t int_least64_t;


typedef __uint_least8_t uint_least8_t;
typedef __uint_least16_t uint_least16_t;
typedef __uint_least32_t uint_least32_t;
typedef __uint_least64_t uint_least64_t;





typedef signed char int_fast8_t;

typedef long int int_fast16_t;
typedef long int int_fast32_t;
typedef long int int_fast64_t;
# 71 "/usr/include/stdint.h" 3 4
typedef unsigned char uint_fast8_t;

typedef unsigned long int uint_fast16_t;
typedef unsigned long int uint_fast32_t;
typedef unsigned long int uint_fast64_t;
# 87 "/usr/include/stdint.h" 3 4
typedef long int intptr_t;


typedef unsigned long int uintptr_t;
# 101 "/usr/include/stdint.h" 3 4
typedef __intmax_t intmax_t;
typedef __uintmax_t uintmax_t;
# 10 "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/stdint.h" 2 3 4
# 15 "./pre-field.c" 2
# 24 "./pre-field.c"
 
# 24 "./pre-field.c"
                       void
secp256k1_fe_mul_inner(uint64_t *r, const uint64_t *a,
                       const uint64_t *restrict b) {
  uint128_t c, d;
  uint64_t t3, t4, tx, u0;
  uint64_t a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4];
  const uint64_t M = 0xFFFFFFFFFFFFFULL, R = 0x1000003D10ULL;
# 39 "./pre-field.c"
  d = (uint128_t)a0 * b[3] + (uint128_t)a1 * b[2] + (uint128_t)a2 * b[1] +
      (uint128_t)a3 * b[0];

  c = (uint128_t)a4 * b[4];

  d += (uint128_t)R * (uint64_t)c;
  c >>= 64;

  t3 = d & M;
  d >>= 52;


  d += (uint128_t)a0 * b[4] + (uint128_t)a1 * b[3] + (uint128_t)a2 * b[2] +
       (uint128_t)a3 * b[1] + (uint128_t)a4 * b[0];

  d += (uint128_t)(R << 12) * (uint64_t)c;

  t4 = d & M;
  d >>= 52;

  tx = (t4 >> 48);
  t4 &= (M >> 4);


  c = (uint128_t)a0 * b[0];

  d += (uint128_t)a1 * b[4] + (uint128_t)a2 * b[3] + (uint128_t)a3 * b[2] +
       (uint128_t)a4 * b[1];

  u0 = d & M;
  d >>= 52;


  u0 = (u0 << 4) | tx;

  c += (uint128_t)u0 * (R >> 4);

  r[0] = c & M;
  c >>= 52;


  c += (uint128_t)a0 * b[1] + (uint128_t)a1 * b[0];

  d += (uint128_t)a2 * b[4] + (uint128_t)a3 * b[3] + (uint128_t)a4 * b[2];

  c += (d & M) * R;
  d >>= 52;

  r[1] = c & M;
  c >>= 52;


  c += (uint128_t)a0 * b[2] + (uint128_t)a1 * b[1] + (uint128_t)a2 * b[0];

  d += (uint128_t)a3 * b[4] + (uint128_t)a4 * b[3];

  c += (uint128_t)R * (uint64_t)d;
  d >>= 64;


  r[2] = c & M;
  c >>= 52;

  c += (uint128_t)(R << 12) * (uint64_t)d + t3;

  r[3] = c & M;
  c >>= 52;

  c += t4;

  r[4] = c;

}

 void secp256k1_fe_sqr_inner(uint64_t *r,
                                                    const uint64_t *a) {
  uint128_t c, d;
  uint64_t a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4];
  int64_t t3, t4, tx, u0;
  const uint64_t M = 0xFFFFFFFFFFFFFULL, R = 0x1000003D10ULL;







  d = (uint128_t)(a0 * 2) * a3 + (uint128_t)(a1 * 2) * a2;

  c = (uint128_t)a4 * a4;

  d += (uint128_t)R * (uint64_t)c;
  c >>= 64;

  t3 = d & M;
  d >>= 52;


  a4 *= 2;
  d += (uint128_t)a0 * a4 + (uint128_t)(a1 * 2) * a3 + (uint128_t)a2 * a2;

  d += (uint128_t)(R << 12) * (uint64_t)c;

  t4 = d & M;
  d >>= 52;

  tx = (t4 >> 48);
  t4 &= (M >> 4);


  c = (uint128_t)a0 * a0;

  d += (uint128_t)a1 * a4 + (uint128_t)(a2 * 2) * a3;

  u0 = d & M;
  d >>= 52;


  u0 = (u0 << 4) | tx;

  c += (uint128_t)u0 * (R >> 4);

  r[0] = c & M;
  c >>= 52;


  a0 *= 2;
  c += (uint128_t)a0 * a1;

  d += (uint128_t)a2 * a4 + (uint128_t)a3 * a3;

  c += (d & M) * R;
  d >>= 52;

  r[1] = c & M;
  c >>= 52;


  c += (uint128_t)a0 * a2 + (uint128_t)a1 * a1;

  d += (uint128_t)a3 * a4;

  c += (uint128_t)R * (uint64_t)d;
  d >>= 64;

  r[2] = c & M;
  c >>= 52;


  c += (uint128_t)(R << 12) * (uint64_t)d + t3;

  r[3] = c & M;
  c >>= 52;

  c += t4;

  r[4] = c;

}
