aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/lustrev6-convertible-2cgc/convertible_main.c
blob: 285f8941dfc9b9c22376f0569e3e866bc5ad8f67 (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
/* This file was generated by lv6 version master.737 (2727a7744111c84f7984634d2bd3ad6f7c6c7ff9). */
/*  lv6 -2cgc -node main convertible.lus */
/* on vanoise the 08/05/2019 at 23:54:11 */
#include "convertible_main.h"
//// Defining step functions
// Memory initialisation for Lustre_arrow_ctx
void Lustre_arrow_ctx_reset(Lustre_arrow_ctx_type* ctx){
  int _i;
  ctx->_memory = _true;
}

// Initialisation of the  internal structure of Lustre_arrow_ctx
void Lustre_arrow_ctx_init(Lustre_arrow_ctx_type* ctx){
  // ctx->client_data = cdata;
  Lustre_arrow_ctx_reset(ctx);
 }
// Step function(s) for Lustre_arrow_ctx
void Lustre_arrow_step(_integer i1,_integer i2,_integer *out,Lustre_arrow_ctx_type* ctx){  *out = ((ctx->_memory)? i1 : i2);
  ctx->_memory = _false;

} // End of Lustre_arrow_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;
}

// Initialisation of the  internal structure of Lustre_arrow_2_ctx
void Lustre_arrow_2_ctx_init(Lustre_arrow_2_ctx_type* ctx){
  // ctx->client_data = cdata;
  Lustre_arrow_2_ctx_reset(ctx);
 }
// Step function(s) for Lustre_arrow_2_ctx
void Lustre_arrow_2_step(_real i1,_real i2,_real *out,Lustre_arrow_2_ctx_type* ctx){  *out = ((ctx->_memory)? i1 : i2);
  ctx->_memory = _false;

} // End of Lustre_arrow_2_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;
}

// Initialisation of the  internal structure of Lustre_arrow_3_ctx
void Lustre_arrow_3_ctx_init(Lustre_arrow_3_ctx_type* ctx){
  // ctx->client_data = cdata;
  Lustre_arrow_3_ctx_reset(ctx);
 }
// Step function(s) for Lustre_arrow_3_ctx
void Lustre_arrow_3_step(_real i1[50],_real i2[50],_real out[50]/*out*/,Lustre_arrow_3_ctx_type* ctx){  _assign_rp50(out, ((ctx->_memory)? i1 : i2), sizeof(_real [50]));
  ctx->_memory = _false;

} // End of Lustre_arrow_3_step

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

} // End of Lustre_hat_step

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

}

// Initialisation of the  internal structure of Lustre_pre_ctx
void Lustre_pre_ctx_init(Lustre_pre_ctx_type* ctx){
  // ctx->client_data = cdata;
  Lustre_pre_ctx_reset(ctx);
 }
// Step function(s) for Lustre_pre_ctx
void Lustre_pre_get(_integer *out,Lustre_pre_ctx_type* ctx){
  *out = ctx->_memory;

} // End of Lustre_pre_get

void Lustre_pre_set(_integer i1,Lustre_pre_ctx_type* ctx){
  ctx->_memory = i1;

} // End of Lustre_pre_set

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

}

// Initialisation of the  internal structure of Lustre_pre_2_ctx
void Lustre_pre_2_ctx_init(Lustre_pre_2_ctx_type* ctx){
  // ctx->client_data = cdata;
  Lustre_pre_2_ctx_reset(ctx);
 }
// Step function(s) for Lustre_pre_2_ctx
void Lustre_pre_2_get(_real *out,Lustre_pre_2_ctx_type* ctx){
  *out = ctx->_memory;

} // End of Lustre_pre_2_get

void Lustre_pre_2_set(_real i1,Lustre_pre_2_ctx_type* ctx){
  ctx->_memory = i1;

} // End of Lustre_pre_2_set

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

}

// Initialisation of the  internal structure of Lustre_pre_3_ctx
void Lustre_pre_3_ctx_init(Lustre_pre_3_ctx_type* ctx){
  // ctx->client_data = cdata;
  Lustre_pre_3_ctx_reset(ctx);
 }
// Step function(s) for Lustre_pre_3_ctx
void Lustre_pre_3_get(_real out[50]/*out*/,Lustre_pre_3_ctx_type* ctx){
  _assign_rp50(out, ctx->_memory, sizeof(_real [50]));

} // End of Lustre_pre_3_get

void Lustre_pre_3_set(_real i1[50],Lustre_pre_3_ctx_type* ctx){
  _assign_rp50(ctx->_memory, i1, sizeof(_real [50]));

} // End of Lustre_pre_3_set

// Step function(s) for Lustre_slash_ctx
void Lustre_slash_step(_real i1,_real i2,_real *out){
  *out = (i1 / i2);

} // 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 _split_3;
   convertible_update_acc dummy;

  _split_3.i = 0;
  _split_3.j = jv;
  _split_3.v = v;
  fillred_update_cell_do_50_step(_split_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 _split_2;
   _boolean _split_1;

  _split_2 = - x;
  _split_1 = x >= 0.0;
   if (_split_1 == _true) {
     *y = x;
   } else {
     *y = _split_2;
   }

} // End of convertible_abs_step

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

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

} // End of convertible_braking_time_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_roof_ctx_reset(&ctx->convertible_roof_ctx_tab[0]);
    convertible_may_collide_ctx_reset(&ctx->convertible_may_collide_ctx_tab[0]);
}

// Initialisation of the  internal structure of convertible_main_ctx
void convertible_main_ctx_init(convertible_main_ctx_type* ctx){
  // ctx->client_data = cdata;
  convertible_main_ctx_reset(ctx);
 }
// Step function(s) for convertible_main_ctx
void convertible_main_step(_boolean Start,_boolean Parked,_boolean Rot,_boolean Tick,_boolean OnOff,_boolean Done,_real Dist,_boolean *Danger,_boolean *Locked,_real *Speed,_real *Roof_Speed,convertible_main_ctx_type* ctx){   _boolean _split_7;
   _real _split_6;
   _real _split_5;
   _integer St;
   _boolean _split_8;
   _boolean _split_9;

  _split_8 = OnOff & Start;
  _split_9 = ! _split_8;
  convertible_roof_step(Tick,Parked,OnOff,Done,Locked,Roof_Speed,&ctx->convertible_roof_ctx_tab[0]); 
  convertible_speed_kmh_step(Rot,Tick,Speed,&ctx->convertible_speed_kmh_ctx_tab[0]); 
  convertible_vehicle_step(Start,*Locked,*Speed,Dist,&St,&ctx->convertible_vehicle_ctx_tab[0]); 
  switch (St){
  case convertible_anti_col:
  _split_6 = Dist;
  _split_5 = *Speed;
  convertible_may_collide_step(_split_5,_split_6,&_split_7,&ctx->convertible_may_collide_ctx_tab[0]); 
  *Danger = _split_7;
  break;
  case convertible_run:
  *Danger = _false;
  break;
  case convertible_stationnary:
  *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 _split_10;

  _split_10 = x < y;
   if (_split_10 == _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_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[0]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[0]);
}

// Initialisation of the  internal structure of convertible_may_collide_ctx
void convertible_may_collide_ctx_init(convertible_may_collide_ctx_type* ctx){
  // ctx->client_data = cdata;
  convertible_may_collide_ctx_reset(ctx);
 }
// Step function(s) for convertible_may_collide_ctx
void convertible_may_collide_step(_real Speed,_real Dist,_boolean *Res,convertible_may_collide_ctx_type* ctx){   _real _split_17;
   _real _split_16;
   _real _split_15;
   _real _split_14;
   _real _split_13;
   _real _split_12;
   _real _split_11;
   _real Accel;
   _real tChoc;
   _real tBrake;

  Lustre_pre_2_get(&_split_11,&ctx->Lustre_pre_2_ctx_tab[0]); 
  _split_12 = Speed - _split_11;
  Lustre_slash_step(_split_12,0.1,&_split_13); 
  Lustre_pre_2_set(Speed,&ctx->Lustre_pre_2_ctx_tab[0]); 
  Lustre_arrow_2_step(0.0,_split_13,&Accel,&ctx->Lustre_arrow_2_ctx_tab[0]); 
  convertible_braking_time_step(Speed,&tBrake); 
  _split_15 = - 2.0;
  _split_16 = _split_15 * Dist;
  _split_14 = 2.0 * Speed;
  convertible_solve_eq_d2_step(Accel,_split_14,_split_16,&tChoc); 
  _split_17 = 2.0 + tBrake;
  *Res = tChoc < _split_17;

} // 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

// Memory initialisation for convertible_roof_ctx
void convertible_roof_ctx_reset(convertible_roof_ctx_type* ctx){
  int _i;

    convertible_roof_speed_ctx_reset(&ctx->convertible_roof_speed_ctx_tab[0]);
    Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]);
    Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]);
}

