-
+ A6703D0851FB4F5A7C05EA94B0EA1C9DF3B79379B43C55EF10481496984DC6B58C3B26FC009607EDE37917758CC7576065049C5A511EEE7E0B9048E1A1B06654
smg_comms/mpi/mpih-mul3.c
(0 . 0)(1 . 62)
7141 /* mpihelp-mul_3.c - MPI helper functions
7142 * Modified by No Such Labs. (C) 2015. See README.
7143 *
7144 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
7145 * SHA256(gnupg-1.4.10.tar.gz):
7146 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
7147 * (C) 1994-2005 Free Software Foundation, Inc.
7148 *
7149 * This program is free software: you can redistribute it and/or modify
7150 * it under the terms of the GNU General Public License as published by
7151 * the Free Software Foundation, either version 3 of the License, or
7152 * (at your option) any later version.
7153 *
7154 * This program is distributed in the hope that it will be useful,
7155 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7156 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7157 * GNU General Public License for more details.
7158 *
7159 * You should have received a copy of the GNU General Public License
7160 * along with this program. If not, see <http://www.gnu.org/licenses/>.
7161 */
7162
7163 #include <stdio.h>
7164 #include <stdlib.h>
7165
7166 #include "knobs.h"
7167 #include "mpi-internal.h"
7168 #include "longlong.h"
7169
7170
7171 mpi_limb_t
7172 mpihelp_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
7173 mpi_size_t s1_size, mpi_limb_t s2_limb)
7174 {
7175 mpi_limb_t cy_limb;
7176 mpi_size_t j;
7177 mpi_limb_t prod_high, prod_low;
7178 mpi_limb_t x;
7179
7180 /* The loop counter and index J goes from -SIZE to -1. This way
7181 * the loop becomes faster. */
7182 j = -s1_size;
7183 res_ptr -= j;
7184 s1_ptr -= j;
7185
7186 cy_limb = 0;
7187 do {
7188 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
7189
7190 prod_low += cy_limb;
7191 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
7192
7193 x = res_ptr[j];
7194 prod_low = x - prod_low;
7195 cy_limb += prod_low > x?1:0;
7196 res_ptr[j] = prod_low;
7197 } while( ++j );
7198
7199 return cy_limb;
7200 }
7201
7202