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

; 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 }
%struct.ZSTD_CCtx_params_s = type { i32, %struct.ZSTD_compressionParameters, %struct.ZSTD_frameParameters, i32, i32, i32, i32, i32, i32, %struct.ldmParams_t, %struct.ZSTD_customMem }
%struct.ZSTD_frameParameters = type { i32, i32, i32 }
%struct.ldmParams_t = type { i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }
%struct.ZSTD_prefixDict_s = type { ptr, i64, i32 }
%struct.ZSTD_outBuffer_s = type { ptr, i64, i64 }
%struct.ZSTD_inBuffer_s = type { ptr, i64, i64 }
%struct.ZSTD_CCtx_s = type { i32, i32, i32, %struct.ZSTD_CCtx_params_s, %struct.ZSTD_CCtx_params_s, i32, ptr, i64, i64, i64, i64, i64, %struct.XXH64_state_s, %struct.ZSTD_customMem, i64, %struct.seqStore_t, %struct.ldmState_t, ptr, i64, %struct.rawSeqStore_t, %struct.ZSTD_blockState_t, ptr, ptr, i64, i64, i64, i64, ptr, i64, i64, i64, i32, i32, ptr, ptr, %struct.ZSTD_prefixDict_s }
%struct.XXH64_state_s = type { i64, i64, i64, i64, i64, [4 x i64], i32, [2 x i32] }
%struct.seqStore_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32 }
%struct.ldmState_t = type { %struct.ZSTD_window_t, ptr, ptr, i64 }
%struct.ZSTD_window_t = type { ptr, ptr, ptr, i32, i32 }
%struct.rawSeqStore_t = type { ptr, i64, i64, i64 }
%struct.ZSTD_blockState_t = type { ptr, ptr, %struct.ZSTD_matchState_t }
%struct.ZSTD_matchState_t = type { %struct.ZSTD_window_t, i32, i32, i32, i32, ptr, ptr, ptr, %struct.optState_t }
%struct.optState_t = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @ZSTD_getCParamsFromCCtxParams(ptr dead_on_unwind noalias writable sret(%struct.ZSTD_compressionParameters) align 4, ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @ERR_isError(i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_resetCStream_internal(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef byval(%struct.ZSTD_CCtx_params_s) align 8, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @ZSTD_compressStream_generic(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i64 @ZSTD_compress_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #3 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.ZSTD_CCtx_params_s, align 8
  %11 = alloca %struct.ZSTD_prefixDict_s, align 8
  %12 = alloca %struct.ZSTD_compressionParameters, align 4
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ZSTD_outBuffer_s, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ZSTD_outBuffer_s, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !14
  %22 = icmp ugt i64 %18, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %4
  store i64 -1, ptr %5, align 8
  br label %111

24:                                               ; preds = %4
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %25, i32 0, i32 2
  %27 = load i64, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %28, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !17
  %31 = icmp ugt i64 %27, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  store i64 -1, ptr %5, align 8
  br label %111

33:                                               ; preds = %24
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %34, i32 0, i32 31
  %36 = load i32, ptr %35, align 8, !tbaa !18
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %89

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 120, ptr %10) #4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %39, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %40, i64 120, i1 false), !tbaa.struct !35
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %41, i32 0, i32 35
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %42, i64 24, i1 false), !tbaa.struct !36
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %43, i32 0, i32 35
  call void @llvm.memset.p0.i64(ptr align 8 %44, i8 0, i64 24, i1 false)
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 2
  br i1 %46, label %47, label %54

47:                                               ; preds = %38
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !17
  %51 = add i64 %50, 1
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %52, i32 0, i32 9
  store i64 %51, ptr %53, align 8, !tbaa !38
  br label %54

54:                                               ; preds = %47, %38
  %55 = getelementptr inbounds %struct.ZSTD_CCtx_params_s, ptr %10, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 28, ptr %12) #4
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %58, i32 0, i32 9
  %60 = load i64, ptr %59, align 8, !tbaa !38
  %61 = sub i64 %60, 1
  call void @ZSTD_getCParamsFromCCtxParams(ptr dead_on_unwind writable sret(%struct.ZSTD_compressionParameters) align 4 %12, ptr noundef %57, i64 noundef %61, i64 noundef 0)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %55, ptr align 4 %12, i64 28, i1 false), !tbaa.struct !39
  call void @llvm.lifetime.end.p0(i64 28, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ZSTD_prefixDict_s, ptr %11, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !40
  %65 = getelementptr inbounds %struct.ZSTD_prefixDict_s, ptr %11, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !41
  %67 = getelementptr inbounds %struct.ZSTD_prefixDict_s, ptr %11, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !42
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %69, i32 0, i32 34
  %71 = load ptr, ptr %70, align 8, !tbaa !43
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %72, i32 0, i32 9
  %74 = load i64, ptr %73, align 8, !tbaa !38
  %75 = sub i64 %74, 1
  %76 = call i64 @ZSTD_resetCStream_internal(ptr noundef %62, ptr noundef %64, i64 noundef %66, i32 noundef %68, ptr noundef %71, ptr noundef byval(%struct.ZSTD_CCtx_params_s) align 8 %10, i64 noundef %75)
  store i64 %76, ptr %13, align 8, !tbaa !37
  %77 = load i64, ptr %13, align 8, !tbaa !37
  %78 = call i32 @ERR_isError(i64 noundef %77)
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %82

80:                                               ; preds = %54
  %81 = load i64, ptr %13, align 8, !tbaa !37
  store i64 %81, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %83

82:                                               ; preds = %54
  store i32 0, ptr %14, align 4
  br label %83

83:                                               ; preds = %82, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %84 = load i32, ptr %14, align 4
  switch i32 %84, label %86 [
    i32 0, label %85
  ]

85:                                               ; preds = %83
  store i32 0, ptr %14, align 4
  br label %86

86:                                               ; preds = %85, %83
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 120, ptr %10) #4
  %87 = load i32, ptr %14, align 4
  switch i32 %87, label %113 [
    i32 0, label %88
    i32 1, label %111
  ]

