; LLVM IR from JayXon/Leanify :: lib/LZMA (LzFind)

; 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._CMatchFinder = type { ptr, i32, i32, i32, i32, i32, i32, i8, i8, i8, i8, i32, ptr, ptr, i32, i32, ptr, ptr, i32, i32, i32, i32, i64, i32, i32, i32, i32, [256 x i32], i64, i64 }

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

; Function Attrs: noinline nounwind uwtable
declare hidden void @MatchFinder_CheckLimits(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @Hc3Zip_MatchFinder_Skip(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %119, %2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._CMatchFinder, ptr %15, i32 0, i32 4
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = icmp ult i32 %17, 3
  br i1 %18, label %19, label %23

19:                                               ; preds = %14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @MatchFinder_MovePos(ptr noundef %20)
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = add i32 %21, -1
  store i32 %22, ptr %4, align 4, !tbaa !9
  br label %119

23:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._CMatchFinder, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 8, !tbaa !15
  store i32 %26, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %27 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %27, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._CMatchFinder, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !16
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = sub i32 %30, %31
  store i32 %32, ptr %10, align 4, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp ugt i32 %33, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %23
  %37 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %37, ptr %9, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %36, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = sub i32 %40, %39
  store i32 %41, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._CMatchFinder, ptr %42, i32 0, i32 5
  %44 = load i32, ptr %43, align 8, !tbaa !17
  store i32 %44, ptr %11, align 4, !tbaa !9
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._CMatchFinder, ptr %45, i32 0, i32 13
  %47 = load ptr, ptr %46, align 8, !tbaa !18
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  store ptr %50, ptr %7, align 8, !tbaa !5
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = add i32 %51, %52
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._CMatchFinder, ptr %54, i32 0, i32 5
  store i32 %53, ptr %55, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._CMatchFinder, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !19
  store ptr %58, ptr %5, align 8, !tbaa !5
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._CMatchFinder, ptr %59, i32 0, i32 12
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  store ptr %61, ptr %6, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %100, %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 2
  %65 = load i8, ptr %64, align 1, !tbaa !21
  %66 = zext i8 %65 to i32
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 0
  %69 = load i8, ptr %68, align 1, !tbaa !21
  %70 = zext i8 %69 to i32
  %71 = shl i32 %70, 8
  %72 = or i32 %66, %71
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._CMatchFinder, ptr %73, i32 0, i32 27
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 1
  %77 = load i8, ptr %76, align 1, !tbaa !21
  %78 = zext i8 %77 to i64
  %79 = getelementptr inbounds [256 x i32], ptr %74, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = xor i32 %72, %80
  %82 = and i32 %81, 65535
  store i32 %82, ptr %13, align 4, !tbaa !9
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %83, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !9
  store i32 %87, ptr %12, align 4, !tbaa !9
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %13, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr %89, i64 %91
  store i32 %88, ptr %92, align 4, !tbaa !9
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i32 1
  store ptr %94, ptr %5, align 8, !tbaa !5
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = add i32 %95, 1
  store i32 %96, ptr %8, align 4, !tbaa !9
  %97 = load i32, ptr %12, align 4, !tbaa !9
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds i32, ptr %98, i32 1
  store ptr %99, ptr %7, align 8, !tbaa !5
  store i32 %97, ptr %98, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %100

100:                                              ; preds = %62
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = add i32 %101, -1
  store i32 %102, ptr %9, align 4, !tbaa !9
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %62, label %104, !llvm.loop !22

104:                                              ; preds = %100
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct._CMatchFinder, ptr %106, i32 0, i32 0
  store ptr %105, ptr %107, align 8, !tbaa !19
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._CMatchFinder, ptr %109, i32 0, i32 1
  store i32 %108, ptr %110, align 8, !tbaa !15
  %111 = load i32, ptr %8, align 4, !tbaa !9
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct._CMatchFinder, ptr %112, i32 0, i32 2
  %114 = load i32, ptr %113, align 4, !tbaa !16
  %115 = icmp eq i32 %111, %114
  br i1 %115, label %116, label %118

116:                                              ; preds = %104
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  call void @MatchFinder_CheckLimits(ptr noundef %117)
  br label %118

118:                                              ; preds = %116, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %119

119:                                              ; preds = %118, %19
  %120 = load i32, ptr %4, align 4, !tbaa !9
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %14, label %122, !llvm.loop !24

122:                                              ; preds = %119
  ret void
}

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 20}
!12 = !{!"_CMatchFinder", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !10, i64 36, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !13, i64 96, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !7, i64 120, !13, i64 1144, !14, i64 1152}
!13 = !{!"long", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !6, i64 48}
!19 = !{!12, !6, i64 0}
!20 = !{!12, !6, i64 40}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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: noinline nounwind uwtable
declare hidden void @MatchFinder_MovePos(ptr noundef) local_unnamed_addr #0

; Function Attrs: noinline nounwind uwtable
declare hidden void @MatchFinder_CheckLimits(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @Hc3Zip_MatchFinder_Skip(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = getelementptr inbounds i8, ptr %0, i64 120
  br label %10

10:                                               ; preds = %51, %2
  %.0 = phi i32 [ %1, %2 ], [ %.1, %51 ]
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp ult i32 %11, 3
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  tail call void @MatchFinder_MovePos(ptr noundef nonnull %0)
  %14 = add i32 %.0, -1
  br label %51

15:                                               ; preds = %10
  %16 = load i32, ptr %4, align 8, !tbaa !13
  %17 = load i32, ptr %5, align 4, !tbaa !14
  %18 = sub i32 %17, %16
  %spec.select = tail call i32 @llvm.umin.i32(i32 %.0, i32 %18)
  %19 = load i32, ptr %6, align 8, !tbaa !15
  %20 = load ptr, ptr %7, align 8, !tbaa !16
  %21 = zext i32 %19 to i64
  %22 = getelementptr inbounds i32, ptr %20, i64 %21
  %23 = add i32 %spec.select, %19
  store i32 %23, ptr %6, align 8, !tbaa !15
  %24 = load ptr, ptr %0, align 8, !tbaa !17
  %25 = load ptr, ptr %8, align 8, !tbaa !18
  br label %26

26:                                               ; preds = %26, %15
  %.145 = phi i32 [ %spec.select, %15 ], [ %45, %26 ]
  %.043 = phi i32 [ %16, %15 ], [ %43, %26 ]
  %.042 = phi ptr [ %22, %15 ], [ %44, %26 ]
  %.041 = phi ptr [ %24, %15 ], [ %34, %26 ]
  %27 = getelementptr inbounds i8, ptr %.041, i64 2
  %28 = load i8, ptr %27, align 1, !tbaa !19
  %29 = zext i8 %28 to i32
  %30 = load i8, ptr %.041, align 1, !tbaa !19
  %31 = zext i8 %30 to i32
  %32 = shl nuw nsw i32 %31, 8
  %33 = or disjoint i32 %32, %29
  %34 = getelementptr inbounds i8, ptr %.041, i64 1
  %35 = load i8, ptr %34, align 1, !tbaa !19
  %36 = zext i8 %35 to i64
  %37 = getelementptr inbounds [256 x i32], ptr %9, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !20
  %.masked = and i32 %38, 65535
  %39 = xor i32 %33, %.masked
  %40 = zext nneg i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %25, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !20
  store i32 %.043, ptr %41, align 4, !tbaa !20
  %43 = add i32 %.043, 1
  %44 = getelementptr inbounds i8, ptr %.042, i64 4
  store i32 %42, ptr %.042, align 4, !tbaa !20
  %45 = add i32 %.145, -1
  %.not = icmp eq i32 %45, 0
  br i1 %.not, label %46, label %26, !llvm.loop !21

46:                                               ; preds = %26
  %47 = sub i32 %.0, %spec.select
  store ptr %34, ptr %0, align 8, !tbaa !17
  store i32 %43, ptr %4, align 8, !tbaa !13
  %48 = load i32, ptr %5, align 4, !tbaa !14
  %49 = icmp eq i32 %43, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %46
  tail call void @MatchFinder_CheckLimits(ptr noundef nonnull %0)
  br label %51

51:                                               ; preds = %46, %50, %13
  %.1 = phi i32 [ %14, %13 ], [ %47, %50 ], [ %47, %46 ]
  %.not47 = icmp eq i32 %.1, 0
  br i1 %.not47, label %52, label %10, !llvm.loop !23

52:                                               ; preds = %51
  ret void
}

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

attributes #0 = { noinline 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 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 20}
!6 = !{!"_CMatchFinder", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !8, i64 32, !8, i64 33, !8, i64 34, !8, i64 35, !10, i64 36, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !7, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !11, i64 96, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !8, i64 120, !11, i64 1144, !12, i64 1152}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !7, i64 48}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !7, i64 40}
!19 = !{!8, !8, i64 0}
!20 = !{!10, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass