; LLVM IR from JayXon/Leanify :: lib/LZMA (LzFindMt)

; 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._CMatchFinderMt = type { ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, ptr, ptr, i32, [1 x i32], %struct._CMtSync, [128 x i8], ptr, i32, i32, i32, i32, ptr, i32, i32, i32, ptr, i32, i32, i32, %struct._CMtSync, ptr, ptr }
%struct._CMtSync = type { i32, %struct._CThread, i64, i32, i32, i32, i32, i32, i32, %struct._CEvent, %struct._CEvent, %struct._CSemaphore, %struct._CSemaphore, %struct._CCriticalSection }
%struct._CThread = type { i64, i32 }
%struct._CEvent = type { i32, i32, i32, %union.pthread_mutex_t, %union.pthread_cond_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct._CSemaphore = type { i32, i32, i32, %union.pthread_mutex_t, %union.pthread_cond_t }
%struct._CCriticalSection = type { %union.pthread_mutex_t }
%struct.ISzAlloc = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @MatchFinderMt_Create(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #0 {
  %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
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._CMatchFinderMt, ptr %18, i32 0, i32 30
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  store ptr %20, ptr %14, align 8, !tbaa !5
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._CMatchFinderMt, ptr %22, i32 0, i32 8
  store i32 %21, ptr %23, align 4, !tbaa !20
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = mul i32 %24, 4
  %26 = icmp ule i32 65536, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %6
  store i32 5, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %92

28:                                               ; preds = %6
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._CMatchFinderMt, ptr %29, i32 0, i32 15
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = icmp ne ptr %31, null
  br i1 %32, label %53, label %33

33:                                               ; preds = %28
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ISzAlloc, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = call ptr %36(ptr noundef %37, i64 noundef 5242880)
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._CMatchFinderMt, ptr %39, i32 0, i32 15
  store ptr %38, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._CMatchFinderMt, ptr %41, i32 0, i32 15
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %33
  store i32 2, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %92

46:                                               ; preds = %33
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._CMatchFinderMt, ptr %47, i32 0, i32 15
  %49 = load ptr, ptr %48, align 8, !tbaa !21
  %50 = getelementptr inbounds i32, ptr %49, i64 262144
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._CMatchFinderMt, ptr %51, i32 0, i32 1
  store ptr %50, ptr %52, align 8, !tbaa !24
  br label %53

53:                                               ; preds = %46, %28
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = add i32 %54, 1310720
  store i32 %55, ptr %10, align 4, !tbaa !9
  %56 = load i32, ptr %12, align 4, !tbaa !9
  %57 = add i32 %56, 131072
  store i32 %57, ptr %12, align 4, !tbaa !9
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = load i32, ptr %10, align 4, !tbaa !9
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = call i32 @MatchFinder_Create(ptr noundef %58, i32 noundef %59, i32 noundef %60, i32 noundef %61, i32 noundef %62, ptr noundef %63)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %67, label %66

66:                                               ; preds = %53
  store i32 2, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %92

67:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._CMatchFinderMt, ptr %68, i32 0, i32 28
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = call i32 @MtSync_Create(ptr noundef %69, ptr noundef @HashThreadFunc2, ptr noundef %70)
  store i32 %71, ptr %16, align 4, !tbaa !9
  %72 = load i32, ptr %16, align 4, !tbaa !9
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %67
  %75 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %75, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %77

76:                                               ; preds = %67
  store i32 0, ptr %15, align 4
  br label %77

77:                                               ; preds = %76, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %78 = load i32, ptr %15, align 4
  switch i32 %78, label %92 [
    i32 0, label %79
  ]

79:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._CMatchFinderMt, ptr %80, i32 0, i32 13
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = call i32 @MtSync_Create(ptr noundef %81, ptr noundef @BtThreadFunc2, ptr noundef %82)
  store i32 %83, ptr %17, align 4, !tbaa !9
  %84 = load i32, ptr %17, align 4, !tbaa !9
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %88

86:                                               ; preds = %79
  %87 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %87, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %89

88:                                               ; preds = %79
  store i32 0, ptr %15, align 4
  br label %89

89:                                               ; preds = %88, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  %90 = load i32, ptr %15, align 4
  switch i32 %90, label %92 [
    i32 0, label %91
  ]

91:                                               ; preds = %89
  store i32 0, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %92

92:                                               ; preds = %91, %89, %77, %66, %45, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %93 = load i32, ptr %7, align 4
  ret i32 %93
}

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

declare i32 @MatchFinder_Create(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: noinline nounwind uwtable
declare hidden i32 @MtSync_Create(ptr noundef, ptr noundef, ptr noundef) #3

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @BtThreadFunc2(ptr 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { 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, !6, i64 1312}
!12 = !{!"_CMatchFinderMt", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !7, i64 76, !13, i64 80, !7, i64 592, !6, i64 720, !10, i64 728, !10, i64 732, !10, i64 736, !10, i64 740, !6, i64 744, !10, i64 752, !10, i64 756, !10, i64 760, !6, i64 768, !10, i64 776, !10, i64 780, !10, i64 784, !13, i64 792, !6, i64 1304, !6, i64 1312}
!13 = !{!"_CMtSync", !10, i64 0, !14, i64 8, !16, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !17, i64 56, !17, i64 160, !18, i64 264, !18, i64 368, !19, i64 472}
!14 = !{!"_CThread", !15, i64 0, !10, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"_CEvent", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16, !7, i64 56}
!18 = !{!"_CSemaphore", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16, !7, i64 56}
!19 = !{!"_CCriticalSection", !7, i64 0}
!20 = !{!12, !10, i64 52}
!21 = !{!12, !6, i64 720}
!22 = !{!23, !6, i64 0}
!23 = !{!"ISzAlloc", !6, i64 0, !6, i64 8}
!24 = !{!12, !6, i64 8}


; 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 i32 @MatchFinderMt_Create(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %0, i64 1312
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %1, ptr %9, align 4, !tbaa !18
  %10 = and i32 %3, 1073725440
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %30

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 720
  %13 = load ptr, ptr %12, align 8, !tbaa !19
  %.not33 = icmp eq ptr %13, null
  br i1 %.not33, label %14, label %20

14:                                               ; preds = %11
  %15 = load ptr, ptr %5, align 8, !tbaa !20
  %16 = tail call ptr %15(ptr noundef nonnull %5, i64 noundef 5242880) #3
  store ptr %16, ptr %12, align 8, !tbaa !19
  %.not34 = icmp eq ptr %16, null
  br i1 %.not34, label %30, label %17

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %16, i64 1048576
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %18, ptr %19, align 8, !tbaa !22
  br label %20

20:                                               ; preds = %17, %11
  %21 = add i32 %2, 1310720
  %22 = add i32 %4, 131072
  %23 = tail call i32 @MatchFinder_Create(ptr noundef %8, i32 noundef %1, i32 noundef %21, i32 noundef %3, i32 noundef %22, ptr noundef %5) #3
  %.not35 = icmp eq i32 %23, 0
  br i1 %.not35, label %30, label %24

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 792
  %26 = tail call i32 @MtSync_Create(ptr noundef nonnull %25, ptr noundef nonnull @HashThreadFunc2, ptr noundef nonnull %0)
  %.not36 = icmp eq i32 %26, 0
  br i1 %.not36, label %27, label %30

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 80
  %29 = tail call i32 @MtSync_Create(ptr noundef nonnull %28, ptr noundef nonnull @BtThreadFunc2, ptr noundef nonnull %0)
  br label %30

30:                                               ; preds = %27, %20, %14, %6, %24
  %.2 = phi i32 [ %26, %24 ], [ 5, %6 ], [ 2, %14 ], [ 2, %20 ], [ %29, %27 ]
  ret i32 %.2
}

declare i32 @MatchFinder_Create(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: noinline nounwind uwtable
declare hidden i32 @MtSync_Create(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @BtThreadFunc2(ptr 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 = { "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 = { 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 #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, !7, i64 1312}
!6 = !{!"_CMatchFinderMt", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !10, i64 72, !8, i64 76, !11, i64 80, !8, i64 592, !7, i64 720, !10, i64 728, !10, i64 732, !10, i64 736, !10, i64 740, !7, i64 744, !10, i64 752, !10, i64 756, !10, i64 760, !7, i64 768, !10, i64 776, !10, i64 780, !10, i64 784, !11, i64 792, !7, i64 1304, !7, i64 1312}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_CMtSync", !10, i64 0, !12, i64 8, !14, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !15, i64 56, !15, i64 160, !16, i64 264, !16, i64 368, !17, i64 472}
!12 = !{!"_CThread", !13, i64 0, !10, i64 8}
!13 = !{!"long", !8, i64 0}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"_CEvent", !10, i64 0, !10, i64 4, !10, i64 8, !8, i64 16, !8, i64 56}
!16 = !{!"_CSemaphore", !10, i64 0, !10, i64 4, !10, i64 8, !8, i64 16, !8, i64 56}
!17 = !{!"_CCriticalSection", !8, i64 0}
!18 = !{!6, !10, i64 52}
!19 = !{!6, !7, i64 720}
!20 = !{!21, !7, i64 0}
!21 = !{!"ISzAlloc", !7, i64 0, !7, i64 8}
!22 = !{!6, !7, i64 8}


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