88:                                               ; preds = %86
  br label %89

89:                                               ; preds = %88, %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = call i64 @ZSTD_compressStream_generic(ptr noundef %90, ptr noundef %91, ptr noundef %92, i32 noundef %93)
  store i64 %94, ptr %15, align 8, !tbaa !37
  %95 = load i64, ptr %15, align 8, !tbaa !37
  %96 = call i32 @ERR_isError(i64 noundef %95)
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %100

98:                                               ; preds = %89
  %99 = load i64, ptr %15, align 8, !tbaa !37
  store i64 %99, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %101

100:                                              ; preds = %89
  store i32 0, ptr %14, align 4
  br label %101

101:                                              ; preds = %100, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  %102 = load i32, ptr %14, align 4
  switch i32 %102, label %113 [
    i32 0, label %103
    i32 1, label %111
  ]

103:                                              ; preds = %101
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %104, i32 0, i32 29
  %106 = load i64, ptr %105, align 8, !tbaa !44
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %107, i32 0, i32 30
  %109 = load i64, ptr %108, align 8, !tbaa !45
  %110 = sub i64 %106, %109
  store i64 %110, ptr %5, align 8
  br label %111

111:                                              ; preds = %103, %101, %86, %32, %23
  %112 = load i64, ptr %5, align 8
  ret i64 %112

113:                                              ; preds = %101, %86
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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, !13, i64 16}
!12 = !{!"ZSTD_outBuffer_s", !6, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!16, !13, i64 16}
!16 = !{!"ZSTD_inBuffer_s", !6, i64 0, !13, i64 8, !13, i64 16}
!17 = !{!16, !13, i64 8}
!18 = !{!19, !10, i64 856}
!19 = !{!"ZSTD_CCtx_s", !10, i64 0, !10, i64 4, !10, i64 8, !20, i64 16, !20, i64 136, !10, i64 256, !6, i64 264, !13, i64 272, !13, i64 280, !25, i64 288, !25, i64 296, !25, i64 304, !26, i64 312, !24, i64 400, !13, i64 424, !27, i64 432, !28, i64 496, !6, i64 552, !13, i64 560, !30, i64 568, !31, i64 600, !6, i64 776, !6, i64 784, !13, i64 792, !13, i64 800, !13, i64 808, !13, i64 816, !6, i64 824, !13, i64 832, !13, i64 840, !13, i64 848, !10, i64 856, !10, i64 860, !6, i64 864, !6, i64 872, !34, i64 880}
!20 = !{!"ZSTD_CCtx_params_s", !10, i64 0, !21, i64 4, !22, i64 32, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !23, i64 68, !24, i64 96}
!21 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!22 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!23 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!24 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"long long", !7, i64 0}
!26 = !{!"XXH64_state_s", !25, i64 0, !25, i64 8, !25, i64 16, !25, i64 24, !25, i64 32, !7, i64 40, !10, i64 72, !7, i64 76}
!27 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60}
!28 = !{!"", !29, i64 0, !6, i64 32, !6, i64 40, !13, i64 48}
!29 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28}
!30 = !{!"", !6, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!31 = !{!"", !6, i64 0, !6, i64 8, !32, i64 16}
!32 = !{!"", !29, i64 0, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !6, i64 56, !6, i64 64, !33, i64 72}
!33 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80}
!34 = !{!"ZSTD_prefixDict_s", !6, i64 0, !13, i64 8, !10, i64 16}
!35 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 4, !9, i64 36, i64 4, !9, i64 40, i64 4, !9, i64 44, i64 4, !9, i64 48, i64 4, !9, i64 52, i64 4, !9, i64 56, i64 4, !9, i64 60, i64 4, !9, i64 64, i64 4, !9, i64 68, i64 4, !9, i64 72, i64 4, !9, i64 76, i64 4, !9, i64 80, i64 4, !9, i64 84, i64 4, !9, i64 88, i64 4, !9, i64 96, i64 8, !5, i64 104, i64 8, !5, i64 112, i64 8, !5}
!36 = !{i64 0, i64 8, !5, i64 8, i64 8, !37, i64 16, i64 4, !9}
!37 = !{!13, !13, i64 0}
!38 = !{!19, !25, i64 288}
!39 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 4, !9}
!40 = !{!34, !6, i64 0}
!41 = !{!34, !13, i64 8}
!42 = !{!34, !10, i64 16}
!43 = !{!19, !6, i64 872}
!44 = !{!19, !13, i64 840}
!45 = !{!19, !13, i64 848}


