; LLVM IR from taichi-dev/taichi :: taichi/common (miniz)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.mz_zip_archive = type { i64, i64, i32, i32, i32, i32, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mz_zip_internal_state_tag = type { %struct.mz_zip_array, %struct.mz_zip_array, %struct.mz_zip_array, i32, i32, i32, ptr, i64, ptr, i64, i64 }
%struct.mz_zip_array = type { ptr, i64, i64, i32 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @mz_zip_set_error(ptr noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @mz_write_le32(ptr noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @mz_write_le64(ptr noundef, i64 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @mz_write_le16(ptr noundef, i16 noundef zeroext) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mz_zip_writer_finalize_archive(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca [256 x i8], align 16
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %7) #5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %22

12:                                               ; preds = %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.mz_zip_archive, ptr %13, i32 0, i32 15
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %22

17:                                               ; preds = %12
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mz_zip_archive, ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = icmp ne i32 %20, 2
  br i1 %21, label %22, label %25

22:                                               ; preds = %17, %12, %1
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call i32 @mz_zip_set_error(ptr noundef %23, i32 noundef 24)
  store i32 %24, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

25:                                               ; preds = %17
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mz_zip_archive, ptr %26, i32 0, i32 15
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  store ptr %28, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %43

33:                                               ; preds = %25
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.mz_zip_array, ptr %35, i32 0, i32 1
  %37 = load i64, ptr %36, align 8, !tbaa !17
  %38 = icmp uge i64 %37, 4294967295
  br i1 %38, label %39, label %42

39:                                               ; preds = %33
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = call i32 @mz_zip_set_error(ptr noundef %40, i32 noundef 2)
  store i32 %41, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

42:                                               ; preds = %33
  br label %63

43:                                               ; preds = %25
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mz_zip_archive, ptr %44, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !18
  %47 = icmp ugt i32 %46, 65535
  br i1 %47, label %59, label %48

48:                                               ; preds = %43
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mz_zip_archive, ptr %49, i32 0, i32 0
  %51 = load i64, ptr %50, align 8, !tbaa !19
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.mz_zip_array, ptr %53, i32 0, i32 1
  %55 = load i64, ptr %54, align 8, !tbaa !17
  %56 = add i64 %51, %55
  %57 = add i64 %56, 22
  %58 = icmp ugt i64 %57, 4294967295
  br i1 %58, label %59, label %62

59:                                               ; preds = %48, %43
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = call i32 @mz_zip_set_error(ptr noundef %60, i32 noundef 2)
  store i32 %61, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

62:                                               ; preds = %48
  br label %63

63:                                               ; preds = %62, %42
  store i64 0, ptr %5, align 8, !tbaa !20
  store i64 0, ptr %6, align 8, !tbaa !20
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mz_zip_archive, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !18
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %103

68:                                               ; preds = %63
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.mz_zip_archive, ptr %69, i32 0, i32 0
  %71 = load i64, ptr %70, align 8, !tbaa !19
  store i64 %71, ptr %5, align 8, !tbaa !20
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.mz_zip_array, ptr %73, i32 0, i32 1
  %75 = load i64, ptr %74, align 8, !tbaa !17
  store i64 %75, ptr %6, align 8, !tbaa !20
  %76 = load i64, ptr %5, align 8, !tbaa !20
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mz_zip_archive, ptr %77, i32 0, i32 1
  store i64 %76, ptr %78, align 8, !tbaa !21
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.mz_zip_archive, ptr %79, i32 0, i32 12
  %81 = load ptr, ptr %80, align 8, !tbaa !22
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.mz_zip_archive, ptr %82, i32 0, i32 14
  %84 = load ptr, ptr %83, align 8, !tbaa !23
  %85 = load i64, ptr %5, align 8, !tbaa !20
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %86, i32 0, i32 0
  %88 = getelementptr inbounds %struct.mz_zip_array, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !24
  %90 = load i64, ptr %6, align 8, !tbaa !20
  %91 = call i64 %81(ptr noundef %84, i64 noundef %85, ptr noundef %89, i64 noundef %90)
  %92 = load i64, ptr %6, align 8, !tbaa !20
  %93 = icmp ne i64 %91, %92
  br i1 %93, label %94, label %97

94:                                               ; preds = %68
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = call i32 @mz_zip_set_error(ptr noundef %95, i32 noundef 19)
  store i32 %96, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

97:                                               ; preds = %68
  %98 = load i64, ptr %6, align 8, !tbaa !20
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.mz_zip_archive, ptr %99, i32 0, i32 0
  %101 = load i64, ptr %100, align 8, !tbaa !19
  %102 = add i64 %101, %98
  store i64 %102, ptr %100, align 8, !tbaa !19
  br label %103

103:                                              ; preds = %97, %63
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %104, i32 0, i32 4
  %106 = load i32, ptr %105, align 4, !tbaa !14
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %190

108:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.mz_zip_archive, ptr %109, i32 0, i32 0
  %111 = load i64, ptr %110, align 8, !tbaa !19
  store i64 %111, ptr %9, align 8, !tbaa !20
  %112 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %112, i8 0, i64 256, i1 false)
  %113 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %114 = getelementptr inbounds i8, ptr %113, i64 0
  call void @mz_write_le32(ptr noundef %114, i32 noundef 101075792)
  %115 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %116 = getelementptr inbounds i8, ptr %115, i64 4
  call void @mz_write_le64(ptr noundef %116, i64 noundef 44)
  %117 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %118 = getelementptr inbounds i8, ptr %117, i64 12
  call void @mz_write_le16(ptr noundef %118, i16 noundef zeroext 798)
  %119 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %120 = getelementptr inbounds i8, ptr %119, i64 14
  call void @mz_write_le16(ptr noundef %120, i16 noundef zeroext 45)
  %121 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %122 = getelementptr inbounds i8, ptr %121, i64 24
  %123 = load ptr, ptr %3, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.mz_zip_archive, ptr %123, i32 0, i32 2
  %125 = load i32, ptr %124, align 8, !tbaa !18
  %126 = zext i32 %125 to i64
  call void @mz_write_le64(ptr noundef %122, i64 noundef %126)
  %127 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %128 = getelementptr inbounds i8, ptr %127, i64 32
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.mz_zip_archive, ptr %129, i32 0, i32 2
  %131 = load i32, ptr %130, align 8, !tbaa !18
  %132 = zext i32 %131 to i64
  call void @mz_write_le64(ptr noundef %128, i64 noundef %132)
  %133 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %134 = getelementptr inbounds i8, ptr %133, i64 40
  %135 = load i64, ptr %6, align 8, !tbaa !20
  call void @mz_write_le64(ptr noundef %134, i64 noundef %135)
  %136 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %137 = getelementptr inbounds i8, ptr %136, i64 48
  %138 = load i64, ptr %5, align 8, !tbaa !20
  call void @mz_write_le64(ptr noundef %137, i64 noundef %138)
  %139 = load ptr, ptr %3, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.mz_zip_archive, ptr %139, i32 0, i32 12
  %141 = load ptr, ptr %140, align 8, !tbaa !22
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.mz_zip_archive, ptr %142, i32 0, i32 14
  %144 = load ptr, ptr %143, align 8, !tbaa !23
  %145 = load ptr, ptr %3, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.mz_zip_archive, ptr %145, i32 0, i32 0
  %147 = load i64, ptr %146, align 8, !tbaa !19
  %148 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %149 = call i64 %141(ptr noundef %144, i64 noundef %147, ptr noundef %148, i64 noundef 56)
  %150 = icmp ne i64 %149, 56
  br i1 %150, label %151, label %154

151:                                              ; preds = %108
  %152 = load ptr, ptr %3, align 8, !tbaa !5
  %153 = call i32 @mz_zip_set_error(ptr noundef %152, i32 noundef 19)
  store i32 %153, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %187

154:                                              ; preds = %108
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.mz_zip_archive, ptr %155, i32 0, i32 0
  %157 = load i64, ptr %156, align 8, !tbaa !19
  %158 = add i64 %157, 56
  store i64 %158, ptr %156, align 8, !tbaa !19
  %159 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %159, i8 0, i64 256, i1 false)
  %160 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %161 = getelementptr inbounds i8, ptr %160, i64 0
  call void @mz_write_le32(ptr noundef %161, i32 noundef 117853008)
  %162 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %163 = getelementptr inbounds i8, ptr %162, i64 8
  %164 = load i64, ptr %9, align 8, !tbaa !20
  call void @mz_write_le64(ptr noundef %163, i64 noundef %164)
  %165 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %166 = getelementptr inbounds i8, ptr %165, i64 16
  call void @mz_write_le32(ptr noundef %166, i32 noundef 1)
  %167 = load ptr, ptr %3, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.mz_zip_archive, ptr %167, i32 0, i32 12
  %169 = load ptr, ptr %168, align 8, !tbaa !22
  %170 = load ptr, ptr %3, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.mz_zip_archive, ptr %170, i32 0, i32 14
  %172 = load ptr, ptr %171, align 8, !tbaa !23
  %173 = load ptr, ptr %3, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.mz_zip_archive, ptr %173, i32 0, i32 0
  %175 = load i64, ptr %174, align 8, !tbaa !19
  %176 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %177 = call i64 %169(ptr noundef %172, i64 noundef %175, ptr noundef %176, i64 noundef 20)
  %178 = icmp ne i64 %177, 20
  br i1 %178, label %179, label %182

179:                                              ; preds = %154
  %180 = load ptr, ptr %3, align 8, !tbaa !5
  %181 = call i32 @mz_zip_set_error(ptr noundef %180, i32 noundef 19)
  store i32 %181, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %187

182:                                              ; preds = %154
  %183 = load ptr, ptr %3, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.mz_zip_archive, ptr %183, i32 0, i32 0
  %185 = load i64, ptr %184, align 8, !tbaa !19
  %186 = add i64 %185, 20
  store i64 %186, ptr %184, align 8, !tbaa !19
  store i32 0, ptr %8, align 4
  br label %187

187:                                              ; preds = %182, %179, %151
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %188 = load i32, ptr %8, align 4
  switch i32 %188, label %278 [
    i32 0, label %189
  ]

189:                                              ; preds = %187
  br label %190

190:                                              ; preds = %189, %103
  %191 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %191, i8 0, i64 256, i1 false)
  %192 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %193 = getelementptr inbounds i8, ptr %192, i64 0
  call void @mz_write_le32(ptr noundef %193, i32 noundef 101010256)
  %194 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %195 = getelementptr inbounds i8, ptr %194, i64 8
  %196 = load ptr, ptr %3, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.mz_zip_archive, ptr %196, i32 0, i32 2
  %198 = load i32, ptr %197, align 8, !tbaa !18
  %199 = icmp ult i32 65535, %198
  br i1 %199, label %200, label %201

200:                                              ; preds = %190
  br label %205

201:                                              ; preds = %190
  %202 = load ptr, ptr %3, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.mz_zip_archive, ptr %202, i32 0, i32 2
  %204 = load i32, ptr %203, align 8, !tbaa !18
  br label %205

205:                                              ; preds = %201, %200
  %206 = phi i32 [ 65535, %200 ], [ %204, %201 ]
  %207 = trunc i32 %206 to i16
  call void @mz_write_le16(ptr noundef %195, i16 noundef zeroext %207)
  %208 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %209 = getelementptr inbounds i8, ptr %208, i64 10
  %210 = load ptr, ptr %3, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.mz_zip_archive, ptr %210, i32 0, i32 2
  %212 = load i32, ptr %211, align 8, !tbaa !18
  %213 = icmp ult i32 65535, %212
  br i1 %213, label %214, label %215

214:                                              ; preds = %205
  br label %219

215:                                              ; preds = %205
  %216 = load ptr, ptr %3, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.mz_zip_archive, ptr %216, i32 0, i32 2
  %218 = load i32, ptr %217, align 8, !tbaa !18
  br label %219

219:                                              ; preds = %215, %214
  %220 = phi i32 [ 65535, %214 ], [ %218, %215 ]
  %221 = trunc i32 %220 to i16
  call void @mz_write_le16(ptr noundef %209, i16 noundef zeroext %221)
  %222 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %223 = getelementptr inbounds i8, ptr %222, i64 12
  %224 = load i64, ptr %6, align 8, !tbaa !20
  %225 = icmp ult i64 4294967295, %224
  br i1 %225, label %226, label %227

226:                                              ; preds = %219
  br label %229

227:                                              ; preds = %219
  %228 = load i64, ptr %6, align 8, !tbaa !20
  br label %229

229:                                              ; preds = %227, %226
  %230 = phi i64 [ 4294967295, %226 ], [ %228, %227 ]
  %231 = trunc i64 %230 to i32
  call void @mz_write_le32(ptr noundef %223, i32 noundef %231)
  %232 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %233 = getelementptr inbounds i8, ptr %232, i64 16
  %234 = load i64, ptr %5, align 8, !tbaa !20
  %235 = icmp ult i64 4294967295, %234
  br i1 %235, label %236, label %237

236:                                              ; preds = %229
  br label %239

237:                                              ; preds = %229
  %238 = load i64, ptr %5, align 8, !tbaa !20
  br label %239

239:                                              ; preds = %237, %236
  %240 = phi i64 [ 4294967295, %236 ], [ %238, %237 ]
  %241 = trunc i64 %240 to i32
  call void @mz_write_le32(ptr noundef %233, i32 noundef %241)
  %242 = load ptr, ptr %3, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.mz_zip_archive, ptr %242, i32 0, i32 12
  %244 = load ptr, ptr %243, align 8, !tbaa !22
  %245 = load ptr, ptr %3, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.mz_zip_archive, ptr %245, i32 0, i32 14
  %247 = load ptr, ptr %246, align 8, !tbaa !23
  %248 = load ptr, ptr %3, align 8, !tbaa !5
  %249 = getelementptr inbounds %struct.mz_zip_archive, ptr %248, i32 0, i32 0
  %250 = load i64, ptr %249, align 8, !tbaa !19
  %251 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %252 = call i64 %244(ptr noundef %247, i64 noundef %250, ptr noundef %251, i64 noundef 22)
  %253 = icmp ne i64 %252, 22
  br i1 %253, label %254, label %257

254:                                              ; preds = %239
  %255 = load ptr, ptr %3, align 8, !tbaa !5
  %256 = call i32 @mz_zip_set_error(ptr noundef %255, i32 noundef 19)
  store i32 %256, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

257:                                              ; preds = %239
  %258 = load ptr, ptr %4, align 8, !tbaa !5
  %259 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %258, i32 0, i32 6
  %260 = load ptr, ptr %259, align 8, !tbaa !25
  %261 = icmp ne ptr %260, null
  br i1 %261, label %262, label %271

262:                                              ; preds = %257
  %263 = load ptr, ptr %4, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.mz_zip_internal_state_tag, ptr %263, i32 0, i32 6
  %265 = load ptr, ptr %264, align 8, !tbaa !25
  %266 = call i32 @fflush(ptr noundef %265)
  %267 = icmp eq i32 %266, -1
  br i1 %267, label %268, label %271

268:                                              ; preds = %262
  %269 = load ptr, ptr %3, align 8, !tbaa !5
  %270 = call i32 @mz_zip_set_error(ptr noundef %269, i32 noundef 21)
  store i32 %270, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

271:                                              ; preds = %262, %257
  %272 = load ptr, ptr %3, align 8, !tbaa !5
  %273 = getelementptr inbounds %struct.mz_zip_archive, ptr %272, i32 0, i32 0
  %274 = load i64, ptr %273, align 8, !tbaa !19
  %275 = add i64 %274, 22
  store i64 %275, ptr %273, align 8, !tbaa !19
  %276 = load ptr, ptr %3, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.mz_zip_archive, ptr %276, i32 0, i32 3
  store i32 3, ptr %277, align 4, !tbaa !13
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %278

278:                                              ; preds = %271, %268, %254, %187, %94, %59, %39, %22
  call void @llvm.lifetime.end.p0(i64 256, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %279 = load i32, ptr %2, align 4
  ret i32 %279
}

declare i32 @fflush(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 104}
!10 = !{!"", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !11, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 20}
!14 = !{!15, !12, i64 100}
!15 = !{!"mz_zip_internal_state_tag", !16, i64 0, !16, i64 32, !16, i64 64, !12, i64 96, !12, i64 100, !12, i64 104, !6, i64 112, !11, i64 120, !6, i64 128, !11, i64 136, !11, i64 144}
!16 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!17 = !{!15, !11, i64 8}
!18 = !{!10, !12, i64 16}
!19 = !{!10, !11, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 8}
!22 = !{!10, !6, i64 80}
!23 = !{!10, !6, i64 96}
!24 = !{!15, !6, i64 0}
!25 = !{!15, !6, i64 112}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @mz_zip_set_error(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @mz_write_le32(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @mz_write_le64(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @mz_write_le16(ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mz_zip_writer_finalize_archive(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #6
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %9, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not70 = icmp eq ptr %5, null
  br i1 %.not70, label %9, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %.not71 = icmp eq i32 %8, 2
  br i1 %.not71, label %11, label %9

9:                                                ; preds = %6, %3, %1
  %10 = tail call i32 @mz_zip_set_error(ptr noundef %0, i32 noundef 24)
  br label %.thread

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %5, i64 100
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %.not72 = icmp eq i32 %13, 0
  br i1 %.not72, label %20, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %5, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !16
  %17 = icmp ugt i64 %16, 4294967294
  br i1 %17, label %18, label %._crit_edge

._crit_edge:                                      ; preds = %14
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !17
  br label %33

18:                                               ; preds = %14
  %19 = tail call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 2)
  br label %.thread

20:                                               ; preds = %11
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !17
  %23 = icmp ugt i32 %22, 65535
  br i1 %23, label %31, label %24

24:                                               ; preds = %20
  %25 = load i64, ptr %0, align 8, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %5, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = add i64 %25, -4294967274
  %29 = add i64 %28, %27
  %30 = icmp ult i64 %29, -4294967296
  br i1 %30, label %31, label %33

31:                                               ; preds = %24, %20
  %32 = tail call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 2)
  br label %.thread

33:                                               ; preds = %._crit_edge, %24
  %34 = phi i64 [ %16, %._crit_edge ], [ %27, %24 ]
  %35 = phi i32 [ %.pre, %._crit_edge ], [ %22, %24 ]
  %36 = getelementptr inbounds i8, ptr %0, i64 16
  %.not73 = icmp eq i32 %35, 0
  br i1 %.not73, label %51, label %37

37:                                               ; preds = %33
  %38 = load i64, ptr %0, align 8, !tbaa !18
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %38, ptr %39, align 8, !tbaa !19
  %40 = getelementptr inbounds i8, ptr %0, i64 80
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = getelementptr inbounds i8, ptr %0, i64 96
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = load ptr, ptr %5, align 8, !tbaa !22
  %45 = tail call i64 %41(ptr noundef %43, i64 noundef %38, ptr noundef %44, i64 noundef %34) #6
  %.not74 = icmp eq i64 %45, %34
  br i1 %.not74, label %48, label %46

46:                                               ; preds = %37
  %47 = tail call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 19)
  br label %.thread

48:                                               ; preds = %37
  %49 = load i64, ptr %0, align 8, !tbaa !18
  %50 = add i64 %49, %34
  store i64 %50, ptr %0, align 8, !tbaa !18
  %.pre83 = load i32, ptr %12, align 4, !tbaa !13
  br label %51

51:                                               ; preds = %48, %33
  %52 = phi i32 [ %.pre83, %48 ], [ %13, %33 ]
  %.063 = phi i64 [ %38, %48 ], [ 0, %33 ]
  %.062 = phi i64 [ %34, %48 ], [ 0, %33 ]
  %.not75 = icmp eq i32 %52, 0
  br i1 %.not75, label %88, label %53

53:                                               ; preds = %51
  %54 = load i64, ptr %0, align 8, !tbaa !18
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %2, i8 0, i64 256, i1 false)
  call void @mz_write_le32(ptr noundef nonnull %2, i32 noundef 101075792)
  %55 = getelementptr inbounds i8, ptr %2, i64 4
  call void @mz_write_le64(ptr noundef nonnull %55, i64 noundef 44)
  %56 = getelementptr inbounds i8, ptr %2, i64 12
  call void @mz_write_le16(ptr noundef nonnull %56, i16 noundef zeroext 798)
  %57 = getelementptr inbounds i8, ptr %2, i64 14
  call void @mz_write_le16(ptr noundef nonnull %57, i16 noundef zeroext 45)
  %58 = getelementptr inbounds i8, ptr %2, i64 24
  %59 = load i32, ptr %36, align 8, !tbaa !17
  %60 = zext i32 %59 to i64
  call void @mz_write_le64(ptr noundef nonnull %58, i64 noundef %60)
  %61 = getelementptr inbounds i8, ptr %2, i64 32
  %62 = load i32, ptr %36, align 8, !tbaa !17
  %63 = zext i32 %62 to i64
  call void @mz_write_le64(ptr noundef nonnull %61, i64 noundef %63)
  %64 = getelementptr inbounds i8, ptr %2, i64 40
  call void @mz_write_le64(ptr noundef nonnull %64, i64 noundef %.062)
  %65 = getelementptr inbounds i8, ptr %2, i64 48
  call void @mz_write_le64(ptr noundef nonnull %65, i64 noundef %.063)
  %66 = getelementptr inbounds i8, ptr %0, i64 80
  %67 = load ptr, ptr %66, align 8, !tbaa !20
  %68 = getelementptr inbounds i8, ptr %0, i64 96
  %69 = load ptr, ptr %68, align 8, !tbaa !21
  %70 = load i64, ptr %0, align 8, !tbaa !18
  %71 = call i64 %67(ptr noundef %69, i64 noundef %70, ptr noundef nonnull %2, i64 noundef 56) #6
  %.not76 = icmp eq i64 %71, 56
  br i1 %.not76, label %74, label %72

72:                                               ; preds = %53
  %73 = call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 19)
  br label %.thread

74:                                               ; preds = %53
  %75 = load i64, ptr %0, align 8, !tbaa !18
  %76 = add i64 %75, 56
  store i64 %76, ptr %0, align 8, !tbaa !18
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %2, i8 0, i64 256, i1 false)
  call void @mz_write_le32(ptr noundef nonnull %2, i32 noundef 117853008)
  %77 = getelementptr inbounds i8, ptr %2, i64 8
  call void @mz_write_le64(ptr noundef nonnull %77, i64 noundef %54)
  %78 = getelementptr inbounds i8, ptr %2, i64 16
  call void @mz_write_le32(ptr noundef nonnull %78, i32 noundef 1)
  %79 = load ptr, ptr %66, align 8, !tbaa !20
  %80 = load ptr, ptr %68, align 8, !tbaa !21
  %81 = load i64, ptr %0, align 8, !tbaa !18
  %82 = call i64 %79(ptr noundef %80, i64 noundef %81, ptr noundef nonnull %2, i64 noundef 20) #6
  %.not77 = icmp eq i64 %82, 20
  br i1 %.not77, label %85, label %83

83:                                               ; preds = %74
  %84 = call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 19)
  br label %.thread

85:                                               ; preds = %74
  %86 = load i64, ptr %0, align 8, !tbaa !18
  %87 = add i64 %86, 20
  store i64 %87, ptr %0, align 8, !tbaa !18
  br label %88

88:                                               ; preds = %85, %51
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %2, i8 0, i64 256, i1 false)
  call void @mz_write_le32(ptr noundef nonnull %2, i32 noundef 101010256)
  %89 = getelementptr inbounds i8, ptr %2, i64 8
  %90 = load i32, ptr %36, align 8, !tbaa !17
  %spec.select82 = call i32 @llvm.umin.i32(i32 %90, i32 65535)
  %spec.select = trunc nuw i32 %spec.select82 to i16
  call void @mz_write_le16(ptr noundef nonnull %89, i16 noundef zeroext %spec.select)
  %91 = getelementptr inbounds i8, ptr %2, i64 10
  %92 = load i32, ptr %36, align 8, !tbaa !17
  %93 = call i32 @llvm.umin.i32(i32 %92, i32 65535)
  %94 = trunc nuw i32 %93 to i16
  call void @mz_write_le16(ptr noundef nonnull %91, i16 noundef zeroext %94)
  %95 = getelementptr inbounds i8, ptr %2, i64 12
  %96 = call i64 @llvm.umin.i64(i64 %.062, i64 4294967295)
  %97 = trunc nuw i64 %96 to i32
  call void @mz_write_le32(ptr noundef nonnull %95, i32 noundef %97)
  %98 = getelementptr inbounds i8, ptr %2, i64 16
  %99 = call i64 @llvm.umin.i64(i64 %.063, i64 4294967295)
  %100 = trunc nuw i64 %99 to i32
  call void @mz_write_le32(ptr noundef nonnull %98, i32 noundef %100)
  %101 = getelementptr inbounds i8, ptr %0, i64 80
  %102 = load ptr, ptr %101, align 8, !tbaa !20
  %103 = getelementptr inbounds i8, ptr %0, i64 96
  %104 = load ptr, ptr %103, align 8, !tbaa !21
  %105 = load i64, ptr %0, align 8, !tbaa !18
  %106 = call i64 %102(ptr noundef %104, i64 noundef %105, ptr noundef nonnull %2, i64 noundef 22) #6
  %.not78 = icmp eq i64 %106, 22
  br i1 %.not78, label %109, label %107

