; 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._IMatchFinder = type { ptr, ptr, ptr, ptr, ptr }
%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: nounwind uwtable
declare dso_local ptr @MatchFinder_GetPointerToCurrentPos(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @MatchFinder_GetNumAvailableBytes(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @MatchFinder_Init(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @MatchFinder_CreateVTable(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct._IMatchFinder, ptr %5, i32 0, i32 0
  store ptr @MatchFinder_Init, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._IMatchFinder, ptr %7, i32 0, i32 1
  store ptr @MatchFinder_GetNumAvailableBytes, ptr %8, align 8, !tbaa !11
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._IMatchFinder, ptr %9, i32 0, i32 2
  store ptr @MatchFinder_GetPointerToCurrentPos, ptr %10, align 8, !tbaa !12
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._CMatchFinder, ptr %11, i32 0, i32 8
  %13 = load i8, ptr %12, align 1, !tbaa !13
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %20, label %15

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._IMatchFinder, ptr %16, i32 0, i32 3
  store ptr @Hc4_MatchFinder_GetMatches, ptr %17, align 8, !tbaa !18
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._IMatchFinder, ptr %18, i32 0, i32 4
  store ptr @Hc4_MatchFinder_Skip, ptr %19, align 8, !tbaa !19
  br label %47

20:                                               ; preds = %2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._CMatchFinder, ptr %21, i32 0, i32 21
  %23 = load i32, ptr %22, align 4, !tbaa !20
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %30

25:                                               ; preds = %20
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._IMatchFinder, ptr %26, i32 0, i32 3
  store ptr @Bt2_MatchFinder_GetMatches, ptr %27, align 8, !tbaa !18
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._IMatchFinder, ptr %28, i32 0, i32 4
  store ptr @Bt2_MatchFinder_Skip, ptr %29, align 8, !tbaa !19
  br label %46

30:                                               ; preds = %20
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._CMatchFinder, ptr %31, i32 0, i32 21
  %33 = load i32, ptr %32, align 4, !tbaa !20
  %34 = icmp eq i32 %33, 3
  br i1 %34, label %35, label %40

35:                                               ; preds = %30
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._IMatchFinder, ptr %36, i32 0, i32 3
  store ptr @Bt3_MatchFinder_GetMatches, ptr %37, align 8, !tbaa !18
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._IMatchFinder, ptr %38, i32 0, i32 4
  store ptr @Bt3_MatchFinder_Skip, ptr %39, align 8, !tbaa !19
  br label %45

40:                                               ; preds = %30
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._IMatchFinder, ptr %41, i32 0, i32 3
  store ptr @Bt4_MatchFinder_GetMatches, ptr %42, align 8, !tbaa !18
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._IMatchFinder, ptr %43, i32 0, i32 4
  store ptr @Bt4_MatchFinder_Skip, ptr %44, align 8, !tbaa !19
  br label %45

45:                                               ; preds = %40, %35
  br label %46

46:                                               ; preds = %45, %25
  br label %47

47:                                               ; preds = %46, %15
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @Hc4_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Hc4_MatchFinder_Skip(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @Bt2_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Bt2_MatchFinder_Skip(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @Bt3_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Bt3_MatchFinder_Skip(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @Bt4_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Bt4_MatchFinder_Skip(ptr noundef, i32 noundef) #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_IMatchFinder", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}
!13 = !{!14, !7, i64 33}
!14 = !{!"_CMatchFinder", !6, i64 0, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !15, i64 36, !6, i64 40, !6, i64 48, !15, i64 56, !15, i64 60, !6, i64 64, !6, i64 72, !15, i64 80, !15, i64 84, !15, i64 88, !15, i64 92, !16, i64 96, !15, i64 104, !15, i64 108, !15, i64 112, !15, i64 116, !7, i64 120, !16, i64 1144, !17, i64 1152}
!15 = !{!"int", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = !{!10, !6, i64 24}
!19 = !{!10, !6, i64 32}
!20 = !{!14, !15, i64 92}


; 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 @MatchFinder_GetPointerToCurrentPos(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @MatchFinder_GetNumAvailableBytes(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @MatchFinder_Init(ptr noundef) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @MatchFinder_CreateVTable(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  store ptr @MatchFinder_Init, ptr %1, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr @MatchFinder_GetNumAvailableBytes, ptr %3, align 8, !tbaa !10
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr @MatchFinder_GetPointerToCurrentPos, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 33
  %6 = load i8, ptr %5, align 1, !tbaa !12
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %7, label %10

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr @Hc4_MatchFinder_GetMatches, ptr %8, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr @Hc4_MatchFinder_Skip, ptr %9, align 8, !tbaa !18
  br label %18

10:                                               ; preds = %2
  %11 = getelementptr inbounds i8, ptr %0, i64 92
  %12 = load i32, ptr %11, align 4, !tbaa !19
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  %14 = getelementptr inbounds i8, ptr %1, i64 32
  switch i32 %12, label %17 [
    i32 2, label %15
    i32 3, label %16
  ]

15:                                               ; preds = %10
  store ptr @Bt2_MatchFinder_GetMatches, ptr %13, align 8, !tbaa !17
  store ptr @Bt2_MatchFinder_Skip, ptr %14, align 8, !tbaa !18
  br label %18

16:                                               ; preds = %10
  store ptr @Bt3_MatchFinder_GetMatches, ptr %13, align 8, !tbaa !17
  store ptr @Bt3_MatchFinder_Skip, ptr %14, align 8, !tbaa !18
  br label %18

17:                                               ; preds = %10
  store ptr @Bt4_MatchFinder_GetMatches, ptr %13, align 8, !tbaa !17
  store ptr @Bt4_MatchFinder_Skip, ptr %14, align 8, !tbaa !18
  br label %18

18:                                               ; preds = %15, %17, %16, %7
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @Hc4_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Hc4_MatchFinder_Skip(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @Bt2_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Bt2_MatchFinder_Skip(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @Bt3_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Bt3_MatchFinder_Skip(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @Bt4_MatchFinder_GetMatches(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @Bt4_MatchFinder_Skip(ptr noundef, i32 noundef) #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" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !7, i64 0}
!6 = !{!"_IMatchFinder", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !8, i64 33}
!13 = !{!"_CMatchFinder", !7, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !8, i64 32, !8, i64 33, !8, i64 34, !8, i64 35, !14, i64 36, !7, i64 40, !7, i64 48, !14, i64 56, !14, i64 60, !7, i64 64, !7, i64 72, !14, i64 80, !14, i64 84, !14, i64 88, !14, i64 92, !15, i64 96, !14, i64 104, !14, i64 108, !14, i64 112, !14, i64 116, !8, i64 120, !15, i64 1144, !16, i64 1152}
!14 = !{!"int", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"long long", !8, i64 0}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !7, i64 32}
!19 = !{!13, !14, i64 92}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass