; LLVM IR from kuba--/zip :: src (zip)

; 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.zip_t = type { %struct.mz_zip_archive, i32, %struct.zip_entry_t }
%struct.mz_zip_archive = type { i64, i64, i32, i32, i32, i32, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.zip_entry_t = type { i64, ptr, i64, i64, i32, i64, [30 x i8], i64, i16, %struct.mz_zip_writer_add_state, %struct.tdefl_compressor, i32, i64 }
%struct.mz_zip_writer_add_state = type { ptr, i64, i64 }
%struct.tdefl_compressor = type { ptr, ptr, i32, [2 x i32], i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32, ptr, i64, i64, [33025 x i8], [3 x [288 x i16]], [3 x [288 x i16]], [3 x [288 x i8]], [65536 x i8], [32768 x i16], [32768 x i16], [85196 x i8] }

; 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: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @zip_entries_total(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i64 @zip_entries_delete(ptr noundef %0, ptr noundef %1, i64 noundef %2) #3 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store ptr null, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %20, label %14

14:                                               ; preds = %3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %21

17:                                               ; preds = %14
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %3
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %78

21:                                               ; preds = %17, %14
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  store i64 0, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %78

28:                                               ; preds = %24, %21
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call i64 @zip_entries_total(ptr noundef %29)
  store i64 %30, ptr %8, align 8, !tbaa !9
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = icmp slt i64 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %28
  %34 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %34, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %78

35:                                               ; preds = %28
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = call noalias ptr @calloc(i64 noundef %36, i64 noundef 32) #5
  store ptr %37, ptr %10, align 8, !tbaa !5
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  store i64 -21, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %78

41:                                               ; preds = %35
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.zip_t, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.mz_zip_archive, ptr %43, i32 0, i32 3
  store i32 1, ptr %44, align 4, !tbaa !11
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load i64, ptr %8, align 8, !tbaa !9
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i64, ptr %7, align 8, !tbaa !9
  %50 = call i64 @zip_entry_set(ptr noundef %45, ptr noundef %46, i64 noundef %47, ptr noundef %48, i64 noundef %49)
  store i64 %50, ptr %9, align 8, !tbaa !9
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %53, label %63

53:                                               ; preds = %41
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %59

57:                                               ; preds = %54
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %58) #4
  store ptr null, ptr %10, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %57, %54
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  %62 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %62, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %78

63:                                               ; preds = %41
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load i64, ptr %8, align 8, !tbaa !9
  %67 = trunc i64 %66 to i32
  %68 = call i64 @zip_entries_delete_mark(ptr noundef %64, ptr noundef %65, i32 noundef %67)
  store i64 %68, ptr %9, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %63
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %74

72:                                               ; preds = %69
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %73) #4
  store ptr null, ptr %10, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %72, %69
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  %77 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %77, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %78

78:                                               ; preds = %76, %61, %40, %33, %27, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %79 = load i64, ptr %4, align 8
  ret i64 %79
}

; Function Attrs: nounwind uwtable
declare hidden i64 @zip_entry_set(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i64 @zip_entries_delete_mark(ptr noundef, ptr noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nounwind allocsize(0,1) "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 = { nounwind }
attributes #5 = { nounwind allocsize(0,1) }

!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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 20}
!12 = !{!"zip_t", !13, i64 0, !14, i64 112, !15, i64 120}
!13 = !{!"", !10, i64 0, !10, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !10, 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}
!14 = !{!"int", !7, i64 0}
!15 = !{!"zip_entry_t", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !14, i64 32, !10, i64 40, !7, i64 48, !10, i64 80, !16, i64 88, !17, i64 96, !18, i64 120, !14, i64 319472, !10, i64 319480}
!16 = !{!"short", !7, i64 0}
!17 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"", !6, i64 0, !6, i64 8, !14, i64 16, !7, i64 20, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !14, i64 44, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !14, i64 80, !14, i64 84, !14, i64 88, !14, i64 92, !14, i64 96, !14, i64 100, !14, i64 104, !14, i64 108, !14, i64 112, !14, i64 116, !14, i64 120, !14, i64 124, !14, i64 128, !14, i64 132, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !14, i64 168, !6, i64 176, !10, i64 184, !10, i64 192, !7, i64 200, !7, i64 33226, !7, i64 34954, !7, i64 36682, !7, i64 37546, !7, i64 103082, !7, i64 168618, !7, i64 234154}


; 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @zip_entries_total(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i64 @zip_entries_delete(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = icmp eq ptr %0, null
  br i1 %4, label %22, label %5

5:                                                ; preds = %3
  %6 = icmp eq ptr %1, null
  %7 = icmp ne i64 %2, 0
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %22, label %8

8:                                                ; preds = %5
  %9 = icmp eq i64 %2, 0
  %or.cond3 = and i1 %6, %9
  br i1 %or.cond3, label %22, label %10

10:                                               ; preds = %8
  %11 = tail call i64 @zip_entries_total(ptr noundef nonnull %0)
  %12 = icmp slt i64 %11, 0
  br i1 %12, label %22, label %13

13:                                               ; preds = %10
  %14 = tail call noalias ptr @calloc(i64 noundef %11, i64 noundef 32) #3
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %22, label %15

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 1, ptr %16, align 4, !tbaa !5
  %17 = tail call i64 @zip_entry_set(ptr noundef nonnull %0, ptr noundef nonnull %14, i64 noundef %11, ptr noundef %1, i64 noundef %2)
  %18 = icmp slt i64 %17, 0
  br i1 %18, label %.sink.split, label %19

19:                                               ; preds = %15
  %20 = trunc i64 %11 to i32
  %21 = tail call i64 @zip_entries_delete_mark(ptr noundef nonnull %0, ptr noundef nonnull %14, i32 noundef %20)
  br label %.sink.split

.sink.split:                                      ; preds = %15, %19
  %.0.ph = phi i64 [ %21, %19 ], [ %17, %15 ]
  tail call void @free(ptr noundef nonnull %14) #4
  br label %22

22:                                               ; preds = %.sink.split, %13, %10, %8, %3, %5
  %.0 = phi i64 [ -1, %5 ], [ -1, %3 ], [ 0, %8 ], [ %11, %10 ], [ -21, %13 ], [ %.0.ph, %.sink.split ]
  ret i64 %.0
}

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

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

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #2 = { 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 allocsize(0,1) }
attributes #4 = { 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 20}
!6 = !{!"zip_t", !7, i64 0, !11, i64 112, !13, i64 120}
!7 = !{!"", !8, i64 0, !8, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !8, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"zip_entry_t", !8, i64 0, !12, i64 8, !8, i64 16, !8, i64 24, !11, i64 32, !8, i64 40, !9, i64 48, !8, i64 80, !14, i64 88, !15, i64 96, !16, i64 120, !11, i64 319472, !8, i64 319480}
!14 = !{!"short", !9, i64 0}
!15 = !{!"", !12, i64 0, !8, i64 8, !8, i64 16}
!16 = !{!"", !12, i64 0, !12, i64 8, !11, i64 16, !9, i64 20, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !11, i64 168, !12, i64 176, !8, i64 184, !8, i64 192, !9, i64 200, !9, i64 33226, !9, i64 34954, !9, i64 36682, !9, i64 37546, !9, i64 103082, !9, i64 168618, !9, i64 234154}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass