; 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: nounwind uwtable
define dso_local void @MatchFinder_Construct(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct._CMatchFinder, ptr %6, i32 0, i32 16
  store ptr null, ptr %7, align 8, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._CMatchFinder, ptr %8, i32 0, i32 10
  store i8 0, ptr %9, align 1, !tbaa !14
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._CMatchFinder, ptr %10, i32 0, i32 12
  store ptr null, ptr %11, align 8, !tbaa !15
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._CMatchFinder, ptr %12, i32 0, i32 29
  store i64 -1, ptr %13, align 8, !tbaa !16
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  call void @MatchFinder_SetDefaultSettings(ptr noundef %14)
  store i32 0, ptr %3, align 4, !tbaa !17
  br label %15

15:                                               ; preds = %41, %1
  %16 = load i32, ptr %3, align 4, !tbaa !17
  %17 = icmp ult i32 %16, 256
  br i1 %17, label %18, label %44

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %19 = load i32, ptr %3, align 4, !tbaa !17
  store i32 %19, ptr %4, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %20

20:                                               ; preds = %31, %18
  %21 = load i32, ptr %5, align 4, !tbaa !17
  %22 = icmp ult i32 %21, 8
  br i1 %22, label %23, label %34

23:                                               ; preds = %20
  %24 = load i32, ptr %4, align 4, !tbaa !17
  %25 = lshr i32 %24, 1
  %26 = load i32, ptr %4, align 4, !tbaa !17
  %27 = and i32 %26, 1
  %28 = sub i32 0, %27
  %29 = and i32 -306674912, %28
  %30 = xor i32 %25, %29
  store i32 %30, ptr %4, align 4, !tbaa !17
  br label %31

31:                                               ; preds = %23
  %32 = load i32, ptr %5, align 4, !tbaa !17
  %33 = add i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !17
  br label %20, !llvm.loop !18

34:                                               ; preds = %20
  %35 = load i32, ptr %4, align 4, !tbaa !17
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._CMatchFinder, ptr %36, i32 0, i32 27
  %38 = load i32, ptr %3, align 4, !tbaa !17
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds [256 x i32], ptr %37, i64 0, i64 %39
  store i32 %35, ptr %40, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %41

41:                                               ; preds = %34
  %42 = load i32, ptr %3, align 4, !tbaa !17
  %43 = add i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !17
  br label %15, !llvm.loop !20

44:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 64}
!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 = !{!10, !7, i64 35}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !13, i64 1152}
!17 = !{!11, !11, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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
define dso_local void @MatchFinder_Construct(ptr noundef %0) local_unnamed_addr #0 {
vector.ph:
  %1 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr null, ptr %1, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 35
  store i8 0, ptr %2, align 1, !tbaa !13
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr null, ptr %3, align 8, !tbaa !14
  %4 = getelementptr inbounds i8, ptr %0, i64 1152
  store i64 -1, ptr %4, align 8, !tbaa !15
  tail call void @MatchFinder_SetDefaultSettings(ptr noundef %0)
  %5 = getelementptr inbounds i8, ptr %0, i64 120
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %6 = lshr <4 x i32> %vec.ind, <i32 1, i32 1, i32 1, i32 1>
  %7 = and <4 x i32> %vec.ind, <i32 1, i32 1, i32 1, i32 1>
  %8 = icmp eq <4 x i32> %7, zeroinitializer
  %9 = select <4 x i1> %8, <4 x i32> zeroinitializer, <4 x i32> <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %10 = xor <4 x i32> %9, %6
  %11 = lshr <4 x i32> %10, <i32 1, i32 1, i32 1, i32 1>
  %12 = and <4 x i32> %vec.ind, <i32 2, i32 2, i32 2, i32 2>
  %13 = icmp eq <4 x i32> %12, zeroinitializer
  %14 = select <4 x i1> %13, <4 x i32> zeroinitializer, <4 x i32> <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %15 = xor <4 x i32> %14, %11
  %16 = lshr <4 x i32> %15, <i32 6, i32 6, i32 6, i32 6>
  %17 = and <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %18 = icmp eq <4 x i32> %17, zeroinitializer
  %19 = select <4 x i1> %18, <4 x i32> zeroinitializer, <4 x i32> <i32 124634137, i32 124634137, i32 124634137, i32 124634137>
  %20 = xor <4 x i32> %19, %16
  %21 = and <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %22 = icmp eq <4 x i32> %21, zeroinitializer
  %23 = select <4 x i1> %22, <4 x i32> zeroinitializer, <4 x i32> <i32 249268274, i32 249268274, i32 249268274, i32 249268274>
  %24 = xor <4 x i32> %23, %20
  %25 = and <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  %26 = icmp eq <4 x i32> %25, zeroinitializer
  %27 = select <4 x i1> %26, <4 x i32> zeroinitializer, <4 x i32> <i32 498536548, i32 498536548, i32 498536548, i32 498536548>
  %28 = xor <4 x i32> %27, %24
  %29 = and <4 x i32> %vec.ind, <i32 32, i32 32, i32 32, i32 32>
  %30 = icmp eq <4 x i32> %29, zeroinitializer
  %31 = select <4 x i1> %30, <4 x i32> zeroinitializer, <4 x i32> <i32 997073096, i32 997073096, i32 997073096, i32 997073096>
  %32 = xor <4 x i32> %31, %28
  %33 = and <4 x i32> %10, <i32 32, i32 32, i32 32, i32 32>
  %34 = icmp eq <4 x i32> %33, zeroinitializer
  %35 = select <4 x i1> %34, <4 x i32> zeroinitializer, <4 x i32> <i32 1994146192, i32 1994146192, i32 1994146192, i32 1994146192>
  %36 = xor <4 x i32> %35, %32
  %37 = and <4 x i32> %15, <i32 32, i32 32, i32 32, i32 32>
  %38 = icmp eq <4 x i32> %37, zeroinitializer
  %39 = select <4 x i1> %38, <4 x i32> zeroinitializer, <4 x i32> <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %40 = xor <4 x i32> %39, %36
  %41 = getelementptr inbounds [256 x i32], ptr %5, i64 0, i64 %index
  store <4 x i32> %40, ptr %41, align 4, !tbaa !16
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %42 = icmp eq i64 %index.next, 256
  br i1 %42, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @MatchFinder_SetDefaultSettings(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, !7, i64 64}
!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, !8, i64 35}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !12, i64 1152}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass