What if someone makes the profit of 50,000 but has a loan of more than 100,000 so does he have to pay off the loan and then pay khums if any additional amount is left?

If he paid the amount he has in hand (50k) to settle his loan before khoms due date, he is exempted. Otherwise, he has to pay the khoms.