; LLVM IR from ionescu007/minlzma :: minlzlib (lzmadec)

; 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._DECODER_STATE = type { i32, i32, i32, i32, i32, i32, %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { [8 x [768 x i16]], [12 x i16], [12 x i16], [12 x [4 x i16]], [12 x i16], [12 x i16], %struct._LENGTH_DECODER_STATE, [12 x [4 x i16]], [4 x [64 x i16]], [114 x i16], [16 x i16], %struct._LENGTH_DECODER_STATE }
%struct._LENGTH_DECODER_STATE = type { i16, i16, [4 x [8 x i16]], [4 x [8 x i16]], [256 x i16] }

@Decoder = external dso_local global %struct._DECODER_STATE, align 4

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

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

; 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 dso_local ptr @LzGetDistSlot() #0

declare zeroext i8 @RcGetBitTree(ptr noundef, i16 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare dso_local void @LzDecodeLen(ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
define dso_local void @LzDecodeMatch(i8 noundef zeroext %0) #0 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store i8 %0, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %6 = load i8, ptr %2, align 1, !tbaa !5
  call void @LzDecodeLen(ptr noundef getelementptr inbounds (%struct.anon, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 6), i32 0, i32 11), i8 noundef zeroext %6)
  %7 = load i32, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 3), align 4, !tbaa !8
  store i32 %7, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 4), align 4, !tbaa !11
  %8 = load i32, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 2), align 4, !tbaa !12
  store i32 %8, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 3), align 4, !tbaa !8
  %9 = load i32, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  store i32 %9, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 2), align 4, !tbaa !12
  %10 = call ptr @LzGetDistSlot()
  store ptr %10, ptr %3, align 8, !tbaa !14
  %11 = load ptr, ptr %3, align 8, !tbaa !14
  %12 = call zeroext i8 @RcGetBitTree(ptr noundef %11, i16 noundef zeroext 64)
  store i8 %12, ptr %4, align 1, !tbaa !5
  %13 = load i8, ptr %4, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = icmp slt i32 %14, 4
  br i1 %15, label %16, label %19

16:                                               ; preds = %1
  %17 = load i8, ptr %4, align 1, !tbaa !5
  %18 = zext i8 %17 to i32
  store i32 %18, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  br label %58

19:                                               ; preds = %1
  %20 = load i8, ptr %4, align 1, !tbaa !5
  %21 = zext i8 %20 to i32
  %22 = ashr i32 %21, 1
  %23 = sub nsw i32 %22, 1
  %24 = trunc i32 %23 to i8
  store i8 %24, ptr %5, align 1, !tbaa !5
  %25 = load i8, ptr %4, align 1, !tbaa !5
  %26 = zext i8 %25 to i32
  %27 = and i32 %26, 1
  %28 = or i32 2, %27
  %29 = load i8, ptr %5, align 1, !tbaa !5
  %30 = zext i8 %29 to i32
  %31 = shl i32 %28, %30
  store i32 %31, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  %32 = load i8, ptr %4, align 1, !tbaa !5
  %33 = zext i8 %32 to i32
  %34 = icmp slt i32 %33, 14
  br i1 %34, label %35, label %42

35:                                               ; preds = %19
  %36 = load i32, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  %37 = load i8, ptr %4, align 1, !tbaa !5
  %38 = zext i8 %37 to i32
  %39 = sub i32 %36, %38
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds [114 x i16], ptr getelementptr inbounds (%struct.anon, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 6), i32 0, i32 9), i64 0, i64 %40
  store ptr %41, ptr %3, align 8, !tbaa !14
  br label %51

42:                                               ; preds = %19
  %43 = load i8, ptr %5, align 1, !tbaa !5
  %44 = zext i8 %43 to i32
  %45 = sub nsw i32 %44, 4
  %46 = trunc i32 %45 to i8
  %47 = call i32 @RcGetFixed(i8 noundef zeroext %46)
  %48 = shl i32 %47, 4
  %49 = load i32, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  %50 = or i32 %49, %48
  store i32 %50, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  store i8 4, ptr %5, align 1, !tbaa !5
  store ptr getelementptr inbounds (%struct.anon, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 6), i32 0, i32 10), ptr %3, align 8, !tbaa !14
  br label %51

51:                                               ; preds = %42, %35
  %52 = load ptr, ptr %3, align 8, !tbaa !14
  %53 = load i8, ptr %5, align 1, !tbaa !5
  %54 = call zeroext i8 @RcGetReverseBitTree(ptr noundef %52, i8 noundef zeroext %53)
  %55 = zext i8 %54 to i32
  %56 = load i32, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  %57 = or i32 %56, %55
  store i32 %57, ptr getelementptr inbounds (%struct._DECODER_STATE, ptr @Decoder, i32 0, i32 1), align 4, !tbaa !13
  br label %58

58:                                               ; preds = %51, %16
  call void @LzSetMatch(ptr noundef @Decoder)
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare i32 @RcGetFixed(i8 noundef zeroext) #2

declare zeroext i8 @RcGetReverseBitTree(ptr noundef, i8 noundef zeroext) #2

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 12}
!9 = !{!"_DECODER_STATE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24}
!10 = !{!"int", !6, i64 0}
!11 = !{!9, !10, i64 16}
!12 = !{!9, !10, i64 8}
!13 = !{!9, !10, i64 4}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !6, i64 0}


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

%struct._DECODER_STATE = type { i32, i32, i32, i32, i32, i32, %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { [8 x [768 x i16]], [12 x i16], [12 x i16], [12 x [4 x i16]], [12 x i16], [12 x i16], %struct._LENGTH_DECODER_STATE, [12 x [4 x i16]], [4 x [64 x i16]], [114 x i16], [16 x i16], %struct._LENGTH_DECODER_STATE }
%struct._LENGTH_DECODER_STATE = type { i16, i16, [4 x [8 x i16]], [4 x [8 x i16]], [256 x i16] }

@Decoder = external dso_local global %struct._DECODER_STATE, align 4

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @LzGetDistSlot() local_unnamed_addr #0

declare zeroext i8 @RcGetBitTree(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @LzDecodeLen(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @LzDecodeMatch(i8 noundef zeroext %0) local_unnamed_addr #0 {
  tail call void @LzDecodeLen(ptr noundef nonnull getelementptr inbounds (i8, ptr @Decoder, i64 14016), i8 noundef zeroext %0)
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @Decoder, i64 12), align 4, !tbaa !5
  store i32 %2, ptr getelementptr inbounds (i8, ptr @Decoder, i64 16), align 4, !tbaa !10
  %3 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @Decoder, i64 4), align 4, !tbaa !11
  store <2 x i32> %3, ptr getelementptr inbounds (i8, ptr @Decoder, i64 8), align 4, !tbaa !11
  %4 = tail call ptr @LzGetDistSlot()
  %5 = tail call zeroext i8 @RcGetBitTree(ptr noundef %4, i16 noundef zeroext 64) #2
  %6 = zext i8 %5 to i32
  %7 = icmp ult i8 %5, 4
  br i1 %7, label %31, label %8

8:                                                ; preds = %1
  %9 = lshr i8 %5, 1
  %10 = add nsw i8 %9, -1
  %11 = and i32 %6, 1
  %12 = or disjoint i32 %11, 2
  %13 = zext nneg i8 %10 to i32
  %14 = shl i32 %12, %13
  store i32 %14, ptr getelementptr inbounds (i8, ptr @Decoder, i64 4), align 4, !tbaa !12
  %15 = icmp ult i8 %5, 14
  br i1 %15, label %16, label %20

16:                                               ; preds = %8
  %17 = sub i32 %14, %6
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds [114 x i16], ptr getelementptr inbounds (i8, ptr @Decoder, i64 13756), i64 0, i64 %18
  br label %26

20:                                               ; preds = %8
  %21 = add nsw i8 %9, -5
  %22 = tail call i32 @RcGetFixed(i8 noundef zeroext %21) #2
  %23 = shl i32 %22, 4
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @Decoder, i64 4), align 4, !tbaa !12
  %25 = or i32 %24, %23
  store i32 %25, ptr getelementptr inbounds (i8, ptr @Decoder, i64 4), align 4, !tbaa !12
  br label %26

26:                                               ; preds = %20, %16
  %.011 = phi ptr [ %19, %16 ], [ getelementptr inbounds (i8, ptr @Decoder, i64 13984), %20 ]
  %.0 = phi i8 [ %10, %16 ], [ 4, %20 ]
  %27 = tail call zeroext i8 @RcGetReverseBitTree(ptr noundef nonnull %.011, i8 noundef zeroext %.0) #2
  %28 = zext i8 %27 to i32
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @Decoder, i64 4), align 4, !tbaa !12
  %30 = or i32 %29, %28
  br label %31

31:                                               ; preds = %1, %26
  %storemerge = phi i32 [ %30, %26 ], [ %6, %1 ]
  store i32 %storemerge, ptr getelementptr inbounds (i8, ptr @Decoder, i64 4), align 4, !tbaa !12
  tail call void @LzSetMatch(ptr noundef nonnull @Decoder)
  ret void
}

declare i32 @RcGetFixed(i8 noundef zeroext) local_unnamed_addr #1

declare zeroext i8 @RcGetReverseBitTree(ptr noundef, i8 noundef zeroext) local_unnamed_addr #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 = { "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, !7, i64 12}
!6 = !{!"_DECODER_STATE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 4}


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