bool getSwitchIndex(Block block, out int numInstrs, out Block switchTarget) { numInstrs = -1; switchTarget = null; if (block.Instructions.Count < 2) return false; int count = block.Instructions.Count; if (!block.Instructions[count - 2].isLdcI4()) return false; if (!block.Instructions[count - 1].isStloc() || getLocalVar(block.Instructions[count - 1]) != stateVar) return false; if (!block.isFallThrough() || !switchTargetBlocks.ContainsKey(block.FallThrough)) return false; int switchIndex = (int)block.Instructions[count - 2].getLdcI4Value(); if (switchIndex < 0 || switchIndex >= switchBlock.Targets.Count) return false; numInstrs = 2; switchTarget = switchBlock.Targets[switchIndex]; return true; }