; 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_CCtx_s = type { i32, i32, i32, %struct.ZSTD_CCtx_params_s, %struct.ZSTD_CCtx_params_s, %struct.ZSTD_CCtx_params_s, i32, i64, %struct.ZSTD_cwksp, i64, i64, i64, i64, %struct.XXH_NAMESPACEXXH64_state_s, %struct.ZSTD_customMem, ptr, i64, %struct.SeqCollector, i32, i32, %struct.seqStore_t, %struct.ldmState_t, ptr, i64, %struct.rawSeqStore_t, %struct.ZSTD_blockState_t, ptr, i32, ptr, i64, i64, i64, i64, ptr, i64, i64, i64, i32, i32, %struct.ZSTD_inBuffer_s, i64, i64, %struct.ZSTD_localDict, ptr, %struct.ZSTD_prefixDict_s, ptr, %struct.ZSTD_blockSplitCtx, ptr, i64 }
%struct.ZSTD_CCtx_params_s = type { i32, %struct.ZSTD_compressionParameters, %struct.ZSTD_frameParameters, i32, i32, i64, i32, i32, i32, i32, i64, i32, i32, %struct.ldmParams_t, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ZSTD_customMem, i32, i32, ptr, ptr, i64, i32 }
%struct.ZSTD_compressionParameters = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_frameParameters = type { i32, i32, i32 }
%struct.ldmParams_t = type { i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_cwksp = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i32, i32, i32 }
%struct.XXH_NAMESPACEXXH64_state_s = type { i64, [4 x i64], [4 x i64], i32, i32, i64 }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }
%struct.SeqCollector = type { i32, ptr, i64, i64 }
%struct.seqStore_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i32, i32 }
%struct.ldmState_t = type { %struct.ZSTD_window_t, ptr, i32, ptr, [64 x i64], [64 x %struct.ldmMatchCandidate_t] }
%struct.ZSTD_window_t = type { ptr, ptr, ptr, i32, i32, i32 }
%struct.ldmMatchCandidate_t = type { ptr, i32, i32, ptr }
%struct.rawSeqStore_t = type { ptr, i64, 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, [8 x i32], i64, i32, ptr, ptr, ptr, i32, i32, %struct.optState_t, ptr, %struct.ZSTD_compressionParameters, ptr, 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_inBuffer_s = type { ptr, i64, i64 }
%struct.ZSTD_localDict = type { ptr, ptr, i64, i32, ptr }
%struct.ZSTD_prefixDict_s = type { ptr, i64, i32 }
%struct.ZSTD_blockSplitCtx = type { %struct.seqStore_t, %struct.seqStore_t, %struct.seqStore_t, %struct.seqStore_t, %struct.seqStore_t, [196 x i32], %struct.ZSTD_entropyCTablesMetadata_t }
%struct.ZSTD_entropyCTablesMetadata_t = type { %struct.ZSTD_hufCTablesMetadata_t, %struct.ZSTD_fseCTablesMetadata_t }
%struct.ZSTD_hufCTablesMetadata_t = type { i32, [128 x i8], i64 }
%struct.ZSTD_fseCTablesMetadata_t = type { i32, i32, i32, [133 x i8], i64, i64 }

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

; Function Attrs: nounwind uwtable
define dso_local i64 @ZSTD_CCtx_refCDict(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %7, i32 0, i32 37
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %20

11:                                               ; preds = %6
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  store i64 -60, ptr %3, align 8
  br label %26

20:                                               ; preds = %6
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ZSTD_clearAllDicts(ptr noundef %22)
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %24, i32 0, i32 43
  store ptr %23, ptr %25, align 8, !tbaa !36
  store i64 0, ptr %3, align 8
  br label %26

26:                                               ; preds = %21, %19
  %27 = load i64, ptr %3, align 8
  ret i64 %27
}

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 3608}
!10 = !{!"ZSTD_CCtx_s", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !12, i64 232, !12, i64 448, !11, i64 664, !15, i64 672, !18, i64 680, !15, i64 752, !19, i64 760, !19, i64 768, !19, i64 776, !20, i64 784, !17, i64 872, !6, i64 896, !15, i64 904, !21, i64 912, !11, i64 944, !11, i64 948, !22, i64 952, !23, i64 1032, !6, i64 3144, !15, i64 3152, !25, i64 3160, !26, i64 3200, !6, i64 3520, !11, i64 3528, !6, i64 3536, !15, i64 3544, !15, i64 3552, !15, i64 3560, !15, i64 3568, !6, i64 3576, !15, i64 3584, !15, i64 3592, !15, i64 3600, !11, i64 3608, !11, i64 3612, !29, i64 3616, !15, i64 3640, !15, i64 3648, !30, i64 3656, !6, i64 3696, !31, i64 3704, !6, i64 3728, !32, i64 3736, !6, i64 5232, !15, i64 5240}
!11 = !{!"int", !7, i64 0}
!12 = !{!"ZSTD_CCtx_params_s", !11, i64 0, !13, i64 4, !14, i64 32, !11, i64 44, !11, i64 48, !15, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !15, i64 80, !11, i64 88, !11, i64 92, !16, i64 96, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !17, i64 152, !11, i64 176, !11, i64 180, !6, i64 184, !6, i64 192, !15, i64 200, !11, i64 208}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!17 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !11, i64 60, !11, i64 64, !11, i64 68}
!19 = !{!"long long", !7, i64 0}
!20 = !{!"XXH_NAMESPACEXXH64_state_s", !15, i64 0, !7, i64 8, !7, i64 40, !11, i64 72, !11, i64 76, !15, i64 80}
!21 = !{!"", !11, i64 0, !6, i64 8, !15, i64 16, !15, i64 24}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !15, i64 64, !11, i64 72, !11, i64 76}
!23 = !{!"", !24, i64 0, !6, i64 40, !11, i64 48, !6, i64 56, !7, i64 64, !7, i64 576}
!24 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32}
!25 = !{!"", !6, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!26 = !{!"", !6, i64 0, !6, i64 8, !27, i64 16}
!27 = !{!"ZSTD_matchState_t", !24, i64 0, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !6, i64 56, !7, i64 64, !15, i64 96, !11, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !11, i64 136, !11, i64 140, !28, i64 144, !6, i64 248, !13, i64 256, !6, i64 288, !11, i64 296, !11, i64 300}
!28 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, 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, !6, i64 88, !11, i64 96}
!29 = !{!"ZSTD_inBuffer_s", !6, i64 0, !15, i64 8, !15, i64 16}
!30 = !{!"", !6, i64 0, !6, i64 8, !15, i64 16, !11, i64 24, !6, i64 32}
!31 = !{!"ZSTD_prefixDict_s", !6, i64 0, !15, i64 8, !11, i64 16}
!32 = !{!"", !22, i64 0, !22, i64 80, !22, i64 160, !22, i64 240, !22, i64 320, !7, i64 400, !33, i64 1184}
!33 = !{!"", !34, i64 0, !35, i64 144}
!34 = !{!"", !11, i64 0, !7, i64 4, !15, i64 136}
!35 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !15, i64 152, !15, i64 160}
!36 = !{!10, !6, i64 3696}


