diff --git a/jchuff.c b/jchuff.c
index 5fbc53d..1fcc6cf 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -555,6 +555,7 @@ def store
     i = $idx.next
     printf("\t\t\"cmp   %s, #0\\n\"\n", r)
     printf("\t\t\"strh  %s, [%%[out], #%d]\\n\"\n", r, i * 2)
+    printf("\t\t\"it ne\\n\"\n")
     printf("\t\t\"movne %%[n], #%d\\n\"\n", i)
 end
 
@@ -583,252 +584,315 @@ find_last_nonzero_index (JCOEFPTR block, JCOEFPTR out)
     "ldrh  %[tmp3], [%[blk], #32]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #2]\n"
+    "it ne\n"
     "movne %[n], #1\n"
     "ldrh  %[tmp1], [%[blk], #18]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #4]\n"
+    "it ne\n"
     "movne %[n], #2\n"
     "ldrh  %[tmp2], [%[blk], #4]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #6]\n"
+    "it ne\n"
     "movne %[n], #3\n"
     "ldrh  %[tmp3], [%[blk], #6]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #8]\n"
+    "it ne\n"
     "movne %[n], #4\n"
     "ldrh  %[tmp1], [%[blk], #20]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #10]\n"
+    "it ne\n"
     "movne %[n], #5\n"
     "ldrh  %[tmp2], [%[blk], #34]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #12]\n"
+    "it ne\n"
     "movne %[n], #6\n"
     "ldrh  %[tmp3], [%[blk], #48]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #14]\n"
+    "it ne\n"
     "movne %[n], #7\n"
     "ldrh  %[tmp1], [%[blk], #64]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #16]\n"
+    "it ne\n"
     "movne %[n], #8\n"
     "ldrh  %[tmp2], [%[blk], #50]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #18]\n"
+    "it ne\n"
     "movne %[n], #9\n"
     "ldrh  %[tmp3], [%[blk], #36]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #20]\n"
+    "it ne\n"
     "movne %[n], #10\n"
     "ldrh  %[tmp1], [%[blk], #22]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #22]\n"
+    "it ne\n"
     "movne %[n], #11\n"
     "ldrh  %[tmp2], [%[blk], #8]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #24]\n"
+    "it ne\n"
     "movne %[n], #12\n"
     "ldrh  %[tmp3], [%[blk], #10]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #26]\n"
+    "it ne\n"
     "movne %[n], #13\n"
     "ldrh  %[tmp1], [%[blk], #24]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #28]\n"
+    "it ne\n"
     "movne %[n], #14\n"
     "ldrh  %[tmp2], [%[blk], #38]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #30]\n"
+    "it ne\n"
     "movne %[n], #15\n"
     "ldrh  %[tmp3], [%[blk], #52]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #32]\n"
+    "it ne\n"
     "movne %[n], #16\n"
     "ldrh  %[tmp1], [%[blk], #66]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #34]\n"
+    "it ne\n"
     "movne %[n], #17\n"
     "ldrh  %[tmp2], [%[blk], #80]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #36]\n"
+    "it ne\n"
     "movne %[n], #18\n"
     "ldrh  %[tmp3], [%[blk], #96]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #38]\n"
+    "it ne\n"
     "movne %[n], #19\n"
     "ldrh  %[tmp1], [%[blk], #82]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #40]\n"
+    "it ne\n"
     "movne %[n], #20\n"
     "ldrh  %[tmp2], [%[blk], #68]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #42]\n"
+    "it ne\n"
     "movne %[n], #21\n"
     "ldrh  %[tmp3], [%[blk], #54]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #44]\n"
+    "it ne\n"
     "movne %[n], #22\n"
     "ldrh  %[tmp1], [%[blk], #40]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #46]\n"
+    "it ne\n"
     "movne %[n], #23\n"
     "ldrh  %[tmp2], [%[blk], #26]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #48]\n"
+    "it ne\n"
     "movne %[n], #24\n"
     "ldrh  %[tmp3], [%[blk], #12]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #50]\n"
+    "it ne\n"
     "movne %[n], #25\n"
     "ldrh  %[tmp1], [%[blk], #14]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #52]\n"
+    "it ne\n"
     "movne %[n], #26\n"
     "ldrh  %[tmp2], [%[blk], #28]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #54]\n"
+    "it ne\n"
     "movne %[n], #27\n"
     "ldrh  %[tmp3], [%[blk], #42]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #56]\n"
+    "it ne\n"
     "movne %[n], #28\n"
     "ldrh  %[tmp1], [%[blk], #56]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #58]\n"
+    "it ne\n"
     "movne %[n], #29\n"
     "ldrh  %[tmp2], [%[blk], #70]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #60]\n"
+    "it ne\n"
     "movne %[n], #30\n"
     "ldrh  %[tmp3], [%[blk], #84]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #62]\n"
