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

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatchFinder_MovePos(ptr noundef %18)
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %19, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %108

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

104:                                              ; preds = %20
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatchFinder_CheckLimits(ptr noundef %105)
  br label %106

106:                                              ; preds = %104, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %107, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %108

108:                                              ; preds = %106, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %109 = load ptr, ptr %3, align 8
  ret ptr %109
}

; Function Attrs: nounwind uwtable
declare hidden ptr @Hc_GetMatchesSpec(i64 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, ptr 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, !11, i64 20}
!10 = !{!"_CMatchFinder", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !11, i64 36, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !6, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !12, i64 96, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !7, i64 120, !12, i64 1144, !13, i64 1152}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !11, i64 8}
!19 = !{!10, !6, i64 48}
!20 = !{!10, !11, i64 24}
!21 = !{!10, !11, i64 28}
!22 = !{!10, !11, i64 60}
!23 = !{!10, !11, i64 12}


; 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 ptr @Hc3Zip_MatchFinder_GetMatches(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp ult i32 %4, 3
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @MatchFinder_MovePos(ptr noundef nonnull %0)
  br label %51

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

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

51:                                               ; preds = %7, %50, %6
  %.0 = phi ptr [ %1, %6 ], [ %40, %50 ], [ %40, %7 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden ptr @Hc_GetMatchesSpec(i64 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, ptr 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}


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