Severe pain under rib cage which becomes worse on bending can be some sort of musculoskeletal pain
.....the other thing can be pricarditis whose pain becomes worse on bending or the gastric reflux
where bending causes increased pressure over the abdomen causing more reflux and increased pain....
In my opinion you must go for chest xray PA view to see the underlying lung and rib cage. barium meal
to see for filling defect on stomach wall for peptic ulcers, ECG to see cardiac status where in pericarditis
can be ST segment elevation typically plateau shape....
Meet your doctor and in meantime you can take analgesics muscle relaxent combination and a proton pump
inhibitor like omeprazole....
Don't forget to consult your family physician