<commit_before>// This code is derived from golangs math/big package
// Copyright 2009 The Go Authors. All rights reserved.
// Arduino Port Copyright 2013 <NAME>
// Use of this source code is governed by a BSD-style
// license that can be found in the GOLANG_LICENSE file.

#include <bignat.h>
#include <panic.h>

//#define ALIASCHECKS

const WORD _S = sizeof(WORD);
const WORD _W = _S << 3;
const WORD _B = (WORD)(1<<_W);
const WORD _M = _B-1;

const WORD _W2 = _W/2;
const WORD _B2 = 1 << _W2;
const WORD _M2 = _B2-1;

bignat::bignat(WORD *data,int cap) : data(data),cap(cap),len(0) {
}

inline void bignat::make(int n) {
  if( n<= this->cap ){
    this->len=n;
    return;
  } else {
    PANIC(PANIC_NAT_MAKE_OVERFLOW);
  }  
}

inline void bignat::norm(){
  int i = this->len;
  while( i>0 && this->data[i-1] == 0 ){
    i--;
  }
  this->len=i;
}

void bignat::Set(const struct bignat &b){
#ifdef ALIASCHECKS
  if( this!=&b ){
#endif
    this->make(b.len);
    memcpy(this->data,b.data,b.len * sizeof(WORD));
#ifdef ALIASCHECKS
  } else {
    PANIC(PANIC_NAT_SET_ALIAS);
  }
#endif
}

void bignat::Set(WORD word) {
  this->make(1);
  this->data[0]=word;
  this->norm();
}

WORD bignat::subWW(WORD *z0,WORD x,WORD y,WORD c){
  WORD z1 = 0;
  
  WORD yc = y+c;
  *z0 = x-yc;
  if( *z0 > x || yc < y ){
    z1 = 1;
  }
  
  return z1;
}

WORD bignat::addWW(WORD *z0,WORD x,WORD y,WORD c){
  WORD z1 = 0;
  <commit_msg>remove norm() only needed when zero is set.<commit_after>// This code is derived from golangs math/big package
// Copyright 2009 The Go Authors. All rights reserved.
// Arduino Port Copyright 2013 <NAME>
// Use of this source code is governed by a BSD-style
// license that can be found in the GOLANG_LICENSE file.

#include <bignat.h>
#include <panic.h>

//#define ALIASCHECKS

const WORD _S = sizeof(WORD);
const WORD _W = _S << 3;
const WORD _B = (WORD)(1<<_W);
const WORD _M = _B-1;

const WORD _W2 = _W/2;
const WORD _B2 = 1 << _W2;
const WORD _M2 = _B2-1;

bignat::bignat(WORD *data,int cap) : data(data),cap(cap),len(0) {
}

inline void bignat::make(int n) {
  if( n<= this->cap ){
    this->len=n;
    return;
  } else {
    PANIC(PANIC_NAT_MAKE_OVERFLOW);
  }  
}

inline void bignat::norm(){
  int i = this->len;
  while( i>0 && this->data[i-1] == 0 ){
    i--;
  }
  this->len=i;
}

void bignat::Set(const struct bignat &b){
#ifdef ALIASCHECKS
  if( this!=&b ){
#endif
    this->make(b.len);
    memcpy(this->data,b.data,b.len * sizeof(WORD));
#ifdef ALIASCHECKS
  } else {
    PANIC(PANIC_NAT_SET_ALIAS);
  }
#endif
}

void bignat::Set(WORD word) {
    this->make(1);
    this->data[0]=word;
}

WORD bignat::subWW(WORD *z0,WORD x,WORD y,WORD c){
  WORD z1 = 0;
  
  WORD yc = y+c;
  *z0 = x-yc;
  if( *z0 > x || yc < y ){
    z1 = 1;
  }
  
  return z1;
}

WORD bignat::addWW(WORD *z0,WORD x,WORD y,WORD c){
  WORD z1 = 0;
  
{'fraction_non_alphanumeric': 0.16526610644257703, 'fraction_numerical': 0.025210084033613446, 'mean_word_length': 3.158660844250364, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6689884', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1232, 'n_words': 326}