/* multierr.c: example with multiple errors */

#include<stdlib.h>
#include<assert.h>

#pragma TASS input
int n;
#pragma TASS input
int extent;

void main() {
	/* possible division by 0: recoverable by restriction of pc: n!=0 */
	/* possible int division with negative denominator: restrict by n>0 */
	int m = 10/n;
	
	/* possible negative extent? recoverable by adding to pc: extent>=0 */
	double a[extent];
	
	double *q = &a[0];
	
	/* assertion violation: recoverable by restriction of pc: n>=1 */ 
	assert n>=1;
	
	/* possible array index out of bounds : recoverable by restriction of pc */
	a[3] = 3.14;
	
	/* memory leak: recoverable, ignored */
	leak();
	
	/* free on invalid pointer: recoverable, treated as No-op */
	// was free(&a[0]); but model builder rejects
	free(q);
	
	assert 1==1;
}


void leak() {
	double *p;
	
	p = (double*)malloc(10*sizeof(double));
}