1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o %t 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc /* Sparc is not C99-compliant */ 4*f4a2713aSLionel Sambuc #if defined(sparc) || defined(__sparc__) || defined(__sparcv9) 5*f4a2713aSLionel Sambuc main()6*f4a2713aSLionel Sambucint main() { return 0; } 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc #else /* sparc */ 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc #define ESCAPE 2 11*f4a2713aSLionel Sambuc #define IMAGE_WIDTH 150 12*f4a2713aSLionel Sambuc #define IMAGE_HEIGHT 50 13*f4a2713aSLionel Sambuc #if 1 14*f4a2713aSLionel Sambuc #define IMAGE_SIZE 60 15*f4a2713aSLionel Sambuc #else 16*f4a2713aSLionel Sambuc #define IMAGE_SIZE 5000 17*f4a2713aSLionel Sambuc #endif 18*f4a2713aSLionel Sambuc #define START_X -2.1 19*f4a2713aSLionel Sambuc #define END_X 1.0 20*f4a2713aSLionel Sambuc #define START_Y -1.25 21*f4a2713aSLionel Sambuc #define MAX_ITER 100 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc #define step_X ((END_X - START_X)/IMAGE_WIDTH) 24*f4a2713aSLionel Sambuc #define step_Y ((-START_Y - START_Y)/IMAGE_HEIGHT) 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc #define I 1.0iF 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc int putchar(char c); 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc volatile double __complex__ accum; 31*f4a2713aSLionel Sambuc mandel()32*f4a2713aSLionel Sambucvoid mandel() { 33*f4a2713aSLionel Sambuc int x, y, n; 34*f4a2713aSLionel Sambuc for (y = 0; y < IMAGE_HEIGHT; ++y) { 35*f4a2713aSLionel Sambuc for (x = 0; x < IMAGE_WIDTH; ++x) { 36*f4a2713aSLionel Sambuc double __complex__ c = (START_X+x*step_X) + (START_Y+y*step_Y) * I; 37*f4a2713aSLionel Sambuc double __complex__ z = 0.0; 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc for (n = 0; n < MAX_ITER; ++n) { 40*f4a2713aSLionel Sambuc z = z * z + c; 41*f4a2713aSLionel Sambuc if (hypot(__real__ z, __imag__ z) >= ESCAPE) 42*f4a2713aSLionel Sambuc break; 43*f4a2713aSLionel Sambuc } 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuc if (n == MAX_ITER) 46*f4a2713aSLionel Sambuc putchar(' '); 47*f4a2713aSLionel Sambuc else if (n > 6) 48*f4a2713aSLionel Sambuc putchar('.'); 49*f4a2713aSLionel Sambuc else if (n > 3) 50*f4a2713aSLionel Sambuc putchar('+'); 51*f4a2713aSLionel Sambuc else if (n > 2) 52*f4a2713aSLionel Sambuc putchar('x'); 53*f4a2713aSLionel Sambuc else 54*f4a2713aSLionel Sambuc putchar('*'); 55*f4a2713aSLionel Sambuc } 56*f4a2713aSLionel Sambuc putchar('\n'); 57*f4a2713aSLionel Sambuc } 58*f4a2713aSLionel Sambuc } 59*f4a2713aSLionel Sambuc main()60*f4a2713aSLionel Sambucint main() { 61*f4a2713aSLionel Sambuc mandel(); 62*f4a2713aSLionel Sambuc return 0; 63*f4a2713aSLionel Sambuc } 64*f4a2713aSLionel Sambuc 65*f4a2713aSLionel Sambuc #endif /* sparc */ 66