; 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_DCtx_s = type { ptr, ptr, ptr, ptr, %struct.ZSTD_entropyDTables_t, [640 x i32], ptr, ptr, ptr, ptr, i64, %struct.ZSTD_frameHeader, i64, i64, i32, i32, i32, i32, %struct.XXH_NAMESPACEXXH64_state_s, i64, i32, i32, i32, ptr, %struct.ZSTD_customMem, i64, i64, i64, i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, i32, i32, i32, ptr, i64, i64, i64, ptr, i64, i64, i64, i64, i32, i32, i32, %struct.ZSTD_outBuffer_s, ptr, ptr, i32, [65568 x i8], [18 x i8], i64 }
%struct.ZSTD_entropyDTables_t = type { [513 x %struct.ZSTD_seqSymbol], [257 x %struct.ZSTD_seqSymbol], [513 x %struct.ZSTD_seqSymbol], [4097 x i32], [3 x i32], [157 x i32] }
%struct.ZSTD_seqSymbol = type { i16, i8, i8, i32 }
%struct.ZSTD_frameHeader = type { i64, i64, i32, i32, i32, i32, 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.ZSTD_outBuffer_s = type { ptr, i64, i64 }

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

; Function Attrs: nounwind uwtable
define dso_local i64 @ZSTD_DCtx_getParameter(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %8, label %46 [
    i32 100, label %9
    i32 1000, label %16
    i32 1001, label %21
    i32 1002, label %26
    i32 1003, label %31
    i32 1004, label %36
    i32 1005, label %41
  ]

9:                                                ; preds = %3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %10, i32 0, i32 43
  %12 = load i64, ptr %11, align 8, !tbaa !11
  %13 = trunc i64 %12 to i32
  %14 = call i32 @ZSTD_highbit32(i32 noundef %13)
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %14, ptr %15, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %17, i32 0, i32 20
  %19 = load i32, ptr %18, align 8, !tbaa !20
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %19, ptr %20, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

21:                                               ; preds = %3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %22, i32 0, i32 51
  %24 = load i32, ptr %23, align 8, !tbaa !21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %24, ptr %25, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

26:                                               ; preds = %3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %27, i32 0, i32 21
  %29 = load i32, ptr %28, align 4, !tbaa !22
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %29, ptr %30, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

31:                                               ; preds = %3
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %32, i32 0, i32 36
  %34 = load i32, ptr %33, align 8, !tbaa !23
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %34, ptr %35, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

36:                                               ; preds = %3
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %37, i32 0, i32 37
  %39 = load i32, ptr %38, align 4, !tbaa !24
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %39, ptr %40, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

41:                                               ; preds = %3
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ZSTD_DCtx_s, ptr %42, i32 0, i32 38
  %44 = load i32, ptr %43, align 8, !tbaa !25
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %44, ptr %45, align 4, !tbaa !9
  store i64 0, ptr %4, align 8
  br label %57

46:                                               ; preds = %3
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  store i64 -40, ptr %4, align 8
  br label %57

57:                                               ; preds = %56, %41, %36, %31, %26, %21, %16, %9
  %58 = load i64, ptr %4, align 8
  ret i64 %58
}

attributes #0 = { inlinehint 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 = { 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, !14, i64 30264}
!12 = !{!"ZSTD_DCtx_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !7, i64 27324, !6, i64 29888, !6, i64 29896, !6, i64 29904, !6, i64 29912, !14, i64 29920, !15, i64 29928, !14, i64 29976, !14, i64 29984, !10, i64 29992, !10, i64 29996, !10, i64 30000, !10, i64 30004, !17, i64 30008, !14, i64 30096, !10, i64 30104, !10, i64 30108, !10, i64 30112, !6, i64 30120, !18, i64 30128, !14, i64 30152, !14, i64 30160, !14, i64 30168, !10, i64 30176, !10, i64 30180, !6, i64 30184, !6, i64 30192, !10, i64 30200, !10, i64 30204, !10, i64 30208, !6, i64 30216, !10, i64 30224, !10, i64 30228, !10, i64 30232, !10, i64 30236, !6, i64 30240, !14, i64 30248, !14, i64 30256, !14, i64 30264, !6, i64 30272, !14, i64 30280, !14, i64 30288, !14, i64 30296, !14, i64 30304, !10, i64 30312, !10, i64 30316, !10, i64 30320, !19, i64 30328, !6, i64 30352, !6, i64 30360, !10, i64 30368, !7, i64 30372, !7, i64 95940, !14, i64 95960}
!13 = !{!"", !7, i64 0, !7, i64 4104, !7, i64 6160, !7, i64 10264, !7, i64 26652, !7, i64 26664}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !16, i64 0, !16, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"XXH_NAMESPACEXXH64_state_s", !14, i64 0, !7, i64 8, !7, i64 40, !10, i64 72, !10, i64 76, !14, i64 80}
!18 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"ZSTD_outBuffer_s", !6, i64 0, !14, i64 8, !14, i64 16}
!20 = !{!12, !10, i64 30104}
!21 = !{!12, !10, i64 30320}
!22 = !{!12, !10, i64 30108}
!23 = !{!12, !10, i64 30224}
!24 = !{!12, !10, i64 30228}
!25 = !{!12, !10, i64 30232}


; 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: inlinehint nounwind uwtable
declare hidden i32 @ZSTD_highbit32(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -40, 1) i64 @ZSTD_DCtx_getParameter(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  switch i32 %1, label %27 [
    i32 100, label %4
    i32 1000, label %9
    i32 1001, label %12
    i32 1002, label %15
    i32 1003, label %18
    i32 1004, label %21
    i32 1005, label %24
  ]

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 30264
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = trunc i64 %6 to i32
  %8 = tail call i32 @ZSTD_highbit32(i32 noundef %7)
  br label %.sink.split

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 30104
  %11 = load i32, ptr %10, align 8, !tbaa !18
  br label %.sink.split

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 30320
  %14 = load i32, ptr %13, align 8, !tbaa !19
  br label %.sink.split

15:                                               ; preds = %3
  %16 = getelementptr inbounds i8, ptr %0, i64 30108
  %17 = load i32, ptr %16, align 4, !tbaa !20
  br label %.sink.split

18:                                               ; preds = %3
  %19 = getelementptr inbounds i8, ptr %0, i64 30224
  %20 = load i32, ptr %19, align 8, !tbaa !21
  br label %.sink.split

21:                                               ; preds = %3
  %22 = getelementptr inbounds i8, ptr %0, i64 30228
  %23 = load i32, ptr %22, align 4, !tbaa !22
  br label %.sink.split

24:                                               ; preds = %3
  %25 = getelementptr inbounds i8, ptr %0, i64 30232
  %26 = load i32, ptr %25, align 8, !tbaa !23
  br label %.sink.split

.sink.split:                                      ; preds = %4, %9, %12, %15, %18, %21, %24
  %.sink = phi i32 [ %26, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %9 ], [ %8, %4 ]
  store i32 %.sink, ptr %2, align 4, !tbaa !24
  br label %27

27:                                               ; preds = %.sink.split, %3
  %.0 = phi i64 [ -40, %3 ], [ 0, %.sink.split ]
  ret i64 %.0
}

attributes #0 = { inlinehint 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 = { 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 30264}
!6 = !{!"ZSTD_DCtx_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !8, i64 27324, !7, i64 29888, !7, i64 29896, !7, i64 29904, !7, i64 29912, !11, i64 29920, !12, i64 29928, !11, i64 29976, !11, i64 29984, !14, i64 29992, !14, i64 29996, !14, i64 30000, !14, i64 30004, !15, i64 30008, !11, i64 30096, !14, i64 30104, !14, i64 30108, !14, i64 30112, !7, i64 30120, !16, i64 30128, !11, i64 30152, !11, i64 30160, !11, i64 30168, !14, i64 30176, !14, i64 30180, !7, i64 30184, !7, i64 30192, !14, i64 30200, !14, i64 30204, !14, i64 30208, !7, i64 30216, !14, i64 30224, !14, i64 30228, !14, i64 30232, !14, i64 30236, !7, i64 30240, !11, i64 30248, !11, i64 30256, !11, i64 30264, !7, i64 30272, !11, i64 30280, !11, i64 30288, !11, i64 30296, !11, i64 30304, !14, i64 30312, !14, i64 30316, !14, i64 30320, !17, i64 30328, !7, i64 30352, !7, i64 30360, !14, i64 30368, !8, i64 30372, !8, i64 95940, !11, i64 95960}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !8, i64 0, !8, i64 4104, !8, i64 6160, !8, i64 10264, !8, i64 26652, !8, i64 26664}
!11 = !{!"long", !8, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40}
!13 = !{!"long long", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"XXH_NAMESPACEXXH64_state_s", !11, i64 0, !8, i64 8, !8, i64 40, !14, i64 72, !14, i64 76, !11, i64 80}
!16 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!17 = !{!"ZSTD_outBuffer_s", !7, i64 0, !11, i64 8, !11, i64 16}
!18 = !{!6, !14, i64 30104}
!19 = !{!6, !14, i64 30320}
!20 = !{!6, !14, i64 30108}
!21 = !{!6, !14, i64 30224}
!22 = !{!6, !14, i64 30228}
!23 = !{!6, !14, i64 30232}
!24 = !{!14, !14, i64 0}


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