; LLVM IR from JayXon/Leanify :: lib/zopfli (hash)

; 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.ZopfliHash = type { ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @ZopfliResetHash(i64 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %6 = load ptr, ptr %4, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.ZopfliHash, ptr %6, i32 0, i32 3
  store i32 0, ptr %7, align 8, !tbaa !11
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %17, %2
  %9 = load i64, ptr %5, align 8, !tbaa !5
  %10 = icmp ult i64 %9, 65536
  br i1 %10, label %11, label %20

11:                                               ; preds = %8
  %12 = load ptr, ptr %4, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.ZopfliHash, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = load i64, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds i32, ptr %14, i64 %15
  store i32 -1, ptr %16, align 4, !tbaa !15
  br label %17

17:                                               ; preds = %11
  %18 = load i64, ptr %5, align 8, !tbaa !5
  %19 = add i64 %18, 1
  store i64 %19, ptr %5, align 8, !tbaa !5
  br label %8, !llvm.loop !16

20:                                               ; preds = %8
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %38, %20
  %22 = load i64, ptr %5, align 8, !tbaa !5
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %25, label %41

25:                                               ; preds = %21
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = trunc i64 %26 to i16
  %28 = load ptr, ptr %4, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.ZopfliHash, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = load i64, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds i16, ptr %30, i64 %31
  store i16 %27, ptr %32, align 2, !tbaa !19
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.ZopfliHash, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = load i64, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds i32, ptr %35, i64 %36
  store i32 -1, ptr %37, align 4, !tbaa !15
  br label %38

38:                                               ; preds = %25
  %39 = load i64, ptr %5, align 8, !tbaa !5
  %40 = add i64 %39, 1
  store i64 %40, ptr %5, align 8, !tbaa !5
  br label %21, !llvm.loop !22

41:                                               ; preds = %21
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %52, %41
  %43 = load i64, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %3, align 8, !tbaa !5
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %46, label %55

46:                                               ; preds = %42
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.ZopfliHash, ptr %47, i32 0, i32 8
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  %50 = load i64, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds i16, ptr %49, i64 %50
  store i16 0, ptr %51, align 2, !tbaa !19
  br label %52

52:                                               ; preds = %46
  %53 = load i64, ptr %5, align 8, !tbaa !5
  %54 = add i64 %53, 1
  store i64 %54, ptr %5, align 8, !tbaa !5
  br label %42, !llvm.loop !24

55:                                               ; preds = %42
  %56 = load ptr, ptr %4, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.ZopfliHash, ptr %56, i32 0, i32 7
  store i32 0, ptr %57, align 8, !tbaa !25
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %67, %55
  %59 = load i64, ptr %5, align 8, !tbaa !5
  %60 = icmp ult i64 %59, 65536
  br i1 %60, label %61, label %70

61:                                               ; preds = %58
  %62 = load ptr, ptr %4, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.ZopfliHash, ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !26
  %65 = load i64, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds i32, ptr %64, i64 %65
  store i32 -1, ptr %66, align 4, !tbaa !15
  br label %67

67:                                               ; preds = %61
  %68 = load i64, ptr %5, align 8, !tbaa !5
  %69 = add i64 %68, 1
  store i64 %69, ptr %5, align 8, !tbaa !5
  br label %58, !llvm.loop !27

70:                                               ; preds = %58
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %88, %70
  %72 = load i64, ptr %5, align 8, !tbaa !5
  %73 = load i64, ptr %3, align 8, !tbaa !5
  %74 = icmp ult i64 %72, %73
  br i1 %74, label %75, label %91

75:                                               ; preds = %71
  %76 = load i64, ptr %5, align 8, !tbaa !5
  %77 = trunc i64 %76 to i16
  %78 = load ptr, ptr %4, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.ZopfliHash, ptr %78, i32 0, i32 5
  %80 = load ptr, ptr %79, align 8, !tbaa !28
  %81 = load i64, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds i16, ptr %80, i64 %81
  store i16 %77, ptr %82, align 2, !tbaa !19
  %83 = load ptr, ptr %4, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.ZopfliHash, ptr %83, i32 0, i32 6
  %85 = load ptr, ptr %84, align 8, !tbaa !29
  %86 = load i64, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds i32, ptr %85, i64 %86
  store i32 -1, ptr %87, align 4, !tbaa !15
  br label %88

88:                                               ; preds = %75
  %89 = load i64, ptr %5, align 8, !tbaa !5
  %90 = add i64 %89, 1
  store i64 %90, ptr %5, align 8, !tbaa !5
  br label %71, !llvm.loop !30

91:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 24}
!12 = !{!"ZopfliHash", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !13, i64 56, !10, i64 64}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 0}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !10, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!12, !10, i64 16}
!22 = distinct !{!22, !17}
!23 = !{!12, !10, i64 64}
!24 = distinct !{!24, !17}
!25 = !{!12, !13, i64 56}
!26 = !{!12, !10, i64 32}
!27 = distinct !{!27, !17}
!28 = !{!12, !10, i64 40}
!29 = !{!12, !10, i64 48}
!30 = distinct !{!30, !17}


; 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: nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @ZopfliResetHash(i64 noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
.preheader32:
  %2 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %1, align 8, !tbaa !11
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(262144) %3, i8 -1, i64 262144, i1 false), !tbaa !12
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %.preheader32
  %4 = getelementptr inbounds i8, ptr %1, i64 56
  store i32 0, ptr %4, align 8, !tbaa !13
  %5 = getelementptr inbounds i8, ptr %1, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !14
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(262144) %6, i8 -1, i64 262144, i1 false), !tbaa !12
  br label %._crit_edge40

