package optimizer import "strings" // passJmpNext removes unconditional jumps to the immediately following label. // Pattern: jmp L; L: → (remove jmp) func passJmpNext(lines []asmLine) []asmLine { var result []asmLine skipNext := false for i := 0; i < len(lines); i++ { if skipNext { skipNext = false continue } line := lines[i] // Check for jmp L followed by label L: if line.isCode && line.opcode == "jmp" && i+1 < len(lines) { next := lines[i+1] if next.isLabel && strings.TrimSpace(next.text) == strings.TrimSpace(line.operand) { // Remove the jmp, keep the label result = append(result, next) skipNext = true continue } } result = append(result, line) } return result }