// Initialisation of the  internal structure of convertible_roof_ctx
void convertible_roof_ctx_init(convertible_roof_ctx_type* ctx){
  // ctx->client_data = cdata;
  convertible_roof_ctx_reset(ctx);
 }
// Step function(s) for convertible_roof_ctx
void convertible_roof_step(_boolean Tick,_boolean Parked,_boolean OnOff,_boolean Done,_boolean *Locked,_real *Roof_Speed,convertible_roof_ctx_type* ctx){   _real _split_25;
   _real _split_24;
   _integer _split_23;
   _boolean _split_22;
   _integer _split_21;
   _boolean _split_20;
   _boolean _split_19;
   _integer _split_18;
   _integer pst;
   _integer st;
   _boolean Tick_on_in_motion;

  Lustre_pre_get(&_split_18,&ctx->Lustre_pre_ctx_tab[0]); 
  switch (pst){
  case convertible_in_motion:
  _split_22 = Done;
   if (_split_22 == _true) {
     _split_23 = convertible_locked;
   } else {
     _split_23 = convertible_in_motion;
   }
  st = _split_23;
  break;
}
  _split_19 = OnOff & Parked;
  switch (pst){
  case convertible_locked:
  _split_20 = _split_19;
   if (_split_20 == _true) {
     _split_21 = convertible_in_motion;
   } else {
     _split_21 = convertible_locked;
   }
  st = _split_21;
  break;
}
  Lustre_pre_set(st,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_arrow_step(convertible_locked,_split_18,&pst,&ctx->Lustre_arrow_ctx_tab[0]); 
  *Locked = st == convertible_locked;
  switch (st){
  case convertible_in_motion:
  Tick_on_in_motion = Tick;
  convertible_roof_speed_step(Tick_on_in_motion,&_split_25,&ctx->convertible_roof_speed_ctx_tab[0]); 
  *Roof_Speed = _split_25;
  break;
  case convertible_locked:
  _split_24 = 0.0;
  *Roof_Speed = _split_24;
  break;
}

} // End of convertible_roof_step

// Memory initialisation for convertible_roof_speed_ctx
void convertible_roof_speed_ctx_reset(convertible_roof_speed_ctx_type* ctx){
  int _i;

    Lustre_pre_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[0]);
    Lustre_pre_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[1]);
    Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[0]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[1]);
    Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]);
}

// Initialisation of the  internal structure of convertible_roof_speed_ctx
void convertible_roof_speed_ctx_init(convertible_roof_speed_ctx_type* ctx){
  // ctx->client_data = cdata;
  convertible_roof_speed_ctx_reset(ctx);
 }
// Step function(s) for convertible_roof_speed_ctx
void convertible_roof_speed_step(_boolean Tick,_real *Roof_Speed,convertible_roof_speed_ctx_type* ctx){   _real _split_48;
   _real _split_47;
   _real _split_46;
   _real _split_45;
   _real _split_44;
   _real _split_43;
   _real _split_42;
   _real _split_41;
   _real _split_40;
   _real _split_39;
   _real _split_38;
   _real _split_37;
   _real _split_36;
   _real _split_35;
   _real _split_34;
   _real _split_33;
   _integer _split_32;
   _boolean _split_31;
   _real _split_30;
   _integer _split_29;
   _boolean _split_28;
   _real _split_27;
   _integer _split_26;
   _integer pst;
   _integer st;
   _real kh;
   _real Roof_Percent;
   _real pRoof_Percent;
   _real slow_it_down;
   _real pRoof_Speed;

  switch (Tick){
  case _true:
  Lustre_pre_get(&_split_26,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_pre_2_get(&_split_33,&ctx->Lustre_pre_2_ctx_tab[0]); 
  Lustre_arrow_2_step(0.0,_split_33,&pRoof_Percent,&ctx->Lustre_arrow_2_ctx_tab[0]); 
  switch (pst){
  case convertible_fast:
  _split_27 = pRoof_Percent;
  _split_28 = _split_27 < 85.0;
   if (_split_28 == _true) {
     _split_29 = convertible_fast;
   } else {
     _split_29 = convertible_slow;
   }
  st = _split_29;
  break;
  case convertible_slow:
  _split_30 = pRoof_Percent;
  _split_31 = _split_30 < 100.0;
   if (_split_31 == _true) {
     _split_32 = convertible_slow;
   } else {
     _split_32 = convertible_wait;
   }
  st = _split_32;
  break;
  case convertible_wait:
  st = convertible_fast;
  break;
}
  Lustre_pre_set(st,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_arrow_step(convertible_wait,_split_26,&pst,&ctx->Lustre_arrow_ctx_tab[0]); 
  Lustre_slash_step(5.,0.1,&_split_38); 
  Lustre_slash_step(100.,_split_38,&kh); 
  _split_43 = kh + pRoof_Percent;
  switch (st){
  case convertible_fast:
  _split_44 = _split_43;
  Roof_Percent = _split_44;
  break;
  case convertible_slow:
  _split_47 = pRoof_Percent;
  _split_34 = pRoof_Percent;
  _split_35 = 100.0 - _split_34;
  Lustre_slash_step(_split_35,5.0,&_split_36); 
  convertible_sqrt_step(_split_36,&_split_37); 
  convertible_sqrt_step(_split_37,&slow_it_down); 
  _split_45 = kh;
  _split_46 = slow_it_down * _split_45;
  _split_48 = _split_46 + _split_47;
  Roof_Percent = _split_48;
  break;
  case convertible_wait:
  Roof_Percent = 0.0;
  break;
}
  Lustre_pre_2_set(Roof_Percent,&ctx->Lustre_pre_2_ctx_tab[0]); 
  break;
}
  Lustre_pre_2_get(&_split_39,&ctx->Lustre_pre_2_ctx_tab[1]); 
  Lustre_arrow_2_step(0.0,_split_39,&pRoof_Speed,&ctx->Lustre_arrow_2_ctx_tab[1]); 
  switch (Tick){
  case _false:
  _split_40 = pRoof_Speed;
  *Roof_Speed = _split_40;
  break;
  case _true:
  switch (st){
  case convertible_fast:
  _split_42 = 10.0;
  break;
  case convertible_slow:
  _split_41 = 10.0 * slow_it_down;
  _split_42 = _split_41;
  break;
  case convertible_wait:
  _split_42 = 0.0;
  break;
}
  *Roof_Speed = _split_42;
  break;
}
  Lustre_pre_2_set(*Roof_Speed,&ctx->Lustre_pre_2_ctx_tab[1]); 

} // End of convertible_roof_speed_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 _split_77;
   _real _split_76;
   _real _split_75;
   _real _split_74;
   _real _split_73;
   _real _split_72;
   _real _split_71;
   _real _split_70;
   _real _split_69;
   _real _split_68;
   _real _split_67;
   _real _split_66;
   _real _split_65;
   _real _split_64;
   _real _split_63;
   _real _split_62;
   _real _split_61;
   _real _split_60;
   _real _split_59;
   _integer _split_58;
   _integer _split_57;
   _boolean _split_56;
   _boolean _split_55;
   _integer _split_54;
   _boolean _split_53;
   _boolean _split_52;
   _real _split_51;
   _real _split_50;
   _real _split_49;
   _real delta;
   _integer sol_nb;
   _real a2;
   _real b2;
   _real delta_pos;

  _split_50 = 4.0 * a;
  _split_51 = _split_50 * c;
  _split_49 = b * b;
  delta = _split_49 - _split_51;
  _split_56 = delta == 0.0;
   if (_split_56 == _true) {
     _split_57 = convertible_one_sol;
   } else {
     _split_57 = convertible_two_sol;
   }
  _split_55 = delta < 0.0;
   if (_split_55 == _true) {
     _split_58 = convertible_no_sol;
   } else {
     _split_58 = _split_57;
   }
  _split_53 = b == 0.0;
   if (_split_53 == _true) {
     _split_54 = convertible_no_sol;
   } else {
     _split_54 = convertible_deg1;
   }
  _split_52 = a == 0.0;
   if (_split_52 == _true) {
     sol_nb = _split_54;
   } else {
     sol_nb = _split_58;
   }
  switch (sol_nb){
  case convertible_two_sol:
  delta_pos = delta;
  a2 = a;
  b2 = b;
  convertible_sqrt_step(delta_pos,&_split_68); 
  _split_69 = 2.0 * a2;
  Lustre_slash_step(_split_68,_split_69,&_split_70); 
  _split_67 = - b2;
  _split_71 = _split_67 + _split_70;
  convertible_sqrt_step(delta_pos,&_split_73); 
  _split_74 = 2.0 * a2;
  Lustre_slash_step(_split_73,_split_74,&_split_75); 
  _split_72 = - b2;
  _split_76 = _split_72 - _split_75;
  convertible_maxr_step(_split_71,_split_76,&_split_77); 
  break;
}
  _split_63 = - b;
  _split_64 = 2.0 * a;
  Lustre_slash_step(_split_63,_split_64,&_split_65); 
  switch (sol_nb){
  case convertible_one_sol:
  _split_66 = _split_65;
  break;
}
  _split_60 = - c;
  Lustre_slash_step(_split_60,b,&_split_61); 
  switch (sol_nb){
  case convertible_deg1:
  _split_62 = _split_61;
  *res = _split_62;
  break;
  case convertible_no_sol:
  _split_59 = - 1.0;
  *res = _split_59;
  break;
  case convertible_two_sol:
  *res = _split_77;
  break;
  case convertible_one_sol:
  *res = _split_66;
  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_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[0]);
    Lustre_pre_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[1]);
    Lustre_pre_2_ctx_reset(&ctx->Lustre_pre_2_ctx_tab[2]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[0]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[1]);
    Lustre_arrow_2_ctx_reset(&ctx->Lustre_arrow_2_ctx_tab[2]);
}

