; 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 hidden void @MatchFinder_MovePos(ptr noundef) #1

; Function Attrs: 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) #1 {
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %89, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._CMatchFinder, ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %13, ptr %5, align 4, !tbaa !9
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = icmp ult i32 %14, 3
  br i1 %15, label %16, label %18

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

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

83:                                               ; preds = %18
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  call void @MatchFinder_CheckLimits(ptr noundef %84)
  br label %85

85:                                               ; preds = %83, %18
  store i32 0, ptr %9, align 4
  br label %86

86:                                               ; preds = %85, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %87 = load i32, ptr %9, align 4
  switch i32 %87, label %94 [
    i32 0, label %88
    i32 3, label %89
  ]

88:                                               ; preds = %86
  br label %89

89:                                               ; preds = %88, %86
  %90 = load i32, ptr %4, align 4, !tbaa !9
  %91 = add i32 %90, -1
  store i32 %91, ptr %4, align 4, !tbaa !9
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %10, label %93, !llvm.loop !22

93:                                               ; preds = %89
  ret void

94:                                               ; preds = %86
  unreachable
}

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, !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 12}
!22 = distinct !{!22, !23}
!23 = !{!"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: 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

; Function Attrs: nounwind uwtable
define dso_local void @Hc3Zip_MatchFinder_Skip(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %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 12
  br label %10

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

13:                                               ; preds = %10
  tail call void @MatchFinder_MovePos(ptr noundef nonnull %0)
  br label %45

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

44:                                               ; preds = %14
  tail call void @MatchFinder_CheckLimits(ptr noundef nonnull %0)
  br label %45

45:                                               ; preds = %14, %44, %13
  %46 = add i32 %.0, -1
  %.not = icmp eq i32 %46, 0
  br i1 %.not, label %47, label %10, !llvm.loop !21

47:                                               ; preds = %45
  ret void
}

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 12}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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