Upgrade to openssl-1.0.0e

Bug: 5261862
Change-Id: I34d2d458aa85e61b1faacb8b5f386353be679d9b
diff --git a/ThirdPartyProject.prop b/ThirdPartyProject.prop
index 8368bb7..34ad609 100644
--- a/ThirdPartyProject.prop
+++ b/ThirdPartyProject.prop
@@ -1,7 +1,7 @@
 # Copyright 2010 Google Inc. All Rights Reserved.
 #Fri Jul 16 10:03:09 PDT 2010
-currentVersion=1.0.0d
-version=1.0.0d
+currentVersion=1.0.0e
+version=1.0.0e
 isNative=true
 feedurl=http\://www.openssl.org/
 name=openssl
diff --git a/apps/apps.c b/apps/apps.c
index dc527d1..38e6197 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -798,7 +798,9 @@
 	if (file == NULL)
 		{
 #ifdef _IONBF
+# ifndef OPENSSL_NO_SETVBUF_IONBF
 		setvbuf(stdin, NULL, _IONBF, 0);
+# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 #endif
 		BIO_set_fp(cert,stdin,BIO_NOCLOSE);
 		}
@@ -899,7 +901,9 @@
 	if (file == NULL && maybe_stdin)
 		{
 #ifdef _IONBF
+# ifndef OPENSSL_NO_SETVBUF_IONBF
 		setvbuf(stdin, NULL, _IONBF, 0);
+# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 #endif
 		BIO_set_fp(key,stdin,BIO_NOCLOSE);
 		}
@@ -988,7 +992,9 @@
 	if (file == NULL && maybe_stdin)
 		{
 #ifdef _IONBF
+# ifndef OPENSSL_NO_SETVBUF_IONBF
 		setvbuf(stdin, NULL, _IONBF, 0);
+# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 #endif
 		BIO_set_fp(key,stdin,BIO_NOCLOSE);
 		}
diff --git a/apps/asn1pars.c b/apps/asn1pars.c
index b5d65e7..0d66070 100644
--- a/apps/asn1pars.c
+++ b/apps/asn1pars.c
@@ -408,6 +408,7 @@
 
 	atyp = ASN1_generate_nconf(genstr, cnf);
 	NCONF_free(cnf);
+	cnf = NULL;
 
 	if (!atyp)
 		return -1;
diff --git a/apps/enc.c b/apps/enc.c
index c28d8b1..076225c 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -393,8 +393,10 @@
 
 	if (inf == NULL)
 	        {
+#ifndef OPENSSL_NO_SETVBUF_IONBF
 		if (bufsize != NULL)
 			setvbuf(stdin, (char *)NULL, _IONBF, 0);
+#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 		BIO_set_fp(in,stdin,BIO_NOCLOSE);
 	        }
 	else
@@ -447,8 +449,10 @@
 	if (outf == NULL)
 		{
 		BIO_set_fp(out,stdout,BIO_NOCLOSE);
+#ifndef OPENSSL_NO_SETVBUF_IONBF
 		if (bufsize != NULL)
 			setvbuf(stdout, (char *)NULL, _IONBF, 0);
+#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 #ifdef OPENSSL_SYS_VMS
 		{
 		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
diff --git a/apps/openssl-vms.cnf b/apps/openssl-vms.cnf
deleted file mode 100644
index 20ed61b..0000000
--- a/apps/openssl-vms.cnf
+++ /dev/null
@@ -1,350 +0,0 @@
-#
-# OpenSSL example configuration file.
-# This is mostly being used for generation of certificate requests.
-#
-
-# This definition stops the following lines choking if HOME isn't
-# defined.
-HOME			= .
-RANDFILE		= $ENV::HOME/.rnd
-
-# Extra OBJECT IDENTIFIER info:
-#oid_file		= $ENV::HOME/.oid
-oid_section		= new_oids
-
-# To use this configuration file with the "-extfile" option of the
-# "openssl x509" utility, name here the section containing the
-# X.509v3 extensions to use:
-# extensions		= 
-# (Alternatively, use a configuration file that has only
-# X.509v3 extensions in its main [= default] section.)
-
-[ new_oids ]
-
-# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
-# Add a simple OID like this:
-# testoid1=1.2.3.4
-# Or use config file substitution like this:
-# testoid2=${testoid1}.5.6
-
-# Policies used by the TSA examples.
-tsa_policy1 = 1.2.3.4.1
-tsa_policy2 = 1.2.3.4.5.6
-tsa_policy3 = 1.2.3.4.5.7
-
-####################################################################
-[ ca ]
-default_ca	= CA_default		# The default ca section
-
-####################################################################
-[ CA_default ]
-
-dir		= sys\$disk:[.demoCA		# Where everything is kept
-certs		= $dir.certs]		# Where the issued certs are kept
-crl_dir		= $dir.crl]		# Where the issued crl are kept
-database	= $dir]index.txt	# database index file.
-#unique_subject	= no			# Set to 'no' to allow creation of
-					# several ctificates with same subject.
-new_certs_dir	= $dir.newcerts]		# default place for new certs.
-
-certificate	= $dir]cacert.pem 	# The CA certificate
-serial		= $dir]serial. 		# The current serial number
-crlnumber	= $dir]crlnumber.	# the current crl number
-					# must be commented out to leave a V1 CRL
-crl		= $dir]crl.pem 		# The current CRL
-private_key	= $dir.private]cakey.pem# The private key
-RANDFILE	= $dir.private].rand	# private random number file
-
-x509_extensions	= usr_cert		# The extentions to add to the cert
-
-# Comment out the following two lines for the "traditional"
-# (and highly broken) format.
-name_opt 	= ca_default		# Subject Name options
-cert_opt 	= ca_default		# Certificate field options
-
-# Extension copying option: use with caution.
-# copy_extensions = copy
-
-# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
-# so this is commented out by default to leave a V1 CRL.
-# crlnumber must also be commented out to leave a V1 CRL.
-# crl_extensions	= crl_ext
-
-default_days	= 365			# how long to certify for
-default_crl_days= 30			# how long before next CRL
-default_md	= default		# use public key default MD
-preserve	= no			# keep passed DN ordering
-
-# A few difference way of specifying how similar the request should look
-# For type CA, the listed attributes must be the same, and the optional
-# and supplied fields are just that :-)
-policy		= policy_match
-
-# For the CA policy
-[ policy_match ]
-countryName		= match
-stateOrProvinceName	= match
-organizationName	= match
-organizationalUnitName	= optional
-commonName		= supplied
-emailAddress		= optional
-
-# For the 'anything' policy
-# At this point in time, you must list all acceptable 'object'
-# types.
-[ policy_anything ]
-countryName		= optional
-stateOrProvinceName	= optional
-localityName		= optional
-organizationName	= optional
-organizationalUnitName	= optional
-commonName		= supplied
-emailAddress		= optional
-
-####################################################################
-[ req ]
-default_bits		= 1024
-default_keyfile 	= privkey.pem
-distinguished_name	= req_distinguished_name
-attributes		= req_attributes
-x509_extensions	= v3_ca	# The extentions to add to the self signed cert
-
-# Passwords for private keys if not present they will be prompted for
-# input_password = secret
-# output_password = secret
-
-# This sets a mask for permitted string types. There are several options. 
-# default: PrintableString, T61String, BMPString.
-# pkix	 : PrintableString, BMPString (PKIX recommendation before 2004)
-# utf8only: only UTF8Strings (PKIX recommendation after 2004).
-# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
-# MASK:XXXX a literal mask value.
-# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings.
-string_mask = utf8only
-
-# req_extensions = v3_req # The extensions to add to a certificate request
-
-[ req_distinguished_name ]
-countryName			= Country Name (2 letter code)
-countryName_default		= AU
-countryName_min			= 2
-countryName_max			= 2
-
-stateOrProvinceName		= State or Province Name (full name)
-stateOrProvinceName_default	= Some-State
-
-localityName			= Locality Name (eg, city)
-
-0.organizationName		= Organization Name (eg, company)
-0.organizationName_default	= Internet Widgits Pty Ltd
-
-# we can do this but it is not needed normally :-)
-#1.organizationName		= Second Organization Name (eg, company)
-#1.organizationName_default	= World Wide Web Pty Ltd
-
-organizationalUnitName		= Organizational Unit Name (eg, section)
-#organizationalUnitName_default	=
-
-commonName			= Common Name (eg, YOUR name)
-commonName_max			= 64
-
-emailAddress			= Email Address
-emailAddress_max		= 64
-
-# SET-ex3			= SET extension number 3
-
-[ req_attributes ]
-challengePassword		= A challenge password
-challengePassword_min		= 4
-challengePassword_max		= 20
-
-unstructuredName		= An optional company name
-
-[ usr_cert ]
-
-# These extensions are added when 'ca' signs a request.
-
-# This goes against PKIX guidelines but some CAs do it and some software
-# requires this to avoid interpreting an end user certificate as a CA.
-
-basicConstraints=CA:FALSE
-
-# Here are some examples of the usage of nsCertType. If it is omitted
-# the certificate can be used for anything *except* object signing.
-
-# This is OK for an SSL server.
-# nsCertType			= server
-
-# For an object signing certificate this would be used.
-# nsCertType = objsign
-
-# For normal client use this is typical
-# nsCertType = client, email
-
-# and for everything including object signing:
-# nsCertType = client, email, objsign
-
-# This is typical in keyUsage for a client certificate.
-# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
-
-# This will be displayed in Netscape's comment listbox.
-nsComment			= "OpenSSL Generated Certificate"
-
-# PKIX recommendations harmless if included in all certificates.
-subjectKeyIdentifier=hash
-authorityKeyIdentifier=keyid,issuer
-
-# This stuff is for subjectAltName and issuerAltname.
-# Import the email address.
-# subjectAltName=email:copy
-# An alternative to produce certificates that aren't
-# deprecated according to PKIX.
-# subjectAltName=email:move
-
-# Copy subject details
-# issuerAltName=issuer:copy
-
-#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
-#nsBaseUrl
-#nsRevocationUrl
-#nsRenewalUrl
-#nsCaPolicyUrl
-#nsSslServerName
-
-# This is required for TSA certificates.
-# extendedKeyUsage = critical,timeStamping
-
-[ v3_req ]
-
-# Extensions to add to a certificate request
-
-basicConstraints = CA:FALSE
-keyUsage = nonRepudiation, digitalSignature, keyEncipherment
-
-[ v3_ca ]
-
-
-# Extensions for a typical CA
-
-
-# PKIX recommendation.
-
-subjectKeyIdentifier=hash
-
-authorityKeyIdentifier=keyid:always,issuer
-
-# This is what PKIX recommends but some broken software chokes on critical
-# extensions.
-#basicConstraints = critical,CA:true
-# So we do this instead.
-basicConstraints = CA:true
-
-# Key usage: this is typical for a CA certificate. However since it will
-# prevent it being used as an test self-signed certificate it is best
-# left out by default.
-# keyUsage = cRLSign, keyCertSign
-
-# Some might want this also
-# nsCertType = sslCA, emailCA
-
-# Include email address in subject alt name: another PKIX recommendation
-# subjectAltName=email:copy
-# Copy issuer details
-# issuerAltName=issuer:copy
-
-# DER hex encoding of an extension: beware experts only!
-# obj=DER:02:03
-# Where 'obj' is a standard or added object
-# You can even override a supported extension:
-# basicConstraints= critical, DER:30:03:01:01:FF
-
-[ crl_ext ]
-
-# CRL extensions.
-# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
-
-# issuerAltName=issuer:copy
-authorityKeyIdentifier=keyid:always
-
-[ proxy_cert_ext ]
-# These extensions should be added when creating a proxy certificate
-
-# This goes against PKIX guidelines but some CAs do it and some software
-# requires this to avoid interpreting an end user certificate as a CA.
-
-basicConstraints=CA:FALSE
-
-# Here are some examples of the usage of nsCertType. If it is omitted
-# the certificate can be used for anything *except* object signing.
-
-# This is OK for an SSL server.
-# nsCertType			= server
-
-# For an object signing certificate this would be used.
-# nsCertType = objsign
-
-# For normal client use this is typical
-# nsCertType = client, email
-
-# and for everything including object signing:
-# nsCertType = client, email, objsign
-
-# This is typical in keyUsage for a client certificate.
-# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
-
-# This will be displayed in Netscape's comment listbox.
-nsComment			= "OpenSSL Generated Certificate"
-
-# PKIX recommendations harmless if included in all certificates.
-subjectKeyIdentifier=hash
-authorityKeyIdentifier=keyid,issuer
-
-# This stuff is for subjectAltName and issuerAltname.
-# Import the email address.
-# subjectAltName=email:copy
-# An alternative to produce certificates that aren't
-# deprecated according to PKIX.
-# subjectAltName=email:move
-
-# Copy subject details
-# issuerAltName=issuer:copy
-
-#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
-#nsBaseUrl
-#nsRevocationUrl
-#nsRenewalUrl
-#nsCaPolicyUrl
-#nsSslServerName
-
-# This really needs to be in place for it to be a proxy certificate.
-proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
-
-####################################################################
-[ tsa ]
-
-default_tsa = tsa_config1	# the default TSA section
-
-[ tsa_config1 ]
-
-# These are used by the TSA reply generation only.
-dir		= sys\$disk:[.demoCA		# TSA root directory
-serial		= $dir]tsaserial.	# The current serial number (mandatory)
-crypto_device	= builtin		# OpenSSL engine to use for signing
-signer_cert	= $dir/tsacert.pem 	# The TSA signing certificate
-					# (optional)
-certs		= $dir.cacert.pem]	# Certificate chain to include in reply
-					# (optional)
-signer_key	= $dir/private/tsakey.pem # The TSA private key (optional)
-
-default_policy	= tsa_policy1		# Policy if request did not specify it
-					# (optional)
-other_policies	= tsa_policy2, tsa_policy3	# acceptable policies (optional)
-digests		= md5, sha1		# Acceptable message digests (mandatory)
-accuracy	= secs:1, millisecs:500, microsecs:100	# (optional)
-clock_precision_digits  = 0	# number of digits after dot. (optional)
-ordering		= yes	# Is ordering defined for timestamps?
-				# (optional, default: no)
-tsa_name		= yes	# Must the TSA name be included in the reply?
-				# (optional, default: no)
-ess_cert_id_chain	= no	# Must the ESS cert id chain be included?
-				# (optional, default: no)
diff --git a/apps/openssl.c b/apps/openssl.c
index be37ee6..1068957 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -212,8 +212,13 @@
 		}
 	}
 
+#if defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64)
+# define ARGV _Argv
+#else
+# define ARGV Argv
+#endif
 
-int main(int Argc, char *Argv[])
+int main(int Argc, char *ARGV[])
 	{
 	ARGS arg;
 #define PROG_NAME_SIZE	39
@@ -227,7 +232,55 @@
 	char **argv,*p;
 	LHASH_OF(FUNCTION) *prog=NULL;
 	long errline;
- 
+
+#if defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64)
+	/* 2011-03-22 SMS.
+	 * If we have 32-bit pointers everywhere, then we're safe, and
+	 * we bypass this mess, as on non-VMS systems.  (See ARGV,
+	 * above.)
+	 * Problem 1: Compaq/HP C before V7.3 always used 32-bit
+	 * pointers for argv[].
+	 * Fix 1: For a 32-bit argv[], when we're using 64-bit pointers
+	 * everywhere else, we always allocate and use a 64-bit
+	 * duplicate of argv[].
+	 * Problem 2: Compaq/HP C V7.3 (Alpha, IA64) before ECO1 failed
+	 * to NULL-terminate a 64-bit argv[].  (As this was written, the
+	 * compiler ECO was available only on IA64.)
+	 * Fix 2: Unless advised not to (VMS_TRUST_ARGV), we test a
+	 * 64-bit argv[argc] for NULL, and, if necessary, use a
+	 * (properly) NULL-terminated (64-bit) duplicate of argv[].
+	 * The same code is used in either case to duplicate argv[].
+	 * Some of these decisions could be handled in preprocessing,
+	 * but the code tends to get even uglier, and the penalty for
+	 * deciding at compile- or run-time is tiny.
+	 */
+	char **Argv = NULL;
+	int free_Argv = 0;
+
+	if ((sizeof( _Argv) < 8)        /* 32-bit argv[]. */
+# if !defined( VMS_TRUST_ARGV)
+	 || (_Argv[ Argc] != NULL)      /* Untrusted argv[argc] not NULL. */
+# endif
+		)
+		{
+		int i;
+		Argv = OPENSSL_malloc( (Argc+ 1)* sizeof( char *));
+		if (Argv == NULL)
+			{ ret = -1; goto end; }
+		for(i = 0; i < Argc; i++)
+			Argv[i] = _Argv[i];
+		Argv[ Argc] = NULL;     /* Certain NULL termination. */
+		free_Argv = 1;
+		}
+	else
+		{
+		/* Use the known-good 32-bit argv[] (which needs the
+		 * type cast to satisfy the compiler), or the trusted or
+		 * tested-good 64-bit argv[] as-is. */
+		Argv = (char **)_Argv;
+		}
+#endif /* defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64) */
+
 	arg.data=NULL;
 	arg.count=0;
 
@@ -375,6 +428,13 @@
 		BIO_free(bio_err);
 		bio_err=NULL;
 		}
+#if defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64)
+	/* Free any duplicate Argv[] storage. */
+	if (free_Argv)
+		{
+		OPENSSL_free(Argv);
+		}
+#endif
 	OPENSSL_EXIT(ret);
 	}
 
diff --git a/apps/pkcs12.c b/apps/pkcs12.c
index 514a02e..b54c6f8 100644
--- a/apps/pkcs12.c
+++ b/apps/pkcs12.c
@@ -647,7 +647,7 @@
 
     if (!twopass) BUF_strlcpy(macpass, pass, sizeof macpass);
 
-    if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);
+    if ((options & INFO) && p12->mac) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);
     if(macver) {
 #ifdef CRYPTO_MDEBUG
     CRYPTO_push_info("verify MAC");
diff --git a/apps/speed.c b/apps/speed.c
index 74b3a74..b3c5442 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -2705,6 +2705,7 @@
 				else
 					rsa_results[k][1]=d;
 				}
+#ifndef OPENSSL_NO_DSA
 			else if(!strncmp(buf,"+F3:",4))
 				{
 				int k;
@@ -2726,6 +2727,7 @@
 				else
 					dsa_results[k][1]=d;
 				}
+#endif
 #ifndef OPENSSL_NO_ECDSA
 			else if(!strncmp(buf,"+F4:",4))
 				{
diff --git a/crypto/Android.mk b/crypto/Android.mk
index 2bce944..6f09fa5 100644
--- a/crypto/Android.mk
+++ b/crypto/Android.mk
@@ -222,8 +222,6 @@
 	dso/dso_lib.c \
 	dso/dso_null.c \
 	dso/dso_openssl.c \
-	dso/dso_vms.c \
-	dso/dso_win32.c \
 	ec/ec2_mult.c \
 	ec/ec2_smpl.c \
 	ec/ec_ameth.c \
diff --git a/crypto/LPdir_vms.c b/crypto/LPdir_vms.c
deleted file mode 100644
index 85b427a..0000000
--- a/crypto/LPdir_vms.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* $LP: LPlib/source/LPdir_vms.c,v 1.20 2004/08/26 13:36:05 _cvs_levitte Exp $ */
-/*
- * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <descrip.h>
-#include <namdef.h>
-#include <rmsdef.h>
-#include <libfildef.h>
-#include <lib$routines.h>
-#include <strdef.h>
-#include <str$routines.h>
-#include <stsdef.h>
-#ifndef LPDIR_H
-#include "LPdir.h"
-#endif
-
-/* Because some compiler options hide this macor */
-#ifndef EVMSERR
-#define EVMSERR		65535  /* error for non-translatable VMS errors */
-#endif
-
-struct LP_dir_context_st
-{
-  unsigned long VMS_context;
-#ifdef NAML$C_MAXRSS
-  char filespec[NAML$C_MAXRSS+1];
-  char result[NAML$C_MAXRSS+1];
-#else
-  char filespec[256];
-  char result[256];
-#endif
-  struct dsc$descriptor_d filespec_dsc;
-  struct dsc$descriptor_d result_dsc;
-};
-
-const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
-{
-  int status;
-  char *p, *r;
-  size_t l;
-  unsigned long flags = 0;
-#ifdef NAML$C_MAXRSS
-  flags |= LIB$M_FIL_LONG_NAMES;
-#endif
-
-  if (ctx == NULL || directory == NULL)
-    {
-      errno = EINVAL;
-      return 0;
-    }
-
-  errno = 0;
-  if (*ctx == NULL)
-    {
-      size_t filespeclen = strlen(directory);
-      char *filespec = NULL;
-
-      /* MUST be a VMS directory specification!  Let's estimate if it is. */
-      if (directory[filespeclen-1] != ']'
-	  && directory[filespeclen-1] != '>'
-	  && directory[filespeclen-1] != ':')
-	{
-	  errno = EINVAL;
-	  return 0;
-	}
-
-      filespeclen += 4;		/* "*.*;" */
-
-      if (filespeclen >
-#ifdef NAML$C_MAXRSS
-	  NAML$C_MAXRSS
-#else
-	  255
-#endif
-	  )
-	{
-	  errno = ENAMETOOLONG;
-	  return 0;
-	}
-
-      *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
-      if (*ctx == NULL)
-	{
-	  errno = ENOMEM;
-	  return 0;
-	}
-      memset(*ctx, '\0', sizeof(LP_DIR_CTX));
-
-      strcpy((*ctx)->filespec,directory);
-      strcat((*ctx)->filespec,"*.*;");
-      (*ctx)->filespec_dsc.dsc$w_length = filespeclen;
-      (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-      (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S;
-      (*ctx)->filespec_dsc.dsc$a_pointer = (*ctx)->filespec;
-      (*ctx)->result_dsc.dsc$w_length = 0;
-      (*ctx)->result_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-      (*ctx)->result_dsc.dsc$b_class = DSC$K_CLASS_D;
-      (*ctx)->result_dsc.dsc$a_pointer = 0;
-    }
-
-  (*ctx)->result_dsc.dsc$w_length = 0;
-  (*ctx)->result_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-  (*ctx)->result_dsc.dsc$b_class = DSC$K_CLASS_D;
-  (*ctx)->result_dsc.dsc$a_pointer = 0;
-
-  status = lib$find_file(&(*ctx)->filespec_dsc, &(*ctx)->result_dsc,
-			 &(*ctx)->VMS_context, 0, 0, 0, &flags);
-
-  if (status == RMS$_NMF)
-    {
-      errno = 0;
-      vaxc$errno = status;
-      return NULL;
-    }
-
-  if(!$VMS_STATUS_SUCCESS(status))
-    {
-      errno = EVMSERR;
-      vaxc$errno = status;
-      return NULL;
-    }
-
-  /* Quick, cheap and dirty way to discard any device and directory,
-     since we only want file names */
-  l = (*ctx)->result_dsc.dsc$w_length;
-  p = (*ctx)->result_dsc.dsc$a_pointer;
-  r = p;
-  for (; *p; p++)
-    {
-      if (*p == '^' && p[1] != '\0') /* Take care of ODS-5 escapes */
-	{
-	  p++;
-	}
-      else if (*p == ':' || *p == '>' || *p == ']')
-	{
-	  l -= p + 1 - r;
-	  r = p + 1;
-	}
-      else if (*p == ';')
-	{
-	  l = p - r;
-	  break;
-	}
-    }
-
-  strncpy((*ctx)->result, r, l);
-  (*ctx)->result[l] = '\0';
-  str$free1_dx(&(*ctx)->result_dsc);
-
-  return (*ctx)->result;
-}
-
-int LP_find_file_end(LP_DIR_CTX **ctx)
-{
-  if (ctx != NULL && *ctx != NULL)
-    {
-      int status = lib$find_file_end(&(*ctx)->VMS_context);
-
-      free(*ctx);
-
-      if(!$VMS_STATUS_SUCCESS(status))
-	{
-	  errno = EVMSERR;
-	  vaxc$errno = status;
-	  return 0;
-	}
-      return 1;
-    }
-  errno = EINVAL;
-  return 0;
-}
-
diff --git a/crypto/LPdir_win32.c b/crypto/LPdir_win32.c
deleted file mode 100644
index e39872d..0000000
--- a/crypto/LPdir_win32.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $LP: LPlib/source/LPdir_win32.c,v 1.3 2004/08/26 13:36:05 _cvs_levitte Exp $ */
-/*
- * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LP_SYS_WIN32
-#define LP_MULTIBYTE_AVAILABLE
-#include "LPdir_win.c"
diff --git a/crypto/alphacpuid.pl b/crypto/alphacpuid.pl
index c9474ff..4b3cbb9 100644
--- a/crypto/alphacpuid.pl
+++ b/crypto/alphacpuid.pl
@@ -99,19 +99,19 @@
 	beq	$0,.Laligned
 
 .Little:
+	subq	$0,8,$0
 	ldq_u	$1,0($16)
 	mov	$16,$2
 .Lalign:
 	mskbl	$1,$16,$1
 	lda	$16,1($16)
 	subq	$17,1,$17
-	subq	$0,1,$0
+	addq	$0,1,$0
 	beq	$17,.Lout
 	bne	$0,.Lalign
 .Lout:	stq_u	$1,0($2)
 	beq	$17,.Ldone
 	bic	$17,7,$at
-	mov	$17,$0
 	beq	$at,.Little
 
 .Laligned:
@@ -120,9 +120,7 @@
 	lda	$16,8($16)
 	bic	$17,7,$at
 	bne	$at,.Laligned
-	beq	$17,.Ldone
-	mov	$17,$0
-	br	.Little
+	bne	$17,.Little
 .Ldone: ret	($26)
 .end	OPENSSL_cleanse
 ___
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c
index e5fbe7c..3978c91 100644
--- a/crypto/asn1/a_object.c
+++ b/crypto/asn1/a_object.c
@@ -139,7 +139,7 @@
 				ASN1err(ASN1_F_A2D_ASN1_OBJECT,ASN1_R_INVALID_DIGIT);
 				goto err;
 				}
-			if (!use_bn && l > (ULONG_MAX / 10L))
+			if (!use_bn && l >= ((ULONG_MAX - 80) / 10L))
 				{
 				use_bn = 1;
 				if (!bl)
@@ -293,7 +293,7 @@
 	/* Sanity check OID encoding: can't have leading 0x80 in
 	 * subidentifiers, see: X.690 8.19.2
 	 */
-	for (i = 0, p = *pp + 1; i < len - 1; i++, p++)
+	for (i = 0, p = *pp; i < len; i++, p++)
 		{
 		if (*p == 0x80 && (!i || !(p[-1] & 0x80)))
 			{
diff --git a/crypto/asn1/bio_ndef.c b/crypto/asn1/bio_ndef.c
index 370389b..b91f97a 100644
--- a/crypto/asn1/bio_ndef.c
+++ b/crypto/asn1/bio_ndef.c
@@ -57,9 +57,6 @@
 #include <openssl/bio.h>
 #include <openssl/err.h>
 
-#ifndef OPENSSL_SYSNAME_NETWARE
-#include <memory.h>
-#endif
 #include <stdio.h>
 
 /* Experimental NDEF ASN1 BIO support routines */
diff --git a/crypto/asn1/x_name.c b/crypto/asn1/x_name.c
index caa4409..49be08b 100644
--- a/crypto/asn1/x_name.c
+++ b/crypto/asn1/x_name.c
@@ -214,7 +214,9 @@
 	*val = nm.a;
 	*in = p;
 	return ret;
-	err:
+err:
+        if (nm.x != NULL)
+		X509_NAME_free(nm.x);
 	ASN1err(ASN1_F_X509_NAME_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
 	return 0;
 }
@@ -464,7 +466,8 @@
 			}
 		else
 			{
-			*to++ = tolower(*from++);
+			*to++ = tolower(*from);
+			from++;
 			i++;
 			}
 		}
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index 12b0a53..d47310d 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -551,7 +551,30 @@
 #ifdef __DJGPP__
 	i=ioctlsocket(fd,type,(char *)arg);
 #else
-	i=ioctlsocket(fd,type,arg);
+# if defined(OPENSSL_SYS_VMS)
+	/* 2011-02-18 SMS.
+	 * VMS ioctl() can't tolerate a 64-bit "void *arg", but we
+	 * observe that all the consumers pass in an "unsigned long *",
+	 * so we arrange a local copy with a short pointer, and use
+	 * that, instead.
+	 */
+#  if __INITIAL_POINTER_SIZE == 64
+#   define ARG arg_32p
+#   pragma pointer_size save
+#   pragma pointer_size 32
+	unsigned long arg_32;
+	unsigned long *arg_32p;
+#   pragma pointer_size restore
+	arg_32p = &arg_32;
+	arg_32 = *((unsigned long *) arg);
+#  else /* __INITIAL_POINTER_SIZE == 64 */
+#   define ARG arg
+#  endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+# else /* defined(OPENSSL_SYS_VMS) */
+#  define ARG arg
+# endif /* defined(OPENSSL_SYS_VMS) [else] */
+
+	i=ioctlsocket(fd,type,ARG);
 #endif /* __DJGPP__ */
 	if (i < 0)
 		SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
@@ -660,6 +683,7 @@
 	 * note that commonly IPv6 wildchard socket can service
 	 * IPv4 connections just as well...  */
 	memset(&hint,0,sizeof(hint));
+	hint.ai_flags = AI_PASSIVE;
 	if (h)
 		{
 		if (strchr(h,':'))
@@ -672,7 +696,10 @@
 #endif
 			}
 	    	else if (h[0]=='*' && h[1]=='\0')
+			{
+			hint.ai_family = AF_INET;
 			h=NULL;
+			}
 		}
 
 	if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break;
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index 07d012a..71ebe98 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -57,7 +57,6 @@
  *
  */
 
-#ifndef OPENSSL_NO_DGRAM
 
 #include <stdio.h>
 #include <errno.h>
@@ -65,6 +64,7 @@
 #include "cryptlib.h"
 
 #include <openssl/bio.h>
+#ifndef OPENSSL_NO_DGRAM
 
 #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
 #include <sys/timeb.h>
@@ -308,7 +308,6 @@
 			OPENSSL_assert(sa.len.s<=sizeof(sa.peer));
 			sa.len.i = (int)sa.len.s;
 			}
-		dgram_reset_rcv_timeout(b);
 
 		if ( ! data->connected  && ret >= 0)
 			BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer);
@@ -322,6 +321,8 @@
 				data->_errno = get_last_socket_error();
 				}
 			}
+
+		dgram_reset_rcv_timeout(b);
 		}
 	return(ret);
 	}
@@ -745,9 +746,13 @@
 		{
 		err=get_last_socket_error();
 
-#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
-		if ((i == -1) && (err == 0))
-			return(1);
+#if defined(OPENSSL_SYS_WINDOWS)
+	/* If the socket return value (i) is -1
+	 * and err is unexpectedly 0 at this point,
+	 * the error code was overwritten by
+	 * another system call before this error
+	 * handling is called.
+	 */
 #endif
 
 		return(BIO_dgram_non_fatal_error(err));
@@ -810,7 +815,6 @@
 		}
 	return(0);
 	}
-#endif
 
 static void get_current_time(struct timeval *t)
 	{
@@ -828,3 +832,5 @@
 	gettimeofday(t, NULL);
 #endif
 	}
+
+#endif
diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c
index 7ead044..b7dce5c 100644
--- a/crypto/bio/bss_log.c
+++ b/crypto/bio/bss_log.c
@@ -75,6 +75,15 @@
 #  include <descrip.h>
 #  include <lib$routines.h>
 #  include <starlet.h>
+/* Some compiler options may mask the declaration of "_malloc32". */
+#  if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
+#    if __INITIAL_POINTER_SIZE == 64
+#      pragma pointer_size save
+#      pragma pointer_size 32
+    void * _malloc32  (__size_t);
+#      pragma pointer_size restore
+#    endif /* __INITIAL_POINTER_SIZE == 64 */
+#  endif /* __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE */
 #elif defined(__ultrix)
 #  include <sys/syslog.h>
 #elif defined(OPENSSL_SYS_NETWARE)