; 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.ZSTD_compressionParameters = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_CCtx_params_s = type { i32, %struct.ZSTD_compressionParameters, %struct.ZSTD_frameParameters, i32, i32, i32, i32, i32, i32, %struct.ldmParams_t, %struct.ZSTD_customMem }
%struct.ZSTD_frameParameters = type { i32, i32, i32 }
%struct.ldmParams_t = type { i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @ZSTD_getCParamsFromCCtxParams(ptr dead_on_unwind noalias writable sret(%struct.ZSTD_compressionParameters) align 4, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @ERR_isError(i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTD_resetCStream_internal(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef byval(%struct.ZSTD_CCtx_params_s) align 8, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @ZSTD_compressStream_generic(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i64 @ZSTD_compress_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca %struct.ZSTD_CCtx_params_s, align 8
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = icmp ugt i64 %7, %9
  br i1 %10, label %49, label %11

11:                                               ; preds = %4
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !14
  %16 = icmp ugt i64 %13, %15
  br i1 %16, label %49, label %17

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %0, i64 856
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %40

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 120, ptr nonnull %5) #4
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(120) %5, ptr noundef nonnull align 8 dereferenceable(120) %22, i64 120, i1 false), !tbaa.struct !33
  %23 = getelementptr inbounds i8, ptr %0, i64 880
  %.sroa.0.0.copyload = load ptr, ptr %23, align 8, !tbaa !35
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 888
  %.sroa.4.0.copyload = load i64, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !36
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 896
  %.sroa.5.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !34
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %23, i8 0, i64 24, i1 false)
  %24 = icmp eq i32 %3, 2
  br i1 %24, label %26, label %._crit_edge

._crit_edge:                                      ; preds = %21
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 288
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !37
  %25 = add i64 %.pre, -1
  br label %30

26:                                               ; preds = %21
  %27 = load i64, ptr %14, align 8, !tbaa !14
  %28 = add i64 %27, 1
  %29 = getelementptr inbounds i8, ptr %0, i64 288
  store i64 %28, ptr %29, align 8, !tbaa !37
  br label %30

30:                                               ; preds = %._crit_edge, %26
  %31 = phi i64 [ %25, %._crit_edge ], [ %27, %26 ]
  %32 = getelementptr inbounds i8, ptr %5, i64 4
  %33 = getelementptr inbounds i8, ptr %0, i64 288
  call void @ZSTD_getCParamsFromCCtxParams(ptr dead_on_unwind nonnull writable sret(%struct.ZSTD_compressionParameters) align 4 %32, ptr noundef nonnull %22, i64 noundef %31, i64 noundef 0)
  %34 = getelementptr inbounds i8, ptr %0, i64 872
  %35 = load ptr, ptr %34, align 8, !tbaa !38
  %36 = load i64, ptr %33, align 8, !tbaa !37
  %37 = add i64 %36, -1
  %38 = call i64 @ZSTD_resetCStream_internal(ptr noundef nonnull %0, ptr noundef %.sroa.0.0.copyload, i64 noundef %.sroa.4.0.copyload, i32 noundef %.sroa.5.0.copyload, ptr noundef %35, ptr noundef nonnull byval(%struct.ZSTD_CCtx_params_s) align 8 %5, i64 noundef %37)
  %39 = call i32 @ERR_isError(i64 noundef %38)
  %.not.not = icmp eq i32 %39, 0
  call void @llvm.lifetime.end.p0(i64 120, ptr nonnull %5) #4
  br i1 %.not.not, label %40, label %49

40:                                               ; preds = %30, %17
  %41 = call i64 @ZSTD_compressStream_generic(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, i32 noundef %3)
  %42 = call i32 @ERR_isError(i64 noundef %41)
  %.not31.not = icmp eq i32 %42, 0
  br i1 %.not31.not, label %43, label %49

43:                                               ; preds = %40
  %44 = getelementptr inbounds i8, ptr %0, i64 840
  %45 = load i64, ptr %44, align 8, !tbaa !39
  %46 = getelementptr inbounds i8, ptr %0, i64 848
  %47 = load i64, ptr %46, align 8, !tbaa !40
  %48 = sub i64 %45, %47
  br label %49

49:                                               ; preds = %40, %30, %11, %4, %43
  %.3 = phi i64 [ %38, %30 ], [ %41, %40 ], [ %48, %43 ], [ -1, %4 ], [ -1, %11 ]
  ret i64 %.3
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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, !10, i64 16}
!6 = !{!"ZSTD_outBuffer_s", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !10, i64 16}
!13 = !{!"ZSTD_inBuffer_s", !7, i64 0, !10, i64 8, !10, i64 16}
!14 = !{!13, !10, i64 8}
!15 = !{!16, !17, i64 856}
!16 = !{!"ZSTD_CCtx_s", !17, i64 0, !17, i64 4, !17, i64 8, !18, i64 16, !18, i64 136, !17, i64 256, !7, i64 264, !10, i64 272, !10, i64 280, !23, i64 288, !23, i64 296, !23, i64 304, !24, i64 312, !22, i64 400, !10, i64 424, !25, i64 432, !26, i64 496, !7, i64 552, !10, i64 560, !28, i64 568, !29, i64 600, !7, i64 776, !7, i64 784, !10, i64 792, !10, i64 800, !10, i64 808, !10, i64 816, !7, i64 824, !10, i64 832, !10, i64 840, !10, i64 848, !17, i64 856, !17, i64 860, !7, i64 864, !7, i64 872, !32, i64 880}
!17 = !{!"int", !8, i64 0}
!18 = !{!"ZSTD_CCtx_params_s", !17, i64 0, !19, i64 4, !20, i64 32, !17, i64 44, !17, i64 48, !17, i64 52, !17, i64 56, !17, i64 60, !17, i64 64, !21, i64 68, !22, i64 96}
!19 = !{!"", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20, !17, i64 24}
!20 = !{!"", !17, i64 0, !17, i64 4, !17, i64 8}
!21 = !{!"", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20}
!22 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!23 = !{!"long long", !8, i64 0}
!24 = !{!"XXH64_state_s", !23, i64 0, !23, i64 8, !23, i64 16, !23, i64 24, !23, i64 32, !8, i64 40, !17, i64 72, !8, i64 76}
!25 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !17, i64 56, !17, i64 60}
!26 = !{!"", !27, i64 0, !7, i64 32, !7, i64 40, !10, i64 48}
!27 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !17, i64 24, !17, i64 28}
!28 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!29 = !{!"", !7, i64 0, !7, i64 8, !30, i64 16}
!30 = !{!"", !27, i64 0, !17, i64 32, !17, i64 36, !17, i64 40, !17, i64 44, !7, i64 48, !7, i64 56, !7, i64 64, !31, i64 72}
!31 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !17, i64 48, !17, i64 52, !17, i64 56, !17, i64 60, !17, i64 64, !17, i64 68, !17, i64 72, !17, i64 76, !17, i64 80}
!32 = !{!"ZSTD_prefixDict_s", !7, i64 0, !10, i64 8, !17, i64 16}
!33 = !{i64 0, i64 4, !34, i64 4, i64 4, !34, i64 8, i64 4, !34, i64 12, i64 4, !34, i64 16, i64 4, !34, i64 20, i64 4, !34, i64 24, i64 4, !34, i64 28, i64 4, !34, i64 32, i64 4, !34, i64 36, i64 4, !34, i64 40, i64 4, !34, i64 44, i64 4, !34, i64 48, i64 4, !34, i64 52, i64 4, !34, i64 56, i64 4, !34, i64 60, i64 4, !34, i64 64, i64 4, !34, i64 68, i64 4, !34, i64 72, i64 4, !34, i64 76, i64 4, !34, i64 80, i64 4, !34, i64 84, i64 4, !34, i64 88, i64 4, !34, i64 96, i64 8, !35, i64 104, i64 8, !35, i64 112, i64 8, !35}
!34 = !{!17, !17, i64 0}
!35 = !{!7, !7, i64 0}
!36 = !{!10, !10, i64 0}
!37 = !{!16, !23, i64 288}
!38 = !{!16, !7, i64 872}
!39 = !{!16, !10, i64 840}
!40 = !{!16, !10, i64 848}


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