vecfun.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "prescheme.h"
  5. long main(void);
  6. static long *Qvec_a;
  7. long main(void)
  8. {
  9. long *arg3K1;
  10. char **arg2K1;
  11. long arg0K1;
  12. long arg0K0;
  13. long merged_arg0K1;
  14. long merged_arg0K0;
  15. #ifdef USE_DIRECT_THREADING
  16. void *procD0_return_address;
  17. #else
  18. int procD0_return_tag;
  19. #endif
  20. long procD00_return_value;
  21. #ifdef USE_DIRECT_THREADING
  22. void *procD1_return_address;
  23. #else
  24. int procD1_return_tag;
  25. #endif
  26. char *procD10_return_value;
  27. long val1_0X;
  28. long val2_1X;
  29. long val_2X;
  30. long src_26X;
  31. long tgt_25X;
  32. long ix_24X;
  33. char *target_23X;
  34. long total_22X;
  35. long len_21X;
  36. long i_20X;
  37. char *val_19X;
  38. long i_18X;
  39. char *v_17X;
  40. char **result_16X;
  41. long i_15X;
  42. long val_14X;
  43. char *v_13X;
  44. long i_12X;
  45. long v_11X;
  46. long *result_10X;
  47. long i_9X;
  48. long v_8X;
  49. long result_7X;
  50. long i_6X;
  51. long val_5X;
  52. long i_4X;
  53. FILE * out_3X;
  54. { out_3X = stdout;vecfun_init();
  55. ps_write_string("Print vec-a with vector-for-each:\n", out_3X);
  56. arg0K0 = 0;
  57. goto L423;}
  58. L423: {
  59. i_4X = arg0K0;
  60. if ((5 == i_4X)) {
  61. ps_write_string("Print the last value of vec-a with vector-fold:\n", out_3X);
  62. arg0K0 = 0;
  63. arg0K1 = -1;
  64. goto L440;}
  65. else {
  66. val_5X = *(Qvec_a + i_4X);
  67. ps_write_string(" vec-a[", out_3X);
  68. ps_write_integer(i_4X, out_3X);
  69. ps_write_string("] = ", out_3X);
  70. ps_write_integer(val_5X, out_3X);
  71. { long ignoreXX;
  72. PS_WRITE_CHAR(10, out_3X, ignoreXX) }
  73. arg0K0 = (1 + i_4X);
  74. goto L423;}}
  75. L440: {
  76. i_6X = arg0K0;
  77. result_7X = arg0K1;
  78. if ((5 == i_6X)) {
  79. ps_write_string(" vec-a[-1] = ", out_3X);
  80. ps_write_integer(result_7X, out_3X);
  81. { long ignoreXX;
  82. PS_WRITE_CHAR(10, out_3X, ignoreXX) }
  83. ps_write_string("Compute the sum of two vectors with vector-map:\n", out_3X);
  84. merged_arg0K0 = (*(Qvec_a + 0));
  85. merged_arg0K1 = (*(Qvec_a + 0));
  86. #ifdef USE_DIRECT_THREADING
  87. procD0_return_address = &&procD0_return_0;
  88. #else
  89. procD0_return_tag = 0;
  90. #endif
  91. goto procD0;
  92. procD0_return_0:
  93. v_8X = procD00_return_value;
  94. arg0K0 = 0;
  95. arg3K1 = ((long*)malloc(sizeof(long) * 5));
  96. goto L464;}
  97. else {
  98. arg0K0 = (1 + i_6X);
  99. arg0K1 = (*(Qvec_a + i_6X));
  100. goto L440;}}
  101. L464: {
  102. i_9X = arg0K0;
  103. result_10X = arg3K1;
  104. if ((5 == i_9X)) {
  105. arg0K0 = 0;
  106. goto L490;}
  107. else {
  108. merged_arg0K0 = (*(Qvec_a + i_9X));
  109. merged_arg0K1 = (*(Qvec_a + i_9X));
  110. #ifdef USE_DIRECT_THREADING
  111. procD0_return_address = &&procD0_return_1;
  112. #else
  113. procD0_return_tag = 1;
  114. #endif
  115. goto procD0;
  116. procD0_return_1:
  117. v_11X = procD00_return_value;
  118. *(result_10X + i_9X) = v_11X;
  119. arg0K0 = (1 + i_9X);
  120. arg3K1 = result_10X;
  121. goto L464;}}
  122. L490: {
  123. i_12X = arg0K0;
  124. if ((5 == i_12X)) {
  125. free(result_10X);
  126. ps_write_string("Build a vector of strings with vector-map:\n", out_3X);
  127. merged_arg0K0 = (*(Qvec_a + 0));
  128. #ifdef USE_DIRECT_THREADING
  129. procD1_return_address = &&procD1_return_0;
  130. #else
  131. procD1_return_tag = 0;
  132. #endif
  133. goto procD1;
  134. procD1_return_0:
  135. v_13X = procD10_return_value;
  136. arg0K0 = 0;
  137. arg2K1 = ((char**)malloc(sizeof(char*) * 5));
  138. goto L508;}
  139. else {
  140. val_14X = *(result_10X + i_12X);
  141. ps_write_string(" sums[", out_3X);
  142. ps_write_integer(i_12X, out_3X);
  143. ps_write_string("] = ", out_3X);
  144. ps_write_integer(val_14X, out_3X);
  145. { long ignoreXX;
  146. PS_WRITE_CHAR(10, out_3X, ignoreXX) }
  147. arg0K0 = (1 + i_12X);
  148. goto L490;}}
  149. L508: {
  150. i_15X = arg0K0;
  151. result_16X = arg2K1;
  152. if ((5 == i_15X)) {
  153. arg0K0 = 0;
  154. goto L555;}
  155. else {
  156. merged_arg0K0 = (*(Qvec_a + i_15X));
  157. #ifdef USE_DIRECT_THREADING
  158. procD1_return_address = &&procD1_return_1;
  159. #else
  160. procD1_return_tag = 1;
  161. #endif
  162. goto procD1;
  163. procD1_return_1:
  164. v_17X = procD10_return_value;
  165. *(result_16X + i_15X) = v_17X;
  166. arg0K0 = (1 + i_15X);
  167. arg2K1 = result_16X;
  168. goto L508;}}
  169. L555: {
  170. i_18X = arg0K0;
  171. if ((5 == i_18X)) {
  172. arg0K0 = 0;
  173. goto L571;}
  174. else {
  175. val_19X = *(result_16X + i_18X);
  176. ps_write_string(" strs[", out_3X);
  177. ps_write_integer(i_18X, out_3X);
  178. ps_write_string("] = \"", out_3X);
  179. ps_write_string(val_19X, out_3X);
  180. { long ignoreXX;
  181. PS_WRITE_CHAR(34, out_3X, ignoreXX) }
  182. { long ignoreXX;
  183. PS_WRITE_CHAR(10, out_3X, ignoreXX) }
  184. arg0K0 = (1 + i_18X);
  185. goto L555;}}
  186. L571: {
  187. i_20X = arg0K0;
  188. if ((5 == i_20X)) {
  189. free(result_16X);
  190. return 0;}
  191. else {
  192. free((*(result_16X + i_20X)));
  193. arg0K0 = (1 + i_20X);
  194. goto L571;}}
  195. procD1: {
  196. val_2X = merged_arg0K0;{
  197. len_21X = strlen((char *) "x");
  198. total_22X = len_21X * val_2X;
  199. target_23X = (char *)calloc( 1, 1 + total_22X);
  200. arg0K0 = 0;
  201. goto L530;}
  202. L530: {
  203. ix_24X = arg0K0;
  204. if ((ix_24X == total_22X)) {
  205. procD10_return_value = target_23X;
  206. #ifdef USE_DIRECT_THREADING
  207. goto *procD1_return_address;
  208. #else
  209. goto procD1_return;
  210. #endif
  211. }
  212. else {
  213. arg0K0 = ix_24X;
  214. arg0K1 = 0;
  215. goto L537;}}
  216. L537: {
  217. tgt_25X = arg0K0;
  218. src_26X = arg0K1;
  219. if ((src_26X == len_21X)) {
  220. arg0K0 = (ix_24X + len_21X);
  221. goto L530;}
  222. else {
  223. *(target_23X + tgt_25X) = (*("x" + src_26X));
  224. arg0K0 = (1 + tgt_25X);
  225. arg0K1 = (1 + src_26X);
  226. goto L537;}}
  227. #ifndef USE_DIRECT_THREADING
  228. procD1_return:
  229. switch (procD1_return_tag) {
  230. case 0: goto procD1_return_0;
  231. default: goto procD1_return_1;
  232. }
  233. #endif
  234. }
  235. procD0: {
  236. val1_0X = merged_arg0K0;
  237. val2_1X = merged_arg0K1;{
  238. procD00_return_value = (val1_0X + val2_1X);
  239. #ifdef USE_DIRECT_THREADING
  240. goto *procD0_return_address;
  241. #else
  242. goto procD0_return;
  243. #endif
  244. }
  245. #ifndef USE_DIRECT_THREADING
  246. procD0_return:
  247. switch (procD0_return_tag) {
  248. case 0: goto procD0_return_0;
  249. default: goto procD0_return_1;
  250. }
  251. #endif
  252. }
  253. }void
  254. vecfun_init(void)
  255. {
  256. Qvec_a = malloc(5 * sizeof(long));
  257. Qvec_a[0] = 0;
  258. Qvec_a[1] = 1;
  259. Qvec_a[2] = 4;
  260. Qvec_a[3] = 9;
  261. Qvec_a[4] = 16;
  262. }