; LLVM IR from catid/Zpng :: zstd (zstd_fast)

; 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_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, ptr noundef %4, i64 noundef %5) #1 {
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %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 ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ZSTD_compressionParameters, ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %20, ptr %14, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ZSTD_compressionParameters, ptr %21, i32 0, i32 4
  %23 = load i32, ptr %22, align 4, !tbaa !15
  store i32 %23, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ZSTD_compressionParameters, ptr %24, i32 0, i32 5
  %26 = load i32, ptr %25, align 4, !tbaa !16
  store i32 %26, ptr %16, align 4, !tbaa !14
  %27 = load i32, ptr %15, align 4, !tbaa !14
  switch i32 %27, label %28 [
    i32 4, label %29
    i32 5, label %38
    i32 6, label %47
    i32 7, label %56
  ]

28:                                               ; preds = %6
  br label %29

29:                                               ; preds = %28, %6
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = load i64, ptr %13, align 8, !tbaa !9
  %35 = load i32, ptr %14, align 4, !tbaa !14
  %36 = load i32, ptr %16, align 4, !tbaa !14
  %37 = call i64 @ZSTD_compressBlock_fast_generic(ptr noundef %30, ptr noundef %31, ptr noundef %32, ptr noundef %33, i64 noundef %34, i32 noundef %35, i32 noundef %36, i32 noundef 4)
  store i64 %37, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %65

38:                                               ; preds = %6
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = load i64, ptr %13, align 8, !tbaa !9
  %44 = load i32, ptr %14, align 4, !tbaa !14
  %45 = load i32, ptr %16, align 4, !tbaa !14
  %46 = call i64 @ZSTD_compressBlock_fast_generic(ptr noundef %39, ptr noundef %40, ptr noundef %41, ptr noundef %42, i64 noundef %43, i32 noundef %44, i32 noundef %45, i32 noundef 5)
  store i64 %46, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %65

47:                                               ; preds = %6
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load i64, ptr %13, align 8, !tbaa !9
  %53 = load i32, ptr %14, align 4, !tbaa !14
  %54 = load i32, ptr %16, align 4, !tbaa !14
  %55 = call i64 @ZSTD_compressBlock_fast_generic(ptr noundef %48, ptr noundef %49, ptr noundef %50, ptr noundef %51, i64 noundef %52, i32 noundef %53, i32 noundef %54, i32 noundef 6)
  store i64 %55, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %65

56:                                               ; preds = %6
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = load i64, ptr %13, align 8, !tbaa !9
  %62 = load i32, ptr %14, align 4, !tbaa !14
  %63 = load i32, ptr %16, align 4, !tbaa !14
  %64 = call i64 @ZSTD_compressBlock_fast_generic(ptr noundef %57, ptr noundef %58, ptr noundef %59, ptr noundef %60, i64 noundef %61, i32 noundef %62, i32 noundef %63, i32 noundef 7)
  store i64 %64, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %65

65:                                               ; preds = %56, %47, %38, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %66 = load i64, ptr %7, align 8
  ret i64 %66
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_generic(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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 = { alwaysinline 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, !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, !13, i64 8}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 16}
!16 = !{!12, !13, i64 20}


; 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 nocapture noundef readonly %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #0 {
switch.lookup:
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 16
  %9 = load i32, ptr %8, align 4, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %3, i64 20
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %switch.tableidx = add i32 %9, -5
  %12 = icmp ult i32 %switch.tableidx, 3
  %spec.select = select i1 %12, i32 %9, i32 4
  %13 = tail call i64 @ZSTD_compressBlock_fast_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %4, i64 noundef %5, i32 noundef %7, i32 noundef %11, i32 noundef %spec.select)
  ret i64 %13
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i64 @ZSTD_compressBlock_fast_generic(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) 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 = { alwaysinline 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 8}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!6, !7, i64 20}


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