Advertisement
hjalfi

fannkuch.cow (compiled)

Feb 9th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 28.95 KB | None | 0 0
  1. /* BEGIN cowbel runtime library
  2.  *
  3.  * Written in 2012 by David Given.
  4.  *
  5.  * To the extent possible under law, the author of the cowbel runtime
  6.  * library (of which this code, up to the string 'END cowbel runtime library',
  7.  * is part), has dedicated all copyright and related and neighboring rights
  8.  * to this software to the public domain worldwide. This software is
  9.  * distributed without any warranty.
  10.  *
  11.  * Please see the file COPYING.CC0 in the distribution package for more
  12.  * information.
  13.  */
  14.  
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <stdint.h>
  18. #include <stddef.h>
  19. #include <stdarg.h>
  20. #include <string.h>
  21.  
  22. typedef int s_boolean_t;
  23. typedef int s_int_t;
  24.  
  25. typedef struct s_string s_string_t;
  26. struct s_string
  27. {
  28.     s_string_t* prev;
  29.     s_string_t* next;
  30.     const char* data;
  31.     unsigned seglength;
  32.     unsigned totallength;
  33.     const char* cdata;
  34. };
  35.  
  36. typedef void s_string_traverse_cb(s_string_t* s, void* user);
  37.  
  38. static void s_string_traverse(s_string_t* s, s_string_traverse_cb* cb, void* user)
  39. {
  40.         if (s->prev)
  41.                 s_string_traverse(s->prev, cb, user);
  42.         cb(s, user);
  43.         if (s->next)
  44.                 s_string_traverse(s->next, cb, user);
  45. }
  46.  
  47. typedef struct s_array s_array_t;
  48. struct s_array
  49. {
  50.     unsigned length;
  51.     unsigned allocedlength;
  52.     unsigned itemsize;
  53.     char* data;
  54. };
  55.  
  56. #define S_ALLOC_CONSTRUCTOR(type) \
  57.     ((sizeof(type) > 0) ? ((type*) calloc(1, sizeof(type))) : NULL)
  58.  
  59. #define S_CONSTRUCT_CONSTANT_STRING(data) \
  60.     ((s_string_t
  61.  
  62. static void s_throw(const char* message)
  63. {
  64.     fflush(stdout);
  65.     fprintf(stderr, "Runtime error: %s\n", message);
  66.     exit(1);
  67. }
  68.  
  69. /* Boolean methods */
  70.  
  71. #define S_METHOD_BOOLEAN__NOT(b, z) (*z) = !(b)
  72. #define S_METHOD_BOOLEAN__OR(a, b, z) (*z) = (a) | (b)
  73.  
  74. /* Integer methods */
  75.  
  76. #define S_METHOD_INTEGER__ADD(a, b, z) (*z) = (a) + (b)
  77. #define S_METHOD_INTEGER__SUB(a, b, z) (*z) = (a) - (b)
  78. #define S_METHOD_INTEGER__MULTIPLY(a, b, z) (*z) = (a) * (b)
  79. #define S_METHOD_INTEGER__EQUALS(a, b, z) (*z) = (a) == (b)
  80. #define S_METHOD_INTEGER__NOTEQUALS(a, b, z) (*z) = (a) != (b)
  81. #define S_METHOD_INTEGER__GE(a, b, z) (*z) = (a) >= (b)
  82. #define S_METHOD_INTEGER__GT(a, b, z) (*z) = (a) > (b)
  83. #define S_METHOD_INTEGER__LE(a, b, z) (*z) = (a) <= (b)
  84. #define S_METHOD_INTEGER__LT(a, b, z) (*z) = (a) < (b)
  85.  
  86. static void S_METHOD_INTEGER_TOSTRING(int value, s_string_t** result)
  87. {
  88.     s_string_t* s = (s_string_t*) malloc(sizeof(s_string_t));
  89.     s->prev = s->next = NULL;
  90.  
  91.     char* buffer = (char*) malloc(32);
  92.     sprintf(buffer, "%d", value);
  93.  
  94.     s->data = s->cdata = buffer;
  95.     s->seglength = s->totallength = strlen(buffer);
  96.     *result = s;
  97. }
  98.  
  99. /* String methods */
  100.  
  101. static void s_method_string_print_cb(s_string_t* s, void* user)
  102. {
  103.     fwrite(s->data, 1, s->seglength, stdout);
  104. }
  105.  
  106. static void S_METHOD_STRING_PRINT(s_string_t* s)
  107. {
  108.     s_string_traverse(s, s_method_string_print_cb, NULL);
  109.     putchar('\n');
  110. }
  111.  
  112. static void S_METHOD_STRING__ADD(s_string_t* left, s_string_t* right,
  113.         s_string_t** result)
  114. {
  115.     s_string_t* newstring = (s_string_t*) malloc(sizeof(s_string_t));
  116.     newstring->prev = left;
  117.     newstring->next = right;
  118.     newstring->seglength = 0;
  119.     newstring->totallength = left->totallength + right->totallength;
  120.     newstring->data = newstring->cdata = NULL;
  121.     *result = newstring;
  122. }
  123.  
  124. static void S_METHOD_STRING__EQUALS(s_string_t* left, s_string_t* right,
  125.         s_boolean_t* result)
  126. {
  127.     int count;
  128.     const char* pleft = NULL;
  129.     int lseg = 0;
  130.     const char* pright = NULL;
  131.     int rseg = 0;
  132.  
  133.     if (left == right)
  134.         goto success;
  135.  
  136.     if (left->totallength != right->totallength)
  137.         goto fail;
  138.  
  139.     count = left->totallength;
  140.  
  141.     lseg = left->seglength;
  142.     pleft = left->data;
  143.  
  144.     rseg = right->seglength;
  145.     pright = right->data;
  146.  
  147.     while (count--)
  148.     {
  149.         while (lseg == 0)
  150.         {
  151.             left = left->next;
  152.             lseg = left->seglength;
  153.             pleft = left->data;
  154.         }
  155.  
  156.         while (rseg == 0)
  157.         {
  158.             right = right->next;
  159.             rseg = right->seglength;
  160.             pright = right->data;
  161.         }
  162.  
  163.         if (*pleft++ != *pright++)
  164.             goto fail;
  165.  
  166.         lseg--;
  167.         rseg--;
  168.     }
  169.  
  170. success:
  171.     *result = 1;
  172.     return;
  173.  
  174. fail:
  175.     *result = 0;
  176.     return;
  177. }
  178.  
  179. /* END cowbel runtime library */
  180. struct C0__main_;
  181. struct C1_get;
  182. struct C2_set;
  183. struct C3_get;
  184. struct C4_set;
  185. struct C5_Array;
  186. struct C6_Array;
  187. struct C7_fannkuch;
  188. struct C8_fannkuch;
  189. struct C9_fannkuch;
  190. struct C10_fannkuch;
  191. struct C11_fannkuch;
  192. struct C12_fannkuch;
  193. struct C13_fannkuch;
  194. struct C14_fannkuch;
  195. struct C15_fannkuch;
  196. struct C16_fannkuch;
  197. struct C17_fannkuch;
  198. struct C18_fannkuch;
  199. struct C19_fannkuch;
  200. struct C20_fannkuch;
  201. struct C21_fannkuch;
  202. struct C22_fannkuch;
  203. struct C23_Array;
  204. struct C24_Array;
  205. struct C25_Array;
  206. struct C26_Array;
  207. struct C27_get;
  208. struct C28_set;
  209. struct I0_32_interface32;
  210.  
  211. static void cowbel_main();
  212. static void f0_get(void* vc24_Array, s_int_t s0_i, s_int_t* s1_result);
  213. static void f2_set(void* vc24_Array, s_int_t s2_i, s_int_t s3_value);
  214. static void f4_get(void* vc26_Array, s_int_t s4_i, s_int_t* s5_result);
  215. static void f6_set(void* vc26_Array, s_int_t s6_i, s_int_t s7_value);
  216. static void f8_Array(void* vc0__main_, s_int_t s8_size, s_int_t s9_initialiser, struct I0_32_interface32** s10__return_2);
  217. static void f11_fannkuch(void* vc0__main_, s_int_t s11_n, s_int_t* s12_sum, s_int_t* s13_maxflips);
  218. static void f14_Array(void* vc0__main_, s_int_t s14_size, s_int_t s15_initialiser, struct I0_32_interface32** s16__return_2);
  219. static void f17_Array(void* vc0__main_, s_int_t s17_size, s_int_t s18_initialiser, struct I0_32_interface32** s19__return_2);
  220. static void f20_get(void* vc6_Array, s_int_t s20_i, s_int_t* s21_result);
  221. static void f22_set(void* vc6_Array, s_int_t s22_i, s_int_t s23_value);
  222.  
  223. static const char Ssc0__main_[] = {80, 102, 97, 110, 110, 107, 117, 99, 104, 101, 110, 40};
  224. static s_string_t sc0__main_ = { NULL, NULL, Ssc0__main_, 12, 12, NULL};
  225. static const char Ssc1__main_[] = {41, 32, 61, 32};
  226. static s_string_t sc1__main_ = { NULL, NULL, Ssc1__main_, 4, 4, NULL};
  227.  
  228. struct I0_32_interface32
  229. {
  230.     void* o;
  231.     void (*m0_21)(void*, s_int_t, s_int_t*);
  232.     void (*m1_20)(void*, s_int_t, s_int_t);
  233. };
  234.  
  235. struct C0__main_
  236. {
  237. };
  238.  
  239. struct C1_get
  240. {
  241.     struct C23_Array* c23_Array;
  242.     struct C24_Array* c24_Array;
  243. };
  244.  
  245. struct C2_set
  246. {
  247.     struct C23_Array* c23_Array;
  248.     struct C24_Array* c24_Array;
  249. };
  250.  
  251. struct C3_get
  252. {
  253.     struct C25_Array* c25_Array;
  254.     struct C26_Array* c26_Array;
  255. };
  256.  
  257. struct C4_set
  258. {
  259.     struct C25_Array* c25_Array;
  260.     struct C26_Array* c26_Array;
  261. };
  262.  
  263. struct C5_Array
  264. {
  265.     void* s24_ptr;
  266. };
  267.  
  268. struct C6_Array
  269. {
  270.     struct C5_Array* c5_Array;
  271.     struct I0_32_interface32 i1_32_interface32;
  272. };
  273.  
  274. struct C7_fannkuch
  275. {
  276.     struct C0__main_* c0__main_;
  277. };
  278.  
  279. struct C8_fannkuch
  280. {
  281.     struct C7_fannkuch* c7_fannkuch;
  282. };
  283.  
  284. struct C9_fannkuch
  285. {
  286.     struct C7_fannkuch* c7_fannkuch;
  287. };
  288.  
  289. struct C10_fannkuch
  290. {
  291.     struct C7_fannkuch* c7_fannkuch;
  292.     struct C9_fannkuch* c9_fannkuch;
  293. };
  294.  
  295. struct C11_fannkuch
  296. {
  297.     struct C7_fannkuch* c7_fannkuch;
  298.     struct C9_fannkuch* c9_fannkuch;
  299.     struct C10_fannkuch* c10_fannkuch;
  300. };
  301.  
  302. struct C12_fannkuch
  303. {
  304.     struct C7_fannkuch* c7_fannkuch;
  305.     struct C9_fannkuch* c9_fannkuch;
  306.     struct C10_fannkuch* c10_fannkuch;
  307. };
  308.  
  309. struct C13_fannkuch
  310. {
  311.     struct C7_fannkuch* c7_fannkuch;
  312.     struct C9_fannkuch* c9_fannkuch;
  313.     struct C10_fannkuch* c10_fannkuch;
  314.     struct C12_fannkuch* c12_fannkuch;
  315. };
  316.  
  317. struct C14_fannkuch
  318. {
  319.     struct C7_fannkuch* c7_fannkuch;
  320.     struct C9_fannkuch* c9_fannkuch;
  321.     struct C10_fannkuch* c10_fannkuch;
  322.     struct C12_fannkuch* c12_fannkuch;
  323.     struct C13_fannkuch* c13_fannkuch;
  324. };
  325.  
  326. struct C15_fannkuch
  327. {
  328.     struct C7_fannkuch* c7_fannkuch;
  329.     struct C9_fannkuch* c9_fannkuch;
  330.     struct C10_fannkuch* c10_fannkuch;
  331.     struct C12_fannkuch* c12_fannkuch;
  332. };
  333.  
  334. struct C16_fannkuch
  335. {
  336.     struct C7_fannkuch* c7_fannkuch;
  337.     struct C9_fannkuch* c9_fannkuch;
  338.     struct C10_fannkuch* c10_fannkuch;
  339.     struct C12_fannkuch* c12_fannkuch;
  340.     struct C15_fannkuch* c15_fannkuch;
  341. };
  342.  
  343. struct C17_fannkuch
  344. {
  345.     struct C7_fannkuch* c7_fannkuch;
  346.     struct C9_fannkuch* c9_fannkuch;
  347. };
  348.  
  349. struct C18_fannkuch
  350. {
  351.     struct C7_fannkuch* c7_fannkuch;
  352.     struct C9_fannkuch* c9_fannkuch;
  353. };
  354.  
  355. struct C19_fannkuch
  356. {
  357.     struct C7_fannkuch* c7_fannkuch;
  358.     struct C9_fannkuch* c9_fannkuch;
  359.     struct C18_fannkuch* c18_fannkuch;
  360. };
  361.  
  362. struct C20_fannkuch
  363. {
  364.     struct C7_fannkuch* c7_fannkuch;
  365.     struct C9_fannkuch* c9_fannkuch;
  366.     struct C18_fannkuch* c18_fannkuch;
  367.     struct C19_fannkuch* c19_fannkuch;
  368. };
  369.  
  370. struct C21_fannkuch
  371. {
  372. };
  373.  
  374. struct C22_fannkuch
  375. {
  376.     struct C7_fannkuch* c7_fannkuch;
  377.     struct C9_fannkuch* c9_fannkuch;
  378.     struct C18_fannkuch* c18_fannkuch;
  379.     struct C19_fannkuch* c19_fannkuch;
  380. };
  381.  
  382. struct C23_Array
  383. {
  384.     void* s25_ptr;
  385. };
  386.  
  387. struct C24_Array
  388. {
  389.     struct C23_Array* c23_Array;
  390.     struct I0_32_interface32 i1_32_interface32;
  391. };
  392.  
  393. struct C25_Array
  394. {
  395.     void* s26_ptr;
  396. };
  397.  
  398. struct C26_Array
  399. {
  400.     struct C25_Array* c25_Array;
  401.     struct I0_32_interface32 i1_32_interface32;
  402. };
  403.  
  404. struct C27_get
  405. {
  406.     struct C5_Array* c5_Array;
  407.     struct C6_Array* c6_Array;
  408. };
  409.  
  410. struct C28_set
  411. {
  412.     struct C5_Array* c5_Array;
  413.     struct C6_Array* c6_Array;
  414. };
  415.  
  416. static void cowbel_main()
  417. {
  418. B0__main_:;
  419.     struct C0__main_* c0__main_ = S_ALLOC_CONSTRUCTOR(struct C0__main_);
  420.     s_int_t s27_n;
  421.     s_int_t s28_sum;
  422.     s_int_t s29_maxflips;
  423.     s_int_t s30__temp_8;
  424.     s_int_t s31__temp_9;
  425.     s_int_t s32__temp_10;
  426.     s_string_t* s33__temp_11;
  427.     s_string_t* s34__temp_12;
  428.     s_string_t* s35__temp_13;
  429.     s_string_t* s36__temp_14;
  430.     s_string_t* s37__temp_15;
  431.     s_string_t* s38__temp_16;
  432.     s_string_t* s39__temp_17;
  433.     s_string_t* s40__temp_18;
  434.     s30__temp_8 = 11;
  435.     s27_n = s30__temp_8;
  436.     f11_fannkuch(c0__main_, s27_n, &s31__temp_9, &s32__temp_10);
  437.     s28_sum = s31__temp_9;
  438.     s29_maxflips = s32__temp_10;
  439.     S_METHOD_INTEGER_TOSTRING(s28_sum, &s33__temp_11);
  440.     S_METHOD_STRING_PRINT(s33__temp_11);
  441.     S_METHOD_INTEGER_TOSTRING(s29_maxflips, &s34__temp_12);
  442.     s35__temp_13 = &sc1__main_;
  443.     S_METHOD_INTEGER_TOSTRING(s27_n, &s36__temp_14);
  444.     s37__temp_15 = &sc0__main_;
  445.     S_METHOD_STRING__ADD(s37__temp_15, s36__temp_14, &s38__temp_16);
  446.     S_METHOD_STRING__ADD(s38__temp_16, s35__temp_13, &s39__temp_17);
  447.     S_METHOD_STRING__ADD(s39__temp_17, s34__temp_12, &s40__temp_18);
  448.     S_METHOD_STRING_PRINT(s40__temp_18);
  449.     goto B1__main_;
  450. B1__main_:;
  451.     return;
  452. }
  453.  
  454. static void f0_get(void* vc24_Array, s_int_t s0_i, s_int_t* s1_result)
  455. {
  456.     struct C24_Array* c24_Array = vc24_Array;
  457. B2_get:;
  458.     struct C1_get f0_storage;
  459.     struct C1_get* c1_get =  &f0_storage;
  460.     c1_get->c23_Array = c24_Array->c23_Array;
  461.     c1_get->c24_Array = c24_Array;
  462. *s1_result = ((typeof(*s1_result)*)c1_get->c23_Array->s25_ptr)[s0_i];
  463.     goto B3_get;
  464. B3_get:;
  465.     return;
  466. }
  467.  
  468. static void f2_set(void* vc24_Array, s_int_t s2_i, s_int_t s3_value)
  469. {
  470.     struct C24_Array* c24_Array = vc24_Array;
  471. B4_set:;
  472.     struct C2_set f0_storage;
  473.     struct C2_set* c2_set =  &f0_storage;
  474.     c2_set->c23_Array = c24_Array->c23_Array;
  475.     c2_set->c24_Array = c24_Array;
  476. ((typeof(s3_value)*)c2_set->c23_Array->s25_ptr)[s2_i] = s3_value;
  477.     goto B5_set;
  478. B5_set:;
  479.     return;
  480. }
  481.  
  482. static void f4_get(void* vc26_Array, s_int_t s4_i, s_int_t* s5_result)
  483. {
  484.     struct C26_Array* c26_Array = vc26_Array;
  485. B6_get:;
  486.     struct C3_get f0_storage;
  487.     struct C3_get* c3_get =  &f0_storage;
  488.     c3_get->c25_Array = c26_Array->c25_Array;
  489.     c3_get->c26_Array = c26_Array;
  490. *s5_result = ((typeof(*s5_result)*)c3_get->c25_Array->s26_ptr)[s4_i];
  491.     goto B7_get;
  492. B7_get:;
  493.     return;
  494. }
  495.  
  496. static void f6_set(void* vc26_Array, s_int_t s6_i, s_int_t s7_value)
  497. {
  498.     struct C26_Array* c26_Array = vc26_Array;
  499. B8_set:;
  500.     struct C4_set f0_storage;
  501.     struct C4_set* c4_set =  &f0_storage;
  502.     c4_set->c25_Array = c26_Array->c25_Array;
  503.     c4_set->c26_Array = c26_Array;
  504. ((typeof(s7_value)*)c4_set->c25_Array->s26_ptr)[s6_i] = s7_value;
  505.     goto B9_set;
  506. B9_set:;
  507.     return;
  508. }
  509.  
  510. static void f8_Array(void* vc0__main_, s_int_t s8_size, s_int_t s9_initialiser, struct I0_32_interface32** s10__return_2)
  511. {
  512.     struct C0__main_* c0__main_ = vc0__main_;
  513. B10_Array:;
  514.     struct C5_Array* c5_Array = S_ALLOC_CONSTRUCTOR(struct C5_Array);
  515.     s_int_t s41__temp_19;
  516.     void* s42__temp_20;
  517.     struct C6_Array* s43__temp_21;
  518.     struct I0_32_interface32* s44__temp_22;
  519.     s41__temp_19 = 0;
  520.     c5_Array->s24_ptr = s42__temp_20;
  521. c5_Array->s24_ptr = calloc(s8_size, sizeof(s9_initialiser));
  522.     struct C6_Array* c6_Array = S_ALLOC_CONSTRUCTOR(struct C6_Array);
  523.     c6_Array->c5_Array = c5_Array;
  524.     c6_Array->i1_32_interface32.o = c6_Array;
  525.     c6_Array->i1_32_interface32.m0_21 = f20_get;
  526.     c6_Array->i1_32_interface32.m1_20 = f22_set;
  527.     s43__temp_21 = c6_Array;
  528.     s44__temp_22 = &s43__temp_21->i1_32_interface32;
  529.     *s10__return_2 = s44__temp_22;
  530.     goto B11_Array;
  531. B11_Array:;
  532.     return;
  533. }
  534.  
  535. static void f11_fannkuch(void* vc0__main_, s_int_t s11_n, s_int_t* s12_sum, s_int_t* s13_maxflips)
  536. {
  537.     struct C0__main_* c0__main_ = vc0__main_;
  538. B12_fannkuch:;
  539.     struct C7_fannkuch f0_storage;
  540.     struct C7_fannkuch* c7_fannkuch =  &f0_storage;
  541.     c7_fannkuch->c0__main_ = c0__main_;
  542.     struct I0_32_interface32* s45_p;
  543.     struct I0_32_interface32* s46_q;
  544.     struct I0_32_interface32* s47_s;
  545.     s_int_t s48_sign;
  546.     s_int_t s49_m;
  547.     s_int_t s50__loop_counter_for_i_4;
  548.     s_int_t s51__temp_23;
  549.     struct I0_32_interface32* s52__temp_24;
  550.     s_int_t s53__temp_25;
  551.     struct I0_32_interface32* s54__temp_26;
  552.     s_int_t s55__temp_27;
  553.     struct I0_32_interface32* s56__temp_28;
  554.     s_int_t s57__temp_29;
  555.     s_int_t s58__temp_30;
  556.     s_int_t s59__temp_31;
  557.     s_int_t s60__temp_32;
  558.     s_int_t s61__temp_33;
  559.     s_int_t s62__temp_34;
  560.     s_boolean_t s63__temp_35;
  561.     s_boolean_t s64__temp_108;
  562.     s51__temp_23 = 0;
  563.     f8_Array(c7_fannkuch->c0__main_, s11_n, s51__temp_23, &s52__temp_24);
  564.     s45_p = s52__temp_24;
  565.     s53__temp_25 = 0;
  566.     f14_Array(c7_fannkuch->c0__main_, s11_n, s53__temp_25, &s54__temp_26);
  567.     s46_q = s54__temp_26;
  568.     s55__temp_27 = 0;
  569.     f17_Array(c7_fannkuch->c0__main_, s11_n, s55__temp_27, &s56__temp_28);
  570.     s47_s = s56__temp_28;
  571.     s57__temp_29 = 1;
  572.     s48_sign = s57__temp_29;
  573.     s58__temp_30 = 0;
  574.     *s13_maxflips = s58__temp_30;
  575.     s59__temp_31 = 0;
  576.     *s12_sum = s59__temp_31;
  577.     s60__temp_32 = 1;
  578.     S_METHOD_INTEGER__SUB(s11_n, s60__temp_32, &s61__temp_33);
  579.     s49_m = s61__temp_33;
  580.     s62__temp_34 = 0;
  581.     s50__loop_counter_for_i_4 = s62__temp_34;
  582.     goto B13_fannkuch;
  583. B13_fannkuch:;
  584.     S_METHOD_INTEGER__NOTEQUALS(s50__loop_counter_for_i_4, s11_n, &s63__temp_35);
  585.     if (s63__temp_35) goto B14_fannkuch; else goto B15_fannkuch;
  586. B15_fannkuch:;
  587.     goto B16_fannkuch;
  588. B14_fannkuch:;
  589.     struct C8_fannkuch f1_storage;
  590.     struct C8_fannkuch* c8_fannkuch =  &f1_storage;
  591.     c8_fannkuch->c7_fannkuch = c7_fannkuch;
  592.     s_int_t s65_i;
  593.     s_int_t s66__temp_36;
  594.     s_int_t s67__temp_37;
  595.     s65_i = s50__loop_counter_for_i_4;
  596.     s45_p->m1_20(s45_p->o, s65_i, s65_i);
  597.     s46_q->m1_20(s46_q->o, s65_i, s65_i);
  598.     s47_s->m1_20(s47_s->o, s65_i, s65_i);
  599.     s66__temp_36 = 1;
  600.     S_METHOD_INTEGER__ADD(s50__loop_counter_for_i_4, s66__temp_36, &s67__temp_37);
  601.     s50__loop_counter_for_i_4 = s67__temp_37;
  602.     goto B13_fannkuch;
  603. B16_fannkuch:;
  604.     struct C9_fannkuch f2_storage;
  605.     struct C9_fannkuch* c9_fannkuch =  &f2_storage;
  606.     c9_fannkuch->c7_fannkuch = c7_fannkuch;
  607.     s_int_t s68_q0;
  608.     s_int_t s69__temp_38;
  609.     s_int_t s70__temp_39;
  610.     s_int_t s71__temp_40;
  611.     s_boolean_t s72__temp_41;
  612.     s_int_t s73__temp_69;
  613.     s_boolean_t s74__temp_70;
  614.     s69__temp_38 = 0;
  615.     s45_p->m0_21(s45_p->o, s69__temp_38, &s70__temp_39);
  616.     s68_q0 = s70__temp_39;
  617.     s71__temp_40 = 0;
  618.     S_METHOD_INTEGER__NOTEQUALS(s68_q0, s71__temp_40, &s72__temp_41);
  619.     if (s72__temp_41) goto B17_fannkuch; else goto B18_fannkuch;
  620. B17_fannkuch:;
  621.     struct C10_fannkuch f3_storage;
  622.     struct C10_fannkuch* c10_fannkuch =  &f3_storage;
  623.     c10_fannkuch->c7_fannkuch = c7_fannkuch;
  624.     c10_fannkuch->c9_fannkuch = c9_fannkuch;
  625.     s_int_t s75__loop_counter_for_i_5;
  626.     s_int_t s76_flips;
  627.     s_int_t s77__temp_42;
  628.     s_boolean_t s78__temp_43;
  629.     s_int_t s79__temp_47;
  630.     s_boolean_t s80__temp_68;
  631.     s77__temp_42 = 1;
  632.     s75__loop_counter_for_i_5 = s77__temp_42;
  633.     goto B19_fannkuch;
  634. B18_fannkuch:;
  635.     s73__temp_69 = 1;
  636.     S_METHOD_INTEGER__EQUALS(s48_sign, s73__temp_69, &s74__temp_70);
  637.     if (s74__temp_70) goto B20_fannkuch; else goto B21_fannkuch;
  638. B19_fannkuch:;
  639.     S_METHOD_INTEGER__NOTEQUALS(s75__loop_counter_for_i_5, s11_n, &s78__temp_43);
  640.     if (s78__temp_43) goto B22_fannkuch; else goto B23_fannkuch;
  641. B23_fannkuch:;
  642.     s79__temp_47 = 1;
  643.     s76_flips = s79__temp_47;
  644.     goto B24_fannkuch;
  645. B22_fannkuch:;
  646.     struct C11_fannkuch f4_storage;
  647.     struct C11_fannkuch* c11_fannkuch =  &f4_storage;
  648.     c11_fannkuch->c7_fannkuch = c7_fannkuch;
  649.     c11_fannkuch->c9_fannkuch = c9_fannkuch;
  650.     c11_fannkuch->c10_fannkuch = c10_fannkuch;
  651.     s_int_t s81_i;
  652.     s_int_t s82__temp_44;
  653.     s_int_t s83__temp_45;
  654.     s_int_t s84__temp_46;
  655.     s81_i = s75__loop_counter_for_i_5;
  656.     s45_p->m0_21(s45_p->o, s81_i, &s82__temp_44);
  657.     s46_q->m1_20(s46_q->o, s81_i, s82__temp_44);
  658.     s83__temp_45 = 1;
  659.     S_METHOD_INTEGER__ADD(s75__loop_counter_for_i_5, s83__temp_45, &s84__temp_46);
  660.     s75__loop_counter_for_i_5 = s84__temp_46;
  661.     goto B19_fannkuch;
  662. B24_fannkuch:;
  663.     struct C12_fannkuch f5_storage;
  664.     struct C12_fannkuch* c12_fannkuch =  &f5_storage;
  665.     c12_fannkuch->c7_fannkuch = c7_fannkuch;
  666.     c12_fannkuch->c9_fannkuch = c9_fannkuch;
  667.     c12_fannkuch->c10_fannkuch = c10_fannkuch;
  668.     s_int_t s85_qq;
  669.     s_int_t s86__temp_48;
  670.     s_int_t s87__temp_49;
  671.     s_boolean_t s88__temp_50;
  672.     s_int_t s89__temp_54;
  673.     s_boolean_t s90__temp_55;
  674.     s_int_t s91__temp_66;
  675.     s_int_t s92__temp_67;
  676.     s46_q->m0_21(s46_q->o, s68_q0, &s86__temp_48);
  677.     s85_qq = s86__temp_48;
  678.     s87__temp_49 = 0;
  679.     S_METHOD_INTEGER__EQUALS(s85_qq, s87__temp_49, &s88__temp_50);
  680.     if (s88__temp_50) goto B25_fannkuch; else goto B26_fannkuch;
  681. B25_fannkuch:;
  682.     struct C13_fannkuch f6_storage;
  683.     struct C13_fannkuch* c13_fannkuch =  &f6_storage;
  684.     c13_fannkuch->c7_fannkuch = c7_fannkuch;
  685.     c13_fannkuch->c9_fannkuch = c9_fannkuch;
  686.     c13_fannkuch->c10_fannkuch = c10_fannkuch;
  687.     c13_fannkuch->c12_fannkuch = c12_fannkuch;
  688.     s_int_t s93__temp_51;
  689.     s_int_t s94__temp_52;
  690.     s_boolean_t s95__temp_53;
  691.     S_METHOD_INTEGER__MULTIPLY(s48_sign, s76_flips, &s93__temp_51);
  692.     S_METHOD_INTEGER__ADD(*s12_sum, s93__temp_51, &s94__temp_52);
  693.     *s12_sum = s94__temp_52;
  694.     S_METHOD_INTEGER__GT(s76_flips, *s13_maxflips, &s95__temp_53);
  695.     if (s95__temp_53) goto B27_fannkuch; else goto B28_fannkuch;
  696. B26_fannkuch:;
  697.     s46_q->m1_20(s46_q->o, s68_q0, s68_q0);
  698.     s89__temp_54 = 3;
  699.     S_METHOD_INTEGER__GE(s68_q0, s89__temp_54, &s90__temp_55);
  700.     if (s90__temp_55) goto B29_fannkuch; else goto B30_fannkuch;
  701. B27_fannkuch:;
  702.     struct C14_fannkuch f7_storage;
  703.     struct C14_fannkuch* c14_fannkuch =  &f7_storage;
  704.     c14_fannkuch->c7_fannkuch = c7_fannkuch;
  705.     c14_fannkuch->c9_fannkuch = c9_fannkuch;
  706.     c14_fannkuch->c10_fannkuch = c10_fannkuch;
  707.     c14_fannkuch->c12_fannkuch = c12_fannkuch;
  708.     c14_fannkuch->c13_fannkuch = c13_fannkuch;
  709.     *s13_maxflips = s76_flips;
  710.     goto B28_fannkuch;
  711. B28_fannkuch:;
  712.     goto B31_fannkuch;
  713. B31_fannkuch:;
  714.     goto B18_fannkuch;
  715. B29_fannkuch:;
  716.     struct C15_fannkuch f8_storage;
  717.     struct C15_fannkuch* c15_fannkuch =  &f8_storage;
  718.     c15_fannkuch->c7_fannkuch = c7_fannkuch;
  719.     c15_fannkuch->c9_fannkuch = c9_fannkuch;
  720.     c15_fannkuch->c10_fannkuch = c10_fannkuch;
  721.     c15_fannkuch->c12_fannkuch = c12_fannkuch;
  722.     s_int_t s96_i;
  723.     s_int_t s97_j;
  724.     s_int_t s98__temp_56;
  725.     s_int_t s99__temp_57;
  726.     s_int_t s100__temp_58;
  727.     s_boolean_t s101__temp_65;
  728.     s98__temp_56 = 1;
  729.     s96_i = s98__temp_56;
  730.     s99__temp_57 = 1;
  731.     S_METHOD_INTEGER__SUB(s68_q0, s99__temp_57, &s100__temp_58);
  732.     s97_j = s100__temp_58;
  733.     goto B32_fannkuch;
  734. B30_fannkuch:;
  735.     s68_q0 = s85_qq;
  736.     s91__temp_66 = 1;
  737.     S_METHOD_INTEGER__ADD(s76_flips, s91__temp_66, &s92__temp_67);
  738.     s76_flips = s92__temp_67;
  739.     s80__temp_68 = 1;
  740.     if (s80__temp_68) goto B24_fannkuch; else goto B31_fannkuch;
  741. B32_fannkuch:;
  742.     struct C16_fannkuch f9_storage;
  743.     struct C16_fannkuch* c16_fannkuch =  &f9_storage;
  744.     c16_fannkuch->c7_fannkuch = c7_fannkuch;
  745.     c16_fannkuch->c9_fannkuch = c9_fannkuch;
  746.     c16_fannkuch->c10_fannkuch = c10_fannkuch;
  747.     c16_fannkuch->c12_fannkuch = c12_fannkuch;
  748.     c16_fannkuch->c15_fannkuch = c15_fannkuch;
  749.     s_int_t s102_t;
  750.     s_int_t s103__temp_59;
  751.     s_int_t s104__temp_60;
  752.     s_int_t s105__temp_61;
  753.     s_int_t s106__temp_62;
  754.     s_int_t s107__temp_63;
  755.     s_int_t s108__temp_64;
  756.     s46_q->m0_21(s46_q->o, s96_i, &s103__temp_59);
  757.     s102_t = s103__temp_59;
  758.     s46_q->m0_21(s46_q->o, s97_j, &s104__temp_60);
  759.     s46_q->m1_20(s46_q->o, s96_i, s104__temp_60);
  760.     s46_q->m1_20(s46_q->o, s97_j, s102_t);
  761.     s105__temp_61 = 1;
  762.     S_METHOD_INTEGER__ADD(s96_i, s105__temp_61, &s106__temp_62);
  763.     s96_i = s106__temp_62;
  764.     s107__temp_63 = 1;
  765.     S_METHOD_INTEGER__SUB(s97_j, s107__temp_63, &s108__temp_64);
  766.     s97_j = s108__temp_64;
  767.     S_METHOD_INTEGER__LT(s96_i, s97_j, &s101__temp_65);
  768.     if (s101__temp_65) goto B32_fannkuch; else goto B33_fannkuch;
  769. B33_fannkuch:;
  770.     goto B30_fannkuch;
  771. B20_fannkuch:;
  772.     struct C17_fannkuch f10_storage;
  773.     struct C17_fannkuch* c17_fannkuch =  &f10_storage;
  774.     c17_fannkuch->c7_fannkuch = c7_fannkuch;
  775.     c17_fannkuch->c9_fannkuch = c9_fannkuch;
  776.     s_int_t s109_t;
  777.     s_int_t s110__temp_71;
  778.     s_int_t s111__temp_72;
  779.     s_int_t s112__temp_73;
  780.     s_int_t s113__temp_74;
  781.     s_int_t s114__temp_75;
  782.     s_int_t s115__temp_76;
  783.     s_int_t s116__temp_77;
  784.     s110__temp_71 = 1;
  785.     s45_p->m0_21(s45_p->o, s110__temp_71, &s111__temp_72);
  786.     s109_t = s111__temp_72;
  787.     s112__temp_73 = 1;
  788.     s113__temp_74 = 0;
  789.     s45_p->m0_21(s45_p->o, s113__temp_74, &s114__temp_75);
  790.     s45_p->m1_20(s45_p->o, s112__temp_73, s114__temp_75);
  791.     s115__temp_76 = 0;
  792.     s45_p->m1_20(s45_p->o, s115__temp_76, s109_t);
  793.     s116__temp_77 = -1;
  794.     s48_sign = s116__temp_77;
  795.     goto B34_fannkuch;
  796. B21_fannkuch:;
  797.     struct C18_fannkuch f11_storage;
  798.     struct C18_fannkuch* c18_fannkuch =  &f11_storage;
  799.     c18_fannkuch->c7_fannkuch = c7_fannkuch;
  800.     c18_fannkuch->c9_fannkuch = c9_fannkuch;
  801.     s_int_t s117_t;
  802.     s_int_t s118__loop_counter_for_i_7;
  803.     s_int_t s119__temp_78;
  804.     s_int_t s120__temp_79;
  805.     s_int_t s121__temp_80;
  806.     s_int_t s122__temp_81;
  807.     s_int_t s123__temp_82;
  808.     s_int_t s124__temp_83;
  809.     s_int_t s125__temp_84;
  810.     s_int_t s126__temp_85;
  811.     s_boolean_t s127__temp_86;
  812.     s119__temp_78 = 1;
  813.     s45_p->m0_21(s45_p->o, s119__temp_78, &s120__temp_79);
  814.     s117_t = s120__temp_79;
  815.     s121__temp_80 = 1;
  816.     s122__temp_81 = 2;
  817.     s45_p->m0_21(s45_p->o, s122__temp_81, &s123__temp_82);
  818.     s45_p->m1_20(s45_p->o, s121__temp_80, s123__temp_82);
  819.     s124__temp_83 = 2;
  820.     s45_p->m1_20(s45_p->o, s124__temp_83, s117_t);
  821.     s125__temp_84 = 1;
  822.     s48_sign = s125__temp_84;
  823.     s126__temp_85 = 2;
  824.     s118__loop_counter_for_i_7 = s126__temp_85;
  825.     goto B35_fannkuch;
  826. B34_fannkuch:;
  827.     s64__temp_108 = 1;
  828.     if (s64__temp_108) goto B16_fannkuch; else goto B36_fannkuch;
  829. B36_fannkuch:;
  830.     goto B37_fannkuch;
  831. B37_fannkuch:;
  832.     return;
  833. B35_fannkuch:;
  834.     S_METHOD_INTEGER__NOTEQUALS(s118__loop_counter_for_i_7, s11_n, &s127__temp_86);
  835.     if (s127__temp_86) goto B38_fannkuch; else goto B39_fannkuch;
  836. B39_fannkuch:;
  837.     goto B34_fannkuch;
  838. B38_fannkuch:;
  839.     struct C19_fannkuch f12_storage;
  840.     struct C19_fannkuch* c19_fannkuch =  &f12_storage;
  841.     c19_fannkuch->c7_fannkuch = c7_fannkuch;
  842.     c19_fannkuch->c9_fannkuch = c9_fannkuch;
  843.     c19_fannkuch->c18_fannkuch = c18_fannkuch;
  844.     s_int_t s128_i;
  845.     s_int_t s129_sx;
  846.     s_int_t s130__loop_counter_for_j_6;
  847.     s_int_t s131__temp_87;
  848.     s_int_t s132__temp_88;
  849.     s_boolean_t s133__temp_89;
  850.     s_boolean_t s134__temp_92;
  851.     s_int_t s135__temp_93;
  852.     s_int_t s136__temp_94;
  853.     s_int_t s137__temp_95;
  854.     s_int_t s138__temp_96;
  855.     s_int_t s139__temp_97;
  856.     s_boolean_t s140__temp_98;
  857.     s_int_t s141__temp_104;
  858.     s_int_t s142__temp_105;
  859.     s_int_t s143__temp_106;
  860.     s_int_t s144__temp_107;
  861.     s128_i = s118__loop_counter_for_i_7;
  862.     s47_s->m0_21(s47_s->o, s128_i, &s131__temp_87);
  863.     s129_sx = s131__temp_87;
  864.     s132__temp_88 = 0;
  865.     S_METHOD_INTEGER__NOTEQUALS(s129_sx, s132__temp_88, &s133__temp_89);
  866.     if (s133__temp_89) goto B40_fannkuch; else goto B41_fannkuch;
  867. B40_fannkuch:;
  868.     struct C20_fannkuch f13_storage;
  869.     struct C20_fannkuch* c20_fannkuch =  &f13_storage;
  870.     c20_fannkuch->c7_fannkuch = c7_fannkuch;
  871.     c20_fannkuch->c9_fannkuch = c9_fannkuch;
  872.     c20_fannkuch->c18_fannkuch = c18_fannkuch;
  873.     c20_fannkuch->c19_fannkuch = c19_fannkuch;
  874.     s_int_t s145__temp_90;
  875.     s_int_t s146__temp_91;
  876.     s145__temp_90 = 1;
  877.     S_METHOD_INTEGER__SUB(s129_sx, s145__temp_90, &s146__temp_91);
  878.     s47_s->m1_20(s47_s->o, s128_i, s146__temp_91);
  879.     goto B39_fannkuch;
  880. B41_fannkuch:;
  881.     S_METHOD_INTEGER__EQUALS(s128_i, s49_m, &s134__temp_92);
  882.     if (s134__temp_92) goto B42_fannkuch; else goto B43_fannkuch;
  883. B42_fannkuch:;
  884.     struct C21_fannkuch f14_storage;
  885.     struct C21_fannkuch* c21_fannkuch =  &f14_storage;
  886.     goto B37_fannkuch;
  887. B43_fannkuch:;
  888.     s47_s->m1_20(s47_s->o, s128_i, s128_i);
  889.     s135__temp_93 = 0;
  890.     s45_p->m0_21(s45_p->o, s135__temp_93, &s136__temp_94);
  891.     s117_t = s136__temp_94;
  892.     s137__temp_95 = 0;
  893.     s130__loop_counter_for_j_6 = s137__temp_95;
  894.     goto B44_fannkuch;
  895. B44_fannkuch:;
  896.     s138__temp_96 = 1;
  897.     S_METHOD_INTEGER__ADD(s128_i, s138__temp_96, &s139__temp_97);
  898.     S_METHOD_INTEGER__NOTEQUALS(s130__loop_counter_for_j_6, s139__temp_97, &s140__temp_98);
  899.     if (s140__temp_98) goto B45_fannkuch; else goto B46_fannkuch;
  900. B46_fannkuch:;
  901.     s141__temp_104 = 1;
  902.     S_METHOD_INTEGER__ADD(s128_i, s141__temp_104, &s142__temp_105);
  903.     s45_p->m1_20(s45_p->o, s142__temp_105, s117_t);
  904.     s143__temp_106 = 1;
  905.     S_METHOD_INTEGER__ADD(s118__loop_counter_for_i_7, s143__temp_106, &s144__temp_107);
  906.     s118__loop_counter_for_i_7 = s144__temp_107;
  907.     goto B35_fannkuch;
  908. B45_fannkuch:;
  909.     struct C22_fannkuch f15_storage;
  910.     struct C22_fannkuch* c22_fannkuch =  &f15_storage;
  911.     c22_fannkuch->c7_fannkuch = c7_fannkuch;
  912.     c22_fannkuch->c9_fannkuch = c9_fannkuch;
  913.     c22_fannkuch->c18_fannkuch = c18_fannkuch;
  914.     c22_fannkuch->c19_fannkuch = c19_fannkuch;
  915.     s_int_t s147_j;
  916.     s_int_t s148__temp_99;
  917.     s_int_t s149__temp_100;
  918.     s_int_t s150__temp_101;
  919.     s_int_t s151__temp_102;
  920.     s_int_t s152__temp_103;
  921.     s147_j = s130__loop_counter_for_j_6;
  922.     s148__temp_99 = 1;
  923.     S_METHOD_INTEGER__ADD(s147_j, s148__temp_99, &s149__temp_100);
  924.     s45_p->m0_21(s45_p->o, s149__temp_100, &s150__temp_101);
  925.     s45_p->m1_20(s45_p->o, s147_j, s150__temp_101);
  926.     s151__temp_102 = 1;
  927.     S_METHOD_INTEGER__ADD(s130__loop_counter_for_j_6, s151__temp_102, &s152__temp_103);
  928.     s130__loop_counter_for_j_6 = s152__temp_103;
  929.     goto B44_fannkuch;
  930. }
  931.  
  932. static void f14_Array(void* vc0__main_, s_int_t s14_size, s_int_t s15_initialiser, struct I0_32_interface32** s16__return_2)
  933. {
  934.     struct C0__main_* c0__main_ = vc0__main_;
  935. B47_Array:;
  936.     struct C23_Array* c23_Array = S_ALLOC_CONSTRUCTOR(struct C23_Array);
  937.     s_int_t s153__temp_109;
  938.     void* s154__temp_110;
  939.     struct C24_Array* s155__temp_111;
  940.     struct I0_32_interface32* s156__temp_112;
  941.     s153__temp_109 = 0;
  942.     c23_Array->s25_ptr = s154__temp_110;
  943. c23_Array->s25_ptr = calloc(s14_size, sizeof(s15_initialiser));
  944.     struct C24_Array* c24_Array = S_ALLOC_CONSTRUCTOR(struct C24_Array);
  945.     c24_Array->c23_Array = c23_Array;
  946.     c24_Array->i1_32_interface32.o = c24_Array;
  947.     c24_Array->i1_32_interface32.m0_21 = f0_get;
  948.     c24_Array->i1_32_interface32.m1_20 = f2_set;
  949.     s155__temp_111 = c24_Array;
  950.     s156__temp_112 = &s155__temp_111->i1_32_interface32;
  951.     *s16__return_2 = s156__temp_112;
  952.     goto B48_Array;
  953. B48_Array:;
  954.     return;
  955. }
  956.  
  957. static void f17_Array(void* vc0__main_, s_int_t s17_size, s_int_t s18_initialiser, struct I0_32_interface32** s19__return_2)
  958. {
  959.     struct C0__main_* c0__main_ = vc0__main_;
  960. B49_Array:;
  961.     struct C25_Array* c25_Array = S_ALLOC_CONSTRUCTOR(struct C25_Array);
  962.     s_int_t s157__temp_113;
  963.     void* s158__temp_114;
  964.     struct C26_Array* s159__temp_115;
  965.     struct I0_32_interface32* s160__temp_116;
  966.     s157__temp_113 = 0;
  967.     c25_Array->s26_ptr = s158__temp_114;
  968. c25_Array->s26_ptr = calloc(s17_size, sizeof(s18_initialiser));
  969.     struct C26_Array* c26_Array = S_ALLOC_CONSTRUCTOR(struct C26_Array);
  970.     c26_Array->c25_Array = c25_Array;
  971.     c26_Array->i1_32_interface32.o = c26_Array;
  972.     c26_Array->i1_32_interface32.m0_21 = f4_get;
  973.     c26_Array->i1_32_interface32.m1_20 = f6_set;
  974.     s159__temp_115 = c26_Array;
  975.     s160__temp_116 = &s159__temp_115->i1_32_interface32;
  976.     *s19__return_2 = s160__temp_116;
  977.     goto B50_Array;
  978. B50_Array:;
  979.     return;
  980. }
  981.  
  982. static void f20_get(void* vc6_Array, s_int_t s20_i, s_int_t* s21_result)
  983. {
  984.     struct C6_Array* c6_Array = vc6_Array;
  985. B51_get:;
  986.     struct C27_get f0_storage;
  987.     struct C27_get* c27_get =  &f0_storage;
  988.     c27_get->c5_Array = c6_Array->c5_Array;
  989.     c27_get->c6_Array = c6_Array;
  990. *s21_result = ((typeof(*s21_result)*)c27_get->c5_Array->s24_ptr)[s20_i];
  991.     goto B52_get;
  992. B52_get:;
  993.     return;
  994. }
  995.  
  996. static void f22_set(void* vc6_Array, s_int_t s22_i, s_int_t s23_value)
  997. {
  998.     struct C6_Array* c6_Array = vc6_Array;
  999. B53_set:;
  1000.     struct C28_set f0_storage;
  1001.     struct C28_set* c28_set =  &f0_storage;
  1002.     c28_set->c5_Array = c6_Array->c5_Array;
  1003.     c28_set->c6_Array = c6_Array;
  1004. ((typeof(s23_value)*)c28_set->c5_Array->s24_ptr)[s22_i] = s23_value;
  1005.     goto B54_set;
  1006. B54_set:;
  1007.     return;
  1008. }
  1009.  
  1010. /* BEGIN cowbel runtime library
  1011.  *
  1012.  * Written in 2012 by David Given.
  1013.  *
  1014.  * To the extent possible under law, the author of the cowbel runtime
  1015.  * library (of which this code, up to the string 'END cowbel runtime library',
  1016.  * is part), has dedicated all copyright and related and neighboring rights
  1017.  * to this software to the public domain worldwide. This software is
  1018.  * distributed without any warranty.
  1019.  *
  1020.  * Please see the file COPYING.CC0 in the distribution package for more
  1021.  * information.
  1022.  */
  1023.  
  1024. int main(int argc, const char* argv[])
  1025. {
  1026.     cowbel_main();
  1027.     return 0;
  1028. }
  1029.  
  1030. /* END cowbel runtime library */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement