aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/lustrev6-convertible/convertible_main.c
blob: 19bc40b93d419f4bbe57013ce3d64e64dadb57db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
/* This file was generated by lus2lic version master.668 (35901e970a0c377cc36d6437dcbc61beb8001b54). */
/*  lus2lic -2c convertible.lus -n main */
/* on ovaz the 27/10/2016 at 11:39:07 */
#include "convertible_main.h"
//// Defining step functions
// Memory initialisation for Lustre_arrow_4_ctx
void Lustre_arrow_4_ctx_reset(Lustre_arrow_4_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}
// Memory allocation for Lustre_arrow_4_ctx
Lustre_arrow_4_ctx_type* Lustre_arrow_4_ctx_new_ctx(){

   Lustre_arrow_4_ctx_type* ctx = (Lustre_arrow_4_ctx_type*)calloc(1, sizeof(Lustre_arrow_4_ctx_type));
   // ctx->client_data = cdata;
   Lustre_arrow_4_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_arrow_4_ctx
void Lustre_arrow_4_step(_integer x,_integer y,_integer *z,Lustre_arrow_4_ctx_type* ctx){  *z = ((ctx->_memory)? x : y);
  ctx->_memory = _false;

} // End of Lustre_arrow_4_step

// Memory initialisation for Lustre_arrow_3_ctx
void Lustre_arrow_3_ctx_reset(Lustre_arrow_3_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}
// Memory allocation for Lustre_arrow_3_ctx
Lustre_arrow_3_ctx_type* Lustre_arrow_3_ctx_new_ctx(){

   Lustre_arrow_3_ctx_type* ctx = (Lustre_arrow_3_ctx_type*)calloc(1, sizeof(Lustre_arrow_3_ctx_type));
   // ctx->client_data = cdata;
   Lustre_arrow_3_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_arrow_3_ctx
void Lustre_arrow_3_step(_real x,_real y,_real *z,Lustre_arrow_3_ctx_type* ctx){  *z = ((ctx->_memory)? x : y);
  ctx->_memory = _false;

} // End of Lustre_arrow_3_step

// Memory initialisation for Lustre_arrow_2_ctx
void Lustre_arrow_2_ctx_reset(Lustre_arrow_2_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}
// Memory allocation for Lustre_arrow_2_ctx
Lustre_arrow_2_ctx_type* Lustre_arrow_2_ctx_new_ctx(){

   Lustre_arrow_2_ctx_type* ctx = (Lustre_arrow_2_ctx_type*)calloc(1, sizeof(Lustre_arrow_2_ctx_type));
   // ctx->client_data = cdata;
   Lustre_arrow_2_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_arrow_2_ctx
void Lustre_arrow_2_step(convertible_hood_speed_state x,convertible_hood_speed_state y,convertible_hood_speed_state *z,Lustre_arrow_2_ctx_type* ctx){  *z = ((ctx->_memory)? x : y);
  ctx->_memory = _false;

} // End of Lustre_arrow_2_step

// Memory initialisation for Lustre_arrow_ctx
void Lustre_arrow_ctx_reset(Lustre_arrow_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}
// Memory allocation for Lustre_arrow_ctx
Lustre_arrow_ctx_type* Lustre_arrow_ctx_new_ctx(){

   Lustre_arrow_ctx_type* ctx = (Lustre_arrow_ctx_type*)calloc(1, sizeof(Lustre_arrow_ctx_type));
   // ctx->client_data = cdata;
   Lustre_arrow_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_arrow_ctx
void Lustre_arrow_step(convertible_hood_state x,convertible_hood_state y,convertible_hood_state *z,Lustre_arrow_ctx_type* ctx){  *z = ((ctx->_memory)? x : y);
  ctx->_memory = _false;

} // End of Lustre_arrow_step

// Memory initialisation for Lustre_arrow_6_ctx
void Lustre_arrow_6_ctx_reset(Lustre_arrow_6_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}
// Memory allocation for Lustre_arrow_6_ctx
Lustre_arrow_6_ctx_type* Lustre_arrow_6_ctx_new_ctx(){

   Lustre_arrow_6_ctx_type* ctx = (Lustre_arrow_6_ctx_type*)calloc(1, sizeof(Lustre_arrow_6_ctx_type));
   // ctx->client_data = cdata;
   Lustre_arrow_6_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_arrow_6_ctx
void Lustre_arrow_6_step(convertible_vehicle_state x,convertible_vehicle_state y,convertible_vehicle_state *z,Lustre_arrow_6_ctx_type* ctx){  *z = ((ctx->_memory)? x : y);
  ctx->_memory = _false;

} // End of Lustre_arrow_6_step

// Memory initialisation for Lustre_arrow_5_ctx
void Lustre_arrow_5_ctx_reset(Lustre_arrow_5_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}
// Memory allocation for Lustre_arrow_5_ctx
Lustre_arrow_5_ctx_type* Lustre_arrow_5_ctx_new_ctx(){

   Lustre_arrow_5_ctx_type* ctx = (Lustre_arrow_5_ctx_type*)calloc(1, sizeof(Lustre_arrow_5_ctx_type));
   // ctx->client_data = cdata;
   Lustre_arrow_5_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_arrow_5_ctx
void Lustre_arrow_5_step(_real x[50],_real y[50],_real z[50]/*out*/,Lustre_arrow_5_ctx_type* ctx){  _assign_rp50(z, ((ctx->_memory)? x : y), sizeof(_real [50]));
  ctx->_memory = _false;

} // End of Lustre_arrow_5_step

// Step function(s) for Lustre_eq_ctx
void Lustre_eq_step(_integer x,_integer y,_boolean *z){
  *z = (x == y);

} // End of Lustre_eq_step

// Step function(s) for Lustre_eq_2_ctx
void Lustre_eq_2_step(_real x,_real y,_boolean *z){
  *z = (x == y);

} // End of Lustre_eq_2_step

// Step function(s) for Lustre_eq_3_ctx
void Lustre_eq_3_step(convertible_hood_state x,convertible_hood_state y,_boolean *z){
  *z = (x == y);

} // End of Lustre_eq_3_step

// Step function(s) for Lustre_hat_ctx
void Lustre_hat_step(_real x,_real z[50]/*out*/){
  z[0] = x;
  z[1] = x;
  z[2] = x;
  z[3] = x;
  z[4] = x;
  z[5] = x;
  z[6] = x;
  z[7] = x;
  z[8] = x;
  z[9] = x;
  z[10] = x;
  z[11] = x;
  z[12] = x;
  z[13] = x;
  z[14] = x;
  z[15] = x;
  z[16] = x;
  z[17] = x;
  z[18] = x;
  z[19] = x;
  z[20] = x;
  z[21] = x;
  z[22] = x;
  z[23] = x;
  z[24] = x;
  z[25] = x;
  z[26] = x;
  z[27] = x;
  z[28] = x;
  z[29] = x;
  z[30] = x;
  z[31] = x;
  z[32] = x;
  z[33] = x;
  z[34] = x;
  z[35] = x;
  z[36] = x;
  z[37] = x;
  z[38] = x;
  z[39] = x;
  z[40] = x;
  z[41] = x;
  z[42] = x;
  z[43] = x;
  z[44] = x;
  z[45] = x;
  z[46] = x;
  z[47] = x;
  z[48] = x;
  z[49] = x;

} // End of Lustre_hat_step

// Memory initialisation for Lustre_pre_4_ctx
void Lustre_pre_4_ctx_reset(Lustre_pre_4_ctx_type* ctx){
  int _i;

}
// Memory allocation for Lustre_pre_4_ctx
Lustre_pre_4_ctx_type* Lustre_pre_4_ctx_new_ctx(){

   Lustre_pre_4_ctx_type* ctx = (Lustre_pre_4_ctx_type*)calloc(1, sizeof(Lustre_pre_4_ctx_type));
   // ctx->client_data = cdata;
   Lustre_pre_4_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_pre_4_ctx
void Lustre_pre_4_get(_integer *z,Lustre_pre_4_ctx_type* ctx){
  *z = ctx->_memory;

} // End of Lustre_pre_4_get

void Lustre_pre_4_set(_integer x,Lustre_pre_4_ctx_type* ctx){
  ctx->_memory = x;

} // End of Lustre_pre_4_set

// Memory initialisation for Lustre_pre_3_ctx
void Lustre_pre_3_ctx_reset(Lustre_pre_3_ctx_type* ctx){
  int _i;

}
// Memory allocation for Lustre_pre_3_ctx
Lustre_pre_3_ctx_type* Lustre_pre_3_ctx_new_ctx(){

   Lustre_pre_3_ctx_type* ctx = (Lustre_pre_3_ctx_type*)calloc(1, sizeof(Lustre_pre_3_ctx_type));
   // ctx->client_data = cdata;
   Lustre_pre_3_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_pre_3_ctx
void Lustre_pre_3_get(_real *z,Lustre_pre_3_ctx_type* ctx){
  *z = ctx->_memory;

} // End of Lustre_pre_3_get

void Lustre_pre_3_set(_real x,Lustre_pre_3_ctx_type* ctx){
  ctx->_memory = x;

} // End of Lustre_pre_3_set

// Memory initialisation for Lustre_pre_2_ctx
void Lustre_pre_2_ctx_reset(Lustre_pre_2_ctx_type* ctx){
  int _i;

}
// Memory allocation for Lustre_pre_2_ctx
Lustre_pre_2_ctx_type* Lustre_pre_2_ctx_new_ctx(){

   Lustre_pre_2_ctx_type* ctx = (Lustre_pre_2_ctx_type*)calloc(1, sizeof(Lustre_pre_2_ctx_type));
   // ctx->client_data = cdata;
   Lustre_pre_2_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_pre_2_ctx
void Lustre_pre_2_get(convertible_hood_speed_state *z,Lustre_pre_2_ctx_type* ctx){
  *z = ctx->_memory;

} // End of Lustre_pre_2_get

void Lustre_pre_2_set(convertible_hood_speed_state x,Lustre_pre_2_ctx_type* ctx){
  ctx->_memory = x;

} // End of Lustre_pre_2_set

// Memory initialisation for Lustre_pre_ctx
void Lustre_pre_ctx_reset(Lustre_pre_ctx_type* ctx){
  int _i;

}
// Memory allocation for Lustre_pre_ctx
Lustre_pre_ctx_type* Lustre_pre_ctx_new_ctx(){

   Lustre_pre_ctx_type* ctx = (Lustre_pre_ctx_type*)calloc(1, sizeof(Lustre_pre_ctx_type));
   // ctx->client_data = cdata;
   Lustre_pre_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_pre_ctx
void Lustre_pre_get(convertible_hood_state *z,Lustre_pre_ctx_type* ctx){
  *z = ctx->_memory;

} // End of Lustre_pre_get

void Lustre_pre_set(convertible_hood_state x,Lustre_pre_ctx_type* ctx){
  ctx->_memory = x;

} // End of Lustre_pre_set

// Memory initialisation for Lustre_pre_6_ctx
void Lustre_pre_6_ctx_reset(Lustre_pre_6_ctx_type* ctx){
  int _i;

}
// Memory allocation for Lustre_pre_6_ctx
Lustre_pre_6_ctx_type* Lustre_pre_6_ctx_new_ctx(){

   Lustre_pre_6_ctx_type* ctx = (Lustre_pre_6_ctx_type*)calloc(1, sizeof(Lustre_pre_6_ctx_type));
   // ctx->client_data = cdata;
   Lustre_pre_6_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_pre_6_ctx
void Lustre_pre_6_get(convertible_vehicle_state *z,Lustre_pre_6_ctx_type* ctx){
  *z = ctx->_memory;

} // End of Lustre_pre_6_get

void Lustre_pre_6_set(convertible_vehicle_state x,Lustre_pre_6_ctx_type* ctx){
  ctx->_memory = x;

} // End of Lustre_pre_6_set

// Memory initialisation for Lustre_pre_5_ctx
void Lustre_pre_5_ctx_reset(Lustre_pre_5_ctx_type* ctx){
  int _i;

}
// Memory allocation for Lustre_pre_5_ctx
Lustre_pre_5_ctx_type* Lustre_pre_5_ctx_new_ctx(){

   Lustre_pre_5_ctx_type* ctx = (Lustre_pre_5_ctx_type*)calloc(1, sizeof(Lustre_pre_5_ctx_type));
   // ctx->client_data = cdata;
   Lustre_pre_5_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for Lustre_pre_5_ctx
void Lustre_pre_5_get(_real z[50]/*out*/,Lustre_pre_5_ctx_type* ctx){
  _assign_rp50(z, ctx->_memory, sizeof(_real [50]));

} // End of Lustre_pre_5_get

void Lustre_pre_5_set(_real x[50],Lustre_pre_5_ctx_type* ctx){
  _assign_rp50(ctx->_memory, x, sizeof(_real [50]));

} // End of Lustre_pre_5_set

// Step function(s) for Lustre_slash_ctx
void Lustre_slash_step(_real x,_real y,_real *z){
  *z = (x / y);

} // End of Lustre_slash_step

// Step function(s) for assign_50_ctx
void assign_50_step(_real v,_integer jv,_real t[50],_real nt[50]/*out*/){
   convertible_update_acc _v_3;
   convertible_update_acc dummy;

  _v_3.i = 0;
  _v_3.j = jv;
  _v_3.v = v;
  fillred_update_cell_do_50_step(_v_3,t,&dummy,nt); 

} // End of assign_50_step

// Step function(s) for convertible_abs_ctx
void convertible_abs_step(_real x,_real *y){
   _real _v_2;
   _boolean _v_1;

  _v_2 = - x;
  _v_1 = x >= 0.0;
   if (_v_1 == _true) {
     *y = x;
   } else {
     *y = _v_2;
   }

} // End of convertible_abs_step

// Step function(s) for convertible_braking_time_ctx
void convertible_braking_time_step(_real Speed,_real *res){
   _real _v_4;

  _v_4 = Speed * Speed;
  Lustre_slash_step(_v_4,5500.0,res); 

} // End of convertible_braking_time_step

// Memory initialisation for convertible_hood_ctx
void convertible_hood_ctx_reset(convertible_hood_ctx_type* ctx){
  int _i;

    convertible_hood_speed_ctx_reset(&ctx->convertible_hood_speed_ctx_tab[0]);
    Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]);
    Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]);
}
// Memory allocation for convertible_hood_ctx
convertible_hood_ctx_type* convertible_hood_ctx_new_ctx(){

   convertible_hood_ctx_type* ctx = (convertible_hood_ctx_type*)calloc(1, sizeof(convertible_hood_ctx_type));
   // ctx->client_data = cdata;
   convertible_hood_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for convertible_hood_ctx
void convertible_hood_step(_boolean Tic,_boolean Parked,_boolean OnOff,_boolean Done,_boolean *Locked,_real *Hood_Speed,convertible_hood_ctx_type* ctx){   _real _v_12;
   _real _v_11;
   convertible_hood_state _v_10;
   _boolean _v_9;
   convertible_hood_state _v_8;
   _boolean _v_7;
   _boolean _v_6;
   convertible_hood_state _v_5;
   convertible_hood_state pst;
   convertible_hood_state st;
   _boolean Tic_on_in_motion;

  Lustre_pre_get(&_v_5,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_arrow_step(convertible_locked,_v_5,&pst,&ctx->Lustre_arrow_ctx_tab[0]); 
  switch (pst){
  case convertible_in_motion:
  _v_9 = Done;
   if (_v_9 == _true) {
     _v_10 = convertible_locked;
   } else {
     _v_10 = convertible_in_motion;
   }
  st = _v_10;
  break;
}
  _v_6 = OnOff & Parked;
  switch (pst){
  case convertible_locked:
  _v_7 = _v_6;
   if (_v_7 == _true) {
     _v_8 = convertible_in_motion;
   } else {
     _v_8 = convertible_locked;
   }
  st = _v_8;
  break;
}
  Lustre_pre_set(st,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_eq_3_step(st,convertible_locked,Locked); 
  switch (st){
  case convertible_in_motion:
  Tic_on_in_motion = Tic;
  convertible_hood_speed_step(Tic_on_in_motion,&_v_12,&ctx->convertible_hood_speed_ctx_tab[0]); 
  *Hood_Speed = _v_12;
  break;
  case convertible_locked:
  _v_11 = 0.0;
  *Hood_Speed = _v_11;
  break;
}

} // End of convertible_hood_step

// Memory initialisation for convertible_hood_speed_ctx
void convertible_hood_speed_ctx_reset(convertible_hood_speed_ctx_type* ctx){
  int _i;

    Lustre_pre_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[0]);
    Lustre_pre_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[0]);
    Lustre_pre_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[1]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[0]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[0]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[1]);
}
// Memory allocation for convertible_hood_speed_ctx
convertible_hood_speed_ctx_type* convertible_hood_speed_ctx_new_ctx(){

   convertible_hood_speed_ctx_type* ctx = (convertible_hood_speed_ctx_type*)calloc(1, sizeof(convertible_hood_speed_ctx_type));
   // ctx->client_data = cdata;
   convertible_hood_speed_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for convertible_hood_speed_ctx
void convertible_hood_speed_step(_boolean Tic,_real *Hood_Speed,convertible_hood_speed_ctx_type* ctx){   _real _v_35;
   _real _v_34;
   _real _v_33;
   _real _v_32;
   _real _v_31;
   _real _v_30;
   _real _v_29;
   _real _v_28;
   _real _v_27;
   _real _v_26;
   _real _v_25;
   _real _v_24;
   _real _v_23;
   _real _v_22;
   _real _v_21;
   _real _v_20;
   convertible_hood_speed_state _v_19;
   _boolean _v_18;
   _real _v_17;
   convertible_hood_speed_state _v_16;
   _boolean _v_15;
   _real _v_14;
   convertible_hood_speed_state _v_13;
   convertible_hood_speed_state pst;
   convertible_hood_speed_state st;
   _real kh;
   _real Hood_Percent;
   _real pHood_Percent;
   _real slow_it_down;
   _real pHood_Speed;

  switch (Tic){
  case _true:
  Lustre_pre_2_get(&_v_13,&ctx->Lustre_pre_2_ctx_tab[0]); 
  Lustre_arrow_2_step(convertible_wait,_v_13,&pst,&ctx->Lustre_arrow_2_ctx_tab[0]); 
  Lustre_pre_3_get(&_v_20,&ctx->Lustre_pre_3_ctx_tab[0]); 
  Lustre_arrow_3_step(0.0,_v_20,&pHood_Percent,&ctx->Lustre_arrow_3_ctx_tab[0]); 
  switch (pst){
  case convertible_fast:
  _v_14 = pHood_Percent;
  _v_15 = _v_14 < 85.0;
   if (_v_15 == _true) {
     _v_16 = convertible_fast;
   } else {
     _v_16 = convertible_slow;
   }
  st = _v_16;
  break;
  case convertible_slow:
  _v_17 = pHood_Percent;
  _v_18 = _v_17 < 100.0;
   if (_v_18 == _true) {
     _v_19 = convertible_slow;
   } else {
     _v_19 = convertible_wait;
   }
  st = _v_19;
  break;
  case convertible_wait:
  st = convertible_fast;
  break;
}
  Lustre_pre_2_set(st,&ctx->Lustre_pre_2_ctx_tab[0]); 
  Lustre_slash_step(5.,0.1,&_v_25); 
  Lustre_slash_step(100.,_v_25,&kh); 
  _v_30 = kh + pHood_Percent;
  switch (st){
  case convertible_fast:
  _v_31 = _v_30;
  Hood_Percent = _v_31;
  break;
  case convertible_slow:
  _v_34 = pHood_Percent;
  _v_21 = pHood_Percent;
  _v_22 = 100.0 - _v_21;
  Lustre_slash_step(_v_22,5.0,&_v_23); 
  convertible_sqrt_step(_v_23,&_v_24); 
  convertible_sqrt_step(_v_24,&slow_it_down); 
  _v_32 = kh;
  _v_33 = slow_it_down * _v_32;
  _v_35 = _v_33 + _v_34;
  Hood_Percent = _v_35;
  break;
  case convertible_wait:
  Hood_Percent = 0.0;
  Hood_Percent = 0.0;
  break;
}
  Lustre_pre_3_set(Hood_Percent,&ctx->Lustre_pre_3_ctx_tab[0]); 
  break;
}
  Lustre_pre_3_get(&_v_26,&ctx->Lustre_pre_3_ctx_tab[1]); 
  Lustre_arrow_3_step(0.0,_v_26,&pHood_Speed,&ctx->Lustre_arrow_3_ctx_tab[1]); 
  switch (Tic){
  case _false:
  _v_27 = pHood_Speed;
  *Hood_Speed = _v_27;
  break;
  case _true:
  switch (st){
  case convertible_fast:
  _v_29 = 10.0;
  _v_29 = 10.0;
  break;
  case convertible_slow:
  _v_28 = 10.0 * slow_it_down;
  _v_29 = _v_28;
  break;
  case convertible_wait:
  _v_29 = 0.0;
  _v_29 = 0.0;
  break;
}
  *Hood_Speed = _v_29;
  break;
}
  Lustre_pre_3_set(*Hood_Speed,&ctx->Lustre_pre_3_ctx_tab[1]); 

} // End of convertible_hood_speed_step

// Memory initialisation for convertible_main_ctx
void convertible_main_ctx_reset(convertible_main_ctx_type* ctx){
  int _i;

    convertible_vehicle_ctx_reset(&ctx->convertible_vehicle_ctx_tab[0]);
    convertible_speed_kmh_ctx_reset(&ctx->convertible_speed_kmh_ctx_tab[0]);
    convertible_may_collide_ctx_reset(&ctx->convertible_may_collide_ctx_tab[0]);
    convertible_hood_ctx_reset(&ctx->convertible_hood_ctx_tab[0]);
}
// Memory allocation for convertible_main_ctx
convertible_main_ctx_type* convertible_main_ctx_new_ctx(){

   convertible_main_ctx_type* ctx = (convertible_main_ctx_type*)calloc(1, sizeof(convertible_main_ctx_type));
   // ctx->client_data = cdata;
   convertible_main_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for convertible_main_ctx
void convertible_main_step(_boolean Start,_boolean Parked,_boolean Rot,_boolean Tic,_boolean OnOff,_boolean Done,_real Distance,_boolean *Danger,_boolean *Locked,_real *Speed,_real *Hood_Speed,convertible_main_ctx_type* ctx){   _boolean _v_38;
   _real _v_37;
   _real _v_36;
   convertible_vehicle_state St;
   _boolean _v_39;
   _boolean _v_40;

  _v_39 = OnOff & Start;
  _v_40 = ! _v_39;
  convertible_hood_step(Tic,Parked,OnOff,Done,Locked,Hood_Speed,&ctx->convertible_hood_ctx_tab[0]); 
  convertible_speed_kmh_step(Rot,Tic,Speed,&ctx->convertible_speed_kmh_ctx_tab[0]); 
  convertible_vehicle_step(Start,*Locked,*Speed,Distance,&St,&ctx->convertible_vehicle_ctx_tab[0]); 
  switch (St){
  case convertible_anti_col:
  _v_37 = Distance;
  _v_36 = *Speed;
  convertible_may_collide_step(_v_36,_v_37,&_v_38,&ctx->convertible_may_collide_ctx_tab[0]); 
  *Danger = _v_38;
  break;
  case convertible_run:
  *Danger = _false;
  *Danger = _false;
  break;
  case convertible_stationnary:
  *Danger = _false;
  *Danger = _false;
  break;
}

} // End of convertible_main_step

// Step function(s) for convertible_maxr_ctx
void convertible_maxr_step(_real x,_real y,_real *res){
   _boolean _v_41;

  _v_41 = x < y;
   if (_v_41 == _true) {
     *res = y;
   } else {
     *res = x;
   }

} // End of convertible_maxr_step

// Memory initialisation for convertible_may_collide_ctx
void convertible_may_collide_ctx_reset(convertible_may_collide_ctx_type* ctx){
  int _i;

    Lustre_pre_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[0]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[0]);
}
// Memory allocation for convertible_may_collide_ctx
convertible_may_collide_ctx_type* convertible_may_collide_ctx_new_ctx(){

   convertible_may_collide_ctx_type* ctx = (convertible_may_collide_ctx_type*)calloc(1, sizeof(convertible_may_collide_ctx_type));
   // ctx->client_data = cdata;
   convertible_may_collide_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for convertible_may_collide_ctx
void convertible_may_collide_step(_real Speed,_real Distance,_boolean *Res,convertible_may_collide_ctx_type* ctx){   _real _v_47;
   _real _v_46;
   _real _v_45;
   _real _v_44;
   _real _v_43;
   _real _v_42;
   _real Accel;
   _real tChoc;
   _real tBrake;

  Lustre_pre_3_get(&_v_42,&ctx->Lustre_pre_3_ctx_tab[0]); 
  _v_43 = Speed - _v_42;
  Lustre_slash_step(_v_43,0.1,&_v_44); 
  Lustre_pre_3_set(Speed,&ctx->Lustre_pre_3_ctx_tab[0]); 
  Lustre_arrow_3_step(0.0,_v_44,&Accel,&ctx->Lustre_arrow_3_ctx_tab[0]); 
  convertible_braking_time_step(Speed,&tBrake); 
  _v_46 = -2.0 * Distance;
  _v_45 = 2.0 * Speed;
  convertible_solve_eq_d2_step(Accel,_v_45,_v_46,&tChoc); 
  _v_47 = 2.0 + tBrake;
  *Res = tChoc < _v_47;

} // End of convertible_may_collide_step

// Step function(s) for convertible_ms_to_kmh_ctx
void convertible_ms_to_kmh_step(_real x,_real *res){

  *res = x * 3.6;

} // End of convertible_ms_to_kmh_step

// Step function(s) for convertible_solve_eq_d2_ctx
void convertible_solve_eq_d2_step(_real a,_real b,_real c,_real *res){
   _real _v_75;
   _real _v_74;
   _real _v_73;
   _real _v_72;
   _real _v_71;
   _real _v_70;
   _real _v_69;
   _real _v_68;
   _real _v_67;
   _real _v_66;
   _real _v_65;
   _real _v_64;
   _real _v_63;
   _real _v_62;
   _real _v_61;
   _real _v_60;
   _real _v_59;
   _real _v_58;
   convertible_eq_case _v_57;
   convertible_eq_case _v_56;
   _boolean _v_55;
   _boolean _v_54;
   convertible_eq_case _v_53;
   _boolean _v_52;
   _boolean _v_51;
   _real _v_50;
   _real _v_49;
   _real _v_48;
   _real delta;
   convertible_eq_case sol_nb;
   _real a2;
   _real b2;
   _real delta_pos;

  _v_49 = 4.0 * a;
  _v_50 = _v_49 * c;
  _v_48 = b * b;
  delta = _v_48 - _v_50;
  Lustre_eq_2_step(delta,0.0,&_v_55); 
   if (_v_55 == _true) {
     _v_56 = convertible_one_sol;
   } else {
     _v_56 = convertible_two_sol;
   }
  _v_54 = delta < 0.0;
   if (_v_54 == _true) {
     _v_57 = convertible_no_sol;
   } else {
     _v_57 = _v_56;
   }
  Lustre_eq_2_step(b,0.0,&_v_52); 
   if (_v_52 == _true) {
     _v_53 = convertible_no_sol;
   } else {
     _v_53 = convertible_deg1;
   }
  Lustre_eq_2_step(a,0.0,&_v_51); 
   if (_v_51 == _true) {
     sol_nb = _v_53;
   } else {
     sol_nb = _v_57;
   }
  switch (sol_nb){
  case convertible_two_sol:
  delta_pos = delta;
  a2 = a;
  b2 = b;
  convertible_sqrt_step(delta_pos,&_v_66); 
  _v_67 = 2.0 * a2;
  Lustre_slash_step(_v_66,_v_67,&_v_68); 
  _v_65 = - b2;
  _v_69 = _v_65 + _v_68;
  convertible_sqrt_step(delta_pos,&_v_71); 
  _v_72 = 2.0 * a2;
  Lustre_slash_step(_v_71,_v_72,&_v_73); 
  _v_70 = - b2;
  _v_74 = _v_70 - _v_73;
  convertible_maxr_step(_v_69,_v_74,&_v_75); 
  break;
}
  _v_61 = - b;
  _v_62 = 2.0 * a;
  Lustre_slash_step(_v_61,_v_62,&_v_63); 
  switch (sol_nb){
  case convertible_one_sol:
  _v_64 = _v_63;
  break;
}
  _v_58 = - c;
  Lustre_slash_step(_v_58,b,&_v_59); 
  switch (sol_nb){
  case convertible_deg1:
  _v_60 = _v_59;
  *res = _v_60;
  break;
  case convertible_two_sol:
  *res = _v_75;
  break;
  case convertible_one_sol:
  *res = _v_64;
  break;
  case convertible_no_sol:
  *res = -1.0;
  *res = -1.0;
  break;
}

} // End of convertible_solve_eq_d2_step

// Memory initialisation for convertible_speed_kmh_ctx
void convertible_speed_kmh_ctx_reset(convertible_speed_kmh_ctx_type* ctx){
  int _i;

    sum_50_0d1_ctx_reset(&ctx->sum_50_0d1_ctx_tab[0]);
    sum_50_0d0_ctx_reset(&ctx->sum_50_0d0_ctx_tab[0]);
    Lustre_pre_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[0]);
    Lustre_pre_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[1]);
    Lustre_pre_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[2]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[0]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[1]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[2]);
}
// Memory allocation for convertible_speed_kmh_ctx
convertible_speed_kmh_ctx_type* convertible_speed_kmh_ctx_new_ctx(){

   convertible_speed_kmh_ctx_type* ctx = (convertible_speed_kmh_ctx_type*)calloc(1, sizeof(convertible_speed_kmh_ctx_type));
   // ctx->client_data = cdata;
   convertible_speed_kmh_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for convertible_speed_kmh_ctx
void convertible_speed_kmh_step(_boolean Rot,_boolean Tic,_real *Speed,convertible_speed_kmh_ctx_type* ctx){
  _real _v_87, _v_86, _v_85, _v_84, _v_83, _v_82, _v_81, _v_80;
  _real _v_79, _v_78, _v_77, _v_76, d, t, pd, pt, dx, tx;
  _boolean TicOrRot;

   if (Rot == _true) { dx = 1.4; } else { dx = 0.0; }
   if (Tic == _true) { tx = 0.1; } else { tx = 0.0; }
  TicOrRot = Tic | Rot;
  Lustre_pre_3_get(&_v_76,&ctx->Lustre_pre_3_ctx_tab[0]); 
  Lustre_arrow_3_step(0.0,_v_76,&pd,&ctx->Lustre_arrow_3_ctx_tab[0]); 
  switch (TicOrRot){
  case _false:
    _v_78 = pd;
    d = _v_78;
    break;
  case _true:
    _v_79 = dx;
    sum_50_0d0_step(_v_79,&_v_80,&ctx->sum_50_0d0_ctx_tab[0]); 
    d = _v_80;
    break;
  }
  Lustre_pre_3_set(d,&ctx->Lustre_pre_3_ctx_tab[0]); 
  Lustre_pre_3_get(&_v_77,&ctx->Lustre_pre_3_ctx_tab[1]); 
  Lustre_arrow_3_step(0.0,_v_77,&pt,&ctx->Lustre_arrow_3_ctx_tab[1]); 
  switch (TicOrRot){
  case _false:
    _v_83 = pt;
    _v_84 = _v_83;
    break;
  case _true:
    _v_81 = tx;
    sum_50_0d1_step(_v_81,&_v_82,&ctx->sum_50_0d1_ctx_tab[0]); 
    _v_84 = _v_82;
    break;
  }
  convertible_maxr_step(0.1,_v_84,&t); 
  Lustre_pre_3_set(t,&ctx->Lustre_pre_3_ctx_tab[1]); 
  Lustre_pre_3_get(&_v_87,&ctx->Lustre_pre_3_ctx_tab[2]); 
  Lustre_slash_step(d,t,&_v_85); 
  convertible_ms_to_kmh_step(_v_85,&_v_86); 
  Lustre_pre_3_set(_v_86,&ctx->Lustre_pre_3_ctx_tab[2]); 
  Lustre_arrow_3_step(0.0,_v_87,Speed,&ctx->Lustre_arrow_3_ctx_tab[2]); 

} // End of convertible_speed_kmh_step

// Step function(s) for convertible_sqrt_ctx
void convertible_sqrt_step(_real R,_real *Sqrt){

  squareR_5_step(R,1.0,Sqrt); 

} // End of convertible_sqrt_step

// Memory initialisation for convertible_vehicle_ctx
void convertible_vehicle_ctx_reset(convertible_vehicle_ctx_type* ctx){
  int _i;

    Lustre_pre_6_ctx_reset(&ctx->Lustre_pre_6_ctx_tab[0]);
    Lustre_arrow_6_ctx_reset(&ctx->Lustre_arrow_6_ctx_tab[0]);
}
// Memory allocation for convertible_vehicle_ctx
convertible_vehicle_ctx_type* convertible_vehicle_ctx_new_ctx(){

   convertible_vehicle_ctx_type* ctx = (convertible_vehicle_ctx_type*)calloc(1, sizeof(convertible_vehicle_ctx_type));
   // ctx->client_data = cdata;
   convertible_vehicle_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for convertible_vehicle_ctx
void convertible_vehicle_step(_boolean Start,_boolean Locked,_real Speed,_real Distance,convertible_vehicle_state *st,convertible_vehicle_ctx_type* ctx){   convertible_vehicle_state _v_153;
   _boolean _v_152;
   _boolean _v_151;
   convertible_vehicle_state _v_150;
   convertible_vehicle_state _v_149;
   _boolean _v_148;
   _boolean _v_147;
   _boolean _v_146;
   convertible_vehicle_state _v_145;
   _boolean _v_144;
   _boolean _v_143;
   convertible_vehicle_state _v_142;
   convertible_vehicle_state pst;
   _boolean ac_cond;

  Lustre_pre_6_get(&_v_142,&ctx->Lustre_pre_6_ctx_tab[0]); 
  Lustre_arrow_6_step(convertible_stationnary,_v_142,&pst,&ctx->Lustre_arrow_6_ctx_tab[0]); 
  ac_cond = Speed >= 110.0;
  switch (pst){
  case convertible_anti_col:
  _v_151 = ac_cond;
  _v_152 = ! _v_151;
   if (_v_152 == _true) {
     _v_153 = convertible_run;
   } else {
     _v_153 = convertible_anti_col;
   }
  *st = _v_153;
  break;
}
  Lustre_eq_2_step(Speed,0.0,&_v_147); 
  switch (pst){
  case convertible_run:
  _v_148 = _v_147;
   if (_v_148 == _true) {
     _v_149 = convertible_stationnary;
   } else {
     _v_149 = convertible_run;
   }
  _v_146 = ac_cond;
   if (_v_146 == _true) {
     _v_150 = convertible_anti_col;
   } else {
     _v_150 = _v_149;
   }
  *st = _v_150;
  break;
}
  _v_143 = Start & Locked;
  switch (pst){
  case convertible_stationnary:
  _v_144 = _v_143;
   if (_v_144 == _true) {
     _v_145 = convertible_run;
   } else {
     _v_145 = convertible_stationnary;
   }
  *st = _v_145;
  break;
}
  Lustre_pre_6_set(*st,&ctx->Lustre_pre_6_ctx_tab[0]); 

} // End of convertible_vehicle_step

// Step function(s) for fillred_update_cell_do_50_ctx
void fillred_update_cell_do_50_step(convertible_update_acc acc,_real cell[50],convertible_update_acc *nacc,_real ncell[50]/*out*/){
  int _i;
  for (_i=0 ; _i<49 ; _i+=2){
    update_cell_do_50_step(acc,cell[_i],&acc,&ncell[_i]); 
    update_cell_do_50_step(acc,cell[_i+1],&acc,&ncell[_i+1]); 
  }
   *nacc = acc;

} // End of fillred_update_cell_do_50_step

// Step function(s) for red_rplus_50_real_ctx
void red_rplus_50_real_step(_real i1,_real i2[50],_real *o){
  int _i;
  for (_i=0 ; _i<49 ; _i+=2){
    i1 = i1 + i2[_i];
    i1 = i1 + i2[_i+1];
  }
   *o = i1;

} // End of red_rplus_50_real_step

// Step function(s) for squareR_1_ctx
void squareR_1_step(_real x,_real presqrt,_real *Sqrt){
   _real _v_91;
   _real _v_90;
   _real _v_89;
   _real _v_88;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_v_90); 
  _v_91 = presqrt + _v_90;
  sqrt = 0.5 * _v_91;
  _v_88 = presqrt - sqrt;
  convertible_abs_step(_v_88,&_v_89); 
  ecart = _v_89 < 0.0005;
  *Sqrt = sqrt;

} // End of squareR_1_step

// Step function(s) for squareR_2_ctx
void squareR_2_step(_real x,_real presqrt,_real *Sqrt){
   _real _v_99;
   _real _v_98;
   _real _v_97;
   _real _v_96;
   _real _v_95;
   _real _v_94;
   _real _v_93;
   _real _v_92;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_v_94); 
  _v_95 = presqrt + _v_94;
  sqrt = 0.5 * _v_95;
  _v_92 = presqrt - sqrt;
  convertible_abs_step(_v_92,&_v_93); 
  ecart = _v_93 < 0.0005;
  switch (ecart){
  case _true:
  _v_99 = sqrt;
  *Sqrt = _v_99;
  break;
  case _false:
  _v_97 = sqrt;
  _v_96 = x;
  squareR_1_step(_v_96,_v_97,&_v_98); 
  *Sqrt = _v_98;
  break;
}

} // End of squareR_2_step

// Step function(s) for squareR_3_ctx
void squareR_3_step(_real x,_real presqrt,_real *Sqrt){
   _real _v_107;
   _real _v_106;
   _real _v_105;
   _real _v_104;
   _real _v_103;
   _real _v_102;
   _real _v_101;
   _real _v_100;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_v_102); 
  _v_103 = presqrt + _v_102;
  sqrt = 0.5 * _v_103;
  _v_100 = presqrt - sqrt;
  convertible_abs_step(_v_100,&_v_101); 
  ecart = _v_101 < 0.0005;
  switch (ecart){
  case _true:
  _v_107 = sqrt;
  *Sqrt = _v_107;
  break;
  case _false:
  _v_105 = sqrt;
  _v_104 = x;
  squareR_2_step(_v_104,_v_105,&_v_106); 
  *Sqrt = _v_106;
  break;
}

} // End of squareR_3_step

// Step function(s) for squareR_4_ctx
void squareR_4_step(_real x,_real presqrt,_real *Sqrt){
   _real _v_115;
   _real _v_114;
   _real _v_113;
   _real _v_112;
   _real _v_111;
   _real _v_110;
   _real _v_109;
   _real _v_108;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_v_110); 
  _v_111 = presqrt + _v_110;
  sqrt = 0.5 * _v_111;
  _v_108 = presqrt - sqrt;
  convertible_abs_step(_v_108,&_v_109); 
  ecart = _v_109 < 0.0005;
  switch (ecart){
  case _true:
  _v_115 = sqrt;
  *Sqrt = _v_115;
  break;
  case _false:
  _v_113 = sqrt;
  _v_112 = x;
  squareR_3_step(_v_112,_v_113,&_v_114); 
  *Sqrt = _v_114;
  break;
}

} // End of squareR_4_step

// Step function(s) for squareR_5_ctx
void squareR_5_step(_real x,_real presqrt,_real *Sqrt){
   _real _v_123;
   _real _v_122;
   _real _v_121;
   _real _v_120;
   _real _v_119;
   _real _v_118;
   _real _v_117;
   _real _v_116;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_v_118); 
  _v_119 = presqrt + _v_118;
  sqrt = 0.5 * _v_119;
  _v_116 = presqrt - sqrt;
  convertible_abs_step(_v_116,&_v_117); 
  ecart = _v_117 < 0.0005;
  switch (ecart){
  case _true:
  _v_123 = sqrt;
  *Sqrt = _v_123;
  break;
  case _false:
  _v_121 = sqrt;
  _v_120 = x;
  squareR_4_step(_v_120,_v_121,&_v_122); 
  *Sqrt = _v_122;
  break;
}

} // End of squareR_5_step

// Memory initialisation for sum_50_0d0_ctx
void sum_50_0d0_ctx_reset(sum_50_0d0_ctx_type* ctx){
  int _i;

    Lustre_pre_5_ctx_reset(&ctx->Lustre_pre_5_ctx_tab[0]);
    Lustre_pre_4_ctx_reset(&ctx->Lustre_pre_4_ctx_tab[0]);
    Lustre_arrow_5_ctx_reset(&ctx->Lustre_arrow_5_ctx_tab[0]);
    Lustre_arrow_4_ctx_reset(&ctx->Lustre_arrow_4_ctx_tab[0]);
}
// Memory allocation for sum_50_0d0_ctx
sum_50_0d0_ctx_type* sum_50_0d0_ctx_new_ctx(){

   sum_50_0d0_ctx_type* ctx = (sum_50_0d0_ctx_type*)calloc(1, sizeof(sum_50_0d0_ctx_type));
   // ctx->client_data = cdata;
   sum_50_0d0_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for sum_50_0d0_ctx
void sum_50_0d0_step(_real s,_real *res,sum_50_0d0_ctx_type* ctx){   _integer _v_128;
   _real _v_127[50];
   _real _v_126[50];
   _integer _v_125;
   _integer _v_124;
   _real a[50];
   _real pre_a[50];
   _integer i;

  Lustre_pre_4_get(&_v_124,&ctx->Lustre_pre_4_ctx_tab[0]); 
  Lustre_arrow_4_step(0,_v_124,&_v_125,&ctx->Lustre_arrow_4_ctx_tab[0]); 
  i = _v_125 + 1;
  Lustre_pre_4_set(i,&ctx->Lustre_pre_4_ctx_tab[0]); 
  Lustre_pre_5_get(_v_127,&ctx->Lustre_pre_5_ctx_tab[0]); 
  Lustre_hat_step(0.0,_v_126); 
  Lustre_arrow_5_step(_v_126,_v_127,pre_a,&ctx->Lustre_arrow_5_ctx_tab[0]); 
  _v_128 = i % 50;
  assign_50_step(s,_v_128,pre_a,a); 
  Lustre_pre_5_set(a,&ctx->Lustre_pre_5_ctx_tab[0]); 
  red_rplus_50_real_step(0.0,a,res); 

} // End of sum_50_0d0_step

// Memory initialisation for sum_50_0d1_ctx
void sum_50_0d1_ctx_reset(sum_50_0d1_ctx_type* ctx){
  int _i;

    Lustre_pre_5_ctx_reset(&ctx->Lustre_pre_5_ctx_tab[0]);
    Lustre_pre_4_ctx_reset(&ctx->Lustre_pre_4_ctx_tab[0]);
    Lustre_arrow_5_ctx_reset(&ctx->Lustre_arrow_5_ctx_tab[0]);
    Lustre_arrow_4_ctx_reset(&ctx->Lustre_arrow_4_ctx_tab[0]);
}
// Memory allocation for sum_50_0d1_ctx
sum_50_0d1_ctx_type* sum_50_0d1_ctx_new_ctx(){

   sum_50_0d1_ctx_type* ctx = (sum_50_0d1_ctx_type*)calloc(1, sizeof(sum_50_0d1_ctx_type));
   // ctx->client_data = cdata;
   sum_50_0d1_ctx_reset(ctx);
  return ctx;
}
// Step function(s) for sum_50_0d1_ctx
void sum_50_0d1_step(_real s,_real *res,sum_50_0d1_ctx_type* ctx){   _integer _v_133;
   _real _v_132[50];
   _real _v_131[50];
   _integer _v_130;
   _integer _v_129;
   _real a[50];
   _real pre_a[50];
   _integer i;

  Lustre_pre_4_get(&_v_129,&ctx->Lustre_pre_4_ctx_tab[0]); 
  Lustre_arrow_4_step(0,_v_129,&_v_130,&ctx->Lustre_arrow_4_ctx_tab[0]); 
  i = _v_130 + 1;
  Lustre_pre_4_set(i,&ctx->Lustre_pre_4_ctx_tab[0]); 
  Lustre_pre_5_get(_v_132,&ctx->Lustre_pre_5_ctx_tab[0]); 
  Lustre_hat_step(0.1,_v_131); 
  Lustre_arrow_5_step(_v_131,_v_132,pre_a,&ctx->Lustre_arrow_5_ctx_tab[0]); 
  _v_133 = i % 50;
  assign_50_step(s,_v_133,pre_a,a); 
  Lustre_pre_5_set(a,&ctx->Lustre_pre_5_ctx_tab[0]); 
  red_rplus_50_real_step(0.0,a,res); 

} // End of sum_50_0d1_step

// Step function(s) for update_cell_do_50_ctx
void update_cell_do_50_step(convertible_update_acc acc,_real cell,convertible_update_acc *nacc,_real *ncell){
   _integer _v_139;
   _integer _v_138;
   _integer _v_140;
   _real _v_141;
   _real _v_137;
   _boolean _v_136;
   _integer _v_135;
   _integer _v_134;

  _v_137 = acc.v;
  _v_134 = acc.i;
  _v_135 = acc.j;
  Lustre_eq_step(_v_134,_v_135,&_v_136); 
   if (_v_136 == _true) {
     *ncell = _v_137;
   } else {
     *ncell = cell;
   }
  _v_138 = acc.i;
  _v_139 = _v_138 + 1;
  _v_140 = acc.j;
  _v_141 = acc.v;
  nacc->i = _v_139;
  nacc->j = _v_140;
  nacc->v = _v_141;

} // End of update_cell_do_50_step