; 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 @Bt3Zip_MatchFinder_Skip(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %106, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, 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
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._CMatchFinder, ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 4, !tbaa !11
  store i32 %14, ptr %5, align 4, !tbaa !9
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp ult i32 %15, 3
  br i1 %16, label %17, label %19

17:                                               ; preds = %11
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  call void @MatchFinder_MovePos(ptr noundef %18)
  store i32 3, ptr %9, align 4
  br label %103

19:                                               ; preds = %11
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._CMatchFinder, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 2
  %25 = load i8, ptr %24, align 1, !tbaa !16
  %26 = zext i8 %25 to i32
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 0
  %29 = load i8, ptr %28, align 1, !tbaa !16
  %30 = zext i8 %29 to i32
  %31 = shl i32 %30, 8
  %32 = or i32 %26, %31
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._CMatchFinder, ptr %33, i32 0, i32 27
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !16
  %38 = zext i8 %37 to i64
  %39 = getelementptr inbounds [256 x i32], ptr %34, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = xor i32 %32, %40
  %42 = and i32 %41, 65535
  store i32 %42, ptr %6, align 4, !tbaa !9
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._CMatchFinder, ptr %43, i32 0, i32 12
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !9
  store i32 %49, ptr %8, align 4, !tbaa !9
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._CMatchFinder, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !18
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._CMatchFinder, ptr %53, i32 0, i32 12
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  store i32 %52, ptr %58, align 4, !tbaa !9
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._CMatchFinder, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 8, !tbaa !18
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._CMatchFinder, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !15
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._CMatchFinder, ptr %67, i32 0, i32 13
  %69 = load ptr, ptr %68, align 8, !tbaa !19
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._CMatchFinder, ptr %70, i32 0, i32 5
  %72 = load i32, ptr %71, align 8, !tbaa !20
  %73 = zext i32 %72 to i64
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._CMatchFinder, ptr %74, i32 0, i32 6
  %76 = load i32, ptr %75, align 4, !tbaa !21
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._CMatchFinder, ptr %77, i32 0, i32 15
  %79 = load i32, ptr %78, align 4, !tbaa !22
  call void @SkipMatchesSpec(i32 noundef %59, i32 noundef %60, i32 noundef %63, ptr noundef %66, ptr noundef %69, i64 noundef %73, i32 noundef %76, i32 noundef %79)
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._CMatchFinder, ptr %80, i32 0, i32 5
  %82 = load i32, ptr %81, align 8, !tbaa !20
  %83 = add i32 %82, 1
  store i32 %83, ptr %81, align 8, !tbaa !20
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._CMatchFinder, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = getelementptr inbounds i8, ptr %86, i32 1
  store ptr %87, ptr %85, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._CMatchFinder, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 8, !tbaa !18
  %91 = add i32 %90, 1
  store i32 %91, ptr %10, align 4, !tbaa !9
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._CMatchFinder, ptr %93, i32 0, i32 1
  store i32 %92, ptr %94, align 8, !tbaa !18
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._CMatchFinder, ptr %96, i32 0, i32 2
  %98 = load i32, ptr %97, align 4, !tbaa !23
  %99 = icmp eq i32 %95, %98
  br i1 %99, label %100, label %102

100:                                              ; preds = %19
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  call void @MatchFinder_CheckLimits(ptr noundef %101)
  br label %102

102:                                              ; preds = %100, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  store i32 0, ptr %9, align 4
  br label %103

103:                                              ; preds = %102, %17
  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 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %104 = load i32, ptr %9, align 4
  switch i32 %104, label %111 [
    i32 0, label %105
    i32 3, label %106
  ]

105:                                              ; preds = %103
  br label %106

106:                                              ; preds = %105, %103
  %107 = load i32, ptr %4, align 4, !tbaa !9
  %108 = add i32 %107, -1
  store i32 %108, ptr %4, align 4, !tbaa !9
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %11, label %110, !llvm.loop !24

110:                                              ; preds = %106
  ret void

111:                                              ; preds = %103
  unreachable
}

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

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, !6, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !6, i64 40}
!18 = !{!12, !10, i64 8}
!19 = !{!12, !6, i64 48}
!20 = !{!12, !10, i64 24}
!21 = !{!12, !10, i64 28}
!22 = !{!12, !10, i64 60}
!23 = !{!12, !10, i64 12}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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 @Bt3Zip_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 120
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = getelementptr inbounds i8, ptr %0, i64 28
  %10 = getelementptr inbounds i8, ptr %0, i64 60
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  br label %12

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

15:                                               ; preds = %12
  tail call void @MatchFinder_MovePos(ptr noundef nonnull %0)
  br label %50

16:                                               ; preds = %12
  %17 = load ptr, ptr %0, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %17, i64 2
  %19 = load i8, ptr %18, align 1, !tbaa !14
  %20 = zext i8 %19 to i32
  %21 = load i8, ptr %17, align 1, !tbaa !14
  %22 = zext i8 %21 to i32
  %23 = shl nuw nsw i32 %22, 8
  %24 = or disjoint i32 %23, %20
  %25 = getelementptr inbounds i8, ptr %17, i64 1
  %26 = load i8, ptr %25, align 1, !tbaa !14
  %27 = zext i8 %26 to i64
  %28 = getelementptr inbounds [256 x i32], ptr %4, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !15
  %.masked = and i32 %29, 65535
  %30 = xor i32 %24, %.masked
  %31 = load ptr, ptr %5, align 8, !tbaa !16
  %32 = zext nneg i32 %30 to i64
  %33 = getelementptr inbounds i32, ptr %31, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !15
  %35 = load i32, ptr %6, align 8, !tbaa !17
  store i32 %35, ptr %33, align 4, !tbaa !15
  %36 = load ptr, ptr %7, align 8, !tbaa !18
  %37 = load i32, ptr %8, align 8, !tbaa !19
  %38 = zext i32 %37 to i64
  %39 = load i32, ptr %9, align 4, !tbaa !20
  %40 = load i32, ptr %10, align 4, !tbaa !21
  tail call void @SkipMatchesSpec(i32 noundef %13, i32 noundef %34, i32 noundef %35, ptr noundef nonnull %17, ptr noundef %36, i64 noundef %38, i32 noundef %39, i32 noundef %40)
  %41 = load i32, ptr %8, align 8, !tbaa !19
  %42 = add i32 %41, 1
  store i32 %42, ptr %8, align 8, !tbaa !19
  %43 = load ptr, ptr %0, align 8, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %43, i64 1
  store ptr %44, ptr %0, align 8, !tbaa !13
  %45 = load i32, ptr %6, align 8, !tbaa !17
  %46 = add i32 %45, 1
  store i32 %46, ptr %6, align 8, !tbaa !17
  %47 = load i32, ptr %11, align 4, !tbaa !22
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %50

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

50:                                               ; preds = %16, %49, %15
  %51 = add i32 %.0, -1
  %.not = icmp eq i32 %51, 0
  br i1 %.not, label %52, label %12, !llvm.loop !23

52:                                               ; preds = %50
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @SkipMatchesSpec(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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" }

!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, !7, i64 0}
!14 = !{!8, !8, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!6, !7, i64 40}
!17 = !{!6, !10, i64 8}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !10, i64 24}
!20 = !{!6, !10, i64 28}
!21 = !{!6, !10, i64 60}
!22 = !{!6, !10, i64 12}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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