static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap,
	PQ_64BIT *seq_num)
	{
#if PQ_64BIT_IS_INTEGER
	PQ_64BIT mask = 0x0000000000000001L;
#endif
	PQ_64BIT rcd_num, tmp;

	pq_64bit_init(&rcd_num);
	pq_64bit_init(&tmp);

	/* this is the sequence number for the record just read */
	pq_64bit_bin2num(&rcd_num, s->s3->read_sequence, 8);

	
	if (pq_64bit_gt(&rcd_num, &(bitmap->max_seq_num)) ||
		pq_64bit_eq(&rcd_num, &(bitmap->max_seq_num)))
		{
		pq_64bit_assign(seq_num, &rcd_num);
		pq_64bit_free(&rcd_num);
		pq_64bit_free(&tmp);
		return 1;  /* this record is new */
		}

	pq_64bit_sub(&tmp, &(bitmap->max_seq_num), &rcd_num);

	if ( pq_64bit_get_word(&tmp) > bitmap->length)
		{
		pq_64bit_free(&rcd_num);
		pq_64bit_free(&tmp);
		return 0;  /* stale, outside the window */
		}

#if PQ_64BIT_IS_BIGNUM
	{
	int offset;
	pq_64bit_sub(&tmp, &(bitmap->max_seq_num), &rcd_num);
	pq_64bit_sub_word(&tmp, 1);
	offset = pq_64bit_get_word(&tmp);
	if ( pq_64bit_is_bit_set(&(bitmap->map), offset))
		{
		pq_64bit_free(&rcd_num);
		pq_64bit_free(&tmp);
		return 0;
		}
	}
#else
	mask <<= (bitmap->max_seq_num - rcd_num - 1);
	if (bitmap->map & mask)
		return 0; /* record previously received */
#endif
	
	pq_64bit_assign(seq_num, &rcd_num);
	pq_64bit_free(&rcd_num);
	pq_64bit_free(&tmp);
	return 1;
	}
static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap,
	PQ_64BIT *seq_num)
	{
#if PQ_64BIT_IS_INTEGER
	PQ_64BIT mask = 0x0000000000000001L;
#endif
	PQ_64BIT rcd_num, tmp;

	pq_64bit_init(&rcd_num);
	pq_64bit_init(&tmp);

	 
	pq_64bit_bin2num(&rcd_num, s->s3->read_sequence, 8);

	
	if (pq_64bit_gt(&rcd_num, &(bitmap->max_seq_num)) ||
		pq_64bit_eq(&rcd_num, &(bitmap->max_seq_num)))
		{
		pq_64bit_assign(seq_num, &rcd_num);
		pq_64bit_free(&rcd_num);
		pq_64bit_free(&tmp);
		return 1;   
		}

	pq_64bit_sub(&tmp, &(bitmap->max_seq_num), &rcd_num);

	if ( pq_64bit_get_word(&tmp) > bitmap->length)
		{
		pq_64bit_free(&rcd_num);
		pq_64bit_free(&tmp);
		return 0;   
		}

#if PQ_64BIT_IS_BIGNUM
	{
	int offset;
	pq_64bit_sub(&tmp, &(bitmap->max_seq_num), &rcd_num);
	pq_64bit_sub_word(&tmp, 1);
	offset = pq_64bit_get_word(&tmp);
	if ( pq_64bit_is_bit_set(&(bitmap->map), offset))
		{
		pq_64bit_free(&rcd_num);
		pq_64bit_free(&tmp);
		return 0;
		}
	}
#else
	mask <<= (bitmap->max_seq_num - rcd_num - 1);
	if (bitmap->map & mask)
		return 0;  
#endif
	
	pq_64bit_assign(seq_num, &rcd_num);
	pq_64bit_free(&rcd_num);
	pq_64bit_free(&tmp);
	return 1;
	}