.lr.ph:                                           ; preds = %.preheader32
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %min.iters.check = icmp ult i64 %0, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %0, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i16> [ <i16 0, i16 1, i16 2, i16 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i16> %vec.ind, <i16 4, i16 4, i16 4, i16 4>
  %11 = getelementptr inbounds i16, ptr %8, i64 %index
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  store <4 x i16> %vec.ind, ptr %11, align 2, !tbaa !17
  store <4 x i16> %step.add, ptr %12, align 2, !tbaa !17
  %13 = getelementptr inbounds i32, ptr %10, i64 %index
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %13, align 4, !tbaa !12
  store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %14, align 4, !tbaa !12
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i16> %vec.ind, <i16 8, i16 8, i16 8, i16 8>
  %15 = icmp eq i64 %index.next, %n.vec
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %0
  br i1 %cmp.n, label %.lr.ph39, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %.134.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.134 = phi i64 [ %19, %scalar.ph ], [ %.134.ph, %scalar.ph.preheader ]
  %16 = trunc i64 %.134 to i16
  %17 = getelementptr inbounds i16, ptr %8, i64 %.134
  store i16 %16, ptr %17, align 2, !tbaa !17
  %18 = getelementptr inbounds i32, ptr %10, i64 %.134
  store i32 -1, ptr %18, align 4, !tbaa !12
  %19 = add nuw i64 %.134, 1
  %exitcond.not = icmp eq i64 %19, %0
  br i1 %exitcond.not, label %.lr.ph39, label %scalar.ph, !llvm.loop !23

.lr.ph39:                                         ; preds = %scalar.ph, %middle.block
  %20 = getelementptr inbounds i8, ptr %1, i64 64
  %21 = load ptr, ptr %20, align 8, !tbaa !24
  %22 = shl nuw i64 %0, 1
  tail call void @llvm.memset.p0.i64(ptr align 2 %21, i8 0, i64 %22, i1 false), !tbaa !17
  %23 = getelementptr inbounds i8, ptr %1, i64 56
  store i32 0, ptr %23, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %1, i64 32
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(262144) %25, i8 -1, i64 262144, i1 false), !tbaa !12
  %26 = getelementptr inbounds i8, ptr %1, i64 40
  %27 = load ptr, ptr %26, align 8, !tbaa !25
  %28 = getelementptr inbounds i8, ptr %1, i64 48
  %29 = load ptr, ptr %28, align 8, !tbaa !26
  %min.iters.check47 = icmp ult i64 %0, 8
  br i1 %min.iters.check47, label %scalar.ph46.preheader, label %vector.ph48

vector.ph48:                                      ; preds = %.lr.ph39
  %n.vec50 = and i64 %0, -8
  br label %vector.body52

vector.body52:                                    ; preds = %vector.body52, %vector.ph48
  %index53 = phi i64 [ 0, %vector.ph48 ], [ %index.next58, %vector.body52 ]
  %vec.ind54 = phi <4 x i16> [ <i16 0, i16 1, i16 2, i16 3>, %vector.ph48 ], [ %vec.ind.next57, %vector.body52 ]
  %step.add55 = add <4 x i16> %vec.ind54, <i16 4, i16 4, i16 4, i16 4>
  %30 = getelementptr inbounds i16, ptr %27, i64 %index53
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  store <4 x i16> %vec.ind54, ptr %30, align 2, !tbaa !17
  store <4 x i16> %step.add55, ptr %31, align 2, !tbaa !17
  %32 = getelementptr inbounds i32, ptr %29, i64 %index53
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %32, align 4, !tbaa !12
  store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %33, align 4, !tbaa !12
  %index.next58 = add nuw i64 %index53, 8
  %vec.ind.next57 = add <4 x i16> %vec.ind54, <i16 8, i16 8, i16 8, i16 8>
  %34 = icmp eq i64 %index.next58, %n.vec50
  br i1 %34, label %middle.block45, label %vector.body52, !llvm.loop !27

middle.block45:                                   ; preds = %vector.body52
  %cmp.n59 = icmp eq i64 %n.vec50, %0
  br i1 %cmp.n59, label %._crit_edge40, label %scalar.ph46.preheader

scalar.ph46.preheader:                            ; preds = %middle.block45, %.lr.ph39
  %.438.ph = phi i64 [ 0, %.lr.ph39 ], [ %n.vec50, %middle.block45 ]
  br label %scalar.ph46

scalar.ph46:                                      ; preds = %scalar.ph46.preheader, %scalar.ph46
  %.438 = phi i64 [ %38, %scalar.ph46 ], [ %.438.ph, %scalar.ph46.preheader ]
  %35 = trunc i64 %.438 to i16
  %36 = getelementptr inbounds i16, ptr %27, i64 %.438
  store i16 %35, ptr %36, align 2, !tbaa !17
  %37 = getelementptr inbounds i32, ptr %29, i64 %.438
  store i32 -1, ptr %37, align 4, !tbaa !12
  %38 = add nuw i64 %.438, 1
  %exitcond43.not = icmp eq i64 %38, %0
  br i1 %exitcond43.not, label %._crit_edge40, label %scalar.ph46, !llvm.loop !28

._crit_edge40:                                    ; preds = %scalar.ph46, %middle.block45, %._crit_edge.thread
  ret void
}

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

attributes #0 = { nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !10, i64 24}
!6 = !{!"ZopfliHash", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !10, i64 56}
!14 = !{!6, !7, i64 32}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 16}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !22, !21}
!24 = !{!6, !7, i64 64}
!25 = !{!6, !7, i64 40}
!26 = !{!6, !7, i64 48}
!27 = distinct !{!27, !20, !21, !22}
!28 = distinct !{!28, !20, !22, !21}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass