; 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_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.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_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.XXH64_state_s = type { i64, i64, i64, i64, i64, [4 x i64], i32, [2 x i32] }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }
%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 }
%struct.ZSTD_prefixDict_s = type { ptr, i64, i32 }

; Function Attrs: nounwind uwtable
define dso_local i64 @ZSTD_CCtx_setParameter(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %8, i32 0, i32 31
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %21

12:                                               ; preds = %3
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = call i32 @ZSTD_isUpdateAuthorized(i32 noundef %13)
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %12
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %17, i32 0, i32 1
  store i32 1, ptr %18, align 4, !tbaa !29
  br label %20

19:                                               ; preds = %12
  store i64 -60, ptr %4, align 8
  br label %99

20:                                               ; preds = %16
  br label %21

21:                                               ; preds = %20, %3
  %22 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %22, label %98 [
    i32 10, label %23
    i32 100, label %29
    i32 101, label %41
    i32 102, label %41
    i32 103, label %41
    i32 104, label %41
    i32 105, label %41
    i32 106, label %41
    i32 107, label %41
    i32 1000, label %53
    i32 200, label %53
    i32 201, label %53
    i32 202, label %53
    i32 1100, label %59
    i32 400, label %65
    i32 401, label %80
    i32 402, label %80
    i32 160, label %86
    i32 161, label %86
    i32 162, label %86
    i32 163, label %86
    i32 164, label %86
  ]

23:                                               ; preds = %21
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %25, i32 noundef %26, i32 noundef %27)
  store i64 %28, ptr %4, align 8
  br label %99

29:                                               ; preds = %21
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %30, i32 0, i32 34
  %32 = load ptr, ptr %31, align 8, !tbaa !30
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  store i64 -60, ptr %4, align 8
  br label %99

35:                                               ; preds = %29
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %37, i32 noundef %38, i32 noundef %39)
  store i64 %40, ptr %4, align 8
  br label %99

41:                                               ; preds = %21, %21, %21, %21, %21, %21, %21
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %42, i32 0, i32 34
  %44 = load ptr, ptr %43, align 8, !tbaa !30
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %41
  store i64 -60, ptr %4, align 8
  br label %99

47:                                               ; preds = %41
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %49, i32 noundef %50, i32 noundef %51)
  store i64 %52, ptr %4, align 8
  br label %99

53:                                               ; preds = %21, %21, %21, %21
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %54, i32 0, i32 3
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %55, i32 noundef %56, i32 noundef %57)
  store i64 %58, ptr %4, align 8
  br label %99

59:                                               ; preds = %21
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %60, i32 0, i32 3
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %61, i32 noundef %62, i32 noundef %63)
  store i64 %64, ptr %4, align 8
  br label %99

65:                                               ; preds = %21
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = icmp ugt i32 %66, 0
  br i1 %67, label %68, label %74

68:                                               ; preds = %65
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %69, i32 0, i32 14
  %71 = load i64, ptr %70, align 8, !tbaa !31
  %72 = icmp ne i64 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %68
  store i64 -40, ptr %4, align 8
  br label %99

74:                                               ; preds = %68, %65
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %75, i32 0, i32 3
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %76, i32 noundef %77, i32 noundef %78)
  store i64 %79, ptr %4, align 8
  br label %99

80:                                               ; preds = %21, %21
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %81, i32 0, i32 3
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %82, i32 noundef %83, i32 noundef %84)
  store i64 %85, ptr %4, align 8
  br label %99

86:                                               ; preds = %21, %21, %21, %21, %21
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %87, i32 0, i32 34
  %89 = load ptr, ptr %88, align 8, !tbaa !30
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %86
  store i64 -60, ptr %4, align 8
  br label %99

92:                                               ; preds = %86
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.ZSTD_CCtx_s, ptr %93, i32 0, i32 3
  %95 = load i32, ptr %6, align 4, !tbaa !9
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = call i64 @ZSTD_CCtxParam_setParameter(ptr noundef %94, i32 noundef %95, i32 noundef %96)
  store i64 %97, ptr %4, align 8
  br label %99

98:                                               ; preds = %21
  store i64 -40, ptr %4, align 8
  br label %99

99:                                               ; preds = %98, %92, %91, %80, %74, %73, %59, %53, %47, %46, %35, %34, %23, %19
  %100 = load i64, ptr %4, align 8
  ret i64 %100
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ZSTD_isUpdateAuthorized(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @ZSTD_CCtxParam_setParameter(ptr noundef, i32 noundef, i32 noundef) #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, !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, !10, i64 856}
!12 = !{!"ZSTD_CCtx_s", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !13, i64 136, !10, i64 256, !6, i64 264, !18, i64 272, !18, i64 280, !19, i64 288, !19, i64 296, !19, i64 304, !20, i64 312, !17, i64 400, !18, i64 424, !21, i64 432, !22, i64 496, !6, i64 552, !18, i64 560, !24, i64 568, !25, i64 600, !6, i64 776, !6, i64 784, !18, i64 792, !18, i64 800, !18, i64 808, !18, i64 816, !6, i64 824, !18, i64 832, !18, i64 840, !18, i64 848, !10, i64 856, !10, i64 860, !6, i64 864, !6, i64 872, !28, i64 880}
!13 = !{!"ZSTD_CCtx_params_s", !10, i64 0, !14, i64 4, !15, i64 32, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !16, i64 68, !17, i64 96}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!17 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"long", !7, i64 0}
!19 = !{!"long long", !7, i64 0}
!20 = !{!"XXH64_state_s", !19, i64 0, !19, i64 8, !19, i64 16, !19, i64 24, !19, i64 32, !7, i64 40, !10, i64 72, !7, i64 76}
!21 = !{!"", !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}
!22 = !{!"", !23, i64 0, !6, i64 32, !6, i64 40, !18, i64 48}
!23 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28}
!24 = !{!"", !6, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}
!25 = !{!"", !6, i64 0, !6, i64 8, !26, i64 16}
!26 = !{!"", !23, i64 0, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !6, i64 56, !6, i64 64, !27, i64 72}
!27 = !{!"", !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}
!28 = !{!"ZSTD_prefixDict_s", !6, i64 0, !18, i64 8, !10, i64 16}
!29 = !{!12, !10, i64 4}
!30 = !{!12, !6, i64 872}
!31 = !{!12, !18, i64 424}


; 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_CCtx_setParameter(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 856
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %10, label %6

6:                                                ; preds = %3
  %7 = tail call i32 @ZSTD_isUpdateAuthorized(i32 noundef %1)
  %.not34 = icmp eq i32 %7, 0
  br i1 %.not34, label %26, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1, ptr %9, align 4, !tbaa !27
  br label %10

10:                                               ; preds = %8, %3
  switch i32 %1, label %26 [
    i32 10, label %.sink.split
    i32 100, label %11
    i32 101, label %14
    i32 102, label %14
    i32 103, label %14
    i32 104, label %14
    i32 105, label %14
    i32 106, label %14
    i32 107, label %14
    i32 1000, label %.sink.split
    i32 200, label %.sink.split
    i32 201, label %.sink.split
    i32 202, label %.sink.split
    i32 1100, label %.sink.split
    i32 400, label %17
    i32 401, label %.sink.split
    i32 402, label %.sink.split
    i32 160, label %21
    i32 161, label %21
    i32 162, label %21
    i32 163, label %21
    i32 164, label %21
  ]

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 872
  %13 = load ptr, ptr %12, align 8, !tbaa !28
  %.not39 = icmp eq ptr %13, null
  br i1 %.not39, label %.sink.split, label %26

14:                                               ; preds = %10, %10, %10, %10, %10, %10, %10
  %15 = getelementptr inbounds i8, ptr %0, i64 872
  %16 = load ptr, ptr %15, align 8, !tbaa !28
  %.not38 = icmp eq ptr %16, null
  br i1 %.not38, label %.sink.split, label %26

17:                                               ; preds = %10
  %.not36 = icmp eq i32 %2, 0
  br i1 %.not36, label %.sink.split, label %18

18:                                               ; preds = %17
  %19 = getelementptr inbounds i8, ptr %0, i64 424
  %20 = load i64, ptr %19, align 8, !tbaa !29
  %.not37 = icmp eq i64 %20, 0
  br i1 %.not37, label %.sink.split, label %26

21:                                               ; preds = %10, %10, %10, %10, %10
  %22 = getelementptr inbounds i8, ptr %0, i64 872
  %23 = load ptr, ptr %22, align 8, !tbaa !28
  %.not35 = icmp eq ptr %23, null
  br i1 %.not35, label %.sink.split, label %26

.sink.split:                                      ; preds = %10, %10, %10, %10, %10, %10, %10, %21, %17, %18, %14, %11, %10
  %.sink40 = phi i32 [ %1, %10 ], [ 100, %11 ], [ %1, %14 ], [ 400, %18 ], [ 400, %17 ], [ %1, %21 ], [ %1, %10 ], [ %1, %10 ], [ %1, %10 ], [ %1, %10 ], [ %1, %10 ], [ %1, %10 ], [ %1, %10 ]
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = tail call i64 @ZSTD_CCtxParam_setParameter(ptr noundef nonnull %24, i32 noundef %.sink40, i32 noundef %2)
  br label %26

26:                                               ; preds = %.sink.split, %10, %21, %18, %14, %11, %6
  %.0 = phi i64 [ -60, %6 ], [ -60, %11 ], [ -60, %14 ], [ -40, %18 ], [ -60, %21 ], [ -40, %10 ], [ %25, %.sink.split ]
  ret i64 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ZSTD_isUpdateAuthorized(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @ZSTD_CCtxParam_setParameter(ptr noundef, i32 noundef, i32 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, !7, i64 856}
!6 = !{!"ZSTD_CCtx_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 136, !7, i64 256, !15, i64 264, !16, i64 272, !16, i64 280, !17, i64 288, !17, i64 296, !17, i64 304, !18, i64 312, !14, i64 400, !16, i64 424, !19, i64 432, !20, i64 496, !15, i64 552, !16, i64 560, !22, i64 568, !23, i64 600, !15, i64 776, !15, i64 784, !16, i64 792, !16, i64 800, !16, i64 808, !16, i64 816, !15, i64 824, !16, i64 832, !16, i64 840, !16, i64 848, !7, i64 856, !7, i64 860, !15, i64 864, !15, i64 872, !26, i64 880}
!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, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !13, i64 68, !14, i64 96}
!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 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!14 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!"long long", !8, i64 0}
!18 = !{!"XXH64_state_s", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !8, i64 40, !7, i64 72, !8, i64 76}
!19 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !7, i64 56, !7, i64 60}
!20 = !{!"", !21, i64 0, !15, i64 32, !15, i64 40, !16, i64 48}
!21 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !7, i64 24, !7, i64 28}
!22 = !{!"", !15, i64 0, !16, i64 8, !16, i64 16, !16, i64 24}
!23 = !{!"", !15, i64 0, !15, i64 8, !24, i64 16}
!24 = !{!"", !21, i64 0, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !15, i64 48, !15, i64 56, !15, i64 64, !25, i64 72}
!25 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, 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}
!26 = !{!"ZSTD_prefixDict_s", !15, i64 0, !16, i64 8, !7, i64 16}
!27 = !{!6, !7, i64 4}
!28 = !{!6, !15, i64 872}
!29 = !{!6, !16, i64 424}


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