Tweak how std/gif does interlace row replication
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c
index bdd505e..9dcb62a 100644
--- a/release/c/wuffs-unsupported-snapshot.c
+++ b/release/c/wuffs-unsupported-snapshot.c
@@ -8625,7 +8625,7 @@
 static const uint8_t               //
     wuffs_gif__interlace_count[5]  //
     WUFFS_BASE__POTENTIALLY_UNUSED = {
-        0, 0, 1, 3, 7,
+        0, 1, 2, 4, 8,
 };
 
 static const uint8_t              //
@@ -11112,7 +11112,8 @@
   wuffs_base__table_u8 v_tab = {0};
   uint64_t v_i = 0;
   uint64_t v_j = 0;
-  uint32_t v_replicate_count = 0;
+  uint32_t v_replicate_y0 = 0;
+  uint32_t v_replicate_y1 = 0;
   wuffs_base__slice_u8 v_replicate_dst = {0};
   wuffs_base__slice_u8 v_replicate_src = {0};
 
@@ -11174,25 +11175,22 @@
       if ((self->private_impl.f_num_decoded_frames_value == 0) &&
           !self->private_impl.f_gc_has_transparent_index &&
           (self->private_impl.f_interlace > 1)) {
-        v_replicate_count = ((uint32_t)(
-            wuffs_gif__interlace_count[self->private_impl.f_interlace]));
         v_replicate_src =
             wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
-        while (v_replicate_count > 0) {
-          v_replicate_dst = wuffs_base__table_u8__row(
-              v_tab, wuffs_base__u32__sat_add(self->private_impl.f_dst_y,
-                                              v_replicate_count));
+        v_replicate_y0 =
+            wuffs_base__u32__sat_add(self->private_impl.f_dst_y, 1);
+        v_replicate_y1 = wuffs_base__u32__sat_add(
+            self->private_impl.f_dst_y,
+            ((uint32_t)(
+                wuffs_gif__interlace_count[self->private_impl.f_interlace])));
+        while (v_replicate_y0 < v_replicate_y1) {
+          v_replicate_dst = wuffs_base__table_u8__row(v_tab, v_replicate_y0);
           wuffs_base__slice_u8__copy_from_slice(v_replicate_dst,
                                                 v_replicate_src);
-          v_replicate_count -= 1;
+          v_replicate_y0 += 1;
         }
         self->private_impl.f_dirty_max_excl_y = wuffs_base__u32__max(
-            self->private_impl.f_dirty_max_excl_y,
-            wuffs_base__u32__sat_add(
-                self->private_impl.f_dst_y,
-                (((uint32_t)(wuffs_gif__interlace_count[self->private_impl
-                                                            .f_interlace])) +
-                 1)));
+            self->private_impl.f_dirty_max_excl_y, v_replicate_y1);
       }
       wuffs_base__u32__sat_add_indirect(
           &self->private_impl.f_dst_y,
diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs
index 83e6d25..c06f21a 100644
--- a/std/gif/decode_gif.wuffs
+++ b/std/gif/decode_gif.wuffs
@@ -118,7 +118,7 @@
 // to that maximum value (and therefore outside the frame rect).
 pri const interlace_start array[5] base.u32 = [0xFFFFFFFF, 1, 2, 4, 0]
 pri const interlace_delta array[5] base.u8 = [1, 2, 4, 8, 8]
-pri const interlace_count array[5] base.u8 = [0, 0, 1, 3, 7]
+pri const interlace_count array[5] base.u8 = [0, 1, 2, 4, 8]
 
 pub struct decoder?(
 	width  base.u32,
@@ -1104,7 +1104,8 @@
 	var tab             table base.u8
 	var i               base.u64
 	var j               base.u64
-	var replicate_count base.u32
+	var replicate_y0    base.u32
+	var replicate_y1    base.u32
 	var replicate_dst   slice base.u8
 	var replicate_src   slice base.u8
 
@@ -1178,16 +1179,16 @@
 				(not this.gc_has_transparent_index) and
 				(this.interlace > 1) {
 
-				replicate_count = interlace_count[this.interlace] as base.u32
 				replicate_src = tab.row(y:this.dst_y)
-				while replicate_count > 0 {
-					replicate_dst = tab.row(y:this.dst_y ~sat+ replicate_count)
+				replicate_y0 = this.dst_y ~sat+ 1
+				replicate_y1 = this.dst_y ~sat+ (interlace_count[this.interlace] as base.u32)
+				while replicate_y0 < replicate_y1 {
+					assert replicate_y0 < 0xFFFFFFFF via "a < b: a < c; c <= b"(c:replicate_y1)
+					replicate_dst = tab.row(y:replicate_y0)
 					replicate_dst.copy_from_slice!(s:replicate_src)
-					replicate_count -= 1
+					replicate_y0 += 1
 				}
-
-				this.dirty_max_excl_y = this.dirty_max_excl_y.max(
-					a:this.dst_y ~sat+ ((interlace_count[this.interlace] as base.u32) + 1))
+				this.dirty_max_excl_y = this.dirty_max_excl_y.max(a:replicate_y1)
 			}
 
 			this.dst_y ~sat+= interlace_delta[this.interlace] as base.u32