Pushbutton increment/decrement counter

one issue is the prev state needs to be updated

    if (button2_State != button2prev_State){
        button2prev_State = button2_State;
        if (button2_State == LOW ) {
            x--;
        }
    }

are you sure the buttons are wired to pins 40 & 41?
can you verify with a small program that simply prints the state of the pin

and post code using "</>"