     end if
 
   end for
-  
+
   return bc
 end function
+
+
+function branch_straighten(sequence bc)
+  integer op, c, d
+  for i = 1 to length(bc) do
+    op = and_bits(bc[i], #FF)
+    if op >= JL and op <= JNE then
+      c = and_bits(floor(bc[i] / #1000000), #FF)
+      c -= 2 * and_bits(c, #80)
+      while and_bits(bc[i+1+c], #FF) = JMP do
+        d = and_bits(floor(bc[i+1+c] / #10000), #FFFF)
+        d -= 2 * and_bits(d, #8000)
+        c += d + 1
+      end while
+      bc[i] = and_bits(bc[i], #FFFFFF) + and_bits(c, #FF) * #1000000
+    end if
+  end for
+  return bc
+end function
+
+
 
 procedure disasm(sequence bc)
   integer op, a, b, c, d, sc, sd

        error("expected statement")
      end if
    end if
    --? s
    if length(s) then
      ast = append(ast, s)
    end if
  end while
  return ast
end function



  end for
end procedure



disasm(branch_straighten(compile(parse(GLOBAL)) & asm(END,0,0,0)))