+    "it ne\n"
     "movne %[n], #31\n"
     "ldrh  %[tmp1], [%[blk], #98]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #64]\n"
+    "it ne\n"
     "movne %[n], #32\n"
     "ldrh  %[tmp2], [%[blk], #112]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #66]\n"
+    "it ne\n"
     "movne %[n], #33\n"
     "ldrh  %[tmp3], [%[blk], #114]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #68]\n"
+    "it ne\n"
     "movne %[n], #34\n"
     "ldrh  %[tmp1], [%[blk], #100]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #70]\n"
+    "it ne\n"
     "movne %[n], #35\n"
     "ldrh  %[tmp2], [%[blk], #86]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #72]\n"
+    "it ne\n"
     "movne %[n], #36\n"
     "ldrh  %[tmp3], [%[blk], #72]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #74]\n"
+    "it ne\n"
     "movne %[n], #37\n"
     "ldrh  %[tmp1], [%[blk], #58]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #76]\n"
+    "it ne\n"
     "movne %[n], #38\n"
     "ldrh  %[tmp2], [%[blk], #44]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #78]\n"
+    "it ne\n"
     "movne %[n], #39\n"
     "ldrh  %[tmp3], [%[blk], #30]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #80]\n"
+    "it ne\n"
     "movne %[n], #40\n"
     "ldrh  %[tmp1], [%[blk], #46]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #82]\n"
+    "it ne\n"
     "movne %[n], #41\n"
     "ldrh  %[tmp2], [%[blk], #60]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #84]\n"
+    "it ne\n"
     "movne %[n], #42\n"
     "ldrh  %[tmp3], [%[blk], #74]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #86]\n"
+    "it ne\n"
     "movne %[n], #43\n"
     "ldrh  %[tmp1], [%[blk], #88]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #88]\n"
+    "it ne\n"
     "movne %[n], #44\n"
     "ldrh  %[tmp2], [%[blk], #102]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #90]\n"
+    "it ne\n"
     "movne %[n], #45\n"
     "ldrh  %[tmp3], [%[blk], #116]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #92]\n"
+    "it ne\n"
     "movne %[n], #46\n"
     "ldrh  %[tmp1], [%[blk], #118]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #94]\n"
+    "it ne\n"
     "movne %[n], #47\n"
     "ldrh  %[tmp2], [%[blk], #104]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #96]\n"
+    "it ne\n"
     "movne %[n], #48\n"
     "ldrh  %[tmp3], [%[blk], #90]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #98]\n"
+    "it ne\n"
     "movne %[n], #49\n"
     "ldrh  %[tmp1], [%[blk], #76]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #100]\n"
+    "it ne\n"
     "movne %[n], #50\n"
     "ldrh  %[tmp2], [%[blk], #62]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #102]\n"
+    "it ne\n"
     "movne %[n], #51\n"
     "ldrh  %[tmp3], [%[blk], #78]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #104]\n"
+    "it ne\n"
     "movne %[n], #52\n"
     "ldrh  %[tmp1], [%[blk], #92]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #106]\n"
+    "it ne\n"
     "movne %[n], #53\n"
     "ldrh  %[tmp2], [%[blk], #106]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #108]\n"
+    "it ne\n"
     "movne %[n], #54\n"
     "ldrh  %[tmp3], [%[blk], #120]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #110]\n"
+    "it ne\n"
     "movne %[n], #55\n"
     "ldrh  %[tmp1], [%[blk], #122]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #112]\n"
+    "it ne\n"
     "movne %[n], #56\n"
     "ldrh  %[tmp2], [%[blk], #108]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #114]\n"
+    "it ne\n"
     "movne %[n], #57\n"
     "ldrh  %[tmp3], [%[blk], #94]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #116]\n"
+    "it ne\n"
     "movne %[n], #58\n"
     "ldrh  %[tmp1], [%[blk], #110]\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #118]\n"
+    "it ne\n"
     "movne %[n], #59\n"
     "ldrh  %[tmp2], [%[blk], #124]\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #120]\n"
+    "it ne\n"
     "movne %[n], #60\n"
     "ldrh  %[tmp3], [%[blk], #126]\n"
     "cmp   %[tmp1], #0\n"
     "strh  %[tmp1], [%[out], #122]\n"
+    "it ne\n"
     "movne %[n], #61\n"
     "cmp   %[tmp2], #0\n"
     "strh  %[tmp2], [%[out], #124]\n"
+    "it ne\n"
     "movne %[n], #62\n"
     "cmp   %[tmp3], #0\n"
     "strh  %[tmp3], [%[out], #126]\n"
+    "it ne\n"
     "movne %[n], #63\n"
     : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [tmp3] "=&r" (tmp3),
       [n] "+&r" (n)
