vecfun.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. #include "prescheme.h"
  2. #include "ps-init.h"
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. long main(void);
  7. static long *Qvec_a;
  8. long main(void) {
  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. {
  55. out_3X = stdout;
  56. ps_write_string("Print vec-a with vector-for-each:\n", out_3X);
  57. arg0K0 = 0;
  58. goto L401;
  59. }
  60. L401 : {
  61. i_4X = arg0K0;
  62. if ((5 == i_4X)) {
  63. ps_write_string("Print the last value of vec-a with vector-fold:\n",
  64. out_3X);
  65. arg0K0 = 0;
  66. arg0K1 = -1;
  67. goto L418;
  68. } else {
  69. val_5X = *(Qvec_a + i_4X);
  70. ps_write_string(" vec-a[", out_3X);
  71. ps_write_integer(i_4X, out_3X);
  72. ps_write_string("] = ", out_3X);
  73. ps_write_integer(val_5X, out_3X);
  74. {
  75. long ignoreXX;
  76. PS_WRITE_CHAR(10, out_3X, ignoreXX)
  77. }
  78. arg0K0 = (1 + i_4X);
  79. goto L401;
  80. }
  81. }
  82. L418 : {
  83. i_6X = arg0K0;
  84. result_7X = arg0K1;
  85. if ((5 == i_6X)) {
  86. ps_write_string(" vec-a[-1] = ", out_3X);
  87. ps_write_integer(result_7X, out_3X);
  88. {
  89. long ignoreXX;
  90. PS_WRITE_CHAR(10, out_3X, ignoreXX)
  91. }
  92. ps_write_string("Compute the sum of two vectors with vector-map:\n",
  93. out_3X);
  94. merged_arg0K0 = (*(Qvec_a + 0));
  95. merged_arg0K1 = (*(Qvec_a + 0));
  96. #ifdef USE_DIRECT_THREADING
  97. procD0_return_address = &&procD0_return_0;
  98. #else
  99. procD0_return_tag = 0;
  100. #endif
  101. goto procD0;
  102. procD0_return_0:
  103. v_8X = procD00_return_value;
  104. arg0K0 = 0;
  105. arg3K1 = ((long *)malloc(sizeof(long) * 5));
  106. goto L442;
  107. } else {
  108. arg0K0 = (1 + i_6X);
  109. arg0K1 = (*(Qvec_a + i_6X));
  110. goto L418;
  111. }
  112. }
  113. L442 : {
  114. i_9X = arg0K0;
  115. result_10X = arg3K1;
  116. if ((5 == i_9X)) {
  117. arg0K0 = 0;
  118. goto L468;
  119. } else {
  120. merged_arg0K0 = (*(Qvec_a + i_9X));
  121. merged_arg0K1 = (*(Qvec_a + i_9X));
  122. #ifdef USE_DIRECT_THREADING
  123. procD0_return_address = &&procD0_return_1;
  124. #else
  125. procD0_return_tag = 1;
  126. #endif
  127. goto procD0;
  128. procD0_return_1:
  129. v_11X = procD00_return_value;
  130. *(result_10X + i_9X) = v_11X;
  131. arg0K0 = (1 + i_9X);
  132. arg3K1 = result_10X;
  133. goto L442;
  134. }
  135. }
  136. L468 : {
  137. i_12X = arg0K0;
  138. if ((5 == i_12X)) {
  139. free(result_10X);
  140. ps_write_string("Build a vector of strings with vector-map:\n", out_3X);
  141. merged_arg0K0 = (*(Qvec_a + 0));
  142. #ifdef USE_DIRECT_THREADING
  143. procD1_return_address = &&procD1_return_0;
  144. #else
  145. procD1_return_tag = 0;
  146. #endif
  147. goto procD1;
  148. procD1_return_0:
  149. v_13X = procD10_return_value;
  150. arg0K0 = 0;
  151. arg2K1 = ((char **)malloc(sizeof(char *) * 5));
  152. goto L486;
  153. } else {
  154. val_14X = *(result_10X + i_12X);
  155. ps_write_string(" sums[", out_3X);
  156. ps_write_integer(i_12X, out_3X);
  157. ps_write_string("] = ", out_3X);
  158. ps_write_integer(val_14X, out_3X);
  159. {
  160. long ignoreXX;
  161. PS_WRITE_CHAR(10, out_3X, ignoreXX)
  162. }
  163. arg0K0 = (1 + i_12X);
  164. goto L468;
  165. }
  166. }
  167. L486 : {
  168. i_15X = arg0K0;
  169. result_16X = arg2K1;
  170. if ((5 == i_15X)) {
  171. arg0K0 = 0;
  172. goto L504;
  173. } else {
  174. merged_arg0K0 = (*(Qvec_a + i_15X));
  175. #ifdef USE_DIRECT_THREADING
  176. procD1_return_address = &&procD1_return_1;
  177. #else
  178. procD1_return_tag = 1;
  179. #endif
  180. goto procD1;
  181. procD1_return_1:
  182. v_17X = procD10_return_value;
  183. *(result_16X + i_15X) = v_17X;
  184. arg0K0 = (1 + i_15X);
  185. arg2K1 = result_16X;
  186. goto L486;
  187. }
  188. }
  189. L504 : {
  190. i_18X = arg0K0;
  191. if ((5 == i_18X)) {
  192. arg0K0 = 0;
  193. goto L520;
  194. } else {
  195. val_19X = *(result_16X + i_18X);
  196. ps_write_string(" strs[", out_3X);
  197. ps_write_integer(i_18X, out_3X);
  198. ps_write_string("] = \"", out_3X);
  199. ps_write_string(val_19X, out_3X);
  200. {
  201. long ignoreXX;
  202. PS_WRITE_CHAR(34, out_3X, ignoreXX)
  203. }
  204. {
  205. long ignoreXX;
  206. PS_WRITE_CHAR(10, out_3X, ignoreXX)
  207. }
  208. arg0K0 = (1 + i_18X);
  209. goto L504;
  210. }
  211. }
  212. L520 : {
  213. i_20X = arg0K0;
  214. if ((5 == i_20X)) {
  215. free(result_16X);
  216. return 0;
  217. } else {
  218. free((*(result_16X + i_20X)));
  219. arg0K0 = (1 + i_20X);
  220. goto L520;
  221. }
  222. }
  223. procD1 : {
  224. val_2X = merged_arg0K0;
  225. {
  226. len_21X = strlen((char *)"x");
  227. total_22X = len_21X * val_2X;
  228. target_23X = (char *)calloc(1, 1 + total_22X);
  229. arg0K0 = 0;
  230. goto L108;
  231. }
  232. L108 : {
  233. ix_24X = arg0K0;
  234. if ((ix_24X == total_22X)) {
  235. procD10_return_value = target_23X;
  236. #ifdef USE_DIRECT_THREADING
  237. goto *procD1_return_address;
  238. #else
  239. goto procD1_return;
  240. #endif
  241. } else {
  242. arg0K0 = ix_24X;
  243. arg0K1 = 0;
  244. goto L41;
  245. }
  246. }
  247. L41 : {
  248. tgt_25X = arg0K0;
  249. src_26X = arg0K1;
  250. if ((src_26X == len_21X)) {
  251. arg0K0 = (ix_24X + len_21X);
  252. goto L108;
  253. } else {
  254. *(target_23X + tgt_25X) = (*("x" + src_26X));
  255. arg0K0 = (1 + tgt_25X);
  256. arg0K1 = (1 + src_26X);
  257. goto L41;
  258. }
  259. }
  260. #ifndef USE_DIRECT_THREADING
  261. procD1_return:
  262. switch (procD1_return_tag) {
  263. case 0:
  264. goto procD1_return_0;
  265. default:
  266. goto procD1_return_1;
  267. }
  268. #endif
  269. }
  270. procD0 : {
  271. val1_0X = merged_arg0K0;
  272. val2_1X = merged_arg0K1;
  273. {
  274. procD00_return_value = (val1_0X + val2_1X);
  275. #ifdef USE_DIRECT_THREADING
  276. goto *procD0_return_address;
  277. #else
  278. goto procD0_return;
  279. #endif
  280. }
  281. #ifndef USE_DIRECT_THREADING
  282. procD0_return:
  283. switch (procD0_return_tag) {
  284. case 0:
  285. goto procD0_return_0;
  286. default:
  287. goto procD0_return_1;
  288. }
  289. #endif
  290. }
  291. }
  292. void ps_init(void) {
  293. Qvec_a = malloc(5 * sizeof(long));
  294. Qvec_a[0] = 0;
  295. Qvec_a[1] = 1;
  296. Qvec_a[2] = 4;
  297. Qvec_a[3] = 9;
  298. Qvec_a[4] = 16;
  299. }