; 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
declare hidden void @ZSTD_clearAllDicts(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -60, 1) i64 @ZSTD_CCtx_refCDict(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 3608
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %7

5:                                                ; preds = %2
  tail call void @ZSTD_clearAllDicts(ptr noundef nonnull %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 3696
  store ptr %1, ptr %6, align 8, !tbaa !35
  br label %7

7:                                                ; preds = %2, %5
  %.0 = phi i64 [ 0, %5 ], [ -60, %2 ]
  ret i64 %.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, !7, i64 3608}
!6 = !{!"ZSTD_CCtx_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 232, !10, i64 448, !7, i64 664, !13, i64 672, !17, i64 680, !13, i64 752, !18, i64 760, !18, i64 768, !18, i64 776, !19, i64 784, !15, i64 872, !16, i64 896, !13, i64 904, !20, i64 912, !7, i64 944, !7, i64 948, !21, i64 952, !22, i64 1032, !16, i64 3144, !13, i64 3152, !24, i64 3160, !25, i64 3200, !16, i64 3520, !7, i64 3528, !16, i64 3536, !13, i64 3544, !13, i64 3552, !13, i64 3560, !13, i64 3568, !16, i64 3576, !13, i64 3584, !13, i64 3592, !13, i64 3600, !7, i64 3608, !7, i64 3612, !28, i64 3616, !13, i64 3640, !13, i64 3648, !29, i64 3656, !16, i64 3696, !30, i64 3704, !16, i64 3728, !31, i64 3736, !16, i64 5232, !13, i64 5240}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"ZSTD_CCtx_params_s", !7, i64 0, !11, i64 4, !12, i64 32, !7, i64 44, !7, i64 48, !13, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !13, i64 80, !7, i64 88, !7, i64 92, !14, i64 96, !7, i64 120, !7, i64 124, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !7, i64 144, !7, i64 148, !15, i64 152, !7, i64 176, !7, i64 180, !16, i64 184, !16, i64 192, !13, i64 200, !7, i64 208}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!12 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!13 = !{!"long", !8, i64 0}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!15 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !8, i64 56, !7, i64 60, !7, i64 64, !7, i64 68}
!18 = !{!"long long", !8, i64 0}
!19 = !{!"XXH_NAMESPACEXXH64_state_s", !13, i64 0, !8, i64 8, !8, i64 40, !7, i64 72, !7, i64 76, !13, i64 80}
!20 = !{!"", !7, i64 0, !16, i64 8, !13, i64 16, !13, i64 24}
!21 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !13, i64 56, !13, i64 64, !7, i64 72, !7, i64 76}
!22 = !{!"", !23, i64 0, !16, i64 40, !7, i64 48, !16, i64 56, !8, i64 64, !8, i64 576}
!23 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !7, i64 24, !7, i64 28, !7, i64 32}
!24 = !{!"", !16, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!25 = !{!"", !16, i64 0, !16, i64 8, !26, i64 16}
!26 = !{!"ZSTD_matchState_t", !23, i64 0, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !16, i64 56, !8, i64 64, !13, i64 96, !7, i64 104, !16, i64 112, !16, i64 120, !16, i64 128, !7, i64 136, !7, i64 140, !27, i64 144, !16, i64 248, !11, i64 256, !16, i64 288, !7, i64 296, !7, i64 300}
!27 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !16, i64 88, !7, i64 96}
!28 = !{!"ZSTD_inBuffer_s", !16, i64 0, !13, i64 8, !13, i64 16}
!29 = !{!"", !16, i64 0, !16, i64 8, !13, i64 16, !7, i64 24, !16, i64 32}
!30 = !{!"ZSTD_prefixDict_s", !16, i64 0, !13, i64 8, !7, i64 16}
!31 = !{!"", !21, i64 0, !21, i64 80, !21, i64 160, !21, i64 240, !21, i64 320, !8, i64 400, !32, i64 1184}
!32 = !{!"", !33, i64 0, !34, i64 144}
!33 = !{!"", !7, i64 0, !8, i64 4, !13, i64 136}
!34 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !13, i64 152, !13, i64 160}
!35 = !{!6, !16, i64 3696}


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