You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 397. Integer Replacement.go
    path of file: ./repos/LeetCode-Go/leetcode/0397.Integer-Replacement
    
    the code of the file until where you have to start completion: package leetcode

func integerReplace
    
func integerReplacement(n int) int {
	res := 0
	for n > 1 {
		if (n & 1) == 0 { // 判断是否是偶数
			n >>= 1
		} else if (n+1)%4 == 0 && n != 3 { // 末尾 2 位为 11
			n++
		} else { // 末尾 2 位为 01
			n--
		}
		res++
	}
	return res
}