// Initialisation of the  internal structure of convertible_speed_kmh_ctx
void convertible_speed_kmh_ctx_init(convertible_speed_kmh_ctx_type* ctx){
  // ctx->client_data = cdata;
  convertible_speed_kmh_ctx_reset(ctx);
 }
// Step function(s) for convertible_speed_kmh_ctx
void convertible_speed_kmh_step(_boolean Rot,_boolean Tick,_real *Speed,convertible_speed_kmh_ctx_type* ctx){   _real _split_89;
   _real _split_88;
   _real _split_87;
   _real _split_86;
   _real _split_85;
   _real _split_84;
   _real _split_83;
   _real _split_82;
   _real _split_81;
   _real _split_80;
   _real _split_79;
   _real _split_78;
   _real d;
   _real t;
   _real pd;
   _real pt;
   _real dx;
   _real tx;
   _boolean TickOrRot;

   if (Rot == _true) {
     dx = 1.4;
   } else {
     dx = 0.0;
   }
   if (Tick == _true) {
     tx = 0.1;
   } else {
     tx = 0.0;
   }
  TickOrRot = Tick | Rot;
  Lustre_pre_2_get(&_split_78,&ctx->Lustre_pre_2_ctx_tab[0]); 
  Lustre_arrow_2_step(0.0,_split_78,&pd,&ctx->Lustre_arrow_2_ctx_tab[0]); 
  switch (TickOrRot){
  case _false:
  _split_80 = pd;
  d = _split_80;
  break;
  case _true:
  _split_81 = dx;
  sum_50_0d0_step(_split_81,&_split_82,&ctx->sum_50_0d0_ctx_tab[0]); 
  d = _split_82;
  break;
}
  Lustre_pre_2_set(d,&ctx->Lustre_pre_2_ctx_tab[0]); 
  Lustre_pre_2_get(&_split_79,&ctx->Lustre_pre_2_ctx_tab[1]); 
  Lustre_arrow_2_step(0.0,_split_79,&pt,&ctx->Lustre_arrow_2_ctx_tab[1]); 
  switch (TickOrRot){
  case _false:
  _split_85 = pt;
  _split_86 = _split_85;
  break;
  case _true:
  _split_83 = tx;
  sum_50_0d1_step(_split_83,&_split_84,&ctx->sum_50_0d1_ctx_tab[0]); 
  _split_86 = _split_84;
  break;
}
  convertible_maxr_step(0.1,_split_86,&t); 
  Lustre_pre_2_set(t,&ctx->Lustre_pre_2_ctx_tab[1]); 
  Lustre_pre_2_get(&_split_89,&ctx->Lustre_pre_2_ctx_tab[2]); 
  Lustre_slash_step(d,t,&_split_87); 
  convertible_ms_to_kmh_step(_split_87,&_split_88); 
  Lustre_pre_2_set(_split_88,&ctx->Lustre_pre_2_ctx_tab[2]); 
  Lustre_arrow_2_step(0.0,_split_89,Speed,&ctx->Lustre_arrow_2_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_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]);
    Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]);
}