@@ -300,7 +309,24 @@
 static void xsyslog(BIO *bp, int priority, const char *string)
 {
 	struct dsc$descriptor_s opc_dsc;
+
+/* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */
+#if __INITIAL_POINTER_SIZE == 64
+# pragma pointer_size save
+# pragma pointer_size 32
+# define OPCDEF_TYPE __char_ptr32
+# define OPCDEF_MALLOC _malloc32
+#else /* __INITIAL_POINTER_SIZE == 64 */
+# define OPCDEF_TYPE char *
+# define OPCDEF_MALLOC OPENSSL_malloc
+#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+
 	struct opcdef *opcdef_p;
+
+#if __INITIAL_POINTER_SIZE == 64
+# pragma pointer_size restore
+#endif /* __INITIAL_POINTER_SIZE == 64 */
+
 	char buf[10240];
 	unsigned int len;
         struct dsc$descriptor_s buf_dsc;
@@ -326,8 +352,8 @@
 
 	lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
 
-	/* we know there's an 8 byte header.  That's documented */
-	opcdef_p = (struct opcdef *) OPENSSL_malloc(8 + len);
+	/* We know there's an 8-byte header.  That's documented. */
+	opcdef_p = OPCDEF_MALLOC( 8+ len);
 	opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
 	memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
 	opcdef_p->opc$l_ms_rqstid = 0;
@@ -335,7 +361,7 @@
 
 	opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
 	opc_dsc.dsc$b_class = DSC$K_CLASS_S;
-	opc_dsc.dsc$a_pointer = (char *)opcdef_p;
+	opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p;
 	opc_dsc.dsc$w_length = len + 8;
 
 	sys$sndopr(opc_dsc, 0);
diff --git a/crypto/bn/asm/alpha-mont.pl b/crypto/bn/asm/alpha-mont.pl
index c63458e..03596e2 100644
--- a/crypto/bn/asm/alpha-mont.pl
+++ b/crypto/bn/asm/alpha-mont.pl
@@ -41,7 +41,7 @@
 $m1="s5";
 
 $code=<<___;
-#indef __linux__
+#ifdef __linux__
 #include <asm/regdef.h>
 #else
 #include <asm.h>
diff --git a/crypto/bn/asm/s390x-mont.pl b/crypto/bn/asm/s390x-mont.pl
index d232510..f61246f 100644
--- a/crypto/bn/asm/s390x-mont.pl
+++ b/crypto/bn/asm/s390x-mont.pl
@@ -69,8 +69,8 @@
 	cghi	$num,16		#
 	lghi	%r2,0		#
 	blr	%r14		# if($num<16) return 0;
-	cghi	$num,128	#
-	bhr	%r14		# if($num>128) return 0;
+	cghi	$num,96		#
+	bhr	%r14		# if($num>96) return 0;
 
 	stmg	%r3,%r15,24($sp)
 
diff --git a/crypto/bn/asm/vms.mar b/crypto/bn/asm/vms.mar
deleted file mode 100644
index aefab15..0000000
--- a/crypto/bn/asm/vms.mar
+++ /dev/null
@@ -1,6440 +0,0 @@
-	.title	vax_bn_mul_add_words  unsigned multiply & add, 32*32+32+32=>64
-;
-; w.j.m. 15-jan-1999
-;
-; it's magic ...
-;
-; ULONG bn_mul_add_words(ULONG r[],ULONG a[],int n,ULONG w) {
-;	ULONG c = 0;
-;	int i;
-;	for(i = 0; i < n; i++) <c,r[i]> := r[i] + c + a[i] * w ;
-;	return c;
-; }
-
-r=4 ;(AP)
-a=8 ;(AP)
-n=12 ;(AP)	n	by value (input)
-w=16 ;(AP)	w	by value (input)
-
-
-	.psect	code,nowrt
-
-.entry	bn_mul_add_words,^m<r2,r3,r4,r5,r6>
-
-	moval	@r(ap),r2
-	moval	@a(ap),r3
-	movl	n(ap),r4	; assumed >0 by C code
-	movl	w(ap),r5
-	clrl	r6		; c
-
-0$:
-	emul	r5,(r3),(r2),r0		; w, a[], r[] considered signed
-
-	; fixup for "negative" r[]
-	tstl	(r2)
-	bgeq	10$
-	incl	r1
-10$:
-
-	; add in c
-	addl2	r6,r0
-	adwc	#0,r1
-
-	; combined fixup for "negative" w, a[]
-	tstl	r5
-	bgeq	20$
-	addl2	(r3),r1
-20$:
-	tstl	(r3)
-	bgeq	30$
-	addl2	r5,r1
-30$:
-
-	movl	r0,(r2)+		; store lo result in r[] & advance
-	addl	#4,r3			; advance a[]
-	movl	r1,r6			; store hi result => c
-
-	sobgtr	r4,0$
-
-	movl	r6,r0			; return c
-	ret
-
-	.title	vax_bn_mul_words  unsigned multiply & add, 32*32+32=>64
-;
-; w.j.m. 15-jan-1999
-;
-; it's magic ...
-;
-; ULONG bn_mul_words(ULONG r[],ULONG a[],int n,ULONG w) {
-;	ULONG c = 0;
-;	int i;
-;	for(i = 0; i < num; i++) <c,r[i]> := a[i] * w + c ;
-;	return(c);
-; }
-
-r=4 ;(AP)
-a=8 ;(AP)
-n=12 ;(AP)	n	by value (input)
-w=16 ;(AP)	w	by value (input)
-
-
-	.psect	code,nowrt
-
-.entry	bn_mul_words,^m<r2,r3,r4,r5,r6>
-
-	moval	@r(ap),r2	; r2 -> r[]
-	moval	@a(ap),r3	; r3 -> a[]
-	movl	n(ap),r4	; r4 = loop count (assumed >0 by C code)
-	movl	w(ap),r5	; r5 = w
-	clrl	r6		; r6 = c
-
-0$:
-	; <r1,r0> := w * a[] + c
-	emul	r5,(r3),r6,r0		; w, a[], c considered signed
-
-	; fixup for "negative" c
-	tstl	r6			; c
-	bgeq	10$
-	incl	r1
-10$:
-
-	; combined fixup for "negative" w, a[]
-	tstl	r5			; w
-	bgeq	20$
-	addl2	(r3),r1			; a[]
-20$:
-	tstl	(r3)			; a[]
-	bgeq	30$
-	addl2	r5,r1			; w
-30$:
-
-	movl	r0,(r2)+		; store lo result in r[] & advance
-	addl	#4,r3			; advance a[]
-	movl	r1,r6			; store hi result => c
-
-	sobgtr	r4,0$
-
-	movl	r6,r0			; return c
-	ret
-
-	.title	vax_bn_sqr_words  unsigned square, 32*32=>64
-;
-; w.j.m. 15-jan-1999
-;
-; it's magic ...
-;
-; void bn_sqr_words(ULONG r[],ULONG a[],int n) {
-;	int i;
-;	for(i = 0; i < n; i++) <r[2*i+1],r[2*i]> := a[i] * a[i] ;
-; }
-
-r=4 ;(AP)
-a=8 ;(AP)
-n=12 ;(AP)	n	by value (input)
-
-
-	.psect	code,nowrt
-
-.entry	bn_sqr_words,^m<r2,r3,r4,r5>
-
-	moval	@r(ap),r2	; r2 -> r[]
-	moval	@a(ap),r3	; r3 -> a[]
-	movl	n(ap),r4	; r4 = n (assumed >0 by C code)
-
-0$:
-	movl	(r3)+,r5		; r5 = a[] & advance
-
-	; <r1,r0> := a[] * a[]
-	emul	r5,r5,#0,r0		; a[] considered signed
-
-	; fixup for "negative" a[]
-	tstl	r5			; a[]
-	bgeq	30$
-	addl2	r5,r1			; a[]
-	addl2	r5,r1			; a[]
-30$:
-
-	movl	r0,(r2)+		; store lo result in r[] & advance
-	movl	r1,(r2)+		; store hi result in r[] & advance
-
-	sobgtr	r4,0$
-
-	movl	#1,r0			; return SS$_NORMAL
-	ret
-
-	.title	vax_bn_div_words  unsigned divide
-;
-; Richard Levitte 20-Nov-2000
-;
-; ULONG bn_div_words(ULONG h, ULONG l, ULONG d)
-; {
-;	return ((ULONG)((((ULLONG)h)<<32)|l) / (ULLONG)d);
-; }
-;
-; Using EDIV would be very easy, if it didn't do signed calculations.
-; Any time any of the input numbers are signed, there are problems,
-; usually with integer overflow, at which point it returns useless
-; data (the quotient gets the value of l, and the remainder becomes 0).
-;
-; If it was just for the dividend, it would be very easy, just divide
-; it by 2 (unsigned), do the division, multiply the resulting quotient
-; and remainder by 2, add the bit that was dropped when dividing by 2
-; to the remainder, and do some adjustment so the remainder doesn't
-; end up larger than the divisor.  For some cases when the divisor is
-; negative (from EDIV's point of view, i.e. when the highest bit is set),
-; dividing the dividend by 2 isn't enough, and since some operations
-; might generate integer overflows even when the dividend is divided by
-; 4 (when the high part of the shifted down dividend ends up being exactly
-; half of the divisor, the result is the quotient 0x80000000, which is
-; negative...) it needs to be divided by 8.  Furthermore, the divisor needs
-; to be divided by 2 (unsigned) as well, to avoid more problems with the sign.
-; In this case, a little extra fiddling with the remainder is required.
-;
-; So, the simplest way to handle this is always to divide the dividend
-; by 8, and to divide the divisor by 2 if it's highest bit is set.
-; After EDIV has been used, the quotient gets multiplied by 8 if the
-; original divisor was positive, otherwise 4.  The remainder, oddly
-; enough, is *always* multiplied by 8.
-; NOTE: in the case mentioned above, where the high part of the shifted
-; down dividend ends up being exactly half the shifted down divisor, we
-; end up with a 33 bit quotient.  That's no problem however, it usually
-; means we have ended up with a too large remainder as well, and the
-; problem is fixed by the last part of the algorithm (next paragraph).
-;
-; The routine ends with comparing the resulting remainder with the
-; original divisor and if the remainder is larger, subtract the
-; original divisor from it, and increase the quotient by 1.  This is
-; done until the remainder is smaller than the divisor.
-;
-; The complete algorithm looks like this:
-;
-; d'    = d
-; l'    = l & 7
-; [h,l] = [h,l] >> 3
-; [q,r] = floor([h,l] / d)	# This is the EDIV operation
-; if (q < 0) q = -q		# I doubt this is necessary any more
-;
-; r'    = r >> 29
-; if (d' >= 0)
-;   q'  = q >> 29
-;   q   = q << 3
-; else
-;   q'  = q >> 30
-;   q   = q << 2
-; r     = (r << 3) + l'
-;
-; if (d' < 0)
-;   {
-;     [r',r] = [r',r] - q
-;     while ([r',r] < 0)
-;       {
-;         [r',r] = [r',r] + d
-;         [q',q] = [q',q] - 1
-;       }
-;   }
-;
-; while ([r',r] >= d')
-;   {
-;     [r',r] = [r',r] - d'
-;     [q',q] = [q',q] + 1
-;   }
-;
-; return q
-
-h=4 ;(AP)	h	by value (input)
-l=8 ;(AP)	l	by value (input)
-d=12 ;(AP)	d	by value (input)
-
-;r2 = l, q
-;r3 = h, r
-;r4 = d
-;r5 = l'
-;r6 = r'
-;r7 = d'
-;r8 = q'
-
-	.psect	code,nowrt
-
-.entry	bn_div_words,^m<r2,r3,r4,r5,r6,r7,r8>
-	movl	l(ap),r2
-	movl	h(ap),r3
-	movl	d(ap),r4
-
-	bicl3	#^XFFFFFFF8,r2,r5 ; l' = l & 7
-	bicl3	#^X00000007,r2,r2
-
-	bicl3	#^XFFFFFFF8,r3,r6
-	bicl3	#^X00000007,r3,r3
-        
-	addl	r6,r2
-
-	rotl	#-3,r2,r2	; l = l >> 3
-	rotl	#-3,r3,r3	; h = h >> 3
-                
-	movl	r4,r7		; d' = d
-
-	movl	#0,r6		; r' = 0
-	movl	#0,r8		; q' = 0
-
-	tstl	r4
-	beql	666$		; Uh-oh, the divisor is 0...
-	bgtr	1$
-	rotl	#-1,r4,r4	; If d is negative, shift it right.
-	bicl2	#^X80000000,r4	; Since d is then a large number, the
-				; lowest bit is insignificant
-				; (contradict that, and I'll fix the problem!)
-1$:     
-	ediv	r4,r2,r2,r3	; Do the actual division
-
-	tstl	r2
-	bgeq	3$
-	mnegl	r2,r2		; if q < 0, negate it
-3$:     
-	tstl	r7
-	blss	4$
-	rotl	#3,r2,r2	;   q = q << 3
-	bicl3	#^XFFFFFFF8,r2,r8 ;    q' gets the high bits from q
-	bicl3	#^X00000007,r2,r2
-	bsb	41$
-4$:				; else
-	rotl	#2,r2,r2	;   q = q << 2
-	bicl3	#^XFFFFFFFC,r2,r8 ;   q' gets the high bits from q
-	bicl3	#^X00000003,r2,r2
-41$:
-	rotl	#3,r3,r3	; r = r << 3
-	bicl3	#^XFFFFFFF8,r3,r6 ; r' gets the high bits from r
-	bicl3	#^X00000007,r3,r3
-	addl	r5,r3		; r = r + l'
-
-	tstl	r7
-	bgeq	5$
-	bitl	#1,r7
-	beql	5$		; if d' < 0 && d' & 1
-	subl	r2,r3		;   [r',r] = [r',r] - [q',q]
-	sbwc	r8,r6
-45$:
-	bgeq	5$		;   while r < 0
-	decl	r2		;     [q',q] = [q',q] - 1
-	sbwc	#0,r8
-	addl	r7,r3		;     [r',r] = [r',r] + d'
-	adwc	#0,r6
-	brb	45$
-
-; The return points are placed in the middle to keep a short distance from
-; all the branch points
-42$:
-;	movl	r3,r1
-	movl	r2,r0
-	ret
-666$:
-	movl	#^XFFFFFFFF,r0
-	ret
-
-5$:
-	tstl	r6
-	bneq	6$
-	cmpl	r3,r7
-	blssu	42$		; while [r',r] >= d'
-6$:
-	subl	r7,r3		;   [r',r] = [r',r] - d'
-	sbwc	#0,r6
-	incl	r2		;   [q',q] = [q',q] + 1
-	adwc	#0,r8
-	brb	5$	
-
-	.title	vax_bn_add_words  unsigned add of two arrays
-;
-; Richard Levitte 20-Nov-2000
-;
-; ULONG bn_add_words(ULONG r[], ULONG a[], ULONG b[], int n) {
-;	ULONG c = 0;
-;	int i;
-;	for (i = 0; i < n; i++) <c,r[i]> = a[i] + b[i] + c;
-;	return(c);
-; }
-
-r=4 ;(AP)	r	by reference (output)
-a=8 ;(AP)	a	by reference (input)
-b=12 ;(AP)	b	by reference (input)
-n=16 ;(AP)	n	by value (input)
-
-
-	.psect	code,nowrt
-
-.entry	bn_add_words,^m<r2,r3,r4,r5,r6>
-
-	moval	@r(ap),r2
-	moval	@a(ap),r3
-	moval	@b(ap),r4
-	movl	n(ap),r5	; assumed >0 by C code
-	clrl	r0		; c
-
-	tstl	r5		; carry = 0
-	bleq	666$
-
-0$:
-	movl	(r3)+,r6	; carry untouched
-	adwc	(r4)+,r6	; carry used and touched
-	movl	r6,(r2)+	; carry untouched
-	sobgtr	r5,0$		; carry untouched
-
-	adwc	#0,r0
-666$:
-	ret
-
-	.title	vax_bn_sub_words  unsigned add of two arrays
-;
-; Richard Levitte 20-Nov-2000
-;
-; ULONG bn_sub_words(ULONG r[], ULONG a[], ULONG b[], int n) {
-;	ULONG c = 0;
-;	int i;
-;	for (i = 0; i < n; i++) <c,r[i]> = a[i] - b[i] - c;
-;	return(c);
-; }
-
-r=4 ;(AP)	r	by reference (output)
-a=8 ;(AP)	a	by reference (input)
-b=12 ;(AP)	b	by reference (input)
-n=16 ;(AP)	n	by value (input)
-
-
-	.psect	code,nowrt
-
-.entry	bn_sub_words,^m<r2,r3,r4,r5,r6>
-
-	moval	@r(ap),r2
-	moval	@a(ap),r3
-	moval	@b(ap),r4
-	movl	n(ap),r5	; assumed >0 by C code
-	clrl	r0		; c
-
-	tstl	r5		; carry = 0
-	bleq	666$
-
-0$:
-	movl	(r3)+,r6	; carry untouched
-	sbwc	(r4)+,r6	; carry used and touched
-	movl	r6,(r2)+	; carry untouched
-	sobgtr	r5,0$		; carry untouched
-
-	adwc	#0,r0
-666$:
-	ret
-
-
-;r=4 ;(AP)
-;a=8 ;(AP)
-;b=12 ;(AP)
-;n=16 ;(AP)	n	by value (input)
-
-	.psect	code,nowrt
-
-.entry	BN_MUL_COMBA8,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
-	movab	-924(sp),sp
-	clrq	r8
-
-	clrl	r10
-
-	movl	8(ap),r6
-	movzwl	2(r6),r3
-	movl	12(ap),r7
-	bicl3	#-65536,(r7),r2
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-12(fp)
-	bicl3	#-65536,r3,-16(fp)
-	mull3	r0,-12(fp),-4(fp)
-	mull2	r2,-12(fp)
-	mull3	r2,-16(fp),-8(fp)
-	mull2	r0,-16(fp)
-	addl3	-4(fp),-8(fp),r0
-	bicl3	#0,r0,-4(fp)
-	cmpl	-4(fp),-8(fp)
-	bgequ	noname.45
-	addl2	#65536,-16(fp)
-noname.45:
-	movzwl	-2(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-16(fp)
-	bicl3	#-65536,-4(fp),r0
-	ashl	#16,r0,-8(fp)
-	addl3	-8(fp),-12(fp),r0
-	bicl3	#0,r0,-12(fp)
-	cmpl	-12(fp),-8(fp)
-	bgequ	noname.46
-	incl	-16(fp)
-noname.46:
-	movl	-12(fp),r1
-	movl	-16(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.47
-	incl	r2
-noname.47:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.48
-	incl	r10
-noname.48:
-
-	movl	4(ap),r11
-	movl	r9,(r11)
-
-	clrl	r9
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-28(fp)
-	bicl3	#-65536,r2,-32(fp)
-	mull3	r0,-28(fp),-20(fp)
-	mull2	r3,-28(fp)
-	mull3	r3,-32(fp),-24(fp)
-	mull2	r0,-32(fp)
-	addl3	-20(fp),-24(fp),r0
-	bicl3	#0,r0,-20(fp)
-	cmpl	-20(fp),-24(fp)
-	bgequ	noname.49
-	addl2	#65536,-32(fp)
-noname.49:
-	movzwl	-18(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-32(fp)
-	bicl3	#-65536,-20(fp),r0
-	ashl	#16,r0,-24(fp)
-	addl3	-24(fp),-28(fp),r0
-	bicl3	#0,r0,-28(fp)
-	cmpl	-28(fp),-24(fp)
-	bgequ	noname.50
-	incl	-32(fp)
-noname.50:
-	movl	-28(fp),r1
-	movl	-32(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.51
-	incl	r2
-noname.51:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.52
-	incl	r9
-noname.52:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-44(fp)
-	bicl3	#-65536,r2,-48(fp)
-	mull3	r0,-44(fp),-36(fp)
-	mull2	r3,-44(fp)
-	mull3	r3,-48(fp),-40(fp)
-	mull2	r0,-48(fp)
-	addl3	-36(fp),-40(fp),r0
-	bicl3	#0,r0,-36(fp)
-	cmpl	-36(fp),-40(fp)
-	bgequ	noname.53
-	addl2	#65536,-48(fp)
-noname.53:
-	movzwl	-34(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-48(fp)
-	bicl3	#-65536,-36(fp),r0
-	ashl	#16,r0,-40(fp)
-	addl3	-40(fp),-44(fp),r0
-	bicl3	#0,r0,-44(fp)
-	cmpl	-44(fp),-40(fp)
-	bgequ	noname.54
-	incl	-48(fp)
-noname.54:
-	movl	-44(fp),r1
-	movl	-48(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.55
-	incl	r2
-noname.55:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.56
-	incl	r9
-noname.56:
-
-	movl	r8,4(r11)
-
-	clrl	r8
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-60(fp)
-	bicl3	#-65536,r2,-64(fp)
-	mull3	r0,-60(fp),-52(fp)
-	mull2	r3,-60(fp)
-	mull3	r3,-64(fp),-56(fp)
-	mull2	r0,-64(fp)
-	addl3	-52(fp),-56(fp),r0
-	bicl3	#0,r0,-52(fp)
-	cmpl	-52(fp),-56(fp)
-	bgequ	noname.57
-	addl2	#65536,-64(fp)
-noname.57:
-	movzwl	-50(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-64(fp)
-	bicl3	#-65536,-52(fp),r0
-	ashl	#16,r0,-56(fp)
-	addl3	-56(fp),-60(fp),r0
-	bicl3	#0,r0,-60(fp)
-	cmpl	-60(fp),-56(fp)
-	bgequ	noname.58
-	incl	-64(fp)
-noname.58:
-	movl	-60(fp),r1
-	movl	-64(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.59
-	incl	r2
-noname.59:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.60
-	incl	r8
-noname.60:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-76(fp)
-	bicl3	#-65536,r2,-80(fp)
-	mull3	r0,-76(fp),-68(fp)
-	mull2	r3,-76(fp)
-	mull3	r3,-80(fp),-72(fp)
-	mull2	r0,-80(fp)
-	addl3	-68(fp),-72(fp),r0
-	bicl3	#0,r0,-68(fp)
-	cmpl	-68(fp),-72(fp)
-	bgequ	noname.61
-	addl2	#65536,-80(fp)
-noname.61:
-	movzwl	-66(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-80(fp)
-	bicl3	#-65536,-68(fp),r0
-	ashl	#16,r0,-72(fp)
-	addl3	-72(fp),-76(fp),r0
-	bicl3	#0,r0,-76(fp)
-	cmpl	-76(fp),-72(fp)
-	bgequ	noname.62
-	incl	-80(fp)
-noname.62:
-	movl	-76(fp),r1
-	movl	-80(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.63
-	incl	r2
-noname.63:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.64
-	incl	r8
-noname.64:
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-92(fp)
-	bicl3	#-65536,r2,-96(fp)
-	mull3	r0,-92(fp),-84(fp)
-	mull2	r3,-92(fp)
-	mull3	r3,-96(fp),-88(fp)
-	mull2	r0,-96(fp)
-	addl3	-84(fp),-88(fp),r0
-	bicl3	#0,r0,-84(fp)
-	cmpl	-84(fp),-88(fp)
-	bgequ	noname.65
-	addl2	#65536,-96(fp)
-noname.65:
-	movzwl	-82(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-96(fp)
-	bicl3	#-65536,-84(fp),r0
-	ashl	#16,r0,-88(fp)
-	addl3	-88(fp),-92(fp),r0
-	bicl3	#0,r0,-92(fp)
-	cmpl	-92(fp),-88(fp)
-	bgequ	noname.66
-	incl	-96(fp)
-noname.66:
-	movl	-92(fp),r1
-	movl	-96(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.67
-	incl	r2
-noname.67:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.68
-	incl	r8
-noname.68:
-
-	movl	r10,8(r11)
-
-	clrl	r10
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-108(fp)
-	bicl3	#-65536,r2,-112(fp)
-	mull3	r0,-108(fp),-100(fp)
-	mull2	r3,-108(fp)
-	mull3	r3,-112(fp),-104(fp)
-	mull2	r0,-112(fp)
-	addl3	-100(fp),-104(fp),r0
-	bicl3	#0,r0,-100(fp)
-	cmpl	-100(fp),-104(fp)
-	bgequ	noname.69
-	addl2	#65536,-112(fp)
-noname.69:
-	movzwl	-98(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-112(fp)
-	bicl3	#-65536,-100(fp),r0
-	ashl	#16,r0,-104(fp)
-	addl3	-104(fp),-108(fp),r0
-	bicl3	#0,r0,-108(fp)
-	cmpl	-108(fp),-104(fp)
-	bgequ	noname.70
-	incl	-112(fp)
-noname.70:
-	movl	-108(fp),r1
-	movl	-112(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.71
-	incl	r2
-noname.71:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.72
-	incl	r10
-noname.72:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-124(fp)
-	bicl3	#-65536,r2,-128(fp)
-	mull3	r0,-124(fp),-116(fp)
-	mull2	r3,-124(fp)
-	mull3	r3,-128(fp),-120(fp)
-	mull2	r0,-128(fp)
-	addl3	-116(fp),-120(fp),r0
-	bicl3	#0,r0,-116(fp)
-	cmpl	-116(fp),-120(fp)
-	bgequ	noname.73
-	addl2	#65536,-128(fp)
-noname.73:
-	movzwl	-114(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-128(fp)
-	bicl3	#-65536,-116(fp),r0
-	ashl	#16,r0,-120(fp)
-	addl3	-120(fp),-124(fp),r0
-	bicl3	#0,r0,-124(fp)
-	cmpl	-124(fp),-120(fp)
-	bgequ	noname.74
-	incl	-128(fp)
-noname.74:
-	movl	-124(fp),r1
-	movl	-128(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.75
-	incl	r2
-noname.75:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.76
-	incl	r10
-noname.76:
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-140(fp)
-	bicl3	#-65536,r2,-144(fp)
-	mull3	r0,-140(fp),-132(fp)
-	mull2	r3,-140(fp)
-	mull3	r3,-144(fp),-136(fp)
-	mull2	r0,-144(fp)
-	addl3	-132(fp),-136(fp),r0
-	bicl3	#0,r0,-132(fp)
-	cmpl	-132(fp),-136(fp)
-	bgequ	noname.77
-	addl2	#65536,-144(fp)
-noname.77:
-	movzwl	-130(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-144(fp)
-	bicl3	#-65536,-132(fp),r0
-	ashl	#16,r0,-136(fp)
-	addl3	-136(fp),-140(fp),r0
-	bicl3	#0,r0,-140(fp)
-	cmpl	-140(fp),-136(fp)
-	bgequ	noname.78
-	incl	-144(fp)
-noname.78:
-	movl	-140(fp),r1
-	movl	-144(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.79
-	incl	r2
-noname.79:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.80
-	incl	r10
-noname.80:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-156(fp)
-	bicl3	#-65536,r2,-160(fp)
-	mull3	r0,-156(fp),-148(fp)
-	mull2	r3,-156(fp)
-	mull3	r3,-160(fp),-152(fp)
-	mull2	r0,-160(fp)
-	addl3	-148(fp),-152(fp),r0
-	bicl3	#0,r0,-148(fp)
-	cmpl	-148(fp),-152(fp)
-	bgequ	noname.81
-	addl2	#65536,-160(fp)
-noname.81:
-	movzwl	-146(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-160(fp)
-	bicl3	#-65536,-148(fp),r0
-	ashl	#16,r0,-152(fp)
-	addl3	-152(fp),-156(fp),r0
-	bicl3	#0,r0,-156(fp)
-	cmpl	-156(fp),-152(fp)
-	bgequ	noname.82
-	incl	-160(fp)
-noname.82:
-	movl	-156(fp),r1
-	movl	-160(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.83
-	incl	r2
-noname.83:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.84
-	incl	r10
-noname.84:
-
-	movl	r9,12(r11)
-
-	clrl	r9
-
-	movzwl	18(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r6),-172(fp)
-	bicl3	#-65536,r2,-176(fp)
-	mull3	r0,-172(fp),-164(fp)
-	mull2	r3,-172(fp)
-	mull3	r3,-176(fp),-168(fp)
-	mull2	r0,-176(fp)
-	addl3	-164(fp),-168(fp),r0
-	bicl3	#0,r0,-164(fp)
-	cmpl	-164(fp),-168(fp)
-	bgequ	noname.85
-	addl2	#65536,-176(fp)
-noname.85:
-	movzwl	-162(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-176(fp)
-	bicl3	#-65536,-164(fp),r0
-	ashl	#16,r0,-168(fp)
-	addl3	-168(fp),-172(fp),r0
-	bicl3	#0,r0,-172(fp)
-	cmpl	-172(fp),-168(fp)
-	bgequ	noname.86
-	incl	-176(fp)
-noname.86:
-	movl	-172(fp),r1
-	movl	-176(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.87
-	incl	r2
-noname.87:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.88
-	incl	r9
-noname.88:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-188(fp)
-	bicl3	#-65536,r2,-192(fp)
-	mull3	r0,-188(fp),-180(fp)
-	mull2	r3,-188(fp)
-	mull3	r3,-192(fp),-184(fp)
-	mull2	r0,-192(fp)
-	addl3	-180(fp),-184(fp),r0
-	bicl3	#0,r0,-180(fp)
-	cmpl	-180(fp),-184(fp)
-	bgequ	noname.89
-	addl2	#65536,-192(fp)
-noname.89:
-	movzwl	-178(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-192(fp)
-	bicl3	#-65536,-180(fp),r0
-	ashl	#16,r0,-184(fp)
-	addl3	-184(fp),-188(fp),r0
-	bicl3	#0,r0,-188(fp)
-	cmpl	-188(fp),-184(fp)
-	bgequ	noname.90
-	incl	-192(fp)
-noname.90:
-	movl	-188(fp),r1
-	movl	-192(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.91
-	incl	r2
-noname.91:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.92
-	incl	r9
-noname.92:
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-204(fp)
-	bicl3	#-65536,r2,-208(fp)
-	mull3	r0,-204(fp),-196(fp)
-	mull2	r3,-204(fp)
-	mull3	r3,-208(fp),-200(fp)
-	mull2	r0,-208(fp)
-	addl3	-196(fp),-200(fp),r0
-	bicl3	#0,r0,-196(fp)
-	cmpl	-196(fp),-200(fp)
-	bgequ	noname.93
-	addl2	#65536,-208(fp)
-noname.93:
-	movzwl	-194(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-208(fp)
-	bicl3	#-65536,-196(fp),r0
-	ashl	#16,r0,-200(fp)
-	addl3	-200(fp),-204(fp),r0
-	bicl3	#0,r0,-204(fp)
-	cmpl	-204(fp),-200(fp)
-	bgequ	noname.94
-	incl	-208(fp)
-noname.94:
-	movl	-204(fp),r1
-	movl	-208(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.95
-	incl	r2
-noname.95:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.96
-	incl	r9
-noname.96:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-220(fp)
-	bicl3	#-65536,r2,-224(fp)
-	mull3	r0,-220(fp),-212(fp)
-	mull2	r3,-220(fp)
-	mull3	r3,-224(fp),-216(fp)
-	mull2	r0,-224(fp)
-	addl3	-212(fp),-216(fp),r0
-	bicl3	#0,r0,-212(fp)
-	cmpl	-212(fp),-216(fp)
-	bgequ	noname.97
-	addl2	#65536,-224(fp)
-noname.97:
-	movzwl	-210(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-224(fp)
-	bicl3	#-65536,-212(fp),r0
-	ashl	#16,r0,-216(fp)
-	addl3	-216(fp),-220(fp),r0
-	bicl3	#0,r0,-220(fp)
-	cmpl	-220(fp),-216(fp)
-	bgequ	noname.98
-	incl	-224(fp)
-noname.98:
-	movl	-220(fp),r1
-	movl	-224(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.99
-	incl	r2
-noname.99:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.100
-	incl	r9
-noname.100:
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,16(r7),r3
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-236(fp)
-	bicl3	#-65536,r2,-240(fp)
-	mull3	r0,-236(fp),-228(fp)
-	mull2	r3,-236(fp)
-	mull3	r3,-240(fp),-232(fp)
-	mull2	r0,-240(fp)
-	addl3	-228(fp),-232(fp),r0
-	bicl3	#0,r0,-228(fp)
-	cmpl	-228(fp),-232(fp)
-	bgequ	noname.101
-	addl2	#65536,-240(fp)
-noname.101:
-	movzwl	-226(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-240(fp)
-	bicl3	#-65536,-228(fp),r0
-	ashl	#16,r0,-232(fp)
-	addl3	-232(fp),-236(fp),r0
-	bicl3	#0,r0,-236(fp)
-	cmpl	-236(fp),-232(fp)
-	bgequ	noname.102
-	incl	-240(fp)
-noname.102:
-	movl	-236(fp),r1
-	movl	-240(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.103
-	incl	r2
-noname.103:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.104
-	incl	r9
-noname.104:
-
-	movl	r8,16(r11)
-
-	clrl	r8
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,20(r7),r3
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-252(fp)
-	bicl3	#-65536,r2,-256(fp)
-	mull3	r0,-252(fp),-244(fp)
-	mull2	r3,-252(fp)
-	mull3	r3,-256(fp),-248(fp)
-	mull2	r0,-256(fp)
-	addl3	-244(fp),-248(fp),r0
-	bicl3	#0,r0,-244(fp)
-	cmpl	-244(fp),-248(fp)
-	bgequ	noname.105
-	addl2	#65536,-256(fp)
-noname.105:
-	movzwl	-242(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-256(fp)
-	bicl3	#-65536,-244(fp),r0
-	ashl	#16,r0,-248(fp)
-	addl3	-248(fp),-252(fp),r0
-	bicl3	#0,r0,-252(fp)
-	cmpl	-252(fp),-248(fp)
-	bgequ	noname.106
-	incl	-256(fp)
-noname.106:
-	movl	-252(fp),r1
-	movl	-256(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.107
-	incl	r2
-noname.107:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.108
-	incl	r8
-noname.108:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,16(r7),r3
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-268(fp)
-	bicl3	#-65536,r2,-272(fp)
-	mull3	r0,-268(fp),-260(fp)
-	mull2	r3,-268(fp)
-	mull3	r3,-272(fp),-264(fp)
-	mull2	r0,-272(fp)
-	addl3	-260(fp),-264(fp),r0
-	bicl3	#0,r0,-260(fp)
-	cmpl	-260(fp),-264(fp)
-	bgequ	noname.109
-	addl2	#65536,-272(fp)
-noname.109:
-	movzwl	-258(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-272(fp)
-	bicl3	#-65536,-260(fp),r0
-	ashl	#16,r0,-264(fp)
-	addl3	-264(fp),-268(fp),r0
-	bicl3	#0,r0,-268(fp)
-	cmpl	-268(fp),-264(fp)
-	bgequ	noname.110
-	incl	-272(fp)
-noname.110:
-	movl	-268(fp),r1
-	movl	-272(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.111
-	incl	r2
-noname.111:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.112
-	incl	r8
-noname.112:
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-284(fp)
-	bicl3	#-65536,r2,-288(fp)
-	mull3	r0,-284(fp),-276(fp)
-	mull2	r3,-284(fp)
-	mull3	r3,-288(fp),-280(fp)
-	mull2	r0,-288(fp)
-	addl3	-276(fp),-280(fp),r0
-	bicl3	#0,r0,-276(fp)
-	cmpl	-276(fp),-280(fp)
-	bgequ	noname.113
-	addl2	#65536,-288(fp)
-noname.113:
-	movzwl	-274(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-288(fp)
-	bicl3	#-65536,-276(fp),r0
-	ashl	#16,r0,-280(fp)
-	addl3	-280(fp),-284(fp),r0
-	bicl3	#0,r0,-284(fp)
-	cmpl	-284(fp),-280(fp)
-	bgequ	noname.114
-	incl	-288(fp)
-noname.114:
-	movl	-284(fp),r1
-	movl	-288(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.115
-	incl	r2
-noname.115:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.116
-	incl	r8
-noname.116:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-300(fp)
-	bicl3	#-65536,r2,-304(fp)
-	mull3	r0,-300(fp),-292(fp)
-	mull2	r3,-300(fp)
-	mull3	r3,-304(fp),-296(fp)
-	mull2	r0,-304(fp)
-	addl3	-292(fp),-296(fp),r0
-	bicl3	#0,r0,-292(fp)
-	cmpl	-292(fp),-296(fp)
-	bgequ	noname.117
-	addl2	#65536,-304(fp)
-noname.117:
-	movzwl	-290(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-304(fp)
-	bicl3	#-65536,-292(fp),r0
-	ashl	#16,r0,-296(fp)
-	addl3	-296(fp),-300(fp),r0
-	bicl3	#0,r0,-300(fp)
-	cmpl	-300(fp),-296(fp)
-	bgequ	noname.118
-	incl	-304(fp)
-noname.118:
-	movl	-300(fp),r1
-	movl	-304(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.119
-	incl	r2
-noname.119:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.120
-	incl	r8
-noname.120:
-
-	movzwl	18(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r6),-316(fp)
-	bicl3	#-65536,r2,-320(fp)
-	mull3	r0,-316(fp),-308(fp)
-	mull2	r3,-316(fp)
-	mull3	r3,-320(fp),-312(fp)
-	mull2	r0,-320(fp)
-	addl3	-308(fp),-312(fp),r0
-	bicl3	#0,r0,-308(fp)
-	cmpl	-308(fp),-312(fp)
-	bgequ	noname.121
-	addl2	#65536,-320(fp)
-noname.121:
-	movzwl	-306(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-320(fp)
-	bicl3	#-65536,-308(fp),r0
-	ashl	#16,r0,-312(fp)
-	addl3	-312(fp),-316(fp),r0
-	bicl3	#0,r0,-316(fp)
-	cmpl	-316(fp),-312(fp)
-	bgequ	noname.122
-	incl	-320(fp)
-noname.122:
-	movl	-316(fp),r1
-	movl	-320(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.123
-	incl	r2
-
-noname.123:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.124
-	incl	r8
-noname.124:
-
-	movzwl	22(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,20(r6),-332(fp)
-	bicl3	#-65536,r2,-336(fp)
-	mull3	r0,-332(fp),-324(fp)
-	mull2	r3,-332(fp)
-	mull3	r3,-336(fp),-328(fp)
-	mull2	r0,-336(fp)
-	addl3	-324(fp),-328(fp),r0
-	bicl3	#0,r0,-324(fp)
-	cmpl	-324(fp),-328(fp)
-	bgequ	noname.125
-	addl2	#65536,-336(fp)
-noname.125:
-	movzwl	-322(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-336(fp)
-	bicl3	#-65536,-324(fp),r0
-	ashl	#16,r0,-328(fp)
-	addl3	-328(fp),-332(fp),r0
-	bicl3	#0,r0,-332(fp)
-	cmpl	-332(fp),-328(fp)
-	bgequ	noname.126
-	incl	-336(fp)
-noname.126:
-	movl	-332(fp),r1
-	movl	-336(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.127
-	incl	r2
-noname.127:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.128
-	incl	r8
-noname.128:
-
-	movl	r10,20(r11)
-
-	clrl	r10
-
-	movzwl	26(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,24(r6),-348(fp)
-	bicl3	#-65536,r2,-352(fp)
-	mull3	r0,-348(fp),-340(fp)
-	mull2	r3,-348(fp)
-	mull3	r3,-352(fp),-344(fp)
-	mull2	r0,-352(fp)
-	addl3	-340(fp),-344(fp),r0
-	bicl3	#0,r0,-340(fp)
-	cmpl	-340(fp),-344(fp)
-	bgequ	noname.129
-	addl2	#65536,-352(fp)
-noname.129:
-	movzwl	-338(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-352(fp)
-	bicl3	#-65536,-340(fp),r0
-	ashl	#16,r0,-344(fp)
-	addl3	-344(fp),-348(fp),r0
-	bicl3	#0,r0,-348(fp)
-	cmpl	-348(fp),-344(fp)
-	bgequ	noname.130
-	incl	-352(fp)
-noname.130:
-	movl	-348(fp),r1
-	movl	-352(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.131
-	incl	r2
-noname.131:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.132
-	incl	r10
-noname.132:
-
-	movzwl	22(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,20(r6),-364(fp)
-	bicl3	#-65536,r2,-368(fp)
-	mull3	r0,-364(fp),-356(fp)
-	mull2	r3,-364(fp)
-	mull3	r3,-368(fp),-360(fp)
-	mull2	r0,-368(fp)
-	addl3	-356(fp),-360(fp),r0
-	bicl3	#0,r0,-356(fp)
-	cmpl	-356(fp),-360(fp)
-	bgequ	noname.133
-	addl2	#65536,-368(fp)
-noname.133:
-	movzwl	-354(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-368(fp)
-	bicl3	#-65536,-356(fp),r0
-	ashl	#16,r0,-360(fp)
-	addl3	-360(fp),-364(fp),r0
-	bicl3	#0,r0,-364(fp)
-	cmpl	-364(fp),-360(fp)
-	bgequ	noname.134
-	incl	-368(fp)
-noname.134:
-	movl	-364(fp),r1
-	movl	-368(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.135
-	incl	r2
-noname.135:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.136
-	incl	r10
-noname.136:
-
-	movzwl	18(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r6),-380(fp)
-	bicl3	#-65536,r2,-384(fp)
-	mull3	r0,-380(fp),-372(fp)
-	mull2	r3,-380(fp)
-	mull3	r3,-384(fp),-376(fp)
-	mull2	r0,-384(fp)
-	addl3	-372(fp),-376(fp),r0
-	bicl3	#0,r0,-372(fp)
-	cmpl	-372(fp),-376(fp)
-	bgequ	noname.137
-	addl2	#65536,-384(fp)
-noname.137:
-	movzwl	-370(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-384(fp)
-	bicl3	#-65536,-372(fp),r0
-	ashl	#16,r0,-376(fp)
-	addl3	-376(fp),-380(fp),r0
-	bicl3	#0,r0,-380(fp)
-	cmpl	-380(fp),-376(fp)
-	bgequ	noname.138
-	incl	-384(fp)
-noname.138:
-	movl	-380(fp),r1
-	movl	-384(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.139
-	incl	r2
-noname.139:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.140
-	incl	r10
-noname.140:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-396(fp)
-	bicl3	#-65536,r2,-400(fp)
-	mull3	r0,-396(fp),-388(fp)
-	mull2	r3,-396(fp)
-	mull3	r3,-400(fp),-392(fp)
-	mull2	r0,-400(fp)
-	addl3	-388(fp),-392(fp),r0
-	bicl3	#0,r0,-388(fp)
-	cmpl	-388(fp),-392(fp)
-	bgequ	noname.141
-	addl2	#65536,-400(fp)
-noname.141:
-	movzwl	-386(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-400(fp)
-	bicl3	#-65536,-388(fp),r0
-	ashl	#16,r0,-392(fp)
-	addl3	-392(fp),-396(fp),r0
-	bicl3	#0,r0,-396(fp)
-	cmpl	-396(fp),-392(fp)
-	bgequ	noname.142
-	incl	-400(fp)
-noname.142:
-	movl	-396(fp),r1
-	movl	-400(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.143
-	incl	r2
-noname.143:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.144
-	incl	r10
-noname.144:
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,16(r7),r3
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-412(fp)
-	bicl3	#-65536,r2,-416(fp)
-	mull3	r0,-412(fp),-404(fp)
-	mull2	r3,-412(fp)
-	mull3	r3,-416(fp),-408(fp)
-	mull2	r0,-416(fp)
-	addl3	-404(fp),-408(fp),r0
-	bicl3	#0,r0,-404(fp)
-	cmpl	-404(fp),-408(fp)
-	bgequ	noname.145
-	addl2	#65536,-416(fp)
-noname.145:
-	movzwl	-402(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-416(fp)
-	bicl3	#-65536,-404(fp),r0
-	ashl	#16,r0,-408(fp)
-	addl3	-408(fp),-412(fp),r0
-	bicl3	#0,r0,-412(fp)
-	cmpl	-412(fp),-408(fp)
-	bgequ	noname.146
-	incl	-416(fp)
-noname.146:
-	movl	-412(fp),r1
-	movl	-416(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.147
-	incl	r2
-noname.147:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.148
-	incl	r10
-noname.148:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,20(r7),r3
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-428(fp)
-	bicl3	#-65536,r2,-432(fp)
-	mull3	r0,-428(fp),-420(fp)
-	mull2	r3,-428(fp)
-	mull3	r3,-432(fp),-424(fp)
-	mull2	r0,-432(fp)
-	addl3	-420(fp),-424(fp),r0
-	bicl3	#0,r0,-420(fp)
-	cmpl	-420(fp),-424(fp)
-	bgequ	noname.149
-	addl2	#65536,-432(fp)
-noname.149:
-	movzwl	-418(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-432(fp)
-	bicl3	#-65536,-420(fp),r0
-	ashl	#16,r0,-424(fp)
-	addl3	-424(fp),-428(fp),r0
-	bicl3	#0,r0,-428(fp)
-	cmpl	-428(fp),-424(fp)
-	bgequ	noname.150
-	incl	-432(fp)
-noname.150:
-	movl	-428(fp),r1
-	movl	-432(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.151
-	incl	r2
-noname.151:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.152
-	incl	r10
-noname.152:
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,24(r7),r3
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-444(fp)
-	bicl3	#-65536,r2,-448(fp)
-	mull3	r0,-444(fp),-436(fp)
-	mull2	r3,-444(fp)
-	mull3	r3,-448(fp),-440(fp)
-	mull2	r0,-448(fp)
-	addl3	-436(fp),-440(fp),r0
-	bicl3	#0,r0,-436(fp)
-	cmpl	-436(fp),-440(fp)
-	bgequ	noname.153
-	addl2	#65536,-448(fp)
-noname.153:
-	movzwl	-434(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-448(fp)
-	bicl3	#-65536,-436(fp),r0
-	ashl	#16,r0,-440(fp)
-	addl3	-440(fp),-444(fp),r0
-	bicl3	#0,r0,-444(fp)
-	cmpl	-444(fp),-440(fp)
-	bgequ	noname.154
-	incl	-448(fp)
-noname.154:
-	movl	-444(fp),r1
-	movl	-448(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.155
-	incl	r2
-noname.155:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.156
-	incl	r10
-noname.156:
-
-	movl	r9,24(r11)
-
-	clrl	r9
-
-	movzwl	2(r6),r2
-	bicl3	#-65536,28(r7),r3
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,(r6),-460(fp)
-	bicl3	#-65536,r2,-464(fp)
-	mull3	r0,-460(fp),-452(fp)
-	mull2	r3,-460(fp)
-	mull3	r3,-464(fp),-456(fp)
-	mull2	r0,-464(fp)
-	addl3	-452(fp),-456(fp),r0
-	bicl3	#0,r0,-452(fp)
-	cmpl	-452(fp),-456(fp)
-	bgequ	noname.157
-	addl2	#65536,-464(fp)
-noname.157:
-	movzwl	-450(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-464(fp)
-	bicl3	#-65536,-452(fp),r0
-	ashl	#16,r0,-456(fp)
-	addl3	-456(fp),-460(fp),r0
-	bicl3	#0,r0,-460(fp)
-	cmpl	-460(fp),-456(fp)
-	bgequ	noname.158
-	incl	-464(fp)
-noname.158:
-	movl	-460(fp),r1
-	movl	-464(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.159
-	incl	r2
-noname.159:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.160
-	incl	r9
-noname.160:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,24(r7),r3
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-476(fp)
-	bicl3	#-65536,r2,-480(fp)
-	mull3	r0,-476(fp),-468(fp)
-	mull2	r3,-476(fp)
-	mull3	r3,-480(fp),-472(fp)
-	mull2	r0,-480(fp)
-	addl3	-468(fp),-472(fp),r0
-	bicl3	#0,r0,-468(fp)
-	cmpl	-468(fp),-472(fp)
-	bgequ	noname.161
-	addl2	#65536,-480(fp)
-noname.161:
-	movzwl	-466(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-480(fp)
-	bicl3	#-65536,-468(fp),r0
-	ashl	#16,r0,-472(fp)
-	addl3	-472(fp),-476(fp),r0
-	bicl3	#0,r0,-476(fp)
-	cmpl	-476(fp),-472(fp)
-	bgequ	noname.162
-	incl	-480(fp)
-noname.162:
-	movl	-476(fp),r1
-	movl	-480(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.163
-	incl	r2
-noname.163:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.164
-	incl	r9
-noname.164:
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,20(r7),r3
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-492(fp)
-	bicl3	#-65536,r2,-496(fp)
-	mull3	r0,-492(fp),-484(fp)
-	mull2	r3,-492(fp)
-	mull3	r3,-496(fp),-488(fp)
-	mull2	r0,-496(fp)
-	addl3	-484(fp),-488(fp),r0
-	bicl3	#0,r0,-484(fp)
-	cmpl	-484(fp),-488(fp)
-	bgequ	noname.165
-	addl2	#65536,-496(fp)
-noname.165:
-	movzwl	-482(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-496(fp)
-	bicl3	#-65536,-484(fp),r0
-	ashl	#16,r0,-488(fp)
-	addl3	-488(fp),-492(fp),r0
-	bicl3	#0,r0,-492(fp)
-	cmpl	-492(fp),-488(fp)
-	bgequ	noname.166
-	incl	-496(fp)
-noname.166:
-	movl	-492(fp),r1
-	movl	-496(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.167
-	incl	r2
-noname.167:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.168
-	incl	r9
-noname.168:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,16(r7),r3
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-508(fp)
-	bicl3	#-65536,r2,-512(fp)
-	mull3	r0,-508(fp),-500(fp)
-	mull2	r3,-508(fp)
-	mull3	r3,-512(fp),-504(fp)
-	mull2	r0,-512(fp)
-	addl3	-500(fp),-504(fp),r0
-	bicl3	#0,r0,-500(fp)
-	cmpl	-500(fp),-504(fp)
-	bgequ	noname.169
-	addl2	#65536,-512(fp)
-noname.169:
-	movzwl	-498(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-512(fp)
-	bicl3	#-65536,-500(fp),r0
-	ashl	#16,r0,-504(fp)
-	addl3	-504(fp),-508(fp),r0
-	bicl3	#0,r0,-508(fp)
-	cmpl	-508(fp),-504(fp)
-	bgequ	noname.170
-	incl	-512(fp)
-noname.170:
-	movl	-508(fp),r1
-	movl	-512(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.171
-	incl	r2
-noname.171:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.172
-	incl	r9
-noname.172:
-
-	movzwl	18(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r6),-524(fp)
-	bicl3	#-65536,r2,-528(fp)
-	mull3	r0,-524(fp),-516(fp)
-	mull2	r3,-524(fp)
-	mull3	r3,-528(fp),-520(fp)
-	mull2	r0,-528(fp)
-	addl3	-516(fp),-520(fp),r0
-	bicl3	#0,r0,-516(fp)
-	cmpl	-516(fp),-520(fp)
-	bgequ	noname.173
-	addl2	#65536,-528(fp)
-noname.173:
-	movzwl	-514(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-528(fp)
-	bicl3	#-65536,-516(fp),r0
-	ashl	#16,r0,-520(fp)
-	addl3	-520(fp),-524(fp),r0
-	bicl3	#0,r0,-524(fp)
-	cmpl	-524(fp),-520(fp)
-	bgequ	noname.174
-	incl	-528(fp)
-noname.174:
-	movl	-524(fp),r1
-	movl	-528(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.175
-	incl	r2
-noname.175:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.176
-	incl	r9
-noname.176:
-
-	movzwl	22(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,20(r6),-540(fp)
-	bicl3	#-65536,r2,-544(fp)
-	mull3	r0,-540(fp),-532(fp)
-	mull2	r3,-540(fp)
-	mull3	r3,-544(fp),-536(fp)
-	mull2	r0,-544(fp)
-	addl3	-532(fp),-536(fp),r0
-	bicl3	#0,r0,-532(fp)
-	cmpl	-532(fp),-536(fp)
-	bgequ	noname.177
-	addl2	#65536,-544(fp)
-noname.177:
-	movzwl	-530(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-544(fp)
-	bicl3	#-65536,-532(fp),r0
-	ashl	#16,r0,-536(fp)
-	addl3	-536(fp),-540(fp),r0
-	bicl3	#0,r0,-540(fp)
-	cmpl	-540(fp),-536(fp)
-	bgequ	noname.178
-	incl	-544(fp)
-noname.178:
-	movl	-540(fp),r1
-	movl	-544(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.179
-	incl	r2
-noname.179:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.180
-	incl	r9
-noname.180:
-
-	movzwl	26(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,24(r6),-556(fp)
-	bicl3	#-65536,r2,-560(fp)
-	mull3	r0,-556(fp),-548(fp)
-	mull2	r3,-556(fp)
-	mull3	r3,-560(fp),-552(fp)
-	mull2	r0,-560(fp)
-	addl3	-548(fp),-552(fp),r0
-	bicl3	#0,r0,-548(fp)
-	cmpl	-548(fp),-552(fp)
-	bgequ	noname.181
-	addl2	#65536,-560(fp)
-noname.181:
-	movzwl	-546(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-560(fp)
-	bicl3	#-65536,-548(fp),r0
-	ashl	#16,r0,-552(fp)
-	addl3	-552(fp),-556(fp),r0
-	bicl3	#0,r0,-556(fp)
-	cmpl	-556(fp),-552(fp)
-	bgequ	noname.182
-	incl	-560(fp)
-noname.182:
-	movl	-556(fp),r1
-	movl	-560(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.183
-	incl	r2
-noname.183:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.184
-	incl	r9
-noname.184:
-
-	movzwl	30(r6),r2
-	bicl3	#-65536,(r7),r3
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,28(r6),-572(fp)
-	bicl3	#-65536,r2,-576(fp)
-	mull3	r0,-572(fp),-564(fp)
-	mull2	r3,-572(fp)
-	mull3	r3,-576(fp),-568(fp)
-	mull2	r0,-576(fp)
-	addl3	-564(fp),-568(fp),r0
-	bicl3	#0,r0,-564(fp)
-	cmpl	-564(fp),-568(fp)
-	bgequ	noname.185
-	addl2	#65536,-576(fp)
-noname.185:
-	movzwl	-562(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-576(fp)
-	bicl3	#-65536,-564(fp),r0
-	ashl	#16,r0,-568(fp)
-	addl3	-568(fp),-572(fp),r0
-	bicl3	#0,r0,-572(fp)
-	cmpl	-572(fp),-568(fp)
-	bgequ	noname.186
-	incl	-576(fp)
-noname.186:
-	movl	-572(fp),r1
-	movl	-576(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.187
-	incl	r2
-noname.187:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.188
-	incl	r9
-noname.188:
-
-	movl	r8,28(r11)
-
-	clrl	r8
-
-	movzwl	30(r6),r2
-	bicl3	#-65536,4(r7),r3
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,28(r6),-588(fp)
-	bicl3	#-65536,r2,-592(fp)
-	mull3	r0,-588(fp),-580(fp)
-	mull2	r3,-588(fp)
-	mull3	r3,-592(fp),-584(fp)
-	mull2	r0,-592(fp)
-	addl3	-580(fp),-584(fp),r0
-	bicl3	#0,r0,-580(fp)
-	cmpl	-580(fp),-584(fp)
-	bgequ	noname.189
-	addl2	#65536,-592(fp)
-noname.189:
-	movzwl	-578(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-592(fp)
-	bicl3	#-65536,-580(fp),r0
-	ashl	#16,r0,-584(fp)
-	addl3	-584(fp),-588(fp),r0
-	bicl3	#0,r0,-588(fp)
-	cmpl	-588(fp),-584(fp)
-	bgequ	noname.190
-	incl	-592(fp)
-noname.190:
-	movl	-588(fp),r1
-	movl	-592(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.191
-	incl	r2
-noname.191:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.192
-	incl	r8
-noname.192:
-
-	movzwl	26(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,24(r6),-604(fp)
-	bicl3	#-65536,r2,-608(fp)
-	mull3	r0,-604(fp),-596(fp)
-	mull2	r3,-604(fp)
-	mull3	r3,-608(fp),-600(fp)
-	mull2	r0,-608(fp)
-	addl3	-596(fp),-600(fp),r0
-	bicl3	#0,r0,-596(fp)
-	cmpl	-596(fp),-600(fp)
-	bgequ	noname.193
-	addl2	#65536,-608(fp)
-noname.193:
-	movzwl	-594(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-608(fp)
-	bicl3	#-65536,-596(fp),r0
-	ashl	#16,r0,-600(fp)
-	addl3	-600(fp),-604(fp),r0
-	bicl3	#0,r0,-604(fp)
-	cmpl	-604(fp),-600(fp)
-	bgequ	noname.194
-	incl	-608(fp)
-noname.194:
-	movl	-604(fp),r1
-	movl	-608(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.195
-	incl	r2
-noname.195:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.196
-	incl	r8
-noname.196:
-
-	movzwl	22(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,20(r6),-620(fp)
-	bicl3	#-65536,r2,-624(fp)
-	mull3	r0,-620(fp),-612(fp)
-	mull2	r3,-620(fp)
-	mull3	r3,-624(fp),-616(fp)
-	mull2	r0,-624(fp)
-	addl3	-612(fp),-616(fp),r0
-	bicl3	#0,r0,-612(fp)
-	cmpl	-612(fp),-616(fp)
-	bgequ	noname.197
-	addl2	#65536,-624(fp)
-noname.197:
-	movzwl	-610(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-624(fp)
-	bicl3	#-65536,-612(fp),r0
-	ashl	#16,r0,-616(fp)
-	addl3	-616(fp),-620(fp),r0
-	bicl3	#0,r0,-620(fp)
-	cmpl	-620(fp),-616(fp)
-	bgequ	noname.198
-	incl	-624(fp)
-noname.198:
-	movl	-620(fp),r1
-	movl	-624(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.199
-	incl	r2
-noname.199:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.200
-	incl	r8
-noname.200:
-
-	movzwl	18(r6),r2
-	bicl3	#-65536,16(r7),r3
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r6),-636(fp)
-	bicl3	#-65536,r2,-640(fp)
-	mull3	r0,-636(fp),-628(fp)
-	mull2	r3,-636(fp)
-	mull3	r3,-640(fp),-632(fp)
-	mull2	r0,-640(fp)
-	addl3	-628(fp),-632(fp),r0
-	bicl3	#0,r0,-628(fp)
-	cmpl	-628(fp),-632(fp)
-	bgequ	noname.201
-	addl2	#65536,-640(fp)
-noname.201:
-	movzwl	-626(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-640(fp)
-	bicl3	#-65536,-628(fp),r0
-	ashl	#16,r0,-632(fp)
-	addl3	-632(fp),-636(fp),r0
-	bicl3	#0,r0,-636(fp)
-	cmpl	-636(fp),-632(fp)
-	bgequ	noname.202
-	incl	-640(fp)
-noname.202:
-	movl	-636(fp),r1
-	movl	-640(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.203
-	incl	r2
-noname.203:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.204
-	incl	r8
-noname.204:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,20(r7),r3
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-652(fp)
-	bicl3	#-65536,r2,-656(fp)
-	mull3	r0,-652(fp),-644(fp)
-	mull2	r3,-652(fp)
-	mull3	r3,-656(fp),-648(fp)
-	mull2	r0,-656(fp)
-	addl3	-644(fp),-648(fp),r0
-	bicl3	#0,r0,-644(fp)
-	cmpl	-644(fp),-648(fp)
-	bgequ	noname.205
-	addl2	#65536,-656(fp)
-noname.205:
-	movzwl	-642(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-656(fp)
-	bicl3	#-65536,-644(fp),r0
-	ashl	#16,r0,-648(fp)
-	addl3	-648(fp),-652(fp),r0
-	bicl3	#0,r0,-652(fp)
-	cmpl	-652(fp),-648(fp)
-	bgequ	noname.206
-	incl	-656(fp)
-noname.206:
-	movl	-652(fp),r1
-	movl	-656(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.207
-	incl	r2
-noname.207:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.208
-	incl	r8
-noname.208:
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,24(r7),r3
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-668(fp)
-	bicl3	#-65536,r2,-672(fp)
-	mull3	r0,-668(fp),-660(fp)
-	mull2	r3,-668(fp)
-	mull3	r3,-672(fp),-664(fp)
-	mull2	r0,-672(fp)
-	addl3	-660(fp),-664(fp),r0
-	bicl3	#0,r0,-660(fp)
-	cmpl	-660(fp),-664(fp)
-	bgequ	noname.209
-	addl2	#65536,-672(fp)
-noname.209:
-	movzwl	-658(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-672(fp)
-	bicl3	#-65536,-660(fp),r0
-	ashl	#16,r0,-664(fp)
-	addl3	-664(fp),-668(fp),r0
-	bicl3	#0,r0,-668(fp)
-	cmpl	-668(fp),-664(fp)
-	bgequ	noname.210
-	incl	-672(fp)
-noname.210:
-	movl	-668(fp),r1
-	movl	-672(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.211
-	incl	r2
-noname.211:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.212
-	incl	r8
-noname.212:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,28(r7),r3
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-684(fp)
-	bicl3	#-65536,r2,-688(fp)
-	mull3	r0,-684(fp),-676(fp)
-	mull2	r3,-684(fp)
-	mull3	r3,-688(fp),-680(fp)
-	mull2	r0,-688(fp)
-	addl3	-676(fp),-680(fp),r0
-	bicl3	#0,r0,-676(fp)
-	cmpl	-676(fp),-680(fp)
-	bgequ	noname.213
-	addl2	#65536,-688(fp)
-noname.213:
-	movzwl	-674(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-688(fp)
-	bicl3	#-65536,-676(fp),r0
-	ashl	#16,r0,-680(fp)
-	addl3	-680(fp),-684(fp),r0
-	bicl3	#0,r0,-684(fp)
-	cmpl	-684(fp),-680(fp)
-	bgequ	noname.214
-	incl	-688(fp)
-noname.214:
-	movl	-684(fp),r1
-	movl	-688(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.215
-	incl	r2
-noname.215:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.216
-	incl	r8
-noname.216:
-
-	movl	r10,32(r11)
-
-	clrl	r10
-
-	movzwl	10(r6),r2
-	bicl3	#-65536,28(r7),r3
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r6),-700(fp)
-	bicl3	#-65536,r2,-704(fp)
-	mull3	r0,-700(fp),-692(fp)
-	mull2	r3,-700(fp)
-	mull3	r3,-704(fp),-696(fp)
-	mull2	r0,-704(fp)
-	addl3	-692(fp),-696(fp),r0
-	bicl3	#0,r0,-692(fp)
-	cmpl	-692(fp),-696(fp)
-	bgequ	noname.217
-	addl2	#65536,-704(fp)
-noname.217:
-	movzwl	-690(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-704(fp)
-	bicl3	#-65536,-692(fp),r0
-	ashl	#16,r0,-696(fp)
-	addl3	-696(fp),-700(fp),r0
-	bicl3	#0,r0,-700(fp)
-	cmpl	-700(fp),-696(fp)
-	bgequ	noname.218
-	incl	-704(fp)
-noname.218:
-	movl	-700(fp),r1
-	movl	-704(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.219
-	incl	r2
-noname.219:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.220
-	incl	r10
-noname.220:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,24(r7),r3
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-716(fp)
-	bicl3	#-65536,r2,-720(fp)
-	mull3	r0,-716(fp),-708(fp)
-	mull2	r3,-716(fp)
-	mull3	r3,-720(fp),-712(fp)
-	mull2	r0,-720(fp)
-	addl3	-708(fp),-712(fp),r0
-	bicl3	#0,r0,-708(fp)
-	cmpl	-708(fp),-712(fp)
-	bgequ	noname.221
-	addl2	#65536,-720(fp)
-noname.221:
-	movzwl	-706(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-720(fp)
-	bicl3	#-65536,-708(fp),r0
-	ashl	#16,r0,-712(fp)
-	addl3	-712(fp),-716(fp),r0
-	bicl3	#0,r0,-716(fp)
-	cmpl	-716(fp),-712(fp)
-	bgequ	noname.222
-	incl	-720(fp)
-noname.222:
-	movl	-716(fp),r1
-	movl	-720(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.223
-	incl	r2
-noname.223:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.224
-	incl	r10
-noname.224:
-
-	movzwl	18(r6),r2
-	bicl3	#-65536,20(r7),r3
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r6),-732(fp)
-	bicl3	#-65536,r2,-736(fp)
-	mull3	r0,-732(fp),-724(fp)
-	mull2	r3,-732(fp)
-	mull3	r3,-736(fp),-728(fp)
-	mull2	r0,-736(fp)
-	addl3	-724(fp),-728(fp),r0
-	bicl3	#0,r0,-724(fp)
-	cmpl	-724(fp),-728(fp)
-	bgequ	noname.225
-	addl2	#65536,-736(fp)
-noname.225:
-	movzwl	-722(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-736(fp)
-	bicl3	#-65536,-724(fp),r0
-	ashl	#16,r0,-728(fp)
-	addl3	-728(fp),-732(fp),r0
-	bicl3	#0,r0,-732(fp)
-	cmpl	-732(fp),-728(fp)
-	bgequ	noname.226
-	incl	-736(fp)
-noname.226:
-	movl	-732(fp),r1
-	movl	-736(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.227
-	incl	r2
-noname.227:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.228
-	incl	r10
-noname.228:
-
-	movzwl	22(r6),r2
-	bicl3	#-65536,16(r7),r3
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,20(r6),-748(fp)
-	bicl3	#-65536,r2,-752(fp)
-	mull3	r0,-748(fp),-740(fp)
-	mull2	r3,-748(fp)
-	mull3	r3,-752(fp),-744(fp)
-	mull2	r0,-752(fp)
-	addl3	-740(fp),-744(fp),r0
-	bicl3	#0,r0,-740(fp)
-	cmpl	-740(fp),-744(fp)
-	bgequ	noname.229
-	addl2	#65536,-752(fp)
-noname.229:
-	movzwl	-738(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-752(fp)
-	bicl3	#-65536,-740(fp),r0
-	ashl	#16,r0,-744(fp)
-	addl3	-744(fp),-748(fp),r0
-	bicl3	#0,r0,-748(fp)
-	cmpl	-748(fp),-744(fp)
-	bgequ	noname.230
-	incl	-752(fp)
-noname.230:
-	movl	-748(fp),r1
-	movl	-752(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.231
-	incl	r2
-noname.231:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.232
-	incl	r10
-noname.232:
-
-	movzwl	26(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,24(r6),-764(fp)
-	bicl3	#-65536,r2,-768(fp)
-	mull3	r0,-764(fp),-756(fp)
-	mull2	r3,-764(fp)
-	mull3	r3,-768(fp),-760(fp)
-	mull2	r0,-768(fp)
-	addl3	-756(fp),-760(fp),r0
-	bicl3	#0,r0,-756(fp)
-	cmpl	-756(fp),-760(fp)
-	bgequ	noname.233
-	addl2	#65536,-768(fp)
-noname.233:
-	movzwl	-754(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-768(fp)
-	bicl3	#-65536,-756(fp),r0
-	ashl	#16,r0,-760(fp)
-	addl3	-760(fp),-764(fp),r0
-	bicl3	#0,r0,-764(fp)
-	cmpl	-764(fp),-760(fp)
-	bgequ	noname.234
-	incl	-768(fp)
-noname.234:
-	movl	-764(fp),r1
-	movl	-768(fp),r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.235
-	incl	r2
-noname.235:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.236
-	incl	r10
-noname.236:
-
-	bicl3	#-65536,28(r6),r3
-	movzwl	30(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,8(r7),r2
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-772(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-776(fp)
-	mull2	r0,r4
-	addl3	-772(fp),-776(fp),r0
-	bicl3	#0,r0,-772(fp)
-	cmpl	-772(fp),-776(fp)
-	bgequ	noname.237
-	addl2	#65536,r4
-noname.237:
-	movzwl	-770(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-772(fp),r0
-	ashl	#16,r0,-776(fp)
-	addl2	-776(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-776(fp)
-	bgequ	noname.238
-	incl	r4
-noname.238:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.239
-	incl	r2
-noname.239:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.240
-	incl	r10
-noname.240:
-
-	movl	r9,36(r11)
-
-	clrl	r9
-
-	bicl3	#-65536,28(r6),r3
-	movzwl	30(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r7),r2
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-780(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-784(fp)
-	mull2	r0,r4
-	addl3	-780(fp),-784(fp),r0
-	bicl3	#0,r0,-780(fp)
-	cmpl	-780(fp),-784(fp)
-	bgequ	noname.241
-	addl2	#65536,r4
-noname.241:
-	movzwl	-778(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-780(fp),r0
-	ashl	#16,r0,-784(fp)
-	addl2	-784(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-784(fp)
-	bgequ	noname.242
-	incl	r4
-noname.242:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.243
-	incl	r2
-noname.243:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.244
-	incl	r9
-noname.244:
-
-	bicl3	#-65536,24(r6),r3
-	movzwl	26(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r7),r2
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-788(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-792(fp)
-	mull2	r0,r4
-	addl3	-788(fp),-792(fp),r0
-	bicl3	#0,r0,-788(fp)
-	cmpl	-788(fp),-792(fp)
-	bgequ	noname.245
-	addl2	#65536,r4
-noname.245:
-	movzwl	-786(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-788(fp),r0
-	ashl	#16,r0,-792(fp)
-	addl2	-792(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-792(fp)
-	bgequ	noname.246
-	incl	r4
-noname.246:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.247
-	incl	r2
-noname.247:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.248
-	incl	r9
-noname.248:
-
-	bicl3	#-65536,20(r6),r3
-	movzwl	22(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r7),r2
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-796(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-800(fp)
-	mull2	r0,r4
-	addl3	-796(fp),-800(fp),r0
-	bicl3	#0,r0,-796(fp)
-	cmpl	-796(fp),-800(fp)
-	bgequ	noname.249
-	addl2	#65536,r4
-noname.249:
-	movzwl	-794(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-796(fp),r0
-	ashl	#16,r0,-800(fp)
-	addl2	-800(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-800(fp)
-	bgequ	noname.250
-	incl	r4
-noname.250:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.251
-	incl	r2
-noname.251:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.252
-	incl	r9
-noname.252:
-
-	bicl3	#-65536,16(r6),r3
-	movzwl	18(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,24(r7),r2
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-804(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-808(fp)
-	mull2	r0,r4
-	addl3	-804(fp),-808(fp),r0
-	bicl3	#0,r0,-804(fp)
-	cmpl	-804(fp),-808(fp)
-	bgequ	noname.253
-	addl2	#65536,r4
-noname.253:
-	movzwl	-802(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-804(fp),r0
-	ashl	#16,r0,-808(fp)
-	addl2	-808(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-808(fp)
-	bgequ	noname.254
-	incl	r4
-noname.254:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.255
-	incl	r2
-noname.255:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.256
-	incl	r9
-noname.256:
-
-	bicl3	#-65536,12(r6),r3
-	movzwl	14(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,28(r7),r2
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-812(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-816(fp)
-	mull2	r0,r4
-	addl3	-812(fp),-816(fp),r0
-	bicl3	#0,r0,-812(fp)
-	cmpl	-812(fp),-816(fp)
-	bgequ	noname.257
-	addl2	#65536,r4
-noname.257:
-	movzwl	-810(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-812(fp),r0
-	ashl	#16,r0,-816(fp)
-	addl2	-816(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-816(fp)
-	bgequ	noname.258
-	incl	r4
-noname.258:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.259
-	incl	r2
-noname.259:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.260
-	incl	r9
-noname.260:
-
-	movl	r8,40(r11)
-
-	clrl	r8
-
-	bicl3	#-65536,16(r6),r3
-	movzwl	18(r6),r2
-	bicl3	#-65536,28(r7),r1
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r4
-	bicl3	#-65536,r2,-828(fp)
-	mull3	r0,r4,-820(fp)
-	mull2	r1,r4
-	mull3	r1,-828(fp),-824(fp)
-	mull2	r0,-828(fp)
-	addl3	-820(fp),-824(fp),r0
-	bicl3	#0,r0,-820(fp)
-	cmpl	-820(fp),-824(fp)
-	bgequ	noname.261
-	addl2	#65536,-828(fp)
-noname.261:
-	movzwl	-818(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-828(fp)
-	bicl3	#-65536,-820(fp),r0
-	ashl	#16,r0,-824(fp)
-	addl2	-824(fp),r4
-	bicl2	#0,r4
-	cmpl	r4,-824(fp)
-	bgequ	noname.262
-	incl	-828(fp)
-noname.262:
-	movl	r4,r1
-	movl	-828(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.263
-	incl	r2
-noname.263:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.264
-	incl	r8
-noname.264:
-
-	movzwl	22(r6),r2
-	bicl3	#-65536,24(r7),r3
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,20(r6),-840(fp)
-	bicl3	#-65536,r2,-844(fp)
-	mull3	r0,-840(fp),-832(fp)
-	mull2	r3,-840(fp)
-	mull3	r3,-844(fp),-836(fp)
-	mull2	r0,-844(fp)
-	addl3	-832(fp),-836(fp),r0
-	bicl3	#0,r0,-832(fp)
-	cmpl	-832(fp),-836(fp)
-	bgequ	noname.265
-	addl2	#65536,-844(fp)
-noname.265:
-	movzwl	-830(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-844(fp)
-	bicl3	#-65536,-832(fp),r0
-	ashl	#16,r0,-836(fp)
-	addl3	-836(fp),-840(fp),r0
-	bicl3	#0,r0,-840(fp)
-	cmpl	-840(fp),-836(fp)
-	bgequ	noname.266
-	incl	-844(fp)
-noname.266:
-	movl	-840(fp),r1
-	movl	-844(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.267
-	incl	r2
-noname.267:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.268
-	incl	r8
-noname.268:
-
-	bicl3	#-65536,24(r6),r3
-	movzwl	26(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r7),r2
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-848(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-852(fp)
-	mull2	r0,r4
-	addl3	-848(fp),-852(fp),r0
-	bicl3	#0,r0,-848(fp)
-	cmpl	-848(fp),-852(fp)
-	bgequ	noname.269
-	addl2	#65536,r4
-noname.269:
-	movzwl	-846(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-848(fp),r0
-	ashl	#16,r0,-852(fp)
-	addl2	-852(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-852(fp)
-	bgequ	noname.270
-	incl	r4
-noname.270:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.271
-	incl	r2
-noname.271:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.272
-	incl	r8
-noname.272:
-
-	bicl3	#-65536,28(r6),r3
-	movzwl	30(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r7),r2
-	movzwl	18(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-856(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-860(fp)
-	mull2	r0,r4
-	addl3	-856(fp),-860(fp),r0
-	bicl3	#0,r0,-856(fp)
-	cmpl	-856(fp),-860(fp)
-	bgequ	noname.273
-	addl2	#65536,r4
-noname.273:
-	movzwl	-854(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-856(fp),r0
-	ashl	#16,r0,-860(fp)
-	addl2	-860(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-860(fp)
-	bgequ	noname.274
-	incl	r4
-noname.274:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.275
-	incl	r2
-noname.275:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.276
-	incl	r8
-noname.276:
-
-	movl	r10,44(r11)
-
-	clrl	r10
-
-	bicl3	#-65536,28(r6),r3
-	movzwl	30(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r7),r2
-	movzwl	22(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-864(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-868(fp)
-	mull2	r0,r4
-	addl3	-864(fp),-868(fp),r0
-	bicl3	#0,r0,-864(fp)
-	cmpl	-864(fp),-868(fp)
-	bgequ	noname.277
-	addl2	#65536,r4
-noname.277:
-	movzwl	-862(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-864(fp),r0
-	ashl	#16,r0,-868(fp)
-	addl2	-868(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-868(fp)
-	bgequ	noname.278
-	incl	r4
-noname.278:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.279
-	incl	r2
-noname.279:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.280
-	incl	r10
-noname.280:
-
-	bicl3	#-65536,24(r6),r3
-	movzwl	26(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,24(r7),r2
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-872(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-876(fp)
-	mull2	r0,r4
-	addl3	-872(fp),-876(fp),r0
-	bicl3	#0,r0,-872(fp)
-	cmpl	-872(fp),-876(fp)
-	bgequ	noname.281
-	addl2	#65536,r4
-noname.281:
-	movzwl	-870(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-872(fp),r0
-	ashl	#16,r0,-876(fp)
-	addl2	-876(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-876(fp)
-	bgequ	noname.282
-	incl	r4
-noname.282:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.283
-	incl	r2
-noname.283:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.284
-	incl	r10
-noname.284:
-
-	bicl3	#-65536,20(r6),r3
-	movzwl	22(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,28(r7),r2
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-880(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-884(fp)
-	mull2	r0,r4
-	addl3	-880(fp),-884(fp),r0
-	bicl3	#0,r0,-880(fp)
-	cmpl	-880(fp),-884(fp)
-	bgequ	noname.285
-	addl2	#65536,r4
-noname.285:
-	movzwl	-878(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-880(fp),r0
-	ashl	#16,r0,-884(fp)
-	addl2	-884(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-884(fp)
-	bgequ	noname.286
-	incl	r4
-noname.286:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.287
-	incl	r2
-noname.287:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.288
-	incl	r10
-noname.288:
-
-	movl	r9,48(r11)
-
-	clrl	r9
-
-	bicl3	#-65536,24(r6),r3
-	movzwl	26(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,28(r7),r2
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-888(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-892(fp)
-	mull2	r0,r4
-	addl3	-888(fp),-892(fp),r0
-	bicl3	#0,r0,-888(fp)
-	cmpl	-888(fp),-892(fp)
-	bgequ	noname.289
-	addl2	#65536,r4
-noname.289:
-	movzwl	-886(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-888(fp),r0
-	ashl	#16,r0,-892(fp)
-	addl2	-892(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-892(fp)
-	bgequ	noname.290
-	incl	r4
-noname.290:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.291
-	incl	r2
-noname.291:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.292
-	incl	r9
-noname.292:
-
-	movzwl	30(r6),r2
-	bicl3	#-65536,24(r7),r3
-	movzwl	26(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,28(r6),-904(fp)
-	bicl3	#-65536,r2,-908(fp)
-	mull3	r0,-904(fp),-896(fp)
-	mull2	r3,-904(fp)
-	mull3	r3,-908(fp),-900(fp)
-	mull2	r0,-908(fp)
-	addl3	-896(fp),-900(fp),r0
-	bicl3	#0,r0,-896(fp)
-	cmpl	-896(fp),-900(fp)
-	bgequ	noname.293
-	addl2	#65536,-908(fp)
-noname.293:
-	movzwl	-894(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-908(fp)
-	bicl3	#-65536,-896(fp),r0
-	ashl	#16,r0,-900(fp)
-	addl3	-900(fp),-904(fp),r0
-	bicl3	#0,r0,-904(fp)
-	cmpl	-904(fp),-900(fp)
-	bgequ	noname.294
-	incl	-908(fp)
-noname.294:
-	movl	-904(fp),r1
-	movl	-908(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.295
-	incl	r2
-noname.295:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.296
-	incl	r9
-noname.296:
-
-	movl	r8,52(r11)
-
-	clrl	r8
-
-	movzwl	30(r6),r2
-	bicl3	#-65536,28(r7),r3
-	movzwl	30(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,28(r6),-920(fp)
-	bicl3	#-65536,r2,-924(fp)
-	mull3	r0,-920(fp),-912(fp)
-	mull2	r3,-920(fp)
-	mull3	r3,-924(fp),-916(fp)
-	mull2	r0,-924(fp)
-	addl3	-912(fp),-916(fp),r0
-	bicl3	#0,r0,-912(fp)
-	cmpl	-912(fp),-916(fp)
-	bgequ	noname.297
-	addl2	#65536,-924(fp)
-noname.297:
-	movzwl	-910(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-924(fp)
-	bicl3	#-65536,-912(fp),r0
-	ashl	#16,r0,-916(fp)
-	addl3	-916(fp),-920(fp),r0
-	bicl3	#0,r0,-920(fp)
-	cmpl	-920(fp),-916(fp)
-	bgequ	noname.298
-	incl	-924(fp)
-noname.298:
-	movl	-920(fp),r1
-	movl	-924(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.299
-	incl	r2
-noname.299:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.300
-	incl	r8
-noname.300:
-
-	movl	r10,56(r11)
-
-	movl	r9,60(r11)
-
-	ret	
-
-
-
-;r=4 ;(AP)
-;a=8 ;(AP)
-;b=12 ;(AP)
-;n=16 ;(AP)	n	by value (input)
-
-	.psect	code,nowrt
-
-.entry	BN_MUL_COMBA4,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
-	movab	-156(sp),sp
-
-	clrq	r9
-
-	clrl	r8
-
-	movl	8(ap),r6
-	bicl3	#-65536,(r6),r3
-	movzwl	2(r6),r2
-	bicl2	#-65536,r2
-	movl	12(ap),r7
-	bicl3	#-65536,(r7),r1
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r2,r4
-	mull3	r0,r5,-4(fp)
-	mull2	r1,r5
-	mull3	r1,r4,-8(fp)
-	mull2	r0,r4
-	addl3	-4(fp),-8(fp),r0
-	bicl3	#0,r0,-4(fp)
-	cmpl	-4(fp),-8(fp)
-	bgequ	noname.303
-	addl2	#65536,r4
-noname.303:
-	movzwl	-2(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-4(fp),r0
-	ashl	#16,r0,-8(fp)
-	addl2	-8(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-8(fp)
-	bgequ	noname.304
-	incl	r4
-noname.304:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.305
-	incl	r2
-noname.305:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.306
-	incl	r8
-noname.306:
-
-	movl	4(ap),r11
-	movl	r10,(r11)
-
-	clrl	r10
-
-	bicl3	#-65536,(r6),r3
-	movzwl	2(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r7),r2
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-12(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-16(fp)
-	mull2	r0,r4
-	addl3	-12(fp),-16(fp),r0
-	bicl3	#0,r0,-12(fp)
-	cmpl	-12(fp),-16(fp)
-	bgequ	noname.307
-	addl2	#65536,r4
-noname.307:
-	movzwl	-10(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-12(fp),r0
-	ashl	#16,r0,-16(fp)
-	addl2	-16(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-16(fp)
-	bgequ	noname.308
-	incl	r4
-noname.308:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.309
-	incl	r2
-noname.309:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.310
-	incl	r10
-noname.310:
-
-	bicl3	#-65536,4(r6),r3
-	movzwl	6(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,(r7),r2
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-20(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-24(fp)
-	mull2	r0,r4
-	addl3	-20(fp),-24(fp),r0
-	bicl3	#0,r0,-20(fp)
-	cmpl	-20(fp),-24(fp)
-	bgequ	noname.311
-	addl2	#65536,r4
-noname.311:
-	movzwl	-18(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-20(fp),r0
-	ashl	#16,r0,-24(fp)
-	addl2	-24(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-24(fp)
-	bgequ	noname.312
-	incl	r4
-noname.312:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.313
-	incl	r2
-noname.313:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.314
-	incl	r10
-noname.314:
-
-	movl	r9,4(r11)
-
-	clrl	r9
-
-	bicl3	#-65536,8(r6),r3
-	movzwl	10(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,(r7),r2
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-28(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-32(fp)
-	mull2	r0,r4
-	addl3	-28(fp),-32(fp),r0
-	bicl3	#0,r0,-28(fp)
-	cmpl	-28(fp),-32(fp)
-	bgequ	noname.315
-	addl2	#65536,r4
-noname.315:
-	movzwl	-26(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-28(fp),r0
-	ashl	#16,r0,-32(fp)
-	addl2	-32(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-32(fp)
-	bgequ	noname.316
-	incl	r4
-noname.316:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.317
-	incl	r2
-noname.317:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.318
-	incl	r9
-noname.318:
-
-	bicl3	#-65536,4(r6),r3
-	movzwl	6(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r7),r2
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-36(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-40(fp)
-	mull2	r0,r4
-	addl3	-36(fp),-40(fp),r0
-	bicl3	#0,r0,-36(fp)
-	cmpl	-36(fp),-40(fp)
-	bgequ	noname.319
-	addl2	#65536,r4
-noname.319:
-	movzwl	-34(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-36(fp),r0
-	ashl	#16,r0,-40(fp)
-	addl2	-40(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-40(fp)
-	bgequ	noname.320
-	incl	r4
-noname.320:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.321
-	incl	r2
-noname.321:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.322
-	incl	r9
-noname.322:
-
-	bicl3	#-65536,(r6),r3
-	movzwl	2(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,8(r7),r2
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-44(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-48(fp)
-	mull2	r0,r4
-	addl3	-44(fp),-48(fp),r0
-	bicl3	#0,r0,-44(fp)
-	cmpl	-44(fp),-48(fp)
-	bgequ	noname.323
-	addl2	#65536,r4
-noname.323:
-	movzwl	-42(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-44(fp),r0
-	ashl	#16,r0,-48(fp)
-	addl2	-48(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-48(fp)
-	bgequ	noname.324
-	incl	r4
-noname.324:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.325
-	incl	r2
-noname.325:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.326
-	incl	r9
-noname.326:
-
-	movl	r8,8(r11)
-
-	clrl	r8
-
-	bicl3	#-65536,(r6),r3
-	movzwl	2(r6),r2
-	bicl3	#-65536,12(r7),r1
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r4
-	bicl3	#-65536,r2,-60(fp)
-	mull3	r0,r4,-52(fp)
-	mull2	r1,r4
-	mull3	r1,-60(fp),-56(fp)
-	mull2	r0,-60(fp)
-	addl3	-52(fp),-56(fp),r0
-	bicl3	#0,r0,-52(fp)
-	cmpl	-52(fp),-56(fp)
-	bgequ	noname.327
-	addl2	#65536,-60(fp)
-noname.327:
-	movzwl	-50(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-60(fp)
-	bicl3	#-65536,-52(fp),r0
-	ashl	#16,r0,-56(fp)
-	addl2	-56(fp),r4
-	bicl2	#0,r4
-	cmpl	r4,-56(fp)
-	bgequ	noname.328
-	incl	-60(fp)
-noname.328:
-	movl	r4,r1
-	movl	-60(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.329
-	incl	r2
-noname.329:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.330
-	incl	r8
-noname.330:
-
-	movzwl	6(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r6),-72(fp)
-	bicl3	#-65536,r2,-76(fp)
-	mull3	r0,-72(fp),-64(fp)
-	mull2	r3,-72(fp)
-	mull3	r3,-76(fp),-68(fp)
-	mull2	r0,-76(fp)
-	addl3	-64(fp),-68(fp),r0
-	bicl3	#0,r0,-64(fp)
-	cmpl	-64(fp),-68(fp)
-	bgequ	noname.331
-	addl2	#65536,-76(fp)
-noname.331:
-	movzwl	-62(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-76(fp)
-	bicl3	#-65536,-64(fp),r0
-	ashl	#16,r0,-68(fp)
-	addl3	-68(fp),-72(fp),r0
-	bicl3	#0,r0,-72(fp)
-	cmpl	-72(fp),-68(fp)
-	bgequ	noname.332
-	incl	-76(fp)
-noname.332:
-	movl	-72(fp),r1
-	movl	-76(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.333
-	incl	r2
-noname.333:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.334
-	incl	r8
-noname.334:
-
-	bicl3	#-65536,8(r6),r3
-	movzwl	10(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r7),r2
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-80(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-84(fp)
-	mull2	r0,r4
-	addl3	-80(fp),-84(fp),r0
-	bicl3	#0,r0,-80(fp)
-	cmpl	-80(fp),-84(fp)
-	bgequ	noname.335
-	addl2	#65536,r4
-noname.335:
-	movzwl	-78(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-80(fp),r0
-	ashl	#16,r0,-84(fp)
-	addl2	-84(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-84(fp)
-	bgequ	noname.336
-	incl	r4
-noname.336:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.337
-	incl	r2
-noname.337:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.338
-	incl	r8
-noname.338:
-
-	bicl3	#-65536,12(r6),r3
-	movzwl	14(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,(r7),r2
-	movzwl	2(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-88(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-92(fp)
-	mull2	r0,r4
-	addl3	-88(fp),-92(fp),r0
-	bicl3	#0,r0,-88(fp)
-	cmpl	-88(fp),-92(fp)
-	bgequ	noname.339
-	addl2	#65536,r4
-noname.339:
-	movzwl	-86(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-88(fp),r0
-	ashl	#16,r0,-92(fp)
-	addl2	-92(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-92(fp)
-	bgequ	noname.340
-	incl	r4
-noname.340:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.341
-	incl	r2
-noname.341:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.342
-	incl	r8
-noname.342:
-
-	movl	r10,12(r11)
-
-	clrl	r10
-
-	bicl3	#-65536,12(r6),r3
-	movzwl	14(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r7),r2
-	movzwl	6(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-96(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-100(fp)
-	mull2	r0,r4
-	addl3	-96(fp),-100(fp),r0
-	bicl3	#0,r0,-96(fp)
-	cmpl	-96(fp),-100(fp)
-	bgequ	noname.343
-	addl2	#65536,r4
-noname.343:
-	movzwl	-94(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-96(fp),r0
-	ashl	#16,r0,-100(fp)
-	addl2	-100(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-100(fp)
-	bgequ	noname.344
-	incl	r4
-noname.344:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.345
-	incl	r2
-noname.345:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.346
-	incl	r10
-noname.346:
-
-	bicl3	#-65536,8(r6),r3
-	movzwl	10(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,8(r7),r2
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-104(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-108(fp)
-	mull2	r0,r4
-	addl3	-104(fp),-108(fp),r0
-	bicl3	#0,r0,-104(fp)
-	cmpl	-104(fp),-108(fp)
-	bgequ	noname.347
-	addl2	#65536,r4
-noname.347:
-	movzwl	-102(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-104(fp),r0
-	ashl	#16,r0,-108(fp)
-	addl2	-108(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-108(fp)
-	bgequ	noname.348
-	incl	r4
-noname.348:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.349
-	incl	r2
-noname.349:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.350
-	incl	r10
-noname.350:
-
-	bicl3	#-65536,4(r6),r3
-	movzwl	6(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r7),r2
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-112(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-116(fp)
-	mull2	r0,r4
-	addl3	-112(fp),-116(fp),r0
-	bicl3	#0,r0,-112(fp)
-	cmpl	-112(fp),-116(fp)
-	bgequ	noname.351
-	addl2	#65536,r4
-noname.351:
-	movzwl	-110(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-112(fp),r0
-	ashl	#16,r0,-116(fp)
-	addl2	-116(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-116(fp)
-	bgequ	noname.352
-	incl	r4
-noname.352:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.353
-	incl	r2
-noname.353:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.354
-	incl	r10
-noname.354:
-
-	movl	r9,16(r11)
-
-	clrl	r9
-
-	bicl3	#-65536,8(r6),r3
-	movzwl	10(r6),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r7),r2
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-120(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-124(fp)
-	mull2	r0,r4
-	addl3	-120(fp),-124(fp),r0
-	bicl3	#0,r0,-120(fp)
-	cmpl	-120(fp),-124(fp)
-	bgequ	noname.355
-	addl2	#65536,r4
-noname.355:
-	movzwl	-118(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-120(fp),r0
-	ashl	#16,r0,-124(fp)
-	addl2	-124(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-124(fp)
-	bgequ	noname.356
-	incl	r4
-noname.356:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.357
-	incl	r2
-noname.357:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.358
-	incl	r9
-noname.358:
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,8(r7),r3
-	movzwl	10(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-136(fp)
-	bicl3	#-65536,r2,-140(fp)
-	mull3	r0,-136(fp),-128(fp)
-	mull2	r3,-136(fp)
-	mull3	r3,-140(fp),-132(fp)
-	mull2	r0,-140(fp)
-	addl3	-128(fp),-132(fp),r0
-	bicl3	#0,r0,-128(fp)
-	cmpl	-128(fp),-132(fp)
-	bgequ	noname.359
-	addl2	#65536,-140(fp)
-noname.359:
-	movzwl	-126(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-140(fp)
-	bicl3	#-65536,-128(fp),r0
-	ashl	#16,r0,-132(fp)
-	addl3	-132(fp),-136(fp),r0
-	bicl3	#0,r0,-136(fp)
-	cmpl	-136(fp),-132(fp)
-	bgequ	noname.360
-	incl	-140(fp)
-noname.360:
-	movl	-136(fp),r1
-	movl	-140(fp),r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.361
-	incl	r2
-noname.361:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.362
-	incl	r9
-noname.362:
-
-	movl	r8,20(r11)
-
-	clrl	r8
-
-	movzwl	14(r6),r2
-	bicl3	#-65536,12(r7),r3
-	movzwl	14(r7),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r6),-152(fp)
-	bicl3	#-65536,r2,-156(fp)
-	mull3	r0,-152(fp),-144(fp)
-	mull2	r3,-152(fp)
-	mull3	r3,-156(fp),-148(fp)
-	mull2	r0,-156(fp)
-	addl3	-144(fp),-148(fp),r0
-	bicl3	#0,r0,-144(fp)
-	cmpl	-144(fp),-148(fp)
-	bgequ	noname.363
-	addl2	#65536,-156(fp)
-noname.363:
-	movzwl	-142(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-156(fp)
-	bicl3	#-65536,-144(fp),r0
-	ashl	#16,r0,-148(fp)
-	addl3	-148(fp),-152(fp),r0
-	bicl3	#0,r0,-152(fp)
-	cmpl	-152(fp),-148(fp)
-	bgequ	noname.364
-	incl	-156(fp)
-noname.364:
-	movl	-152(fp),r1
-	movl	-156(fp),r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.365
-	incl	r2
-noname.365:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.366
-	incl	r8
-noname.366:
-
-	movl	r10,24(r11)
-
-	movl	r9,28(r11)
-
-	ret	
-
-
-
-;r=4 ;(AP)
-;a=8 ;(AP)
-;b=12 ;(AP)
-;n=16 ;(AP)	n	by value (input)
-
-	.psect	code,nowrt
-
-.entry	BN_SQR_COMBA8,^m<r2,r3,r4,r5,r6,r7,r8,r9>
-	movab	-444(sp),sp
-
-	clrq	r8
-
-	clrl	r7
-
-	movl	8(ap),r4
-	movl	(r4),r3
-	bicl3	#-65536,r3,-4(fp)
-	extzv	#16,#16,r3,r0
-	bicl3	#-65536,r0,r3
-	movl	-4(fp),r0
-	mull3	r0,r3,-8(fp)
-	mull3	r0,r0,-4(fp)
-	mull2	r3,r3
-	bicl3	#32767,-8(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r3
-	bicl3	#-65536,-8(fp),r0
-	ashl	#17,r0,-8(fp)
-	addl3	-4(fp),-8(fp),r0
-	bicl3	#0,r0,-4(fp)
-	cmpl	-4(fp),-8(fp)
-	bgequ	noname.369
-	incl	r3
-noname.369:
-	movl	-4(fp),r1
-	movl	r3,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.370
-	incl	r2
-noname.370:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.371
-	incl	r7
-noname.371:
-
-	movl	r9,@4(ap)
-
-	clrl	r9
-
-	movzwl	6(r4),r2
-	bicl3	#-65536,(r4),r3
-	movzwl	2(r4),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,4(r4),-20(fp)
-	bicl3	#-65536,r2,-24(fp)
-	mull3	r0,-20(fp),-12(fp)
-	mull2	r3,-20(fp)
-	mull3	r3,-24(fp),-16(fp)
-	mull2	r0,-24(fp)
-	addl3	-12(fp),-16(fp),r0
-	bicl3	#0,r0,-12(fp)
-	cmpl	-12(fp),-16(fp)
-	bgequ	noname.372
-	addl2	#65536,-24(fp)
-noname.372:
-	movzwl	-10(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-24(fp)
-	bicl3	#-65536,-12(fp),r0
-	ashl	#16,r0,-16(fp)
-	addl3	-16(fp),-20(fp),r0
-	bicl3	#0,r0,-20(fp)
-	cmpl	-20(fp),-16(fp)
-	bgequ	noname.373
-	incl	-24(fp)
-noname.373:
-	movl	-20(fp),r3
-	movl	-24(fp),r2
-	bbc	#31,r2,noname.374
-	incl	r9
-noname.374:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.375
-	incl	r2
-noname.375:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.376
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.376
-	incl	r9
-noname.376:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.377
-	incl	r9
-noname.377:
-
-	movl	4(ap),r0
-	movl	r8,4(r0)
-
-	clrl	r8
-
-	movl	8(ap),r4
-	movl	4(r4),r3
-	bicl3	#-65536,r3,-28(fp)
-	extzv	#16,#16,r3,r0
-	bicl3	#-65536,r0,r3
-	movl	-28(fp),r0
-	mull3	r0,r3,-32(fp)
-	mull3	r0,r0,-28(fp)
-	mull2	r3,r3
-	bicl3	#32767,-32(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r3
-	bicl3	#-65536,-32(fp),r0
-	ashl	#17,r0,-32(fp)
-	addl3	-28(fp),-32(fp),r0
-	bicl3	#0,r0,-28(fp)
-	cmpl	-28(fp),-32(fp)
-	bgequ	noname.378
-	incl	r3
-noname.378:
-	movl	-28(fp),r1
-	movl	r3,r2
-	addl2	r1,r7
-	bicl2	#0,r7
-	cmpl	r7,r1
-	bgequ	noname.379
-	incl	r2
-noname.379:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.380
-	incl	r8
-noname.380:
-
-	movzwl	10(r4),r2
-	bicl3	#-65536,(r4),r3
-	movzwl	2(r4),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,8(r4),-44(fp)
-	bicl3	#-65536,r2,-48(fp)
-	mull3	r0,-44(fp),-36(fp)
-	mull2	r3,-44(fp)
-	mull3	r3,-48(fp),-40(fp)
-	mull2	r0,-48(fp)
-	addl3	-36(fp),-40(fp),r0
-	bicl3	#0,r0,-36(fp)
-	cmpl	-36(fp),-40(fp)
-	bgequ	noname.381
-	addl2	#65536,-48(fp)
-noname.381:
-	movzwl	-34(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-48(fp)
-	bicl3	#-65536,-36(fp),r0
-	ashl	#16,r0,-40(fp)
-	addl3	-40(fp),-44(fp),r0
-	bicl3	#0,r0,-44(fp)
-	cmpl	-44(fp),-40(fp)
-	bgequ	noname.382
-	incl	-48(fp)
-noname.382:
-	movl	-44(fp),r3
-	movl	-48(fp),r2
-	bbc	#31,r2,noname.383
-	incl	r8
-noname.383:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.384
-	incl	r2
-noname.384:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.385
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.385
-	incl	r8
-noname.385:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.386
-	incl	r8
-noname.386:
-
-	movl	4(ap),r0
-	movl	r7,8(r0)
-
-	clrl	r7
-
-	movl	8(ap),r0
-	movzwl	14(r0),r2
-	bicl3	#-65536,(r0),r3
-	movzwl	2(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r0),-60(fp)
-	bicl3	#-65536,r2,-64(fp)
-	mull3	r1,-60(fp),-52(fp)
-	mull2	r3,-60(fp)
-	mull3	r3,-64(fp),-56(fp)
-	mull2	r1,-64(fp)
-	addl3	-52(fp),-56(fp),r0
-	bicl3	#0,r0,-52(fp)
-	cmpl	-52(fp),-56(fp)
-	bgequ	noname.387
-	addl2	#65536,-64(fp)
-noname.387:
-	movzwl	-50(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-64(fp)
-	bicl3	#-65536,-52(fp),r0
-	ashl	#16,r0,-56(fp)
-	addl3	-56(fp),-60(fp),r0
-	bicl3	#0,r0,-60(fp)
-	cmpl	-60(fp),-56(fp)
-	bgequ	noname.388
-	incl	-64(fp)
-noname.388:
-	movl	-60(fp),r3
-	movl	-64(fp),r2
-	bbc	#31,r2,noname.389
-	incl	r7
-noname.389:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.390
-	incl	r2
-noname.390:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.391
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.391
-	incl	r7
-noname.391:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.392
-	incl	r7
-noname.392:
-
-	movl	8(ap),r0
-	movzwl	10(r0),r2
-	bicl3	#-65536,4(r0),r3
-	movzwl	6(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,8(r0),-76(fp)
-	bicl3	#-65536,r2,-80(fp)
-	mull3	r1,-76(fp),-68(fp)
-	mull2	r3,-76(fp)
-	mull3	r3,-80(fp),-72(fp)
-	mull2	r1,-80(fp)
-	addl3	-68(fp),-72(fp),r0
-	bicl3	#0,r0,-68(fp)
-	cmpl	-68(fp),-72(fp)
-	bgequ	noname.393
-	addl2	#65536,-80(fp)
-noname.393:
-	movzwl	-66(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-80(fp)
-	bicl3	#-65536,-68(fp),r0
-	ashl	#16,r0,-72(fp)
-	addl3	-72(fp),-76(fp),r0
-	bicl3	#0,r0,-76(fp)
-	cmpl	-76(fp),-72(fp)
-	bgequ	noname.394
-	incl	-80(fp)
-noname.394:
-	movl	-76(fp),r3
-	movl	-80(fp),r2
-	bbc	#31,r2,noname.395
-	incl	r7
-noname.395:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.396
-	incl	r2
-noname.396:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.397
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.397
-	incl	r7
-noname.397:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.398
-	incl	r7
-noname.398:
-
-	movl	4(ap),r0
-	movl	r9,12(r0)
-
-	clrl	r9
-
-	movl	8(ap),r2
-	movl	8(r2),r4
-	bicl3	#-65536,r4,-84(fp)
-	extzv	#16,#16,r4,r0
-	bicl3	#-65536,r0,r4
-	movl	-84(fp),r0
-	mull3	r0,r4,-88(fp)
-	mull3	r0,r0,-84(fp)
-	mull2	r4,r4
-	bicl3	#32767,-88(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r4
-	bicl3	#-65536,-88(fp),r0
-	ashl	#17,r0,-88(fp)
-	addl3	-84(fp),-88(fp),r0
-	bicl3	#0,r0,-84(fp)
-	cmpl	-84(fp),-88(fp)
-	bgequ	noname.399
-	incl	r4
-noname.399:
-	movl	-84(fp),r1
-	movl	r4,r3
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.400
-	incl	r3
-noname.400:
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.401
-	incl	r9
-noname.401:
-
-	movzwl	14(r2),r3
-	bicl3	#-65536,4(r2),r1
-	movzwl	6(r2),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,12(r2),-100(fp)
-	bicl3	#-65536,r3,-104(fp)
-	mull3	r0,-100(fp),-92(fp)
-	mull2	r1,-100(fp)
-	mull3	r1,-104(fp),-96(fp)
-	mull2	r0,-104(fp)
-	addl3	-92(fp),-96(fp),r0
-	bicl3	#0,r0,-92(fp)
-	cmpl	-92(fp),-96(fp)
-	bgequ	noname.402
-	addl2	#65536,-104(fp)
-noname.402:
-	movzwl	-90(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-104(fp)
-	bicl3	#-65536,-92(fp),r0
-	ashl	#16,r0,-96(fp)
-	addl3	-96(fp),-100(fp),r0
-	bicl3	#0,r0,-100(fp)
-	cmpl	-100(fp),-96(fp)
-	bgequ	noname.403
-	incl	-104(fp)
-noname.403:
-	movl	-100(fp),r3
-	movl	-104(fp),r2
-	bbc	#31,r2,noname.404
-	incl	r9
-noname.404:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.405
-	incl	r2
-noname.405:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.406
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.406
-	incl	r9
-noname.406:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.407
-	incl	r9
-noname.407:
-
-	movl	8(ap),r0
-	movzwl	18(r0),r2
-	bicl3	#-65536,(r0),r3
-	movzwl	2(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r0),-116(fp)
-	bicl3	#-65536,r2,-120(fp)
-	mull3	r1,-116(fp),-108(fp)
-	mull2	r3,-116(fp)
-	mull3	r3,-120(fp),-112(fp)
-	mull2	r1,-120(fp)
-	addl3	-108(fp),-112(fp),r0
-	bicl3	#0,r0,-108(fp)
-	cmpl	-108(fp),-112(fp)
-	bgequ	noname.408
-	addl2	#65536,-120(fp)
-noname.408:
-	movzwl	-106(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-120(fp)
-	bicl3	#-65536,-108(fp),r0
-	ashl	#16,r0,-112(fp)
-	addl3	-112(fp),-116(fp),r0
-	bicl3	#0,r0,-116(fp)
-	cmpl	-116(fp),-112(fp)
-	bgequ	noname.409
-	incl	-120(fp)
-noname.409:
-	movl	-116(fp),r3
-	movl	-120(fp),r2
-	bbc	#31,r2,noname.410
-	incl	r9
-noname.410:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.411
-	incl	r2
-noname.411:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.412
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.412
-	incl	r9
-noname.412:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.413
-	incl	r9
-noname.413:
-
-	movl	4(ap),r0
-	movl	r8,16(r0)
-
-	clrl	r8
-
-	movl	8(ap),r0
-	movzwl	22(r0),r2
-	bicl3	#-65536,(r0),r3
-	movzwl	2(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r0),-132(fp)
-	bicl3	#-65536,r2,-136(fp)
-	mull3	r1,-132(fp),-124(fp)
-	mull2	r3,-132(fp)
-	mull3	r3,-136(fp),-128(fp)
-	mull2	r1,-136(fp)
-	addl3	-124(fp),-128(fp),r0
-	bicl3	#0,r0,-124(fp)
-	cmpl	-124(fp),-128(fp)
-	bgequ	noname.414
-	addl2	#65536,-136(fp)
-noname.414:
-	movzwl	-122(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-136(fp)
-	bicl3	#-65536,-124(fp),r0
-	ashl	#16,r0,-128(fp)
-	addl3	-128(fp),-132(fp),r0
-	bicl3	#0,r0,-132(fp)
-	cmpl	-132(fp),-128(fp)
-	bgequ	noname.415
-	incl	-136(fp)
-noname.415:
-	movl	-132(fp),r3
-	movl	-136(fp),r2
-	bbc	#31,r2,noname.416
-	incl	r8
-noname.416:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.417
-	incl	r2
-noname.417:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.418
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.418
-	incl	r8
-noname.418:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.419
-	incl	r8
-noname.419:
-
-	movl	8(ap),r0
-	movzwl	18(r0),r2
-	bicl3	#-65536,4(r0),r3
-	movzwl	6(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r0),-148(fp)
-	bicl3	#-65536,r2,-152(fp)
-	mull3	r1,-148(fp),-140(fp)
-	mull2	r3,-148(fp)
-	mull3	r3,-152(fp),-144(fp)
-	mull2	r1,-152(fp)
-	addl3	-140(fp),-144(fp),r0
-	bicl3	#0,r0,-140(fp)
-	cmpl	-140(fp),-144(fp)
-	bgequ	noname.420
-	addl2	#65536,-152(fp)
-noname.420:
-	movzwl	-138(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-152(fp)
-	bicl3	#-65536,-140(fp),r0
-	ashl	#16,r0,-144(fp)
-	addl3	-144(fp),-148(fp),r0
-	bicl3	#0,r0,-148(fp)
-	cmpl	-148(fp),-144(fp)
-	bgequ	noname.421
-	incl	-152(fp)
-noname.421:
-	movl	-148(fp),r3
-	movl	-152(fp),r2
-	bbc	#31,r2,noname.422
-	incl	r8
-noname.422:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.423
-	incl	r2
-noname.423:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.424
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.424
-	incl	r8
-noname.424:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.425
-	incl	r8
-noname.425:
-
-	movl	8(ap),r0
-	movzwl	14(r0),r2
-	bicl3	#-65536,8(r0),r3
-	movzwl	10(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r0),-164(fp)
-	bicl3	#-65536,r2,-168(fp)
-	mull3	r1,-164(fp),-156(fp)
-	mull2	r3,-164(fp)
-	mull3	r3,-168(fp),-160(fp)
-	mull2	r1,-168(fp)
-	addl3	-156(fp),-160(fp),r0
-	bicl3	#0,r0,-156(fp)
-	cmpl	-156(fp),-160(fp)
-	bgequ	noname.426
-	addl2	#65536,-168(fp)
-noname.426:
-	movzwl	-154(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-168(fp)
-	bicl3	#-65536,-156(fp),r0
-	ashl	#16,r0,-160(fp)
-	addl3	-160(fp),-164(fp),r0
-	bicl3	#0,r0,-164(fp)
-	cmpl	-164(fp),-160(fp)
-	bgequ	noname.427
-	incl	-168(fp)
-noname.427:
-	movl	-164(fp),r3
-	movl	-168(fp),r2
-	bbc	#31,r2,noname.428
-	incl	r8
-noname.428:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.429
-	incl	r2
-noname.429:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.430
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.430
-	incl	r8
-noname.430:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.431
-	incl	r8
-noname.431:
-
-	movl	4(ap),r0
-	movl	r7,20(r0)
-
-	clrl	r7
-
-	movl	8(ap),r2
-	movl	12(r2),r4
-	bicl3	#-65536,r4,-172(fp)
-	extzv	#16,#16,r4,r0
-	bicl3	#-65536,r0,r4
-	movl	-172(fp),r0
-	mull3	r0,r4,-176(fp)
-	mull3	r0,r0,-172(fp)
-	mull2	r4,r4
-	bicl3	#32767,-176(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r4
-	bicl3	#-65536,-176(fp),r0
-	ashl	#17,r0,-176(fp)
-	addl3	-172(fp),-176(fp),r0
-	bicl3	#0,r0,-172(fp)
-	cmpl	-172(fp),-176(fp)
-	bgequ	noname.432
-	incl	r4
-noname.432:
-	movl	-172(fp),r1
-	movl	r4,r3
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.433
-	incl	r3
-noname.433:
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.434
-	incl	r7
-noname.434:
-
-	movzwl	18(r2),r3
-	bicl3	#-65536,8(r2),r1
-	movzwl	10(r2),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,16(r2),-188(fp)
-	bicl3	#-65536,r3,-192(fp)
-	mull3	r0,-188(fp),-180(fp)
-	mull2	r1,-188(fp)
-	mull3	r1,-192(fp),-184(fp)
-	mull2	r0,-192(fp)
-	addl3	-180(fp),-184(fp),r0
-	bicl3	#0,r0,-180(fp)
-	cmpl	-180(fp),-184(fp)
-	bgequ	noname.435
-	addl2	#65536,-192(fp)
-noname.435:
-	movzwl	-178(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-192(fp)
-	bicl3	#-65536,-180(fp),r0
-	ashl	#16,r0,-184(fp)
-	addl3	-184(fp),-188(fp),r0
-	bicl3	#0,r0,-188(fp)
-	cmpl	-188(fp),-184(fp)
-	bgequ	noname.436
-	incl	-192(fp)
-noname.436:
-	movl	-188(fp),r3
-	movl	-192(fp),r2
-	bbc	#31,r2,noname.437
-	incl	r7
-noname.437:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.438
-	incl	r2
-noname.438:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.439
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.439
-	incl	r7
-noname.439:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.440
-	incl	r7
-noname.440:
-
-	movl	8(ap),r0
-	movzwl	22(r0),r2
-	bicl3	#-65536,4(r0),r3
-	movzwl	6(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r0),-204(fp)
-	bicl3	#-65536,r2,-208(fp)
-	mull3	r1,-204(fp),-196(fp)
-	mull2	r3,-204(fp)
-	mull3	r3,-208(fp),-200(fp)
-	mull2	r1,-208(fp)
-	addl3	-196(fp),-200(fp),r0
-	bicl3	#0,r0,-196(fp)
-	cmpl	-196(fp),-200(fp)
-	bgequ	noname.441
-	addl2	#65536,-208(fp)
-noname.441:
-	movzwl	-194(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-208(fp)
-	bicl3	#-65536,-196(fp),r0
-	ashl	#16,r0,-200(fp)
-	addl3	-200(fp),-204(fp),r0
-	bicl3	#0,r0,-204(fp)
-	cmpl	-204(fp),-200(fp)
-	bgequ	noname.442
-	incl	-208(fp)
-noname.442:
-	movl	-204(fp),r3
-	movl	-208(fp),r2
-	bbc	#31,r2,noname.443
-	incl	r7
-noname.443:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.444
-	incl	r2
-noname.444:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.445
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.445
-	incl	r7
-noname.445:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.446
-	incl	r7
-noname.446:
-
-	movl	8(ap),r0
-	movzwl	26(r0),r2
-	bicl3	#-65536,(r0),r3
-	movzwl	2(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,24(r0),-220(fp)
-	bicl3	#-65536,r2,-224(fp)
-	mull3	r1,-220(fp),-212(fp)
-	mull2	r3,-220(fp)
-	mull3	r3,-224(fp),-216(fp)
-	mull2	r1,-224(fp)
-	addl3	-212(fp),-216(fp),r0
-	bicl3	#0,r0,-212(fp)
-	cmpl	-212(fp),-216(fp)
-	bgequ	noname.447
-	addl2	#65536,-224(fp)
-noname.447:
-	movzwl	-210(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-224(fp)
-	bicl3	#-65536,-212(fp),r0
-	ashl	#16,r0,-216(fp)
-	addl3	-216(fp),-220(fp),r0
-	bicl3	#0,r0,-220(fp)
-	cmpl	-220(fp),-216(fp)
-	bgequ	noname.448
-	incl	-224(fp)
-noname.448:
-	movl	-220(fp),r3
-	movl	-224(fp),r2
-	bbc	#31,r2,noname.449
-	incl	r7
-noname.449:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.450
-	incl	r2
-noname.450:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.451
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.451
-	incl	r7
-noname.451:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.452
-	incl	r7
-noname.452:
-
-	movl	4(ap),r0
-	movl	r9,24(r0)
-
-	clrl	r9
-
-	movl	8(ap),r0
-	movzwl	30(r0),r2
-	bicl3	#-65536,(r0),r3
-	movzwl	2(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,28(r0),-236(fp)
-	bicl3	#-65536,r2,-240(fp)
-	mull3	r1,-236(fp),-228(fp)
-	mull2	r3,-236(fp)
-	mull3	r3,-240(fp),-232(fp)
-	mull2	r1,-240(fp)
-	addl3	-228(fp),-232(fp),r0
-	bicl3	#0,r0,-228(fp)
-	cmpl	-228(fp),-232(fp)
-	bgequ	noname.453
-	addl2	#65536,-240(fp)
-noname.453:
-	movzwl	-226(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-240(fp)
-	bicl3	#-65536,-228(fp),r0
-	ashl	#16,r0,-232(fp)
-	addl3	-232(fp),-236(fp),r0
-	bicl3	#0,r0,-236(fp)
-	cmpl	-236(fp),-232(fp)
-	bgequ	noname.454
-	incl	-240(fp)
-noname.454:
-	movl	-236(fp),r3
-	movl	-240(fp),r2
-	bbc	#31,r2,noname.455
-	incl	r9
-noname.455:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.456
-	incl	r2
-noname.456:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.457
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.457
-	incl	r9
-noname.457:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.458
-	incl	r9
-noname.458:
-
-	movl	8(ap),r0
-	movzwl	26(r0),r2
-	bicl3	#-65536,4(r0),r3
-	movzwl	6(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,24(r0),-252(fp)
-	bicl3	#-65536,r2,-256(fp)
-	mull3	r1,-252(fp),-244(fp)
-	mull2	r3,-252(fp)
-	mull3	r3,-256(fp),-248(fp)
-	mull2	r1,-256(fp)
-	addl3	-244(fp),-248(fp),r0
-	bicl3	#0,r0,-244(fp)
-	cmpl	-244(fp),-248(fp)
-	bgequ	noname.459
-	addl2	#65536,-256(fp)
-noname.459:
-	movzwl	-242(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-256(fp)
-	bicl3	#-65536,-244(fp),r0
-	ashl	#16,r0,-248(fp)
-	addl3	-248(fp),-252(fp),r0
-	bicl3	#0,r0,-252(fp)
-	cmpl	-252(fp),-248(fp)
-	bgequ	noname.460
-	incl	-256(fp)
-noname.460:
-	movl	-252(fp),r3
-	movl	-256(fp),r2
-	bbc	#31,r2,noname.461
-	incl	r9
-noname.461:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.462
-	incl	r2
-noname.462:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.463
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.463
-	incl	r9
-noname.463:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.464
-	incl	r9
-noname.464:
-
-	movl	8(ap),r0
-	movzwl	22(r0),r2
-	bicl3	#-65536,8(r0),r3
-	movzwl	10(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r0),-268(fp)
-	bicl3	#-65536,r2,-272(fp)
-	mull3	r1,-268(fp),-260(fp)
-	mull2	r3,-268(fp)
-	mull3	r3,-272(fp),-264(fp)
-	mull2	r1,-272(fp)
-	addl3	-260(fp),-264(fp),r0
-	bicl3	#0,r0,-260(fp)
-	cmpl	-260(fp),-264(fp)
-	bgequ	noname.465
-	addl2	#65536,-272(fp)
-noname.465:
-	movzwl	-258(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-272(fp)
-	bicl3	#-65536,-260(fp),r0
-	ashl	#16,r0,-264(fp)
-	addl3	-264(fp),-268(fp),r0
-	bicl3	#0,r0,-268(fp)
-	cmpl	-268(fp),-264(fp)
-	bgequ	noname.466
-	incl	-272(fp)
-noname.466:
-	movl	-268(fp),r3
-	movl	-272(fp),r2
-	bbc	#31,r2,noname.467
-	incl	r9
-noname.467:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.468
-	incl	r2
-noname.468:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.469
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.469
-	incl	r9
-noname.469:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.470
-	incl	r9
-noname.470:
-
-	movl	8(ap),r0
-	movzwl	18(r0),r2
-	bicl3	#-65536,12(r0),r3
-	movzwl	14(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r0),-284(fp)
-	bicl3	#-65536,r2,-288(fp)
-	mull3	r1,-284(fp),-276(fp)
-	mull2	r3,-284(fp)
-	mull3	r3,-288(fp),-280(fp)
-	mull2	r1,-288(fp)
-	addl3	-276(fp),-280(fp),r0
-	bicl3	#0,r0,-276(fp)
-	cmpl	-276(fp),-280(fp)
-	bgequ	noname.471
-	addl2	#65536,-288(fp)
-noname.471:
-	movzwl	-274(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-288(fp)
-	bicl3	#-65536,-276(fp),r0
-	ashl	#16,r0,-280(fp)
-	addl3	-280(fp),-284(fp),r0
-	bicl3	#0,r0,-284(fp)
-	cmpl	-284(fp),-280(fp)
-	bgequ	noname.472
-	incl	-288(fp)
-noname.472:
-	movl	-284(fp),r3
-	movl	-288(fp),r2
-	bbc	#31,r2,noname.473
-	incl	r9
-noname.473:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.474
-	incl	r2
-noname.474:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.475
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.475
-	incl	r9
-noname.475:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.476
-	incl	r9
-noname.476:
-
-	movl	4(ap),r0
-	movl	r8,28(r0)
-
-	clrl	r8
-
-	movl	8(ap),r3
-	movl	16(r3),r4
-	bicl3	#-65536,r4,r5
-	extzv	#16,#16,r4,r0
-	bicl3	#-65536,r0,r4
-	mull3	r5,r4,-292(fp)
-	mull2	r5,r5
-	mull2	r4,r4
-	bicl3	#32767,-292(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r4
-	bicl3	#-65536,-292(fp),r0
-	ashl	#17,r0,-292(fp)
-	addl2	-292(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-292(fp)
-	bgequ	noname.477
-	incl	r4
-noname.477:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r7
-	bicl2	#0,r7
-	cmpl	r7,r1
-	bgequ	noname.478
-	incl	r2
-noname.478:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.479
-	incl	r8
-noname.479:
-
-	bicl3	#-65536,20(r3),r4
-	movzwl	22(r3),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r3),r2
-	movzwl	14(r3),r0
-	bicl2	#-65536,r0
-	movl	r4,r6
-	movl	r1,r5
-	mull3	r0,r6,-296(fp)
-	mull2	r2,r6
-	mull3	r2,r5,-300(fp)
-	mull2	r0,r5
-	addl3	-296(fp),-300(fp),r0
-	bicl3	#0,r0,-296(fp)
-	cmpl	-296(fp),-300(fp)
-	bgequ	noname.480
-	addl2	#65536,r5
-noname.480:
-	movzwl	-294(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r5
-	bicl3	#-65536,-296(fp),r0
-	ashl	#16,r0,-300(fp)
-	addl2	-300(fp),r6
-	bicl2	#0,r6
-	cmpl	r6,-300(fp)
-	bgequ	noname.481
-	incl	r5
-noname.481:
-	movl	r6,r3
-	movl	r5,r2
-	bbc	#31,r2,noname.482
-	incl	r8
-noname.482:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.483
-	incl	r2
-noname.483:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.484
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.484
-	incl	r8
-noname.484:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.485
-	incl	r8
-noname.485:
-
-	movl	8(ap),r0
-	bicl3	#-65536,24(r0),r3
-	movzwl	26(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,8(r0),r2
-	movzwl	10(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-304(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-308(fp)
-	mull2	r0,r4
-	addl3	-304(fp),-308(fp),r0
-	bicl3	#0,r0,-304(fp)
-	cmpl	-304(fp),-308(fp)
-	bgequ	noname.486
-	addl2	#65536,r4
-noname.486:
-	movzwl	-302(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-304(fp),r0
-	ashl	#16,r0,-308(fp)
-	addl2	-308(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-308(fp)
-	bgequ	noname.487
-	incl	r4
-noname.487:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.488
-	incl	r8
-noname.488:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.489
-	incl	r2
-noname.489:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.490
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.490
-	incl	r8
-noname.490:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.491
-	incl	r8
-noname.491:
-
-	movl	8(ap),r0
-	bicl3	#-65536,28(r0),r3
-	movzwl	30(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r0),r2
-	movzwl	6(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-312(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-316(fp)
-	mull2	r0,r4
-	addl3	-312(fp),-316(fp),r0
-	bicl3	#0,r0,-312(fp)
-	cmpl	-312(fp),-316(fp)
-	bgequ	noname.492
-	addl2	#65536,r4
-noname.492:
-	movzwl	-310(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-312(fp),r0
-	ashl	#16,r0,-316(fp)
-	addl2	-316(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-316(fp)
-	bgequ	noname.493
-	incl	r4
-noname.493:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.494
-	incl	r8
-noname.494:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.495
-	incl	r2
-noname.495:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.496
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.496
-	incl	r8
-noname.496:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.497
-	incl	r8
-noname.497:
-
-	movl	4(ap),r0
-	movl	r7,32(r0)
-
-	clrl	r7
-
-	movl	8(ap),r0
-	bicl3	#-65536,28(r0),r3
-	movzwl	30(r0),r2
-	bicl3	#-65536,8(r0),r1
-	movzwl	10(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r4
-	bicl3	#-65536,r2,-328(fp)
-	mull3	r0,r4,-320(fp)
-	mull2	r1,r4
-	mull3	r1,-328(fp),-324(fp)
-	mull2	r0,-328(fp)
-	addl3	-320(fp),-324(fp),r0
-	bicl3	#0,r0,-320(fp)
-	cmpl	-320(fp),-324(fp)
-	bgequ	noname.498
-	addl2	#65536,-328(fp)
-noname.498:
-	movzwl	-318(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-328(fp)
-	bicl3	#-65536,-320(fp),r0
-	ashl	#16,r0,-324(fp)
-	addl2	-324(fp),r4
-	bicl2	#0,r4
-	cmpl	r4,-324(fp)
-	bgequ	noname.499
-	incl	-328(fp)
-noname.499:
-	movl	r4,r3
-	movl	-328(fp),r2
-	bbc	#31,r2,noname.500
-	incl	r7
-noname.500:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.501
-	incl	r2
-noname.501:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.502
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.502
-	incl	r7
-noname.502:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.503
-	incl	r7
-noname.503:
-
-	movl	8(ap),r0
-	movzwl	26(r0),r2
-	bicl3	#-65536,12(r0),r3
-	movzwl	14(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,24(r0),-340(fp)
-	bicl3	#-65536,r2,-344(fp)
-	mull3	r1,-340(fp),-332(fp)
-	mull2	r3,-340(fp)
-	mull3	r3,-344(fp),-336(fp)
-	mull2	r1,-344(fp)
-	addl3	-332(fp),-336(fp),r0
-	bicl3	#0,r0,-332(fp)
-	cmpl	-332(fp),-336(fp)
-	bgequ	noname.504
-	addl2	#65536,-344(fp)
-noname.504:
-	movzwl	-330(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-344(fp)
-	bicl3	#-65536,-332(fp),r0
-	ashl	#16,r0,-336(fp)
-	addl3	-336(fp),-340(fp),r0
-	bicl3	#0,r0,-340(fp)
-	cmpl	-340(fp),-336(fp)
-	bgequ	noname.505
-	incl	-344(fp)
-noname.505:
-	movl	-340(fp),r3
-	movl	-344(fp),r2
-	bbc	#31,r2,noname.506
-	incl	r7
-noname.506:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.507
-	incl	r2
-noname.507:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.508
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.508
-	incl	r7
-noname.508:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.509
-	incl	r7
-noname.509:
-
-	movl	8(ap),r0
-	movzwl	22(r0),r2
-	bicl3	#-65536,16(r0),r3
-	movzwl	18(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r0),-356(fp)
-	bicl3	#-65536,r2,-360(fp)
-	mull3	r1,-356(fp),-348(fp)
-	mull2	r3,-356(fp)
-	mull3	r3,-360(fp),-352(fp)
-	mull2	r1,-360(fp)
-	addl3	-348(fp),-352(fp),r0
-	bicl3	#0,r0,-348(fp)
-	cmpl	-348(fp),-352(fp)
-	bgequ	noname.510
-	addl2	#65536,-360(fp)
-noname.510:
-	movzwl	-346(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-360(fp)
-	bicl3	#-65536,-348(fp),r0
-	ashl	#16,r0,-352(fp)
-	addl3	-352(fp),-356(fp),r0
-	bicl3	#0,r0,-356(fp)
-	cmpl	-356(fp),-352(fp)
-	bgequ	noname.511
-	incl	-360(fp)
-noname.511:
-	movl	-356(fp),r3
-	movl	-360(fp),r2
-	bbc	#31,r2,noname.512
-	incl	r7
-noname.512:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.513
-	incl	r2
-noname.513:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.514
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.514
-	incl	r7
-noname.514:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.515
-	incl	r7
-noname.515:
-
-	movl	4(ap),r0
-	movl	r9,36(r0)
-
-	clrl	r9
-
-	movl	8(ap),r3
-	movl	20(r3),r4
-	bicl3	#-65536,r4,-364(fp)
-	extzv	#16,#16,r4,r0
-	bicl3	#-65536,r0,r4
-	movl	-364(fp),r0
-	mull3	r0,r4,-368(fp)
-	mull3	r0,r0,-364(fp)
-	mull2	r4,r4
-	bicl3	#32767,-368(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r4
-	bicl3	#-65536,-368(fp),r0
-	ashl	#17,r0,-368(fp)
-	addl3	-364(fp),-368(fp),r0
-	bicl3	#0,r0,-364(fp)
-	cmpl	-364(fp),-368(fp)
-	bgequ	noname.516
-	incl	r4
-noname.516:
-	movl	-364(fp),r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.517
-	incl	r2
-noname.517:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.518
-	incl	r9
-noname.518:
-
-	bicl3	#-65536,24(r3),r4
-	movzwl	26(r3),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r3),r2
-	movzwl	18(r3),r0
-	bicl2	#-65536,r0
-	movl	r4,r6
-	movl	r1,r5
-	mull3	r0,r6,-372(fp)
-	mull2	r2,r6
-	mull3	r2,r5,-376(fp)
-	mull2	r0,r5
-	addl3	-372(fp),-376(fp),r0
-	bicl3	#0,r0,-372(fp)
-	cmpl	-372(fp),-376(fp)
-	bgequ	noname.519
-	addl2	#65536,r5
-noname.519:
-	movzwl	-370(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r5
-	bicl3	#-65536,-372(fp),r0
-	ashl	#16,r0,-376(fp)
-	addl2	-376(fp),r6
-	bicl2	#0,r6
-	cmpl	r6,-376(fp)
-	bgequ	noname.520
-	incl	r5
-noname.520:
-	movl	r6,r3
-	movl	r5,r2
-	bbc	#31,r2,noname.521
-	incl	r9
-noname.521:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.522
-	incl	r2
-noname.522:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.523
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.523
-	incl	r9
-noname.523:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.524
-	incl	r9
-noname.524:
-
-	movl	8(ap),r0
-	bicl3	#-65536,28(r0),r3
-	movzwl	30(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,12(r0),r2
-	movzwl	14(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-380(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-384(fp)
-	mull2	r0,r4
-	addl3	-380(fp),-384(fp),r0
-	bicl3	#0,r0,-380(fp)
-	cmpl	-380(fp),-384(fp)
-	bgequ	noname.525
-	addl2	#65536,r4
-noname.525:
-	movzwl	-378(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-380(fp),r0
-	ashl	#16,r0,-384(fp)
-	addl2	-384(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-384(fp)
-	bgequ	noname.526
-	incl	r4
-noname.526:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.527
-	incl	r9
-noname.527:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.528
-	incl	r2
-noname.528:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.529
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.529
-	incl	r9
-noname.529:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.530
-	incl	r9
-noname.530:
-	movl	4(ap),r0
-	movl	r8,40(r0)
-
-	clrl	r8
-
-	movl	8(ap),r0
-	bicl3	#-65536,28(r0),r3
-	movzwl	30(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,16(r0),r2
-	movzwl	18(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-388(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-392(fp)
-	mull2	r0,r4
-	addl3	-388(fp),-392(fp),r0
-	bicl3	#0,r0,-388(fp)
-	cmpl	-388(fp),-392(fp)
-	bgequ	noname.531
-	addl2	#65536,r4
-noname.531:
-	movzwl	-386(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-388(fp),r0
-	ashl	#16,r0,-392(fp)
-	addl2	-392(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-392(fp)
-	bgequ	noname.532
-	incl	r4
-noname.532:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.533
-	incl	r8
-noname.533:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.534
-	incl	r2
-noname.534:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.535
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.535
-	incl	r8
-noname.535:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.536
-	incl	r8
-noname.536:
-
-	movl	8(ap),r0
-	bicl3	#-65536,24(r0),r3
-	movzwl	26(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,20(r0),r2
-	movzwl	22(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-396(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-400(fp)
-	mull2	r0,r4
-	addl3	-396(fp),-400(fp),r0
-	bicl3	#0,r0,-396(fp)
-	cmpl	-396(fp),-400(fp)
-	bgequ	noname.537
-	addl2	#65536,r4
-noname.537:
-	movzwl	-394(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-396(fp),r0
-	ashl	#16,r0,-400(fp)
-	addl2	-400(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-400(fp)
-	bgequ	noname.538
-	incl	r4
-noname.538:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.539
-	incl	r8
-noname.539:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.540
-	incl	r2
-noname.540:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r7
-	bicl2	#0,r7
-	cmpl	r7,r3
-	bgequ	noname.541
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.541
-	incl	r8
-noname.541:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.542
-	incl	r8
-noname.542:
-
-	movl	4(ap),r0
-	movl	r7,44(r0)
-
-	clrl	r7
-
-	movl	8(ap),r3
-	movl	24(r3),r4
-	bicl3	#-65536,r4,r5
-	extzv	#16,#16,r4,r0
-	bicl3	#-65536,r0,r4
-	mull3	r5,r4,-404(fp)
-	mull2	r5,r5
-	mull2	r4,r4
-	bicl3	#32767,-404(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r4
-	bicl3	#-65536,-404(fp),r0
-	ashl	#17,r0,-404(fp)
-	addl2	-404(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-404(fp)
-	bgequ	noname.543
-	incl	r4
-noname.543:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.544
-	incl	r2
-noname.544:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.545
-	incl	r7
-noname.545:
-
-	movzwl	30(r3),r2
-	bicl3	#-65536,20(r3),r1
-	movzwl	22(r3),r0
-	bicl2	#-65536,r0
-	bicl3	#-65536,28(r3),-416(fp)
-	bicl3	#-65536,r2,-420(fp)
-	mull3	r0,-416(fp),-408(fp)
-	mull2	r1,-416(fp)
-	mull3	r1,-420(fp),-412(fp)
-	mull2	r0,-420(fp)
-	addl3	-408(fp),-412(fp),r0
-	bicl3	#0,r0,-408(fp)
-	cmpl	-408(fp),-412(fp)
-	bgequ	noname.546
-	addl2	#65536,-420(fp)
-noname.546:
-	movzwl	-406(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-420(fp)
-	bicl3	#-65536,-408(fp),r0
-	ashl	#16,r0,-412(fp)
-	addl3	-412(fp),-416(fp),r0
-	bicl3	#0,r0,-416(fp)
-	cmpl	-416(fp),-412(fp)
-	bgequ	noname.547
-	incl	-420(fp)
-noname.547:
-	movl	-416(fp),r3
-	movl	-420(fp),r2
-	bbc	#31,r2,noname.548
-	incl	r7
-noname.548:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.549
-	incl	r2
-noname.549:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.550
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.550
-	incl	r7
-noname.550:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.551
-	incl	r7
-noname.551:
-
-	movl	4(ap),r0
-	movl	r9,48(r0)
-
-	clrl	r9
-
-	movl	8(ap),r0
-	movzwl	30(r0),r2
-	bicl3	#-65536,24(r0),r3
-	movzwl	26(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,28(r0),-432(fp)
-	bicl3	#-65536,r2,-436(fp)
-	mull3	r1,-432(fp),-424(fp)
-	mull2	r3,-432(fp)
-	mull3	r3,-436(fp),-428(fp)
-	mull2	r1,-436(fp)
-	addl3	-424(fp),-428(fp),r0
-	bicl3	#0,r0,-424(fp)
-	cmpl	-424(fp),-428(fp)
-	bgequ	noname.552
-	addl2	#65536,-436(fp)
-noname.552:
-	movzwl	-422(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,-436(fp)
-	bicl3	#-65536,-424(fp),r0
-	ashl	#16,r0,-428(fp)
-	addl3	-428(fp),-432(fp),r0
-	bicl3	#0,r0,-432(fp)
-	cmpl	-432(fp),-428(fp)
-	bgequ	noname.553
-	incl	-436(fp)
-noname.553:
-	movl	-432(fp),r3
-	movl	-436(fp),r2
-	bbc	#31,r2,noname.554
-	incl	r9
-noname.554:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.555
-	incl	r2
-noname.555:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.556
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.556
-	incl	r9
-noname.556:
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.557
-	incl	r9
-noname.557:
-
-	movl	4(ap),r4
-	movl	r8,52(r4)
-
-	clrl	r8
-
-	movl	8(ap),r0
-	movl	28(r0),r3
-	bicl3	#-65536,r3,-440(fp)
-	extzv	#16,#16,r3,r0
-	bicl3	#-65536,r0,r3
-	movl	-440(fp),r0
-	mull3	r0,r3,-444(fp)
-	mull3	r0,r0,-440(fp)
-	mull2	r3,r3
-	bicl3	#32767,-444(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r3
-	bicl3	#-65536,-444(fp),r0
-	ashl	#17,r0,-444(fp)
-	addl3	-440(fp),-444(fp),r0
-	bicl3	#0,r0,-440(fp)
-	cmpl	-440(fp),-444(fp)
-	bgequ	noname.558
-	incl	r3
-noname.558:
-	movl	-440(fp),r1
-	movl	r3,r2
-	addl2	r1,r7
-	bicl2	#0,r7
-	cmpl	r7,r1
-	bgequ	noname.559
-	incl	r2
-noname.559:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.560
-	incl	r8
-noname.560:
-
-	movl	r7,56(r4)
-
-	movl	r9,60(r4)
-
-	ret	
-
-
-
-;r=4 ;(AP)
-;a=8 ;(AP)
-;b=12 ;(AP)
-;n=16 ;(AP)	n	by value (input)
-
-	.psect	code,nowrt
-
-.entry	BN_SQR_COMBA4,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10>
-	subl2	#44,sp
-
-	clrq	r8
-
-	clrl	r10
-
-	movl	8(ap),r5
-	movl	(r5),r3
-	bicl3	#-65536,r3,r4
-	extzv	#16,#16,r3,r0
-	bicl3	#-65536,r0,r3
-	mull3	r4,r3,-4(fp)
-	mull2	r4,r4
-	mull2	r3,r3
-	bicl3	#32767,-4(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r3
-	bicl3	#-65536,-4(fp),r0
-	ashl	#17,r0,-4(fp)
-	addl2	-4(fp),r4
-	bicl2	#0,r4
-	cmpl	r4,-4(fp)
-	bgequ	noname.563
-	incl	r3
-noname.563:
-	movl	r4,r1
-	movl	r3,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.564
-	incl	r2
-noname.564:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.565
-	incl	r10
-noname.565:
-
-	movl	r9,@4(ap)
-
-	clrl	r9
-
-	bicl3	#-65536,4(r5),r3
-	movzwl	6(r5),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,(r5),r2
-	movzwl	2(r5),r0
-	bicl2	#-65536,r0
-	movl	r3,r6
-	movl	r1,r4
-	mull3	r0,r6,-8(fp)
-	mull2	r2,r6
-	mull2	r4,r2
-	mull2	r0,r4
-	addl3	-8(fp),r2,r0
-	bicl3	#0,r0,-8(fp)
-	cmpl	-8(fp),r2
-	bgequ	noname.566
-	addl2	#65536,r4
-noname.566:
-	movzwl	-6(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-8(fp),r0
-	ashl	#16,r0,r1
-	addl2	r1,r6
-	bicl2	#0,r6
-	cmpl	r6,r1
-	bgequ	noname.567
-	incl	r4
-noname.567:
-	movl	r6,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.568
-	incl	r9
-noname.568:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.569
-	incl	r2
-noname.569:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.570
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.570
-	incl	r9
-noname.570:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.571
-	incl	r9
-noname.571:
-
-	movl	4(ap),r0
-	movl	r8,4(r0)
-
-	clrl	r8
-
-	movl	8(ap),r4
-	movl	4(r4),r3
-	bicl3	#-65536,r3,r5
-	extzv	#16,#16,r3,r0
-	bicl3	#-65536,r0,r3
-	mull3	r5,r3,r1
-	mull2	r5,r5
-	mull2	r3,r3
-	bicl3	#32767,r1,r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r3
-	bicl2	#-65536,r1
-	ashl	#17,r1,r1
-	addl2	r1,r5
-	bicl2	#0,r5
-	cmpl	r5,r1
-	bgequ	noname.572
-	incl	r3
-noname.572:
-	movl	r5,r1
-	movl	r3,r2
-	addl2	r1,r10
-	bicl2	#0,r10
-	cmpl	r10,r1
-	bgequ	noname.573
-	incl	r2
-noname.573:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.574
-	incl	r8
-noname.574:
-
-	bicl3	#-65536,8(r4),r3
-	movzwl	10(r4),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,(r4),r2
-	movzwl	2(r4),r0
-	bicl2	#-65536,r0
-	movl	r3,r6
-	movl	r1,r5
-	mull3	r0,r6,r7
-	mull2	r2,r6
-	mull2	r5,r2
-	mull2	r0,r5
-	addl2	r2,r7
-	bicl2	#0,r7
-	cmpl	r7,r2
-	bgequ	noname.575
-	addl2	#65536,r5
-noname.575:
-	extzv	#16,#16,r7,r0
-	bicl2	#-65536,r0
-	addl2	r0,r5
-	bicl3	#-65536,r7,r0
-	ashl	#16,r0,r1
-	addl2	r1,r6
-	bicl2	#0,r6
-	cmpl	r6,r1
-	bgequ	noname.576
-	incl	r5
-noname.576:
-	movl	r6,r3
-	movl	r5,r2
-	bbc	#31,r2,noname.577
-	incl	r8
-noname.577:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.578
-	incl	r2
-noname.578:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r10
-	bicl2	#0,r10
-	cmpl	r10,r3
-	bgequ	noname.579
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.579
-	incl	r8
-noname.579:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.580
-	incl	r8
-noname.580:
-
-	movl	4(ap),r0
-	movl	r10,8(r0)
-
-	clrl	r10
-
-	movl	8(ap),r0
-	bicl3	#-65536,12(r0),r3
-	movzwl	14(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,(r0),r2
-	movzwl	2(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,r6
-	mull2	r2,r5
-	mull3	r2,r4,-12(fp)
-	mull2	r0,r4
-	addl2	-12(fp),r6
-	bicl2	#0,r6
-	cmpl	r6,-12(fp)
-	bgequ	noname.581
-	addl2	#65536,r4
-noname.581:
-	extzv	#16,#16,r6,r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,r6,r0
-	ashl	#16,r0,-12(fp)
-	addl2	-12(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-12(fp)
-	bgequ	noname.582
-	incl	r4
-noname.582:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.583
-	incl	r10
-noname.583:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.584
-	incl	r2
-noname.584:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.585
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.585
-	incl	r10
-noname.585:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.586
-	incl	r10
-noname.586:
-
-	movl	8(ap),r0
-	bicl3	#-65536,8(r0),r3
-	movzwl	10(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r0),r2
-	movzwl	6(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-16(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-20(fp)
-	mull2	r0,r4
-	addl3	-16(fp),-20(fp),r0
-	bicl3	#0,r0,-16(fp)
-	cmpl	-16(fp),-20(fp)
-	bgequ	noname.587
-	addl2	#65536,r4
-noname.587:
-	movzwl	-14(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-16(fp),r0
-	ashl	#16,r0,-20(fp)
-	addl2	-20(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-20(fp)
-	bgequ	noname.588
-	incl	r4
-noname.588:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.589
-	incl	r10
-noname.589:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.590
-	incl	r2
-noname.590:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r9
-	bicl2	#0,r9
-	cmpl	r9,r3
-	bgequ	noname.591
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.591
-	incl	r10
-noname.591:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.592
-	incl	r10
-noname.592:
-	movl	4(ap),r0
-	movl	r9,12(r0)
-
-	clrl	r9
-
-	movl	8(ap),r3
-	movl	8(r3),r4
-	bicl3	#-65536,r4,r5
-	extzv	#16,#16,r4,r0
-	bicl3	#-65536,r0,r4
-	mull3	r5,r4,-24(fp)
-	mull2	r5,r5
-	mull2	r4,r4
-	bicl3	#32767,-24(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r4
-	bicl3	#-65536,-24(fp),r0
-	ashl	#17,r0,-24(fp)
-	addl2	-24(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-24(fp)
-	bgequ	noname.593
-	incl	r4
-noname.593:
-	movl	r5,r1
-	movl	r4,r2
-	addl2	r1,r8
-	bicl2	#0,r8
-	cmpl	r8,r1
-	bgequ	noname.594
-	incl	r2
-noname.594:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.595
-	incl	r9
-noname.595:
-
-	bicl3	#-65536,12(r3),r4
-	movzwl	14(r3),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,4(r3),r2
-	movzwl	6(r3),r0
-	bicl2	#-65536,r0
-	movl	r4,r6
-	movl	r1,r5
-	mull3	r0,r6,-28(fp)
-	mull2	r2,r6
-	mull3	r2,r5,-32(fp)
-	mull2	r0,r5
-	addl3	-28(fp),-32(fp),r0
-	bicl3	#0,r0,-28(fp)
-	cmpl	-28(fp),-32(fp)
-	bgequ	noname.596
-	addl2	#65536,r5
-noname.596:
-	movzwl	-26(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r5
-	bicl3	#-65536,-28(fp),r0
-	ashl	#16,r0,-32(fp)
-	addl2	-32(fp),r6
-	bicl2	#0,r6
-	cmpl	r6,-32(fp)
-	bgequ	noname.597
-	incl	r5
-noname.597:
-	movl	r6,r3
-	movl	r5,r2
-	bbc	#31,r2,noname.598
-	incl	r9
-noname.598:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.599
-	incl	r2
-noname.599:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r8
-	bicl2	#0,r8
-	cmpl	r8,r3
-	bgequ	noname.600
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.600
-	incl	r9
-noname.600:
-	addl2	r2,r10
-	bicl2	#0,r10
-	cmpl	r10,r2
-	bgequ	noname.601
-	incl	r9
-noname.601:
-
-	movl	4(ap),r0
-	movl	r8,16(r0)
-
-	clrl	r8
-
-	movl	8(ap),r0
-	bicl3	#-65536,12(r0),r3
-	movzwl	14(r0),r1
-	bicl2	#-65536,r1
-	bicl3	#-65536,8(r0),r2
-	movzwl	10(r0),r0
-	bicl2	#-65536,r0
-	movl	r3,r5
-	movl	r1,r4
-	mull3	r0,r5,-36(fp)
-	mull2	r2,r5
-	mull3	r2,r4,-40(fp)
-	mull2	r0,r4
-	addl3	-36(fp),-40(fp),r0
-	bicl3	#0,r0,-36(fp)
-	cmpl	-36(fp),-40(fp)
-	bgequ	noname.602
-	addl2	#65536,r4
-noname.602:
-	movzwl	-34(fp),r0
-	bicl2	#-65536,r0
-	addl2	r0,r4
-	bicl3	#-65536,-36(fp),r0
-	ashl	#16,r0,-40(fp)
-	addl2	-40(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-40(fp)
-	bgequ	noname.603
-	incl	r4
-noname.603:
-	movl	r5,r3
-	movl	r4,r2
-	bbc	#31,r2,noname.604
-	incl	r8
-noname.604:
-	addl2	r2,r2
-	bicl2	#0,r2
-	bbc	#31,r3,noname.605
-	incl	r2
-noname.605:
-	addl2	r3,r3
-	bicl2	#0,r3
-	addl2	r3,r10
-	bicl2	#0,r10
-	cmpl	r10,r3
-	bgequ	noname.606
-	incl	r2
-	bicl3	#0,r2,r0
-	bneq	noname.606
-	incl	r8
-noname.606:
-	addl2	r2,r9
-	bicl2	#0,r9
-	cmpl	r9,r2
-	bgequ	noname.607
-	incl	r8
-noname.607:
-
-	movl	4(ap),r4
-	movl	r10,20(r4)
-
-	clrl	r10
-
-	movl	8(ap),r0
-	movl	12(r0),r3
-	bicl3	#-65536,r3,r5
-	extzv	#16,#16,r3,r0
-	bicl3	#-65536,r0,r3
-	mull3	r5,r3,-44(fp)
-	mull2	r5,r5
-	mull2	r3,r3
-	bicl3	#32767,-44(fp),r0
-	extzv	#15,#17,r0,r0
-	addl2	r0,r3
-	bicl3	#-65536,-44(fp),r0
-	ashl	#17,r0,-44(fp)
-	addl2	-44(fp),r5
-	bicl2	#0,r5
-	cmpl	r5,-44(fp)
-	bgequ	noname.608
-	incl	r3
-noname.608:
-	movl	r5,r1
-	movl	r3,r2
-	addl2	r1,r9
-	bicl2	#0,r9
-	cmpl	r9,r1
-	bgequ	noname.609
-	incl	r2
-noname.609:
-	addl2	r2,r8
-	bicl2	#0,r8
-	cmpl	r8,r2
-	bgequ	noname.610
-	incl	r10
-noname.610:
-
-	movl	r9,24(r4)
-
-	movl	r8,28(r4)
-
-	ret	
-
-; For now, the code below doesn't work, so I end this prematurely.
-.end
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h
index e484b7f..a0bc478 100644
--- a/crypto/bn/bn.h
+++ b/crypto/bn/bn.h
@@ -253,6 +253,24 @@
 #define BN_HEX_FMT2	"%08X"
 #endif
 
+/* 2011-02-22 SMS.
+ * In various places, a size_t variable or a type cast to size_t was
+ * used to perform integer-only operations on pointers.  This failed on
+ * VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is
+ * still only 32 bits.  What's needed in these cases is an integer type
+ * with the same size as a pointer, which size_t is not certain to be. 
+ * The only fix here is VMS-specific.
+ */
+#if defined(OPENSSL_SYS_VMS)
+# if __INITIAL_POINTER_SIZE == 64
+#  define PTR_SIZE_INT long long
+# else /* __INITIAL_POINTER_SIZE == 64 */
+#  define PTR_SIZE_INT int
+# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+#else /* defined(OPENSSL_SYS_VMS) */
+# define PTR_SIZE_INT size_t
+#endif /* defined(OPENSSL_SYS_VMS) [else] */
+
 #define BN_DEFAULT_BITS	1280
 
 #define BN_FLG_MALLOCED		0x01
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c
index 527b0fa..432a3aa 100644
--- a/crypto/bn/bn_gf2m.c
+++ b/crypto/bn/bn_gf2m.c
@@ -545,6 +545,7 @@
 		{
 		while (!BN_is_odd(u))
 			{
+			if (BN_is_zero(u)) goto err;
 			if (!BN_rshift1(u, u)) goto err;
 			if (BN_is_odd(b))
 				{
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c
index 7224637..1a86688 100644
--- a/crypto/bn/bn_mont.c
+++ b/crypto/bn/bn_mont.c
@@ -277,7 +277,7 @@
 	m1|=m2;			/* (al!=ri) */
 	m1|=(0-(size_t)v);	/* (al!=ri || v) */
 	m1&=~m2;		/* (al!=ri || v) && !al>ri */
-	nrp=(BN_ULONG *)(((size_t)rp&~m1)|((size_t)ap&m1));
+	nrp=(BN_ULONG *)(((PTR_SIZE_INT)rp&~m1)|((PTR_SIZE_INT)ap&m1));
 	}
 
 	/* 'i<ri' is chosen to eliminate dependency on input data, even
diff --git a/crypto/bn/bn_nist.c b/crypto/bn/bn_nist.c
index 2ca5b01..c6de032 100644
--- a/crypto/bn/bn_nist.c
+++ b/crypto/bn/bn_nist.c
@@ -354,7 +354,7 @@
 	         buf[BN_NIST_192_TOP],
 		 c_d[BN_NIST_192_TOP],
 		*res;
-	size_t   mask;
+	PTR_SIZE_INT mask;
 	static const BIGNUM _bignum_nist_p_192_sqr = {
 		(BN_ULONG *)_nist_p_192_sqr,
 		sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]),
@@ -405,9 +405,10 @@
 	 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'
 	 * this is what happens below, but without explicit if:-) a.
 	 */
-	mask  = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
-	mask &= 0-(size_t)carry;
-	res   = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
+	mask  = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
+	mask &= 0-(PTR_SIZE_INT)carry;
+	res   = (BN_ULONG *)
+	 (((PTR_SIZE_INT)c_d&~mask) | ((PTR_SIZE_INT)r_d&mask));
 	nist_cp_bn(r_d, res, BN_NIST_192_TOP);
 	r->top = BN_NIST_192_TOP;
 	bn_correct_top(r);
@@ -438,8 +439,8 @@
 	         buf[BN_NIST_224_TOP],
 		 c_d[BN_NIST_224_TOP],
 		*res;
-	size_t   mask;
-	union { bn_addsub_f f; size_t p; } u;
+	PTR_SIZE_INT mask;
+	union { bn_addsub_f f; PTR_SIZE_INT p; } u;
 	static const BIGNUM _bignum_nist_p_224_sqr = {
 		(BN_ULONG *)_nist_p_224_sqr,
 		sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]),
@@ -510,16 +511,18 @@
 		 * to be compared to the modulus and conditionally
 		 * adjusted by *subtracting* the latter. */
 		carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP);
-		mask = 0-(size_t)carry;
-		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
+		mask = 0-(PTR_SIZE_INT)carry;
+		u.p = ((PTR_SIZE_INT)bn_sub_words&mask) |
+		 ((PTR_SIZE_INT)bn_add_words&~mask);
 		}
 	else
 		carry = 1;
 
 	/* otherwise it's effectively same as in BN_nist_mod_192... */
-	mask  = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
-	mask &= 0-(size_t)carry;
-	res   = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
+	mask  = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
+	mask &= 0-(PTR_SIZE_INT)carry;
+	res   = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) |
+	 ((PTR_SIZE_INT)r_d&mask));
 	nist_cp_bn(r_d, res, BN_NIST_224_TOP);
 	r->top = BN_NIST_224_TOP;
 	bn_correct_top(r);
@@ -549,8 +552,8 @@
 	         buf[BN_NIST_256_TOP],
 		 c_d[BN_NIST_256_TOP],
 		*res;
-	size_t   mask;
-	union { bn_addsub_f f; size_t p; } u;
+	PTR_SIZE_INT mask;
+	union { bn_addsub_f f; PTR_SIZE_INT p; } u;
 	static const BIGNUM _bignum_nist_p_256_sqr = {
 		(BN_ULONG *)_nist_p_256_sqr,
 		sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]),
@@ -629,15 +632,17 @@
 	else if (carry < 0)
 		{
 		carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
-		mask = 0-(size_t)carry;
-		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
+		mask = 0-(PTR_SIZE_INT)carry;
+		u.p = ((PTR_SIZE_INT)bn_sub_words&mask) |
+		 ((PTR_SIZE_INT)bn_add_words&~mask);
 		}
 	else
 		carry = 1;
 
-	mask  = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
-	mask &= 0-(size_t)carry;
-	res   = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
+	mask  = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
+	mask &= 0-(PTR_SIZE_INT)carry;
+	res   = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) |
+	 ((PTR_SIZE_INT)r_d&mask));
 	nist_cp_bn(r_d, res, BN_NIST_256_TOP);
 	r->top = BN_NIST_256_TOP;
 	bn_correct_top(r);
@@ -671,8 +676,8 @@
 	         buf[BN_NIST_384_TOP],
 		 c_d[BN_NIST_384_TOP],
 		*res;
-	size_t	 mask;
-	union { bn_addsub_f f; size_t p; } u;
+	PTR_SIZE_INT mask;
+	union { bn_addsub_f f; PTR_SIZE_INT p; } u;
 	static const BIGNUM _bignum_nist_p_384_sqr = {
 		(BN_ULONG *)_nist_p_384_sqr,
 		sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]),
@@ -754,15 +759,17 @@
 	else if (carry < 0)
 		{
 		carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP);
-		mask = 0-(size_t)carry;
-		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
+		mask = 0-(PTR_SIZE_INT)carry;
+		u.p = ((PTR_SIZE_INT)bn_sub_words&mask) |
+		 ((PTR_SIZE_INT)bn_add_words&~mask);
 		}
 	else
 		carry = 1;
 
-	mask  = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
-	mask &= 0-(size_t)carry;
-	res   = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
+	mask  = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
+	mask &= 0-(PTR_SIZE_INT)carry;
+	res   = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) |
+	 ((PTR_SIZE_INT)r_d&mask));
 	nist_cp_bn(r_d, res, BN_NIST_384_TOP);
 	r->top = BN_NIST_384_TOP;
 	bn_correct_top(r);
@@ -781,7 +788,7 @@
 	BN_ULONG *r_d, *a_d = a->d,
 		 t_d[BN_NIST_521_TOP],
 		 val,tmp,*res;
-	size_t	mask;
+	PTR_SIZE_INT mask;
 	static const BIGNUM _bignum_nist_p_521_sqr = {
 		(BN_ULONG *)_nist_p_521_sqr,
 		sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]),
@@ -826,8 +833,9 @@
 	r_d[i] &= BN_NIST_521_TOP_MASK;
 
 	bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP);
-	mask = 0-(size_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
-	res  = (BN_ULONG *)(((size_t)t_d&~mask) | ((size_t)r_d&mask));
+	mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
+	res  = (BN_ULONG *)(((PTR_SIZE_INT)t_d&~mask) |
+	 ((PTR_SIZE_INT)r_d&mask));
 	nist_cp_bn(r_d,res,BN_NIST_521_TOP);
 	r->top = BN_NIST_521_TOP;
 	bn_correct_top(r);
diff --git a/crypto/bn/vms-helper.c b/crypto/bn/vms-helper.c
deleted file mode 100644
index 4b63149..0000000
--- a/crypto/bn/vms-helper.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* vms-helper.c */
-/* ====================================================================
- * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
- *
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
- *    endorse or promote products derived from this software without
- *    prior written permission. For written permission, please contact
- *    openssl-core@OpenSSL.org.
- *
- * 5. Products derived from this software may not be called "OpenSSL"
- *    nor may "OpenSSL" appear in their names without prior written
- *    permission of the OpenSSL Project.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- *    acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
- *
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This product includes cryptographic software written by Eric Young
- * (eay@cryptsoft.com).  This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn_lcl.h"
-
-bn_div_words_abort(int i)
-{
-#ifdef BN_DEBUG
-#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
-	fprintf(stderr,"Division would overflow (%d)\n",i);
-#endif
-	abort();
-#endif
-}
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index 0c1ee2b..f5fcbb9 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -64,6 +64,7 @@
 #endif
 
 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
 #include <openssl/conf.h>
 #include <openssl/conf_api.h>
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index 14bae0d..24fe123 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -731,7 +731,6 @@
 	case DLL_THREAD_ATTACH:
 		break;
 	case DLL_THREAD_DETACH:
-		ERR_remove_state(0);
 		break;
 	case DLL_PROCESS_DETACH:
 		break;
diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c
index 4ce91e2..e2df54f 100644
--- a/crypto/dsa/dsa_pmeth.c
+++ b/crypto/dsa/dsa_pmeth.c
@@ -187,6 +187,7 @@
 		case EVP_PKEY_CTRL_MD:
 		if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1   &&
 		    EVP_MD_type((const EVP_MD *)p2) != NID_dsa    &&
+		    EVP_MD_type((const EVP_MD *)p2) != NID_dsaWithSHA    &&
 		    EVP_MD_type((const EVP_MD *)p2) != NID_sha224 &&
 		    EVP_MD_type((const EVP_MD *)p2) != NID_sha256)
 			{
diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c
index 14bd322..c2bc617 100644
--- a/crypto/dso/dso_dlfcn.c
+++ b/crypto/dso/dso_dlfcn.c
@@ -85,6 +85,7 @@
 # define HAVE_DLINFO 1
 # if defined(_AIX) || defined(__CYGWIN__) || \
      defined(__SCO_VERSION__) || defined(_SCO_ELF) || \
+     (defined(__osf__) && !defined(RTLD_NEXT))     || \
      (defined(__OpenBSD__) && !defined(RTLD_SELF))
 #  undef HAVE_DLINFO
 # endif
diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c
deleted file mode 100644
index 3215127..0000000
--- a/crypto/dso/dso_vms.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */
-/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
- * project 2000.
- */
-/* ====================================================================
- * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
- *
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
- *    endorse or promote products derived from this software without
- *    prior written permission. For written permission, please contact
- *    licensing@OpenSSL.org.
- *
- * 5. Products derived from this software may not be called "OpenSSL"
- *    nor may "OpenSSL" appear in their names without prior written
- *    permission of the OpenSSL Project.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- *    acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
- *
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This product includes cryptographic software written by Eric Young
- * (eay@cryptsoft.com).  This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include "cryptlib.h"
-#include <openssl/dso.h>
-#ifdef OPENSSL_SYS_VMS
-#pragma message disable DOLLARID
-#include <rms.h>
-#include <lib$routines.h>
-#include <stsdef.h>
-#include <descrip.h>
-#include <starlet.h>
-#endif
-
-#ifndef OPENSSL_SYS_VMS
-DSO_METHOD *DSO_METHOD_vms(void)
-	{
-	return NULL;
-	}
-#else
-#pragma message disable DOLLARID
-
-static int vms_load(DSO *dso);
-static int vms_unload(DSO *dso);
-static void *vms_bind_var(DSO *dso, const char *symname);
-static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
-#if 0
-static int vms_unbind_var(DSO *dso, char *symname, void *symptr);
-static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
-static int vms_init(DSO *dso);
-static int vms_finish(DSO *dso);
-static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg);
-#endif
-static char *vms_name_converter(DSO *dso, const char *filename);
-static char *vms_merger(DSO *dso, const char *filespec1,
-	const char *filespec2);
-
-static DSO_METHOD dso_meth_vms = {
-	"OpenSSL 'VMS' shared library method",
-	vms_load,
-	NULL, /* unload */
-	vms_bind_var,
-	vms_bind_func,
-/* For now, "unbind" doesn't exist */
-#if 0
-	NULL, /* unbind_var */
-	NULL, /* unbind_func */
-#endif
-	NULL, /* ctrl */
-	vms_name_converter,
-	vms_merger,
-	NULL, /* init */
-	NULL  /* finish */
-	};
-
-/* On VMS, the only "handle" is the file name.  LIB$FIND_IMAGE_SYMBOL depends
- * on the reference to the file name being the same for all calls regarding
- * one shared image, so we'll just store it in an instance of the following
- * structure and put a pointer to that instance in the meth_data stack.
- */
-typedef struct dso_internal_st
-	{
-	/* This should contain the name only, no directory,
-	 * no extension, nothing but a name. */
-	struct dsc$descriptor_s filename_dsc;
-	char filename[FILENAME_MAX+1];
-	/* This contains whatever is not in filename, if needed.
-	 * Normally not defined. */
-	struct dsc$descriptor_s imagename_dsc;
-	char imagename[FILENAME_MAX+1];
-	} DSO_VMS_INTERNAL;
-
-
-DSO_METHOD *DSO_METHOD_vms(void)
-	{
-	return(&dso_meth_vms);
-	}
-
-static int vms_load(DSO *dso)
-	{
-	void *ptr = NULL;
-	/* See applicable comments in dso_dl.c */
-	char *filename = DSO_convert_filename(dso, NULL);
-	DSO_VMS_INTERNAL *p;
-	const char *sp1, *sp2;	/* Search result */
-
-	if(filename == NULL)
-		{
-		DSOerr(DSO_F_VMS_LOAD,DSO_R_NO_FILENAME);
-		goto err;
-		}
-
-	/* A file specification may look like this:
-	 *
-	 *	node::dev:[dir-spec]name.type;ver
-	 *
-	 * or (for compatibility with TOPS-20):
-	 *
-	 *	node::dev:<dir-spec>name.type;ver
-	 *
-	 * and the dir-spec uses '.' as separator.  Also, a dir-spec
-	 * may consist of several parts, with mixed use of [] and <>:
-	 *
-	 *	[dir1.]<dir2>
-	 *
-	 * We need to split the file specification into the name and
-	 * the rest (both before and after the name itself).
-	 */
-	/* Start with trying to find the end of a dir-spec, and save the
-	   position of the byte after in sp1 */
-	sp1 = strrchr(filename, ']');
-	sp2 = strrchr(filename, '>');
-	if (sp1 == NULL) sp1 = sp2;
-	if (sp2 != NULL && sp2 > sp1) sp1 = sp2;
-	if (sp1 == NULL) sp1 = strrchr(filename, ':');
-	if (sp1 == NULL)
-		sp1 = filename;
-	else
-		sp1++;		/* The byte after the found character */
-	/* Now, let's see if there's a type, and save the position in sp2 */
-	sp2 = strchr(sp1, '.');
-	/* If we found it, that's where we'll cut.  Otherwise, look for a
-	   version number and save the position in sp2 */
-	if (sp2 == NULL) sp2 = strchr(sp1, ';');
-	/* If there was still nothing to find, set sp2 to point at the end of
-	   the string */
-	if (sp2 == NULL) sp2 = sp1 + strlen(sp1);
-
-	/* Check that we won't get buffer overflows */
-	if (sp2 - sp1 > FILENAME_MAX
-		|| (sp1 - filename) + strlen(sp2) > FILENAME_MAX)
-		{
-		DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG);
-		goto err;
-		}
-
-	p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL));
-	if(p == NULL)
-		{
-		DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE);
-		goto err;
-		}
-
-	strncpy(p->filename, sp1, sp2-sp1);
-	p->filename[sp2-sp1] = '\0';
-
-	strncpy(p->imagename, filename, sp1-filename);
-	p->imagename[sp1-filename] = '\0';
-	strcat(p->imagename, sp2);
-
-	p->filename_dsc.dsc$w_length = strlen(p->filename);
-	p->filename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-	p->filename_dsc.dsc$b_class = DSC$K_CLASS_S;
-	p->filename_dsc.dsc$a_pointer = p->filename;
-	p->imagename_dsc.dsc$w_length = strlen(p->imagename);
-	p->imagename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-	p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
-	p->imagename_dsc.dsc$a_pointer = p->imagename;
-
-	if(!sk_void_push(dso->meth_data, (char *)p))
-		{
-		DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR);
-		goto err;
-		}
-
-	/* Success (for now, we lie.  We actually do not know...) */
-	dso->loaded_filename = filename;
-	return(1);
-err:
-	/* Cleanup! */
-	if(p != NULL)
-		OPENSSL_free(p);
-	if(filename != NULL)
-		OPENSSL_free(filename);
-	return(0);
-	}
-
-/* Note that this doesn't actually unload the shared image, as there is no
- * such thing in VMS.  Next time it get loaded again, a new copy will
- * actually be loaded.
- */
-static int vms_unload(DSO *dso)
-	{
-	DSO_VMS_INTERNAL *p;
-	if(dso == NULL)
-		{
-		DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
-		return(0);
-		}
-	if(sk_void_num(dso->meth_data) < 1)
-		return(1);
-	p = (DSO_VMS_INTERNAL *)sk_void_pop(dso->meth_data);
-	if(p == NULL)
-		{
-		DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE);
-		return(0);
-		}
-	/* Cleanup */
-	OPENSSL_free(p);
-	return(1);
-	}
-
-/* We must do this in a separate function because of the way the exception
-   handler works (it makes this function return */
-static int do_find_symbol(DSO_VMS_INTERNAL *ptr,
-	struct dsc$descriptor_s *symname_dsc, void **sym,
-	unsigned long flags)
-	{
-	/* Make sure that signals are caught and returned instead of
-	   aborting the program.  The exception handler gets unestablished
-	   automatically on return from this function.  */
-	lib$establish(lib$sig_to_ret);
-
-	if(ptr->imagename_dsc.dsc$w_length)
-		return lib$find_image_symbol(&ptr->filename_dsc,
-			symname_dsc, sym,
-			&ptr->imagename_dsc, flags);
-	else
-		return lib$find_image_symbol(&ptr->filename_dsc,
-			symname_dsc, sym,
-			0, flags);
-	}
-
-void vms_bind_sym(DSO *dso, const char *symname, void **sym)
-	{
-	DSO_VMS_INTERNAL *ptr;
-	int status;
-#if 0
-	int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't
-                               defined in VMS older than 7.0 or so */
-#else
-	int flags = 0;
-#endif
-	struct dsc$descriptor_s symname_dsc;
-	*sym = NULL;
-
-	symname_dsc.dsc$w_length = strlen(symname);
-	symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-	symname_dsc.dsc$b_class = DSC$K_CLASS_S;
-	symname_dsc.dsc$a_pointer = (char *)symname; /* The cast is needed */
-
-	if((dso == NULL) || (symname == NULL))
-		{
-		DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER);
-		return;
-		}
-	if(sk_void_num(dso->meth_data) < 1)
-		{
-		DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR);
-		return;
-		}
-	ptr = (DSO_VMS_INTERNAL *)sk_void_value(dso->meth_data,
-		sk_void_num(dso->meth_data) - 1);
-	if(ptr == NULL)
-		{
-		DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE);
-		return;
-		}
-
-	if(dso->flags & DSO_FLAG_UPCASE_SYMBOL) flags = 0;
-
-	status = do_find_symbol(ptr, &symname_dsc, sym, flags);
-
-	if(!$VMS_STATUS_SUCCESS(status))
-		{
-		unsigned short length;
-		char errstring[257];
-		struct dsc$descriptor_s errstring_dsc;
-
-		errstring_dsc.dsc$w_length = sizeof(errstring);
-		errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-		errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
-		errstring_dsc.dsc$a_pointer = errstring;
-
-		*sym = NULL;
-
-		status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
-
-		if (!$VMS_STATUS_SUCCESS(status))
-			lib$signal(status); /* This is really bad.  Abort!  */
-		else
-			{
-			errstring[length] = '\0';
-
-			DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_SYM_FAILURE);
-			if (ptr->imagename_dsc.dsc$w_length)
-				ERR_add_error_data(9,
-					"Symbol ", symname,
-					" in ", ptr->filename,
-					" (", ptr->imagename, ")",
-					": ", errstring);
-			else
-				ERR_add_error_data(6,
-					"Symbol ", symname,
-					" in ", ptr->filename,
-					": ", errstring);
-			}
-		return;
-		}
-	return;
-	}
-
-static void *vms_bind_var(DSO *dso, const char *symname)
-	{
-	void *sym = 0;
-	vms_bind_sym(dso, symname, &sym);
-	return sym;
-	}
-
-static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
-	{
-	DSO_FUNC_TYPE sym = 0;
-	vms_bind_sym(dso, symname, (void **)&sym);
-	return sym;
-	}
-
-static char *vms_merger(DSO *dso, const char *filespec1, const char *filespec2)
-	{
-	int status;
-	int filespec1len, filespec2len;
-	struct FAB fab;
-#ifdef NAML$C_MAXRSS
-	struct NAML nam;
-	char esa[NAML$C_MAXRSS];
-#else
-	struct NAM nam;
-	char esa[NAM$C_MAXRSS];
-#endif
-	char *merged;
-
-	if (!filespec1) filespec1 = "";
-	if (!filespec2) filespec2 = "";
-	filespec1len = strlen(filespec1);
-	filespec2len = strlen(filespec2);
-
-	fab = cc$rms_fab;
-#ifdef NAML$C_MAXRSS
-	nam = cc$rms_naml;
-#else
-	nam = cc$rms_nam;
-#endif
-
-	fab.fab$l_fna = (char *)filespec1;
-	fab.fab$b_fns = filespec1len;
-	fab.fab$l_dna = (char *)filespec2;
-	fab.fab$b_dns = filespec2len;
-#ifdef NAML$C_MAXRSS
-	if (filespec1len > NAM$C_MAXRSS)
-		{
-		fab.fab$l_fna = 0;
-		fab.fab$b_fns = 0;
-		nam.naml$l_long_filename = (char *)filespec1;
-		nam.naml$l_long_filename_size = filespec1len;
-		}
-	if (filespec2len > NAM$C_MAXRSS)
-		{
-		fab.fab$l_dna = 0;
-		fab.fab$b_dns = 0;
-		nam.naml$l_long_defname = (char *)filespec2;
-		nam.naml$l_long_defname_size = filespec2len;
-		}
-	nam.naml$l_esa = esa;
-	nam.naml$b_ess = NAM$C_MAXRSS;
-	nam.naml$l_long_expand = esa;
-	nam.naml$l_long_expand_alloc = sizeof(esa);
-	nam.naml$b_nop = NAM$M_SYNCHK | NAM$M_PWD;
-	nam.naml$v_no_short_upcase = 1;
-	fab.fab$l_naml = &nam;
-#else
-	nam.nam$l_esa = esa;
-	nam.nam$b_ess = NAM$C_MAXRSS;
-	nam.nam$b_nop = NAM$M_SYNCHK | NAM$M_PWD;
-	fab.fab$l_nam = &nam;
-#endif
-
-	status = sys$parse(&fab, 0, 0);
-
-	if(!$VMS_STATUS_SUCCESS(status))
-		{
-		unsigned short length;
-		char errstring[257];
-		struct dsc$descriptor_s errstring_dsc;
-
-		errstring_dsc.dsc$w_length = sizeof(errstring);
-		errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
-		errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
-		errstring_dsc.dsc$a_pointer = errstring;
-
-		status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
-
-		if (!$VMS_STATUS_SUCCESS(status))
-			lib$signal(status); /* This is really bad.  Abort!  */
-		else
-			{
-			errstring[length] = '\0';
-
-			DSOerr(DSO_F_VMS_MERGER,DSO_R_FAILURE);
-			ERR_add_error_data(7,
-					   "filespec \"", filespec1, "\", ",
-					   "defaults \"", filespec2, "\": ",
-					   errstring);
-			}
-		return(NULL);
-		}
-#ifdef NAML$C_MAXRSS
-	if (nam.naml$l_long_expand_size)
-		{
-		merged = OPENSSL_malloc(nam.naml$l_long_expand_size + 1);
-		if(!merged)
-			goto malloc_err;
-		strncpy(merged, nam.naml$l_long_expand,
-			nam.naml$l_long_expand_size);
-		merged[nam.naml$l_long_expand_size] = '\0';
-		}
-	else
-		{
-		merged = OPENSSL_malloc(nam.naml$b_esl + 1);
-		if(!merged)
-			goto malloc_err;
-		strncpy(merged, nam.naml$l_esa,
-			nam.naml$b_esl);
-		merged[nam.naml$b_esl] = '\0';
-		}
-#else
-	merged = OPENSSL_malloc(nam.nam$b_esl + 1);
-	if(!merged)
-		goto malloc_err;
-	strncpy(merged, nam.nam$l_esa,
-		nam.nam$b_esl);
-	merged[nam.nam$b_esl] = '\0';
-#endif
-	return(merged);
- malloc_err:
-	DSOerr(DSO_F_VMS_MERGER,
-		ERR_R_MALLOC_FAILURE);
-	}
-
-static char *vms_name_converter(DSO *dso, const char *filename)
-	{
-        int len = strlen(filename);
-        char *not_translated = OPENSSL_malloc(len+1);
-        strcpy(not_translated,filename);
-	return(not_translated);
-	}
-
-#endif /* OPENSSL_SYS_VMS */
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
deleted file mode 100644
index 6fb6c54..0000000
--- a/crypto/dso/dso_win32.c
+++ /dev/null
@@ -1,844 +0,0 @@
-/* dso_win32.c -*- mode:C; c-file-style: "eay" -*- */
-/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
- * project 2000.
- */
-/* ====================================================================
- * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
- *
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
- *    endorse or promote products derived from this software without
- *    prior written permission. For written permission, please contact
- *    licensing@OpenSSL.org.
- *
- * 5. Products derived from this software may not be called "OpenSSL"
- *    nor may "OpenSSL" appear in their names without prior written
- *    permission of the OpenSSL Project.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- *    acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
- *
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This product includes cryptographic software written by Eric Young
- * (eay@cryptsoft.com).  This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "cryptlib.h"
-#include <openssl/dso.h>
-
-#if !defined(DSO_WIN32)
-DSO_METHOD *DSO_METHOD_win32(void)
-	{
-	return NULL;
-	}
-#else
-
-#ifdef _WIN32_WCE
-# if _WIN32_WCE < 300
-static FARPROC GetProcAddressA(HMODULE hModule,LPCSTR lpProcName)
-	{
-	WCHAR lpProcNameW[64];
-	int i;
-
-	for (i=0;lpProcName[i] && i<64;i++)
-		lpProcNameW[i] = (WCHAR)lpProcName[i];
-	if (i==64) return NULL;
-	lpProcNameW[i] = 0;
-
-	return GetProcAddressW(hModule,lpProcNameW);
-	}
-# endif
-# undef GetProcAddress
-# define GetProcAddress GetProcAddressA
-
-static HINSTANCE LoadLibraryA(LPCSTR lpLibFileName)
-	{
-	WCHAR *fnamw;
-	size_t len_0=strlen(lpLibFileName)+1,i;
-
-#ifdef _MSC_VER
-	fnamw = (WCHAR *)_alloca (len_0*sizeof(WCHAR));
-#else
-	fnamw = (WCHAR *)alloca (len_0*sizeof(WCHAR));
-#endif
-	if (fnamw == NULL)
-		{
-		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-		return NULL;
-		}
-
-#if defined(_WIN32_WCE) && _WIN32_WCE>=101
-	if (!MultiByteToWideChar(CP_ACP,0,lpLibFileName,len_0,fnamw,len_0))
-#endif
-		for (i=0;i<len_0;i++) fnamw[i]=(WCHAR)lpLibFileName[i];
-
-	return LoadLibraryW(fnamw);
-	}
-#endif
-
-/* Part of the hack in "win32_load" ... */
-#define DSO_MAX_TRANSLATED_SIZE 256
-
-static int win32_load(DSO *dso);
-static int win32_unload(DSO *dso);
-static void *win32_bind_var(DSO *dso, const char *symname);
-static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname);
-#if 0
-static int win32_unbind_var(DSO *dso, char *symname, void *symptr);
-static int win32_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
-static int win32_init(DSO *dso);
-static int win32_finish(DSO *dso);
-static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg);
-#endif
-static char *win32_name_converter(DSO *dso, const char *filename);
-static char *win32_merger(DSO *dso, const char *filespec1,
-	const char *filespec2);
-static int win32_pathbyaddr(void *addr,char *path,int sz);
-static void *win32_globallookup(const char *name);
-
-static const char *openssl_strnchr(const char *string, int c, size_t len);
-
-static DSO_METHOD dso_meth_win32 = {
-	"OpenSSL 'win32' shared library method",
-	win32_load,
-	win32_unload,
-	win32_bind_var,
-	win32_bind_func,
-/* For now, "unbind" doesn't exist */
-#if 0
-	NULL, /* unbind_var */
-	NULL, /* unbind_func */
-#endif
-	NULL, /* ctrl */
-	win32_name_converter,
-	win32_merger,
-	NULL, /* init */
-	NULL, /* finish */
-	win32_pathbyaddr,
-	win32_globallookup
-	};
-
-DSO_METHOD *DSO_METHOD_win32(void)
-	{
-	return(&dso_meth_win32);
-	}
-
-/* For this DSO_METHOD, our meth_data STACK will contain;
- * (i) a pointer to the handle (HINSTANCE) returned from
- *     LoadLibrary(), and copied.
- */
-
-static int win32_load(DSO *dso)
-	{
-	HINSTANCE h = NULL, *p = NULL;
-	/* See applicable comments from dso_dl.c */
-	char *filename = DSO_convert_filename(dso, NULL);
-
-	if(filename == NULL)
-		{
-		DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME);
-		goto err;
-		}
-	h = LoadLibraryA(filename);
-	if(h == NULL)
-		{
-		DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED);
-		ERR_add_error_data(3, "filename(", filename, ")");
-		goto err;
-		}
-	p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE));
-	if(p == NULL)
-		{
-		DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE);
-		goto err;
-		}
-	*p = h;
-	if(!sk_void_push(dso->meth_data, p))
-		{
-		DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
-		goto err;
-		}
-	/* Success */
-	dso->loaded_filename = filename;
-	return(1);
-err:
-	/* Cleanup !*/
-	if(filename != NULL)
-		OPENSSL_free(filename);
-	if(p != NULL)
-		OPENSSL_free(p);
-	if(h != NULL)
-		FreeLibrary(h);
-	return(0);
-	}
-
-static int win32_unload(DSO *dso)
-	{
-	HINSTANCE *p;
-	if(dso == NULL)
-		{
-		DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
-		return(0);
-		}
-	if(sk_void_num(dso->meth_data) < 1)
-		return(1);
-	p = sk_void_pop(dso->meth_data);
-	if(p == NULL)
-		{
-		DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE);
-		return(0);
-		}
-	if(!FreeLibrary(*p))
-		{
-		DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED);
-		/* We should push the value back onto the stack in
-		 * case of a retry. */
-		sk_void_push(dso->meth_data, p);
-		return(0);
-		}
-	/* Cleanup */
-	OPENSSL_free(p);
-	return(1);
-	}
-
-/* Using GetProcAddress for variables? TODO: Check this out in
- * the Win32 API docs, there's probably a variant for variables. */
-static void *win32_bind_var(DSO *dso, const char *symname)
-	{
-	HINSTANCE *ptr;
-	void *sym;
-
-	if((dso == NULL) || (symname == NULL))
-		{
-		DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
-		return(NULL);
-		}
-	if(sk_void_num(dso->meth_data) < 1)
-		{
-		DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR);
-		return(NULL);
-		}
-	ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
-	if(ptr == NULL)
-		{
-		DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE);
-		return(NULL);
-		}
-	sym = GetProcAddress(*ptr, symname);
-	if(sym == NULL)
-		{
-		DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_SYM_FAILURE);
-		ERR_add_error_data(3, "symname(", symname, ")");
-		return(NULL);
-		}
-	return(sym);
-	}
-
-static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
-	{
-	HINSTANCE *ptr;
-	void *sym;
-
-	if((dso == NULL) || (symname == NULL))
-		{
-		DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
-		return(NULL);
-		}
-	if(sk_void_num(dso->meth_data) < 1)
-		{
-		DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR);
-		return(NULL);
-		}
-	ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
-	if(ptr == NULL)
-		{
-		DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE);
-		return(NULL);
-		}
-	sym = GetProcAddress(*ptr, symname);
-	if(sym == NULL)
-		{
-		DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_SYM_FAILURE);
-		ERR_add_error_data(3, "symname(", symname, ")");
-		return(NULL);
-		}
-	return((DSO_FUNC_TYPE)sym);
-	}
-
-struct file_st
-	{
-	const char *node; int nodelen;
-	const char *device; int devicelen;
-	const char *predir; int predirlen;
-	const char *dir; int dirlen;
-	const char *file; int filelen;
-	};
-
-static struct file_st *win32_splitter(DSO *dso, const char *filename,
-	int assume_last_is_dir)
-	{
-	struct file_st *result = NULL;
-	enum { IN_NODE, IN_DEVICE, IN_FILE } position;
-	const char *start = filename;
-	char last;
-
-	if (!filename)
-		{
-		DSOerr(DSO_F_WIN32_SPLITTER,DSO_R_NO_FILENAME);
-		/*goto err;*/
-		return(NULL);
-		}
-
-	result = OPENSSL_malloc(sizeof(struct file_st));
-	if(result == NULL)
-		{
-		DSOerr(DSO_F_WIN32_SPLITTER,
-			ERR_R_MALLOC_FAILURE);
-		return(NULL);
-		}
-
-	memset(result, 0, sizeof(struct file_st));
-	position = IN_DEVICE;
-
-	if((filename[0] == '\\' && filename[1] == '\\')
-		|| (filename[0] == '/' && filename[1] == '/'))
-		{
-		position = IN_NODE;
-		filename += 2;
-		start = filename;
-		result->node = start;
-		}
-
-	do
-		{
-		last = filename[0];
-		switch(last)
-			{
-		case ':':
-			if(position != IN_DEVICE)
-				{
-				DSOerr(DSO_F_WIN32_SPLITTER,
-					DSO_R_INCORRECT_FILE_SYNTAX);
-				/*goto err;*/
-				OPENSSL_free(result);
-				return(NULL);
-				}
-			result->device = start;
-			result->devicelen = (int)(filename - start);
-			position = IN_FILE;
-			start = ++filename;
-			result->dir = start;
-			break;
-		case '\\':
-		case '/':
-			if(position == IN_NODE)
-				{
-				result->nodelen = (int)(filename - start);
-				position = IN_FILE;
-				start = ++filename;
-				result->dir = start;
-				}
-			else if(position == IN_DEVICE)
-				{
-				position = IN_FILE;
-				filename++;
-				result->dir = start;
-				result->dirlen = (int)(filename - start);
-				start = filename;
-				}
-			else
-				{
-				filename++;
-				result->dirlen += (int)(filename - start);
-				start = filename;
-				}
-			break;
-		case '\0':
-			if(position == IN_NODE)
-				{
-				result->nodelen = (int)(filename - start);
-				}
-			else
-				{
-				if(filename - start > 0)
-					{
-					if (assume_last_is_dir)
-						{
-						if (position == IN_DEVICE)
-							{
-							result->dir = start;
-							result->dirlen = 0;
-							}
-						result->dirlen +=
-							(int)(filename - start);
-						}
-					else
-						{
-						result->file = start;
-						result->filelen =
-							(int)(filename - start);
-						}
-					}
-				}
-			break;
-		default:
-			filename++;
-			break;
-			}
-		}
-	while(last);
-
-	if(!result->nodelen) result->node = NULL;
-	if(!result->devicelen) result->device = NULL;
-	if(!result->dirlen) result->dir = NULL;
-	if(!result->filelen) result->file = NULL;
-
-	return(result);
-	}
-
-static char *win32_joiner(DSO *dso, const struct file_st *file_split)
-	{
-	int len = 0, offset = 0;
-	char *result = NULL;
-	const char *start;
-
-	if(!file_split)
-		{
-		DSOerr(DSO_F_WIN32_JOINER,
-				ERR_R_PASSED_NULL_PARAMETER);
-		return(NULL);
-		}
-	if(file_split->node)
-		{
-		len += 2 + file_split->nodelen;	/* 2 for starting \\ */
-		if(file_split->predir || file_split->dir || file_split->file)
-			len++;	/* 1 for ending \ */
-		}
-	else if(file_split->device)
-		{
-		len += file_split->devicelen + 1; /* 1 for ending : */
-		}
-	len += file_split->predirlen;
-	if(file_split->predir && (file_split->dir || file_split->file))
-		{
-		len++;	/* 1 for ending \ */
-		}
-	len += file_split->dirlen;
-	if(file_split->dir && file_split->file)
-		{
-		len++;	/* 1 for ending \ */
-		}
-	len += file_split->filelen;
-
-	if(!len)
-		{
-		DSOerr(DSO_F_WIN32_JOINER, DSO_R_EMPTY_FILE_STRUCTURE);
-		return(NULL);
-		}
-
-	result = OPENSSL_malloc(len + 1);
-	if (!result)
-		{
-		DSOerr(DSO_F_WIN32_JOINER,
-			ERR_R_MALLOC_FAILURE);
-		return(NULL);
-		}
-
-	if(file_split->node)
-		{
-		strcpy(&result[offset], "\\\\"); offset += 2;
-		strncpy(&result[offset], file_split->node,
-			file_split->nodelen); offset += file_split->nodelen;
-		if(file_split->predir || file_split->dir || file_split->file)
-			{
-			result[offset] = '\\'; offset++;
-			}
-		}
-	else if(file_split->device)
-		{
-		strncpy(&result[offset], file_split->device,
-			file_split->devicelen); offset += file_split->devicelen;
-		result[offset] = ':'; offset++;
-		}
-	start = file_split->predir;
-	while(file_split->predirlen > (start - file_split->predir))
-		{
-		const char *end = openssl_strnchr(start, '/',
-			file_split->predirlen - (start - file_split->predir));
-		if(!end)
-			end = start
-				+ file_split->predirlen
-				- (start - file_split->predir);
-		strncpy(&result[offset], start,
-			end - start); offset += (int)(end - start);
-		result[offset] = '\\'; offset++;
-		start = end + 1;
-		}
-#if 0 /* Not needed, since the directory converter above already appeneded
-	 a backslash */
-	if(file_split->predir && (file_split->dir || file_split->file))
-		{
-		result[offset] = '\\'; offset++;
-		}
-#endif
-	start = file_split->dir;
-	while(file_split->dirlen > (start - file_split->dir))
-		{
-		const char *end = openssl_strnchr(start, '/',
-			file_split->dirlen - (start - file_split->dir));
-		if(!end)
-			end = start
-				+ file_split->dirlen
-				- (start - file_split->dir);
-		strncpy(&result[offset], start,
-			end - start); offset += (int)(end - start);
-		result[offset] = '\\'; offset++;
-		start = end + 1;
-		}
-#if 0 /* Not needed, since the directory converter above already appeneded
-	 a backslash */
-	if(file_split->dir && file_split->file)
-		{
-		result[offset] = '\\'; offset++;
-		}
-#endif
-	strncpy(&result[offset], file_split->file,
-		file_split->filelen); offset += file_split->filelen;
-	result[offset] = '\0';
-	return(result);
-	}
-
-static char *win32_merger(DSO *dso, const char *filespec1, const char *filespec2)
-	{
-	char *merged = NULL;
-	struct file_st *filespec1_split = NULL;
-	struct file_st *filespec2_split = NULL;
-
-	if(!filespec1 && !filespec2)
-		{
-		DSOerr(DSO_F_WIN32_MERGER,
-				ERR_R_PASSED_NULL_PARAMETER);
-		return(NULL);
-		}
-	if (!filespec2)
-		{
-		merged = OPENSSL_malloc(strlen(filespec1) + 1);
-		if(!merged)
-			{
-			DSOerr(DSO_F_WIN32_MERGER,
-				ERR_R_MALLOC_FAILURE);
-			return(NULL);
-			}
-		strcpy(merged, filespec1);
-		}
-	else if (!filespec1)
-		{
-		merged = OPENSSL_malloc(strlen(filespec2) + 1);
-		if(!merged)
-			{
-			DSOerr(DSO_F_WIN32_MERGER,
-				ERR_R_MALLOC_FAILURE);
-			return(NULL);
-			}
-		strcpy(merged, filespec2);
-		}
-	else
-		{
-		filespec1_split = win32_splitter(dso, filespec1, 0);
-		if (!filespec1_split)
-			{
-			DSOerr(DSO_F_WIN32_MERGER,
-				ERR_R_MALLOC_FAILURE);
-			return(NULL);
-			}
-		filespec2_split = win32_splitter(dso, filespec2, 1);
-		if (!filespec2_split)
-			{
-			DSOerr(DSO_F_WIN32_MERGER,
-				ERR_R_MALLOC_FAILURE);
-			OPENSSL_free(filespec1_split);
-			return(NULL);
-			}
-
-		/* Fill in into filespec1_split */
-		if (!filespec1_split->node && !filespec1_split->device)
-			{
-			filespec1_split->node = filespec2_split->node;
-			filespec1_split->nodelen = filespec2_split->nodelen;
-			filespec1_split->device = filespec2_split->device;
-			filespec1_split->devicelen = filespec2_split->devicelen;
-			}
-		if (!filespec1_split->dir)
-			{
-			filespec1_split->dir = filespec2_split->dir;
-			filespec1_split->dirlen = filespec2_split->dirlen;
-			}
-		else if (filespec1_split->dir[0] != '\\'
-			&& filespec1_split->dir[0] != '/')
-			{
-			filespec1_split->predir = filespec2_split->dir;
-			filespec1_split->predirlen = filespec2_split->dirlen;
-			}
-		if (!filespec1_split->file)
-			{
-			filespec1_split->file = filespec2_split->file;
-			filespec1_split->filelen = filespec2_split->filelen;
-			}
-
-		merged = win32_joiner(dso, filespec1_split);
-		}
-	OPENSSL_free(filespec1_split);
-	OPENSSL_free(filespec2_split);
-	return(merged);
-	}
-
-static char *win32_name_converter(DSO *dso, const char *filename)
-	{
-	char *translated;
-	int len, transform;
-
-	len = strlen(filename);
-	transform = ((strstr(filename, "/") == NULL) &&
-			(strstr(filename, "\\") == NULL) &&
-			(strstr(filename, ":") == NULL));
-	if(transform)
-		/* We will convert this to "%s.dll" */
-		translated = OPENSSL_malloc(len + 5);
-	else
-		/* We will simply duplicate filename */
-		translated = OPENSSL_malloc(len + 1);
-	if(translated == NULL)
-		{
-		DSOerr(DSO_F_WIN32_NAME_CONVERTER,
-				DSO_R_NAME_TRANSLATION_FAILED); 
-		return(NULL);   
-		}
-	if(transform)
-		sprintf(translated, "%s.dll", filename);
-	else
-		sprintf(translated, "%s", filename);
-	return(translated);
-	}
-
-static const char *openssl_strnchr(const char *string, int c, size_t len)
-	{
-	size_t i;
-	const char *p;
-	for (i = 0, p = string; i < len && *p; i++, p++)
-		{
-		if (*p == c)
-			return p;
-		}
-	return NULL;
-	}
-
-#include <tlhelp32.h>
-#ifdef _WIN32_WCE
-# define DLLNAME "TOOLHELP.DLL"
-#else
-# ifdef MODULEENTRY32
-# undef MODULEENTRY32	/* unmask the ASCII version! */
-# endif
-# define DLLNAME "KERNEL32.DLL"
-#endif
-
-typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
-typedef BOOL (WINAPI *CLOSETOOLHELP32SNAPSHOT)(HANDLE);
-typedef BOOL (WINAPI *MODULE32)(HANDLE, MODULEENTRY32 *);
-
-static int win32_pathbyaddr(void *addr,char *path,int sz)
-	{
-	HMODULE dll;
-	HANDLE hModuleSnap = INVALID_HANDLE_VALUE; 
-	MODULEENTRY32 me32; 
-	CREATETOOLHELP32SNAPSHOT create_snap;
-	CLOSETOOLHELP32SNAPSHOT  close_snap;
-	MODULE32 module_first, module_next;
-	int len;
- 
-	if (addr == NULL)
-		{
-		union	{ int(*f)(void*,char*,int); void *p; } t =
-			{ win32_pathbyaddr };
-		addr = t.p;
-		}
-
-	dll = LoadLibrary(TEXT(DLLNAME));
-	if (dll == NULL)
-		{
-		DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
-		return -1;
-		}
-
-	create_snap = (CREATETOOLHELP32SNAPSHOT)
-		GetProcAddress(dll,"CreateToolhelp32Snapshot");
-	if (create_snap == NULL)
-		{
-		FreeLibrary(dll);
-		DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
-		return -1;
-		}
-	/* We take the rest for granted... */
-#ifdef _WIN32_WCE
-	close_snap = (CLOSETOOLHELP32SNAPSHOT)
-		GetProcAddress(dll,"CloseToolhelp32Snapshot");
-#else
-	close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle;
-#endif
-	module_first = (MODULE32)GetProcAddress(dll,"Module32First");
-	module_next  = (MODULE32)GetProcAddress(dll,"Module32Next");
-
-	hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0); 
-	if( hModuleSnap == INVALID_HANDLE_VALUE ) 
-		{ 
-		FreeLibrary(dll);
-		DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
-		return -1;
-		} 
- 
-	me32.dwSize = sizeof(me32); 
- 
-	if(!(*module_first)(hModuleSnap,&me32)) 
-		{ 
-		(*close_snap)(hModuleSnap);
-		FreeLibrary(dll);
-		DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_FAILURE);
-		return -1;
-		}
- 
-	do	{ 
-		if ((BYTE *)addr >= me32.modBaseAddr &&
-		    (BYTE *)addr <  me32.modBaseAddr+me32.modBaseSize)
-			{
-			(*close_snap)(hModuleSnap);
-			FreeLibrary(dll);
-#ifdef _WIN32_WCE
-# if _WIN32_WCE >= 101
-			return WideCharToMultiByte(CP_ACP,0,me32.szExePath,-1,
-							path,sz,NULL,NULL);
-# else
-			len = (int)wcslen(me32.szExePath);
-			if (sz <= 0) return len+1;
-			if (len >= sz) len=sz-1;
-			for(i=0;i<len;i++)
-				path[i] = (char)me32.szExePath[i];
-			path[len++] = 0;
-			return len;
-# endif
-#else
-			len = (int)strlen(me32.szExePath);
-			if (sz <= 0) return len+1;
-			if (len >= sz) len=sz-1;
-			memcpy(path,me32.szExePath,len);
-			path[len++] = 0;
-			return len;
-#endif
-			} 
-		} while((*module_next)(hModuleSnap, &me32)); 
- 
-	(*close_snap)(hModuleSnap); 
-	FreeLibrary(dll);
-	return 0;
-	}
-
-static void *win32_globallookup(const char *name)
-	{
-	HMODULE dll;
-	HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
-	MODULEENTRY32 me32;
-	CREATETOOLHELP32SNAPSHOT create_snap;
-	CLOSETOOLHELP32SNAPSHOT  close_snap;
-	MODULE32 module_first, module_next;
-	FARPROC ret=NULL;
-
-	dll = LoadLibrary(TEXT(DLLNAME));
-	if (dll == NULL)
-		{
-		DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
-		return NULL;
-		}
-
-	create_snap = (CREATETOOLHELP32SNAPSHOT)
-		GetProcAddress(dll,"CreateToolhelp32Snapshot");
-	if (create_snap == NULL)
-		{
-		FreeLibrary(dll);
-		DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
-		return NULL;
-		}
-	/* We take the rest for granted... */
-#ifdef _WIN32_WCE
-	close_snap = (CLOSETOOLHELP32SNAPSHOT)
-		GetProcAddress(dll,"CloseToolhelp32Snapshot");
-#else
-	close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle;
-#endif
-	module_first = (MODULE32)GetProcAddress(dll,"Module32First");
-	module_next  = (MODULE32)GetProcAddress(dll,"Module32Next");
-
-	hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0);
-	if( hModuleSnap == INVALID_HANDLE_VALUE )
-		{
-		FreeLibrary(dll);
-		DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
-		return NULL;
-		}
-
-	me32.dwSize = sizeof(me32);
-
-	if (!(*module_first)(hModuleSnap,&me32))
-		{
-		(*close_snap)(hModuleSnap);
-		FreeLibrary(dll);
-		return NULL;
-		}
-
-	do	{
-		if ((ret = GetProcAddress(me32.hModule,name)))
-			{
-			(*close_snap)(hModuleSnap);
-			FreeLibrary(dll);
-			return ret;
-			}
-		} while((*module_next)(hModuleSnap,&me32));
-
-	(*close_snap)(hModuleSnap); 
-	FreeLibrary(dll);
-	return NULL;
-	}
-#endif /* DSO_WIN32 */
diff --git a/crypto/ecdsa/ecdsatest.c b/crypto/ecdsa/ecdsatest.c
index aa4e148..26a4a9e 100644
--- a/crypto/ecdsa/ecdsatest.c
+++ b/crypto/ecdsa/ecdsatest.c
@@ -168,10 +168,9 @@
 		return 0;
 		}
 	fbytes_counter ++;
-	ret = BN_bn2bin(tmp, buf);	
-	if (ret == 0 || ret != num)
+	if (num != BN_num_bytes(tmp) || !BN_bn2bin(tmp, buf))
 		ret = 0;
-	else
+	else 
 		ret = 1;
 	if (tmp)
 		BN_free(tmp);
diff --git a/crypto/ecdsa/ecs_ossl.c b/crypto/ecdsa/ecs_ossl.c
index 551cf50..1bbf328 100644
--- a/crypto/ecdsa/ecs_ossl.c
+++ b/crypto/ecdsa/ecs_ossl.c
@@ -144,6 +144,14 @@
 			}
 		while (BN_is_zero(k));
 
+		/* We do not want timing information to leak the length of k,
+		 * so we compute G*k using an equivalent scalar of fixed
+		 * bit-length. */
+
+		if (!BN_add(k, k, order)) goto err;
+		if (BN_num_bits(k) <= BN_num_bits(order))
+			if (!BN_add(k, k, order)) goto err;
+
 		/* compute r the x-coordinate of generator * k */
 		if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx))
 		{
diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c
index 902efac..55c7cdf 100644
--- a/crypto/evp/evp_test.c
+++ b/crypto/evp/evp_test.c
@@ -435,6 +435,7 @@
 	    EXIT(3);
 	    }
 	}
+	fclose(f);
 
 #ifndef OPENSSL_NO_ENGINE
     ENGINE_cleanup();
diff --git a/crypto/hmac/hm_pmeth.c b/crypto/hmac/hm_pmeth.c
index 985921c..71e8567 100644
--- a/crypto/hmac/hm_pmeth.c
+++ b/crypto/hmac/hm_pmeth.c
@@ -147,6 +147,8 @@
 
 static int hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
 	{
+	HMAC_PKEY_CTX *hctx = ctx->data;
+	HMAC_CTX_set_flags(&hctx->ctx, mctx->flags & ~EVP_MD_CTX_FLAG_NO_INIT);
 	EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT);
 	mctx->update = int_update;
 	return 1;
diff --git a/crypto/o_time.c b/crypto/o_time.c
index eecbdd1..9030fde 100644
--- a/crypto/o_time.c
+++ b/crypto/o_time.c
@@ -64,12 +64,18 @@
 #include "o_time.h"
 
 #ifdef OPENSSL_SYS_VMS
-# include <libdtdef.h>
-# include <lib$routines.h>
-# include <lnmdef.h>
-# include <starlet.h>
-# include <descrip.h>
-# include <stdlib.h>
+# if __CRTL_VER >= 70000000 && \
+     (defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE)
+#  define VMS_GMTIME_OK
+# endif
+# ifndef VMS_GMTIME_OK
+#  include <libdtdef.h>
+#  include <lib$routines.h>
+#  include <lnmdef.h>
+#  include <starlet.h>
+#  include <descrip.h>
+#  include <stdlib.h>
+# endif /* ndef VMS_GMTIME_OK */
 #endif
 
 struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
@@ -81,7 +87,7 @@
 	   so we don't even look at the return value */
 	gmtime_r(timer,result);
 	ts = result;
-#elif !defined(OPENSSL_SYS_VMS)
+#elif !defined(OPENSSL_SYS_VMS) || defined(VMS_GMTIME_OK)
 	ts = gmtime(timer);
 	if (ts == NULL)
 		return NULL;
@@ -89,7 +95,7 @@
 	memcpy(result, ts, sizeof(struct tm));
 	ts = result;
 #endif
-#ifdef OPENSSL_SYS_VMS
+#if defined( OPENSSL_SYS_VMS) && !defined( VMS_GMTIME_OK)
 	if (ts == NULL)
 		{
 		static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");
diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c
index 36905d7..e92b86c 100644
--- a/crypto/ocsp/ocsp_lib.c
+++ b/crypto/ocsp/ocsp_lib.c
@@ -170,14 +170,14 @@
 
 	char *host, *port;
 
-	/* dup the buffer since we are going to mess with it */
-	buf = BUF_strdup(url);
-	if (!buf) goto mem_err;
-
 	*phost = NULL;
 	*pport = NULL;
 	*ppath = NULL;
 
+	/* dup the buffer since we are going to mess with it */
+	buf = BUF_strdup(url);
+	if (!buf) goto mem_err;
+
 	/* Check for initial colon */
 	p = strchr(buf, ':');
 
diff --git a/crypto/opensslv.h b/crypto/opensslv.h
index e7fca83..310a338 100644
--- a/crypto/opensslv.h
+++ b/crypto/opensslv.h
@@ -25,11 +25,11 @@
  * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
  *  major minor fix final patch/beta)
  */
-#define OPENSSL_VERSION_NUMBER	0x1000004fL
+#define OPENSSL_VERSION_NUMBER	0x1000005fL
 #ifdef OPENSSL_FIPS
-#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0d-fips 8 Feb 2011"
+#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0e-fips 6 Sep 2011"
 #else
-#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0d 8 Feb 2011"
+#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0e 6 Sep 2011"
 #endif
 #define OPENSSL_VERSION_PTEXT	" part of " OPENSSL_VERSION_TEXT
 
diff --git a/crypto/perlasm/cbc.pl b/crypto/perlasm/cbc.pl
index e43dc9a..6fc2510 100644
--- a/crypto/perlasm/cbc.pl
+++ b/crypto/perlasm/cbc.pl
@@ -158,7 +158,6 @@
 	&jmp_ptr($count);
 
 &set_label("ej7");
-	&xor("edx",		"edx") if $ppro; # ppro friendly
 	&movb(&HB("edx"),	&BP(6,$in,"",0));
 	&shl("edx",8);
 &set_label("ej6");
@@ -170,7 +169,6 @@
 	&jmp(&label("ejend"));
 &set_label("ej3");
 	&movb(&HB("ecx"),	&BP(2,$in,"",0));
-	&xor("ecx",		"ecx") if $ppro; # ppro friendly
 	&shl("ecx",8);
 &set_label("ej2");
 	&movb(&HB("ecx"),	&BP(1,$in,"",0));
diff --git a/crypto/rand/rand_vms.c b/crypto/rand/rand_vms.c
deleted file mode 100644
index 1267a3a..0000000
--- a/crypto/rand/rand_vms.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* crypto/rand/rand_vms.c -*- mode:C; c-file-style: "eay" -*- */
-/* Written by Richard Levitte <richard@levitte.org> for the OpenSSL
- * project 2000.
- */
-/* ====================================================================
- * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
- *
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
- *    endorse or promote products derived from this software without
- *    prior written permission. For written permission, please contact
- *    openssl-core@openssl.org.
- *
- * 5. Products derived from this software may not be called "OpenSSL"
- *    nor may "OpenSSL" appear in their names without prior written
- *    permission of the OpenSSL Project.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- *    acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
- *
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This product includes cryptographic software written by Eric Young
- * (eay@cryptsoft.com).  This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
-
-#include <openssl/rand.h>
-#include "rand_lcl.h"
-
-#if defined(OPENSSL_SYS_VMS)
-
-#include <descrip.h>
-#include <jpidef.h>
-#include <ssdef.h>
-#include <starlet.h>
-#ifdef __DECC
-# pragma message disable DOLLARID
-#endif
-
-static struct items_data_st
-	{
-	short length, code;	/* length is amount of bytes */
-	} items_data[] =
-		{ { 4, JPI$_BUFIO },
-		  { 4, JPI$_CPUTIM },
-		  { 4, JPI$_DIRIO },
-		  { 8, JPI$_LOGINTIM },
-		  { 4, JPI$_PAGEFLTS },
-		  { 4, JPI$_PID },
-		  { 4, JPI$_WSSIZE },
-		  { 0, 0 }
-		};
-		  
-int RAND_poll(void)
-	{
-	long pid, iosb[2];
-	int status = 0;
-	struct
-		{
-		short length, code;
-		long *buffer;
-		int *retlen;
-		} item[32], *pitem;
-	unsigned char data_buffer[256];
-	short total_length = 0;
-	struct items_data_st *pitems_data;
-
-	pitems_data = items_data;
-	pitem = item;
-
-	/* Setup */
-	while (pitems_data->length
-		&& (total_length + pitems_data->length <= 256))
-		{
-		pitem->length = pitems_data->length;
-		pitem->code = pitems_data->code;
-		pitem->buffer = (long *)&data_buffer[total_length];
-		pitem->retlen = 0;
-		total_length += pitems_data->length;
-		pitems_data++;
-		pitem++;
-		}
-	pitem->length = pitem->code = 0;
-
-	/*
-	 * Scan through all the processes in the system and add entropy with
-	 * results from the processes that were possible to look at.
-	 * However, view the information as only half trustable.
-	 */
-	pid = -1;			/* search context */
-	while ((status = sys$getjpiw(0, &pid,  0, item, iosb, 0, 0))
-		!= SS$_NOMOREPROC)
-		{
-		if (status == SS$_NORMAL)
-			{
-			RAND_add(data_buffer, total_length, total_length/2);
-			}
-		}
-	sys$gettim(iosb);
-	RAND_add((unsigned char *)iosb, sizeof(iosb), sizeof(iosb)/2);
-	return 1;
-}
-
-#endif
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index f9b709e..bc7d9c5 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -144,7 +144,9 @@
 	   * I/O because we will waste system entropy. 
 	   */
 	  bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
+#ifndef OPENSSL_NO_SETVBUF_IONBF
 	  setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
+#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 	}
 #endif
 	for (;;)
diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c
index e238d10..18d307e 100644
--- a/crypto/rsa/rsa_oaep.c
+++ b/crypto/rsa/rsa_oaep.c
@@ -189,34 +189,40 @@
 	EVP_MD_CTX c;
 	unsigned char md[EVP_MAX_MD_SIZE];
 	int mdlen;
+	int rv = -1;
 
 	EVP_MD_CTX_init(&c);
 	mdlen = EVP_MD_size(dgst);
 	if (mdlen < 0)
-		return -1;
+		goto err;
 	for (i = 0; outlen < len; i++)
 		{
 		cnt[0] = (unsigned char)((i >> 24) & 255);
 		cnt[1] = (unsigned char)((i >> 16) & 255);
 		cnt[2] = (unsigned char)((i >> 8)) & 255;
 		cnt[3] = (unsigned char)(i & 255);
-		EVP_DigestInit_ex(&c,dgst, NULL);
-		EVP_DigestUpdate(&c, seed, seedlen);
-		EVP_DigestUpdate(&c, cnt, 4);
+		if (!EVP_DigestInit_ex(&c,dgst, NULL)
+			|| !EVP_DigestUpdate(&c, seed, seedlen)
+			|| !EVP_DigestUpdate(&c, cnt, 4))
+			goto err;
 		if (outlen + mdlen <= len)
 			{
-			EVP_DigestFinal_ex(&c, mask + outlen, NULL);
+			if (!EVP_DigestFinal_ex(&c, mask + outlen, NULL))
+				goto err;
 			outlen += mdlen;
 			}
 		else
 			{
-			EVP_DigestFinal_ex(&c, md, NULL);
+			if (!EVP_DigestFinal_ex(&c, md, NULL))
+				goto err;
 			memcpy(mask + outlen, md, len - outlen);
 			outlen = len;
 			}
 		}
+	rv = 0;
+	err:
 	EVP_MD_CTX_cleanup(&c);
-	return 0;
+	return rv;
 	}
 
 static int MGF1(unsigned char *mask, long len, const unsigned char *seed,
diff --git a/crypto/stack/safestack.h b/crypto/stack/safestack.h
index 39914bd..3e76aa5 100644
--- a/crypto/stack/safestack.h
+++ b/crypto/stack/safestack.h
@@ -2056,31 +2056,6 @@
 #define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))
 
 
-#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
-#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
-#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))
-#define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)
-#define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func))
-#define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)
-#define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)
-#define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))
-#define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))
-#define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))
-#define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \
-	((int (*)(const void * const *,const void * const *)) \
-	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))
-#define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)
-#define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))
-#define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))
-#define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))
-#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))
-
-
 #define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
 #define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())
 #define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
@@ -2106,6 +2081,31 @@
 #define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))
 
 
+#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
+#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
+#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))
+#define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)
+#define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func))
+#define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)
+#define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)
+#define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))
+#define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))
+#define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))
+#define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \
+	((int (*)(const void * const *,const void * const *)) \
+	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))
+#define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)
+#define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))
+#define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))
+#define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))
+#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))
+
+
 #define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
 	SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
 #define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
diff --git a/crypto/threads/win32.bat b/crypto/threads/win32.bat
deleted file mode 100755
index ee6da80..0000000
--- a/crypto/threads/win32.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-del mttest.exe
-
-cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssleay32.lib ..\..\out\libeay32.lib
-
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index bd6695d..5a0b024 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -703,6 +703,7 @@
 	x = sk_X509_value(ctx->chain, cnum);
 	ctx->current_cert = x;
 	ctx->current_issuer = NULL;
+	ctx->current_crl_score = 0;
 	ctx->current_reasons = 0;
 	while (ctx->current_reasons != CRLDP_ALL_REASONS)
 		{
@@ -2015,6 +2016,9 @@
 	ctx->error_depth=0;
 	ctx->current_cert=NULL;
 	ctx->current_issuer=NULL;
+	ctx->current_crl=NULL;
+	ctx->current_crl_score=0;
+	ctx->current_reasons=0;
 	ctx->tree = NULL;
 	ctx->parent = NULL;
 
diff --git a/include/openssl/bn.h b/include/openssl/bn.h
index e484b7f..a0bc478 100644
--- a/include/openssl/bn.h
+++ b/include/openssl/bn.h
@@ -253,6 +253,24 @@
 #define BN_HEX_FMT2	"%08X"
 #endif
 
+/* 2011-02-22 SMS.
+ * In various places, a size_t variable or a type cast to size_t was
+ * used to perform integer-only operations on pointers.  This failed on
+ * VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is
+ * still only 32 bits.  What's needed in these cases is an integer type
+ * with the same size as a pointer, which size_t is not certain to be. 
+ * The only fix here is VMS-specific.
+ */
+#if defined(OPENSSL_SYS_VMS)
+# if __INITIAL_POINTER_SIZE == 64
+#  define PTR_SIZE_INT long long
+# else /* __INITIAL_POINTER_SIZE == 64 */
+#  define PTR_SIZE_INT int
+# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+#else /* defined(OPENSSL_SYS_VMS) */
+# define PTR_SIZE_INT size_t
+#endif /* defined(OPENSSL_SYS_VMS) [else] */
+
 #define BN_DEFAULT_BITS	1280
 
 #define BN_FLG_MALLOCED		0x01
diff --git a/include/openssl/opensslv.h b/include/openssl/opensslv.h
index e7fca83..310a338 100644
--- a/include/openssl/opensslv.h
+++ b/include/openssl/opensslv.h
@@ -25,11 +25,11 @@
  * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
  *  major minor fix final patch/beta)
  */
-#define OPENSSL_VERSION_NUMBER	0x1000004fL
+#define OPENSSL_VERSION_NUMBER	0x1000005fL
 #ifdef OPENSSL_FIPS
-#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0d-fips 8 Feb 2011"
+#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0e-fips 6 Sep 2011"
 #else
-#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0d 8 Feb 2011"
+#define OPENSSL_VERSION_TEXT	"OpenSSL 1.0.0e 6 Sep 2011"
 #endif
 #define OPENSSL_VERSION_PTEXT	" part of " OPENSSL_VERSION_TEXT
 
diff --git a/include/openssl/safestack.h b/include/openssl/safestack.h
index 39914bd..3e76aa5 100644
--- a/include/openssl/safestack.h
+++ b/include/openssl/safestack.h
@@ -2056,31 +2056,6 @@
 #define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))
 
 
-#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
-#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
-#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))
-#define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)
-#define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func))
-#define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)
-#define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)
-#define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))
-#define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))
-#define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))
-#define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))
-#define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \
-	((int (*)(const void * const *,const void * const *)) \
-	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))
-#define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)
-#define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))
-#define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))
-#define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))
-#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))
-
-
 #define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
 #define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())
 #define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
@@ -2106,6 +2081,31 @@
 #define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))
 
 
+#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
+#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
+#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))
+#define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)
+#define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func))
+#define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)
+#define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)
+#define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))
+#define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))
+#define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))
+#define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))
+#define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \
+	((int (*)(const void * const *,const void * const *)) \
+	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))
+#define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)
+#define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))
+#define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))
+#define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))
+#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))
+
+
 #define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
 	SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
 #define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
diff --git a/openssl.config b/openssl.config
index 2d1fdfd..bf5c579 100644
--- a/openssl.config
+++ b/openssl.config
@@ -60,11 +60,15 @@
 README.ENGINE \
 apps/CA.com \
 apps/Makefile \
-apps/install.com \
+apps/install-apps.com \
 apps/makeapps.com \
+apps/openssl-vms.cnf \
 apps/ts.c \
 apps/tsget \
+apps/vms_decc_init.c \
 config \
+crypto/LPdir_vms.c \
+crypto/LPdir_win32.c \
 crypto/Makefile \
 crypto/aes/Makefile \
 crypto/asn1/Makefile \
@@ -81,6 +85,8 @@
 crypto/bio/Makefile \
 crypto/bio/bss_rtcp.c \
 crypto/bn/Makefile \
+crypto/bn/asm/vms.mar \
+crypto/bn/vms-helper.c \
 crypto/buffer/Makefile \
 crypto/comp/Makefile \
 crypto/conf/Makefile \
@@ -92,6 +98,8 @@
 crypto/dsa/Makefile \
 crypto/dso/Makefile \
 crypto/dso/dso_beos.c \
+crypto/dso/dso_vms.c \
+crypto/dso/dso_win32.c \
 crypto/ec/Makefile \
 crypto/ecdh/Makefile \
 crypto/ecdsa/Makefile \
@@ -103,7 +111,7 @@
 crypto/evp/m_md2.c \
 crypto/evp/m_sha.c \
 crypto/hmac/Makefile \
-crypto/install.com \
+crypto/install-crypto.com \
 crypto/jpake/Makefile \
 crypto/krb5/Makefile \
 crypto/lhash/Makefile \
@@ -121,6 +129,7 @@
 crypto/pkcs7/bio_pk7.c \
 crypto/pqueue/Makefile \
 crypto/rand/Makefile \
+crypto/rand/rand_vms.c \
 crypto/rc2/Makefile \
 crypto/rc4/Makefile \
 crypto/ripemd/Makefile \
@@ -130,6 +139,7 @@
 crypto/stack/Makefile \
 crypto/store/Makefile \
 crypto/threads/pthreads-vms.com \
+crypto/threads/win32.bat \
 crypto/ts/Makefile \
 crypto/ts/ts.h \
 crypto/ts/ts_asn1.c \
@@ -144,6 +154,7 @@
 crypto/ts/ts_verify_ctx.c \
 crypto/txt_db/Makefile \
 crypto/ui/Makefile \
+crypto/vms_rms.h
 crypto/x509/Makefile \
 crypto/x509v3/Makefile \
 include/openssl/camellia.h \
@@ -157,7 +168,7 @@
 makevms.com \
 openssl.doxy \
 openssl.spec \
-ssl/install.com \
+ssl/install-ssl.com \
 ssl/ssl-lib.com \
 ssl/ssl_task.c \
 " 
diff --git a/openssl.version b/openssl.version
index 2001876..721c467 100644
--- a/openssl.version
+++ b/openssl.version
@@ -1,2 +1,2 @@
 # also update ThirdPartyProject.prop
-OPENSSL_VERSION=1.0.0d
+OPENSSL_VERSION=1.0.0e
diff --git a/patches/crypto_Android.mk b/patches/crypto_Android.mk
index 2bce944..6f09fa5 100644
--- a/patches/crypto_Android.mk
+++ b/patches/crypto_Android.mk
@@ -222,8 +222,6 @@
 	dso/dso_lib.c \
 	dso/dso_null.c \
 	dso/dso_openssl.c \
-	dso/dso_vms.c \
-	dso/dso_win32.c \
 	ec/ec2_mult.c \
 	ec/ec2_smpl.c \
 	ec/ec_ameth.c \
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index af319af..eedac8a 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -348,7 +348,11 @@
 		break;
 	case BIO_C_SET_SSL:
 		if (ssl != NULL)
+			{
 			ssl_free(b);
+			if (!ssl_new(b))
+				return 0;
+			}
 		b->shutdown=(int)num;
 		ssl=(SSL *)ptr;
 		((BIO_SSL *)b->ptr)->ssl=ssl;
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index 4ce4064..2180c6d 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -153,7 +153,7 @@
 #endif
 
 static unsigned char bitmask_start_values[] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
-static unsigned char bitmask_end_values[]   = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f};
+static unsigned char bitmask_end_values[]   = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f};
 
 /* XDTLS:  figure out the right values */
 static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28};
@@ -464,20 +464,9 @@
 
 	memset(msg_hdr, 0x00, sizeof(struct hm_header_st));
 
-	s->d1->handshake_read_seq++;
-	/* we just read a handshake message from the other side:
-	 * this means that we don't need to retransmit of the
-	 * buffered messages.  
-	 * XDTLS: may be able clear out this
-	 * buffer a little sooner (i.e if an out-of-order
-	 * handshake message/record is received at the record
-	 * layer.  
-	 * XDTLS: exception is that the server needs to
-	 * know that change cipher spec and finished messages
-	 * have been received by the client before clearing this
-	 * buffer.  this can simply be done by waiting for the
-	 * first data  segment, but is there a better way?  */
-	dtls1_clear_record_buffer(s);
+	/* Don't change sequence numbers while listening */
+	if (!s->d1->listen)
+		s->d1->handshake_read_seq++;
 
 	s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;
 	return s->init_num;
@@ -813,9 +802,11 @@
 
 	/* 
 	 * if this is a future (or stale) message it gets buffered
-	 * (or dropped)--no further processing at this time 
+	 * (or dropped)--no further processing at this time
+	 * While listening, we accept seq 1 (ClientHello with cookie)
+	 * although we're still expecting seq 0 (ClientHello)
 	 */
-	if ( msg_hdr.seq != s->d1->handshake_read_seq)
+	if (msg_hdr.seq != s->d1->handshake_read_seq && !(s->d1->listen && msg_hdr.seq == 1))
 		return dtls1_process_out_of_seq_message(s, &msg_hdr, ok);
 
 	len = msg_hdr.msg_len;
@@ -1322,7 +1313,8 @@
 dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt,
 			unsigned long len, unsigned long frag_off, unsigned long frag_len)
 	{
-	if ( frag_off == 0)
+	/* Don't change sequence numbers while listening */
+	if (frag_off == 0 && !s->d1->listen)
 		{
 		s->d1->handshake_write_seq = s->d1->next_handshake_write_seq;
 		s->d1->next_handshake_write_seq++;
diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c
index aabbef8..5776671 100644
--- a/ssl/d1_clnt.c
+++ b/ssl/d1_clnt.c
@@ -407,7 +407,8 @@
 
 		case SSL3_ST_CW_CHANGE_A:
 		case SSL3_ST_CW_CHANGE_B:
-			dtls1_start_timer(s);
+			if (!s->hit)
+				dtls1_start_timer(s);
 			ret=dtls1_send_change_cipher_spec(s,
 				SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);
 			if (ret <= 0) goto end;
@@ -442,7 +443,8 @@
 
 		case SSL3_ST_CW_FINISHED_A:
 		case SSL3_ST_CW_FINISHED_B:
-			dtls1_start_timer(s);
+			if (!s->hit)
+				dtls1_start_timer(s);
 			ret=dtls1_send_finished(s,
 				SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,
 				s->method->ssl3_enc->client_finished_label,
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 96b220e..48e8b6f 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -129,26 +129,33 @@
 	return(1);
 	}
 
-void dtls1_free(SSL *s)
+static void dtls1_clear_queues(SSL *s)
 	{
     pitem *item = NULL;
     hm_fragment *frag = NULL;
-
-	ssl3_free(s);
+	DTLS1_RECORD_DATA *rdata;
 
     while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
         {
+		rdata = (DTLS1_RECORD_DATA *) item->data;
+		if (rdata->rbuf.buf)
+			{
+			OPENSSL_free(rdata->rbuf.buf);
+			}
         OPENSSL_free(item->data);
         pitem_free(item);
         }
-    pqueue_free(s->d1->unprocessed_rcds.q);
 
     while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
         {
+		rdata = (DTLS1_RECORD_DATA *) item->data;
+		if (rdata->rbuf.buf)
+			{
+			OPENSSL_free(rdata->rbuf.buf);
+			}
         OPENSSL_free(item->data);
         pitem_free(item);
         }
-    pqueue_free(s->d1->processed_rcds.q);
 
     while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
         {
@@ -157,7 +164,6 @@
         OPENSSL_free(frag);
         pitem_free(item);
         }
-    pqueue_free(s->d1->buffered_messages);
 
     while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
         {
@@ -166,7 +172,6 @@
         OPENSSL_free(frag);
         pitem_free(item);
         }
-	pqueue_free(s->d1->sent_messages);
 
 	while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL)
 		{
@@ -175,6 +180,18 @@
 		OPENSSL_free(frag);
 		pitem_free(item);
 		}
+	}
+
+void dtls1_free(SSL *s)
+	{
+	ssl3_free(s);
+
+	dtls1_clear_queues(s);
+
+    pqueue_free(s->d1->unprocessed_rcds.q);
+    pqueue_free(s->d1->processed_rcds.q);
+    pqueue_free(s->d1->buffered_messages);
+	pqueue_free(s->d1->sent_messages);
 	pqueue_free(s->d1->buffered_app_data.q);
 
 	OPENSSL_free(s->d1);
@@ -182,6 +199,36 @@
 
 void dtls1_clear(SSL *s)
 	{
+    pqueue unprocessed_rcds;
+    pqueue processed_rcds;
+    pqueue buffered_messages;
+	pqueue sent_messages;
+	pqueue buffered_app_data;
+	
+	if (s->d1)
+		{
+		unprocessed_rcds = s->d1->unprocessed_rcds.q;
+		processed_rcds = s->d1->processed_rcds.q;
+		buffered_messages = s->d1->buffered_messages;
+		sent_messages = s->d1->sent_messages;
+		buffered_app_data = s->d1->buffered_app_data.q;
+
+		dtls1_clear_queues(s);
+
+		memset(s->d1, 0, sizeof(*(s->d1)));
+
+		if (s->server)
+			{
+			s->d1->cookie_len = sizeof(s->d1->cookie);
+			}
+
+		s->d1->unprocessed_rcds.q = unprocessed_rcds;
+		s->d1->processed_rcds.q = processed_rcds;
+		s->d1->buffered_messages = buffered_messages;
+		s->d1->sent_messages = sent_messages;
+		s->d1->buffered_app_data.q = buffered_app_data;
+		}
+
 	ssl3_clear(s);
 	if (s->options & SSL_OP_CISCO_ANYCONNECT)
 		s->version=DTLS1_BAD_VER;
@@ -330,6 +377,8 @@
 	memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
 	s->d1->timeout_duration = 1;
 	BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout));
+	/* Clear retransmission buffer */
+	dtls1_clear_record_buffer(s);
 	}
 
 int dtls1_handle_timeout(SSL *s)
@@ -349,7 +398,7 @@
 		{
 		/* fail the connection, enough alerts have been sent */
 		SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED);
-		return 0;
+		return -1;
 		}
 
 	state->timeout.read_timeouts++;
diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c
index c0f6055..91562f3 100644
--- a/ssl/d1_pkt.c
+++ b/ssl/d1_pkt.c
@@ -409,13 +409,13 @@
 	enc_err = s->method->ssl3_enc->enc(s,0);
 	if (enc_err <= 0)
 		{
-		if (enc_err == 0)
-			/* SSLerr() and ssl3_send_alert() have been called */
-			goto err;
-
-		/* otherwise enc_err == -1 */
-		al=SSL_AD_BAD_RECORD_MAC;
-		goto f_err;
+		/* decryption failed, silently discard message */
+		if (enc_err < 0)
+			{
+			rr->length = 0;
+			s->packet_length = 0;
+			}
+		goto err;
 		}
 
 #ifdef TLS_DEBUG
@@ -676,10 +676,12 @@
 
 	/* If this record is from the next epoch (either HM or ALERT),
 	 * and a handshake is currently in progress, buffer it since it
-	 * cannot be processed at this time. */
+	 * cannot be processed at this time. However, do not buffer
+	 * anything while listening.
+	 */
 	if (is_next_epoch)
 		{
-		if (SSL_in_init(s) || s->in_handshake)
+		if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen)
 			{
 			dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num);
 			}
diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c
index 301ceda..a6a4c87 100644
--- a/ssl/d1_srvr.c
+++ b/ssl/d1_srvr.c
@@ -150,6 +150,7 @@
 	unsigned long alg_k;
 	int ret= -1;
 	int new_state,state,skip=0;
+	int listen;
 
 	RAND_add(&Time,sizeof(Time),0);
 	ERR_clear_error();
@@ -159,11 +160,15 @@
 		cb=s->info_callback;
 	else if (s->ctx->info_callback != NULL)
 		cb=s->ctx->info_callback;
+	
+	listen = s->d1->listen;
 
 	/* init things to blank */
 	s->in_handshake++;
 	if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
 
+	s->d1->listen = listen;
+
 	if (s->cert == NULL)
 		{
 		SSLerr(SSL_F_DTLS1_ACCEPT,SSL_R_NO_CERTIFICATE_SET);
@@ -273,11 +278,23 @@
 
 			s->init_num=0;
 
+			/* Reflect ClientHello sequence to remain stateless while listening */
+			if (listen)
+				{
+				memcpy(s->s3->write_sequence, s->s3->read_sequence, sizeof(s->s3->write_sequence));
+				}
+
 			/* If we're just listening, stop here */
-			if (s->d1->listen && s->state == SSL3_ST_SW_SRVR_HELLO_A)
+			if (listen && s->state == SSL3_ST_SW_SRVR_HELLO_A)
 				{
 				ret = 2;
 				s->d1->listen = 0;
+				/* Set expected sequence numbers
+				 * to continue the handshake.
+				 */
+				s->d1->handshake_read_seq = 2;
+				s->d1->handshake_write_seq = 1;
+				s->d1->next_handshake_write_seq = 1;
 				goto end;
 				}
 			
@@ -286,7 +303,6 @@
 		case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
 		case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
 
-			dtls1_start_timer(s);
 			ret = dtls1_send_hello_verify_request(s);
 			if ( ret <= 0) goto end;
 			s->state=SSL3_ST_SW_FLUSH;
@@ -736,9 +752,6 @@
 		/* number of bytes to write */
 		s->init_num=p-buf;
 		s->init_off=0;
-
-		/* buffer the message to handle re-xmits */
-		dtls1_buffer_message(s, 0);
 		}
 
 	/* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */
@@ -1017,12 +1030,11 @@
 				SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
 				goto err;
 				}
-			if (!EC_KEY_up_ref(ecdhp))
+			if ((ecdh = EC_KEY_dup(ecdhp)) == NULL)
 				{
 				SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
 				goto err;
 				}
-			ecdh = ecdhp;
 
 			s->s3->tmp.ecdh=ecdh;
 			if ((EC_KEY_get0_public_key(ecdh) == NULL) ||
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
index a10528e..42bcd62 100644
--- a/ssl/s3_clnt.c
+++ b/ssl/s3_clnt.c
@@ -2320,6 +2320,7 @@
 			if (!DH_generate_key(dh_clnt))
 				{
 				SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);
+				DH_free(dh_clnt);
 				goto err;
 				}
 
@@ -2331,6 +2332,7 @@
 			if (n <= 0)
 				{
 				SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);
+				DH_free(dh_clnt);
 				goto err;
 				}
 
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index fddcf6c..28ee474 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -2198,11 +2198,17 @@
 		}
 #ifndef OPENSSL_NO_DH
 	if (s->s3->tmp.dh != NULL)
+		{
 		DH_free(s->s3->tmp.dh);
+		s->s3->tmp.dh = NULL;
+		}
 #endif
 #ifndef OPENSSL_NO_ECDH
 	if (s->s3->tmp.ecdh != NULL)
+		{
 		EC_KEY_free(s->s3->tmp.ecdh);
+		s->s3->tmp.ecdh = NULL;
+		}
 #endif
 
 	rp = s->s3->rbuf.buf;
diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c
index 31238f6..0d3874a 100644
--- a/ssl/s3_pkt.c
+++ b/ssl/s3_pkt.c
@@ -246,7 +246,8 @@
 		if (i <= 0)
 			{
 			rb->left = left;
-			if (s->mode & SSL_MODE_RELEASE_BUFFERS)
+			if (s->mode & SSL_MODE_RELEASE_BUFFERS &&
+			    SSL_version(s) != DTLS1_VERSION && SSL_version(s) != DTLS1_BAD_VER)
 				if (len+left == 0)
 					ssl3_release_read_buffer(s);
 			return(i);
@@ -885,7 +886,8 @@
 			{
 			wb->left=0;
 			wb->offset+=i;
-			if (s->mode & SSL_MODE_RELEASE_BUFFERS)
+			if (s->mode & SSL_MODE_RELEASE_BUFFERS &&
+			    SSL_version(s) != DTLS1_VERSION && SSL_version(s) != DTLS1_BAD_VER)
 				ssl3_release_write_buffer(s);
 			s->rwstate=SSL_NOTHING;
 			return(s->s3->wpend_ret);
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index 6095d52..6059162 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -801,9 +801,7 @@
 	if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO)
 		{
 		/* Throw away what we have done so far in the current handshake,
-		 * which will now be aborted. (A full SSL_clear would be too much.)
-		 * I hope that tmp.dh is the only thing that may need to be cleared
-		 * when a handshake is not completed ... */
+		 * which will now be aborted. (A full SSL_clear would be too much.) */
 #ifndef OPENSSL_NO_DH
 		if (s->s3->tmp.dh != NULL)
 			{
@@ -811,6 +809,13 @@
 			s->s3->tmp.dh = NULL;
 			}
 #endif
+#ifndef OPENSSL_NO_ECDH
+		if (s->s3->tmp.ecdh != NULL)
+			{
+			EC_KEY_free(s->s3->tmp.ecdh);
+			s->s3->tmp.ecdh = NULL;
+			}
+#endif
 		return 2;
 		}
 	return 1;
@@ -1536,7 +1541,6 @@
 
 			if (s->s3->tmp.dh != NULL)
 				{
-				DH_free(dh);
 				SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
 				goto err;
 				}
@@ -1597,7 +1601,6 @@
 
 			if (s->s3->tmp.ecdh != NULL)
 				{
-				EC_KEY_free(s->s3->tmp.ecdh); 
 				SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
 				goto err;
 				}
@@ -1608,12 +1611,11 @@
 				SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
 				goto err;
 				}
-			if (!EC_KEY_up_ref(ecdhp))
+			if ((ecdh = EC_KEY_dup(ecdhp)) == NULL)
 				{
 				SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
 				goto err;
 				}
-			ecdh = ecdhp;
 
 			s->s3->tmp.ecdh=ecdh;
 			if ((EC_KEY_get0_public_key(ecdh) == NULL) ||
@@ -1776,6 +1778,7 @@
 			    (unsigned char *)encodedPoint, 
 			    encodedlen);
 			OPENSSL_free(encodedPoint);
+			encodedPoint = NULL;
 			p += encodedlen;
 			}
 #endif
@@ -2485,6 +2488,12 @@
 			/* Get encoded point length */
 			i = *p; 
 			p += 1;
+			if (n != 1 + i)
+				{
+				SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
+				    ERR_R_EC_LIB);
+				goto err;
+				}
 			if (EC_POINT_oct2point(group, 
 			    clnt_ecpoint, p, i, bn_ctx) == 0)
 				{
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 38104a2..b169ba9 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1990,7 +1990,7 @@
 #endif
 	X509 *x = NULL;
 	EVP_PKEY *ecc_pkey = NULL;
-	int signature_nid = 0;
+	int signature_nid = 0, pk_nid = 0, md_nid = 0;
 
 	if (c == NULL) return;
 
@@ -2120,18 +2120,15 @@
 		    EVP_PKEY_bits(ecc_pkey) : 0;
 		EVP_PKEY_free(ecc_pkey);
 		if ((x->sig_alg) && (x->sig_alg->algorithm))
+			{
 			signature_nid = OBJ_obj2nid(x->sig_alg->algorithm);
+			OBJ_find_sigid_algs(signature_nid, &md_nid, &pk_nid);
+			}
 #ifndef OPENSSL_NO_ECDH
 		if (ecdh_ok)
 			{
-			const char *sig = OBJ_nid2ln(signature_nid);
-			if (sig == NULL)
-				{
-				ERR_clear_error();
-				sig = "unknown";
-				}
-				
-			if (strstr(sig, "WithRSA"))
+
+			if (pk_nid == NID_rsaEncryption || pk_nid == NID_rsa)
 				{
 				mask_k|=SSL_kECDHr;
 				mask_a|=SSL_aECDH;
@@ -2142,7 +2139,7 @@
 					}
 				}
 
-			if (signature_nid == NID_ecdsa_with_SHA1)
+			if (pk_nid == NID_X9_62_id_ecPublicKey)
 				{
 				mask_k|=SSL_kECDHe;
 				mask_a|=SSL_aECDH;
@@ -2196,7 +2193,7 @@
 	unsigned long alg_k, alg_a;
 	EVP_PKEY *pkey = NULL;
 	int keysize = 0;
-	int signature_nid = 0;
+	int signature_nid = 0, md_nid = 0, pk_nid = 0;
 
 	alg_k = cs->algorithm_mkey;
 	alg_a = cs->algorithm_auth;
@@ -2214,7 +2211,10 @@
 	/* This call populates the ex_flags field correctly */
 	X509_check_purpose(x, -1, 0);
 	if ((x->sig_alg) && (x->sig_alg->algorithm))
+		{
 		signature_nid = OBJ_obj2nid(x->sig_alg->algorithm);
+		OBJ_find_sigid_algs(signature_nid, &md_nid, &pk_nid);
+		}
 	if (alg_k & SSL_kECDHe || alg_k & SSL_kECDHr)
 		{
 		/* key usage, if present, must allow key agreement */
@@ -2226,7 +2226,7 @@
 		if (alg_k & SSL_kECDHe)
 			{
 			/* signature alg must be ECDSA */
-			if (signature_nid != NID_ecdsa_with_SHA1)
+			if (pk_nid != NID_X9_62_id_ecPublicKey)
 				{
 				SSLerr(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG, SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE);
 				return 0;
@@ -2236,13 +2236,7 @@
 			{
 			/* signature alg must be RSA */
 
-			const char *sig = OBJ_nid2ln(signature_nid);
-			if (sig == NULL)
-				{
-				ERR_clear_error();
-				sig = "unknown";
-				}
-			if (strstr(sig, "WithRSA") == NULL)
+			if (pk_nid != NID_rsaEncryption && pk_nid != NID_rsa)
 				{
 				SSLerr(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG, SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE);
 				return 0;