; LLVM IR from philanc/luazen :: src/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: nounwind uwtable
declare dso_local ptr @GetMatchesSpec1(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @Bt3Zip_MatchFinder_GetMatches(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %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) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %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 %7, align 4, !tbaa !14
  %15 = load i32, ptr %7, align 4, !tbaa !14
  %16 = icmp ult i32 %15, 3
  br i1 %16, label %17, label %19

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

19:                                               ; preds = %2
  %20 = load ptr, ptr %4, 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 %9, align 8, !tbaa !5
  %23 = load ptr, ptr %9, 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 %9, 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 %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._CMatchFinder, ptr %33, i32 0, i32 27
  %35 = load ptr, ptr %9, 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 !14
  %41 = xor i32 %32, %40
  %42 = and i32 %41, 65535
  store i32 %42, ptr %8, align 4, !tbaa !14
  %43 = load ptr, ptr %4, 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 %8, align 4, !tbaa !14
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !14
  store i32 %49, ptr %10, align 4, !tbaa !14
  %50 = load ptr, ptr %4, 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 %4, 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 %8, align 4, !tbaa !14
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  store i32 %52, ptr %58, align 4, !tbaa !14
  store i32 0, ptr %6, align 4, !tbaa !14
  %59 = load i32, ptr %7, align 4, !tbaa !14
  %60 = load i32, ptr %10, align 4, !tbaa !14
  %61 = load ptr, ptr %4, 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 %4, 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 %4, 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 %4, 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 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._CMatchFinder, ptr %73, i32 0, i32 6
  %75 = load i32, ptr %74, align 4, !tbaa !21
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._CMatchFinder, ptr %76, i32 0, i32 15
  %78 = load i32, ptr %77, align 4, !tbaa !22
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = load i32, ptr %6, align 4, !tbaa !14
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds i32, ptr %79, i64 %81
  %83 = call ptr @GetMatchesSpec1(i32 noundef %59, i32 noundef %60, i32 noundef %63, ptr noundef %66, ptr noundef %69, i32 noundef %72, i32 noundef %75, i32 noundef %78, ptr noundef %82, i32 noundef 2)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = ptrtoint ptr %83 to i64
  %86 = ptrtoint ptr %84 to i64
  %87 = sub i64 %85, %86
  %88 = sdiv exact i64 %87, 4
  %89 = trunc i64 %88 to i32
  store i32 %89, ptr %6, align 4, !tbaa !14
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._CMatchFinder, ptr %90, i32 0, i32 5
  %92 = load i32, ptr %91, align 8, !tbaa !20
  %93 = add i32 %92, 1
  store i32 %93, ptr %91, align 8, !tbaa !20
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._CMatchFinder, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !15
  %97 = getelementptr inbounds i8, ptr %96, i32 1
  store ptr %97, ptr %95, align 8, !tbaa !15
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._CMatchFinder, ptr %98, i32 0, i32 1
  %100 = load i32, ptr %99, align 8, !tbaa !18
  %101 = add i32 %100, 1
  store i32 %101, ptr %99, align 8, !tbaa !18
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._CMatchFinder, ptr %102, i32 0, i32 2
  %104 = load i32, ptr %103, align 4, !tbaa !23
  %105 = icmp eq i32 %101, %104
  br i1 %105, label %106, label %108

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

108:                                              ; preds = %106, %19
  %109 = load i32, ptr %6, align 4, !tbaa !14
  store i32 %109, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %110

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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: nounwind uwtable
declare dso_local ptr @GetMatchesSpec1(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @Bt3Zip_MatchFinder_GetMatches(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %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 %54

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 = getelementptr inbounds i8, ptr %0, i64 48
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %0, i64 24
  %33 = load i32, ptr %32, align 8, !tbaa !19
  %34 = getelementptr inbounds i8, ptr %0, i64 28
  %35 = load i32, ptr %34, align 4, !tbaa !20
  %36 = getelementptr inbounds i8, ptr %0, i64 60
  %37 = load i32, ptr %36, align 4, !tbaa !21
  %38 = tail call ptr @GetMatchesSpec1(i32 noundef %4, i32 noundef %27, i32 noundef %29, ptr noundef nonnull %8, ptr noundef %31, i32 noundef %33, i32 noundef %35, i32 noundef %37, ptr noundef %1, i32 noundef 2)
  %39 = ptrtoint ptr %38 to i64
  %40 = ptrtoint ptr %1 to i64
  %41 = sub i64 %39, %40
  %42 = lshr exact i64 %41, 2
  %43 = trunc i64 %42 to i32
  %44 = load i32, ptr %32, align 8, !tbaa !19
  %45 = add i32 %44, 1
  store i32 %45, ptr %32, align 8, !tbaa !19
  %46 = load ptr, ptr %0, align 8, !tbaa !13
  %47 = getelementptr inbounds i8, ptr %46, i64 1
  store ptr %47, ptr %0, align 8, !tbaa !13
  %48 = load i32, ptr %28, align 8, !tbaa !17
  %49 = add i32 %48, 1
  store i32 %49, ptr %28, align 8, !tbaa !17
  %50 = getelementptr inbounds i8, ptr %0, i64 12
  %51 = load i32, ptr %50, align 4, !tbaa !22
  %52 = icmp eq i32 %49, %51
  br i1 %52, label %53, label %54

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

54:                                               ; preds = %7, %53, %6
  %.0 = phi i32 [ 0, %6 ], [ %43, %53 ], [ %43, %7 ]
  ret i32 %.0
}

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

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

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

!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