// Initialisation of the  internal structure of convertible_vehicle_ctx
void convertible_vehicle_ctx_init(convertible_vehicle_ctx_type* ctx){
  // ctx->client_data = cdata;
  convertible_vehicle_ctx_reset(ctx);
 }
// Step function(s) for convertible_vehicle_ctx
void convertible_vehicle_step(_boolean Start,_boolean Locked,_real Speed,_real Dist,_integer *st,convertible_vehicle_ctx_type* ctx){   _integer _split_149;
   _boolean _split_148;
   _boolean _split_147;
   _integer _split_146;
   _integer _split_145;
   _boolean _split_144;
   _boolean _split_143;
   _boolean _split_142;
   _integer _split_141;
   _boolean _split_140;
   _boolean _split_139;
   _integer _split_138;
   _integer pst;
   _boolean ac_cond;

  Lustre_pre_get(&_split_138,&ctx->Lustre_pre_ctx_tab[0]); 
  ac_cond = Speed >= 110.0;
  switch (pst){
  case convertible_anti_col:
  _split_147 = ac_cond;
  _split_148 = ! _split_147;
   if (_split_148 == _true) {
     _split_149 = convertible_run;
   } else {
     _split_149 = convertible_anti_col;
   }
  *st = _split_149;
  break;
}
  _split_143 = Speed == 0.0;
  switch (pst){
  case convertible_run:
  _split_144 = _split_143;
   if (_split_144 == _true) {
     _split_145 = convertible_stationnary;
   } else {
     _split_145 = convertible_run;
   }
  _split_142 = ac_cond;
   if (_split_142 == _true) {
     _split_146 = convertible_anti_col;
   } else {
     _split_146 = _split_145;
   }
  *st = _split_146;
  break;
}
  _split_139 = Start & Locked;
  switch (pst){
  case convertible_stationnary:
  _split_140 = _split_139;
   if (_split_140 == _true) {
     _split_141 = convertible_run;
   } else {
     _split_141 = convertible_stationnary;
   }
  *st = _split_141;
  break;
}
  Lustre_pre_set(*st,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_arrow_step(convertible_stationnary,_split_138,&pst,&ctx->Lustre_arrow_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 *out){
  int _i;
  for (_i=0 ; _i<49 ; _i+=2){
    i1 = i1 + i2[_i];
    i1 = i1 + i2[_i+1];
  }
   *out = 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 _split_93;
   _real _split_92;
   _real _split_91;
   _real _split_90;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_split_92); 
  _split_93 = presqrt + _split_92;
  sqrt = 0.5 * _split_93;
  _split_90 = presqrt - sqrt;
  convertible_abs_step(_split_90,&_split_91); 
  ecart = _split_91 < 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 _split_101;
   _real _split_100;
   _real _split_99;
   _real _split_98;
   _real _split_97;
   _real _split_96;
   _real _split_95;
   _real _split_94;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_split_96); 
  _split_97 = presqrt + _split_96;
  sqrt = 0.5 * _split_97;
  _split_94 = presqrt - sqrt;
  convertible_abs_step(_split_94,&_split_95); 
  ecart = _split_95 < 0.0005;
  switch (ecart){
  case _true:
  _split_101 = sqrt;
  *Sqrt = _split_101;
  break;
  case _false:
  _split_99 = sqrt;
  _split_98 = x;
  squareR_1_step(_split_98,_split_99,&_split_100); 
  *Sqrt = _split_100;
  break;
}

} // End of squareR_2_step

// Step function(s) for squareR_3_ctx
void squareR_3_step(_real x,_real presqrt,_real *Sqrt){
   _real _split_109;
   _real _split_108;
   _real _split_107;
   _real _split_106;
   _real _split_105;
   _real _split_104;
   _real _split_103;
   _real _split_102;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_split_104); 
  _split_105 = presqrt + _split_104;
  sqrt = 0.5 * _split_105;
  _split_102 = presqrt - sqrt;
  convertible_abs_step(_split_102,&_split_103); 
  ecart = _split_103 < 0.0005;
  switch (ecart){
  case _true:
  _split_109 = sqrt;
  *Sqrt = _split_109;
  break;
  case _false:
  _split_107 = sqrt;
  _split_106 = x;
  squareR_2_step(_split_106,_split_107,&_split_108); 
  *Sqrt = _split_108;
  break;
}

} // End of squareR_3_step

// Step function(s) for squareR_4_ctx
void squareR_4_step(_real x,_real presqrt,_real *Sqrt){
   _real _split_117;
   _real _split_116;
   _real _split_115;
   _real _split_114;
   _real _split_113;
   _real _split_112;
   _real _split_111;
   _real _split_110;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_split_112); 
  _split_113 = presqrt + _split_112;
  sqrt = 0.5 * _split_113;
  _split_110 = presqrt - sqrt;
  convertible_abs_step(_split_110,&_split_111); 
  ecart = _split_111 < 0.0005;
  switch (ecart){
  case _true:
  _split_117 = sqrt;
  *Sqrt = _split_117;
  break;
  case _false:
  _split_115 = sqrt;
  _split_114 = x;
  squareR_3_step(_split_114,_split_115,&_split_116); 
  *Sqrt = _split_116;
  break;
}

} // End of squareR_4_step

// Step function(s) for squareR_5_ctx
void squareR_5_step(_real x,_real presqrt,_real *Sqrt){
   _real _split_125;
   _real _split_124;
   _real _split_123;
   _real _split_122;
   _real _split_121;
   _real _split_120;
   _real _split_119;
   _real _split_118;
   _real sqrt;
   _boolean ecart;

  Lustre_slash_step(x,presqrt,&_split_120); 
  _split_121 = presqrt + _split_120;
  sqrt = 0.5 * _split_121;
  _split_118 = presqrt - sqrt;
  convertible_abs_step(_split_118,&_split_119); 
  ecart = _split_119 < 0.0005;
  switch (ecart){
  case _true:
  _split_125 = sqrt;
  *Sqrt = _split_125;
  break;
  case _false:
  _split_123 = sqrt;
  _split_122 = x;
  squareR_4_step(_split_122,_split_123,&_split_124); 
  *Sqrt = _split_124;
  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_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[0]);
    Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[0]);
    Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]);
}

// Initialisation of the  internal structure of sum_50_0d0_ctx
void sum_50_0d0_ctx_init(sum_50_0d0_ctx_type* ctx){
  // ctx->client_data = cdata;
  sum_50_0d0_ctx_reset(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 _split_130;
   _real _split_129[50];
   _real _split_128[50];
   _integer _split_127;
   _integer _split_126;
   _real a[50];
   _real pre_a[50];
   _integer i;

  Lustre_pre_get(&_split_126,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_arrow_step(0,_split_126,&_split_127,&ctx->Lustre_arrow_ctx_tab[0]); 
  i = _split_127 + 1;
  Lustre_pre_set(i,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_pre_3_get(_split_129,&ctx->Lustre_pre_3_ctx_tab[0]); 
  Lustre_hat_step(0.0,_split_128); 
  Lustre_arrow_3_step(_split_128,_split_129,pre_a,&ctx->Lustre_arrow_3_ctx_tab[0]); 
  _split_130 = i % 50;
  assign_50_step(s,_split_130,pre_a,a); 
  Lustre_pre_3_set(a,&ctx->Lustre_pre_3_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_3_ctx_reset(&ctx->Lustre_pre_3_ctx_tab[0]);
    Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]);
    Lustre_arrow_3_ctx_reset(&ctx->Lustre_arrow_3_ctx_tab[0]);
    Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]);
}

// Initialisation of the  internal structure of sum_50_0d1_ctx
void sum_50_0d1_ctx_init(sum_50_0d1_ctx_type* ctx){
  // ctx->client_data = cdata;
  sum_50_0d1_ctx_reset(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 _split_135;
   _real _split_134[50];
   _real _split_133[50];
   _integer _split_132;
   _integer _split_131;
   _real a[50];
   _real pre_a[50];
   _integer i;

  Lustre_pre_get(&_split_131,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_arrow_step(0,_split_131,&_split_132,&ctx->Lustre_arrow_ctx_tab[0]); 
  i = _split_132 + 1;
  Lustre_pre_set(i,&ctx->Lustre_pre_ctx_tab[0]); 
  Lustre_pre_3_get(_split_134,&ctx->Lustre_pre_3_ctx_tab[0]); 
  Lustre_hat_step(0.1,_split_133); 
  Lustre_arrow_3_step(_split_133,_split_134,pre_a,&ctx->Lustre_arrow_3_ctx_tab[0]); 
  _split_135 = i % 50;
  assign_50_step(s,_split_135,pre_a,a); 
  Lustre_pre_3_set(a,&ctx->Lustre_pre_3_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 _split_137;
   _boolean _split_136;

  _split_136 = acc.i == acc.j;
   if (_split_136 == _true) {
     *ncell = acc.v;
   } else {
     *ncell = cell;
   }
  _split_137 = acc.i + 1;
  nacc->i = _split_137;
  nacc->j = acc.j;
  nacc->v = acc.v;

} // End of update_cell_do_50_step