107:                                              ; preds = %88
  %108 = call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 19)
  br label %.thread

109:                                              ; preds = %88
  %110 = getelementptr inbounds i8, ptr %5, i64 112
  %111 = load ptr, ptr %110, align 8, !tbaa !23
  %.not79 = icmp eq ptr %111, null
  br i1 %.not79, label %117, label %112

112:                                              ; preds = %109
  %113 = call i32 @fflush(ptr noundef nonnull %111)
  %114 = icmp eq i32 %113, -1
  br i1 %114, label %115, label %117

115:                                              ; preds = %112
  %116 = call i32 @mz_zip_set_error(ptr noundef nonnull %0, i32 noundef 21)
  br label %.thread

117:                                              ; preds = %112, %109
  %118 = load i64, ptr %0, align 8, !tbaa !18
  %119 = add i64 %118, 22
  store i64 %119, ptr %0, align 8, !tbaa !18
  store i32 3, ptr %7, align 4, !tbaa !12
  br label %.thread

.thread:                                          ; preds = %83, %72, %117, %115, %107, %46, %31, %18, %9
  %.1 = phi i32 [ %10, %9 ], [ %19, %18 ], [ %47, %46 ], [ %108, %107 ], [ %116, %115 ], [ 1, %117 ], [ %32, %31 ], [ %84, %83 ], [ %73, %72 ]
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #6
  ret i32 %.1
}

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !11, i64 104}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !10, i64 20}
!13 = !{!14, !10, i64 100}
!14 = !{!"mz_zip_internal_state_tag", !15, i64 0, !15, i64 32, !15, i64 64, !10, i64 96, !10, i64 100, !10, i64 104, !11, i64 112, !7, i64 120, !11, i64 128, !7, i64 136, !7, i64 144}
!15 = !{!"", !11, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!16 = !{!14, !7, i64 8}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !7, i64 8}
!20 = !{!6, !11, i64 80}
!21 = !{!6, !11, i64 96}
!22 = !{!14, !11, i64 0}
!23 = !{!14, !11, i64 112}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass