; LLVM IR from indygreg/python-zstandard :: zstd (zstd)

; 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.ZSTD_matchState_t = type { %struct.ZSTD_window_t, i32, i32, i32, i32, ptr, [8 x i32], i64, i32, ptr, ptr, ptr, i32, i32, %struct.optState_t, ptr, %struct.ZSTD_compressionParameters, ptr, i32, i32 }
%struct.ZSTD_window_t = type { ptr, ptr, ptr, i32, i32, i32 }
%struct.optState_t = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32 }
%struct.ZSTD_compressionParameters = type { i32, i32, i32, i32, i32, i32, i32 }

; 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
define dso_local i64 @ZSTD_compressBlock_fast(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4) #1 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i64 %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ZSTD_matchState_t, ptr %14, i32 0, i32 16
  %16 = getelementptr inbounds %struct.ZSTD_compressionParameters, ptr %15, i32 0, i32 4
  %17 = load i32, ptr %16, align 8, !tbaa !11
  store i32 %17, ptr %12, align 4, !tbaa !17
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ZSTD_matchState_t, ptr %18, i32 0, i32 16
  %20 = getelementptr inbounds %struct.ZSTD_compressionParameters, ptr %19, i32 0, i32 5
  %21 = load i32, ptr %20, align 4, !tbaa !18
  %22 = icmp ugt i32 %21, 1
  br i1 %22, label %23, label %54

23:                                               ; preds = %5
  %24 = load i32, ptr %12, align 4, !tbaa !17
  switch i32 %24, label %25 [
    i32 4, label %26
    i32 5, label %33
    i32 6, label %40
    i32 7, label %47
  ]

25:                                               ; preds = %23
  br label %26

26:                                               ; preds = %25, %23
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = load i64, ptr %11, align 8, !tbaa !9
  %32 = call i64 @ZSTD_compressBlock_fast_noDict_4_1(ptr noundef %27, ptr noundef %28, ptr noundef %29, ptr noundef %30, i64 noundef %31)
  store i64 %32, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

33:                                               ; preds = %23
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load i64, ptr %11, align 8, !tbaa !9
  %39 = call i64 @ZSTD_compressBlock_fast_noDict_5_1(ptr noundef %34, ptr noundef %35, ptr noundef %36, ptr noundef %37, i64 noundef %38)
  store i64 %39, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

40:                                               ; preds = %23
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i64, ptr %11, align 8, !tbaa !9
  %46 = call i64 @ZSTD_compressBlock_fast_noDict_6_1(ptr noundef %41, ptr noundef %42, ptr noundef %43, ptr noundef %44, i64 noundef %45)
  store i64 %46, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

47:                                               ; preds = %23
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = load i64, ptr %11, align 8, !tbaa !9
  %53 = call i64 @ZSTD_compressBlock_fast_noDict_7_1(ptr noundef %48, ptr noundef %49, ptr noundef %50, ptr noundef %51, i64 noundef %52)
  store i64 %53, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

54:                                               ; preds = %5
  %55 = load i32, ptr %12, align 4, !tbaa !17
  switch i32 %55, label %56 [
    i32 4, label %57
    i32 5, label %64
    i32 6, label %71
    i32 7, label %78
  ]

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56, %54
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load i64, ptr %11, align 8, !tbaa !9
  %63 = call i64 @ZSTD_compressBlock_fast_noDict_4_0(ptr noundef %58, ptr noundef %59, ptr noundef %60, ptr noundef %61, i64 noundef %62)
  store i64 %63, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

64:                                               ; preds = %54
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = load i64, ptr %11, align 8, !tbaa !9
  %70 = call i64 @ZSTD_compressBlock_fast_noDict_5_0(ptr noundef %65, ptr noundef %66, ptr noundef %67, ptr noundef %68, i64 noundef %69)
  store i64 %70, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

71:                                               ; preds = %54
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = load i64, ptr %11, align 8, !tbaa !9
  %77 = call i64 @ZSTD_compressBlock_fast_noDict_6_0(ptr noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %75, i64 noundef %76)
  store i64 %77, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

78:                                               ; preds = %54
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = load i64, ptr %11, align 8, !tbaa !9
  %84 = call i64 @ZSTD_compressBlock_fast_noDict_7_0(ptr noundef %79, ptr noundef %80, ptr noundef %81, ptr noundef %82, i64 noundef %83)
  store i64 %84, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %85

85:                                               ; preds = %78, %71, %64, %57, %47, %40, %33, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %86 = load i64, ptr %6, align 8
  ret i64 %86
}

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_4_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_5_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_6_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_7_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_4_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_5_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_6_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_7_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

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 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 272}
!12 = !{!"ZSTD_matchState_t", !13, i64 0, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52, !6, i64 56, !7, i64 64, !10, i64 96, !14, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !14, i64 136, !14, i64 140, !15, i64 144, !6, i64 248, !16, i64 256, !6, i64 288, !14, i64 296, !14, i64 300}
!13 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !14, i64 28, !14, i64 32}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !14, i64 72, !14, i64 76, !14, i64 80, !6, i64 88, !14, i64 96}
!16 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24}
!17 = !{!14, !14, i64 0}
!18 = !{!12, !14, i64 276}


; 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 i64 @ZSTD_compressBlock_fast(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 272
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 276
  %9 = load i32, ptr %8, align 4, !tbaa !15
  %10 = icmp ugt i32 %9, 1
  br i1 %10, label %11, label %20

11:                                               ; preds = %5
  switch i32 %7, label %12 [
    i32 7, label %18
    i32 5, label %14
    i32 6, label %16
  ]

12:                                               ; preds = %11
  %13 = tail call i64 @ZSTD_compressBlock_fast_noDict_4_1(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

14:                                               ; preds = %11
  %15 = tail call i64 @ZSTD_compressBlock_fast_noDict_5_1(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

16:                                               ; preds = %11
  %17 = tail call i64 @ZSTD_compressBlock_fast_noDict_6_1(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

18:                                               ; preds = %11
  %19 = tail call i64 @ZSTD_compressBlock_fast_noDict_7_1(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

20:                                               ; preds = %5
  switch i32 %7, label %21 [
    i32 7, label %27
    i32 5, label %23
    i32 6, label %25
  ]

21:                                               ; preds = %20
  %22 = tail call i64 @ZSTD_compressBlock_fast_noDict_4_0(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

23:                                               ; preds = %20
  %24 = tail call i64 @ZSTD_compressBlock_fast_noDict_5_0(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

25:                                               ; preds = %20
  %26 = tail call i64 @ZSTD_compressBlock_fast_noDict_6_0(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

27:                                               ; preds = %20
  %28 = tail call i64 @ZSTD_compressBlock_fast_noDict_7_0(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4)
  br label %29

29:                                               ; preds = %27, %25, %23, %21, %18, %16, %14, %12
  %.0 = phi i64 [ %13, %12 ], [ %17, %16 ], [ %15, %14 ], [ %19, %18 ], [ %22, %21 ], [ %26, %25 ], [ %24, %23 ], [ %28, %27 ]
  ret i64 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_4_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_5_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_6_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_7_1(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_4_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_5_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_6_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_noDict_7_0(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 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, !11, i64 272}
!6 = !{!"ZSTD_matchState_t", !7, i64 0, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !8, i64 56, !9, i64 64, !12, i64 96, !11, i64 104, !8, i64 112, !8, i64 120, !8, i64 128, !11, i64 136, !11, i64 140, !13, i64 144, !8, i64 248, !14, i64 256, !8, i64 288, !11, i64 296, !11, i64 300}
!7 = !{!"", !8, i64 0, !8, i64 8, !8, i64 16, !11, i64 24, !11, i64 28, !11, i64 32}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!"", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !8, i64 88, !11, i64 96}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!15 = !{!6, !11, i64 276}


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