```\n    function _withdrawUpdateRewardState(uint256 lpAmount_, bool claim_) internal {\n        uint256 numInternalRewardTokens = internalRewardTokens.length;\n        uint256 numExternalRewardTokens = externalRewardTokens.length;\n\n        // Handles accounting logic for internal and external rewards, harvests external rewards\n        uint256[] memory accumulatedInternalRewards = _accumulateInternalRewards();\n        uint256[] memory accumulatedExternalRewards = _accumulateExternalRewards();\n        for (uint256 i; i < numInternalRewardTokens;) {\n            _updateInternalRewardState(i, accumulatedInternalRewards[i]);\n            if (claim_) _claimInternalRewards(i);\n\n            // Update reward debts so as to not understate the amount of rewards owed to the user, and push\n            // any unclaimed rewards to the user's reward debt so that they can be claimed later\n            InternalRewardToken memory rewardToken = internalRewardTokens[i];\n            // @audit In our example, rewardDebtDiff = 3e17 (total rewards are 6e17 so 50% of shares earned 50% of reward tokens)\n            uint256 rewardDebtDiff = lpAmount_ * rewardToken.accumulatedRewardsPerShare;\n\n            // @audit 3e17 > 1e17\n            if (rewardDebtDiff > userRewardDebts[msg.sender][rewardToken.token]) {\n\n                // @audit userRewardDebts is set to 0 (original value was 1e17, the number of tokens that were already claimed)\n                userRewardDebts[msg.sender][rewardToken.token] = 0;\n                // @audit cached amount = 3e17 - 0 = 3e17.\n                // Alice is assigned 3e17 reward tokens to be distributed the next time they claim\n                // The remaining 3e17 LP shares are worth another 3e17 reward tokens.\n                // Alice already claimed 1e17 before the withdrawal.\n                // Thus, Alice receives 7e17 reward tokens instead of 6e17\n                cachedUserRewards[msg.sender][rewardToken.token] +=\n                    rewardDebtDiff - userRewardDebts[msg.sender][rewardToken.token];\n            } else {\n                userRewardDebts[msg.sender][rewardToken.token] -= rewardDebtDiff;\n            }\n\n            unchecked {\n                ++i;\n            }\n        }\n```\n