AMD Interview Question

optimize logic