; LLVM IR from sp-nitech/SPTK :: src/compression (inverse_uniform_quantization)

; 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"

%"class.sptk::InverseUniformQuantization" = type { ptr, double, i32, i32, i8, i32, double }

@_ZTVN4sptk26InverseUniformQuantizationE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk26InverseUniformQuantizationC2EdiNS_19UniformQuantization16QuantizationTypeE(ptr noundef nonnull align 8 dereferenceable(40) %0, double noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !13
  %9 = load ptr, ptr %5, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk26InverseUniformQuantizationE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !15
  %10 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 1
  %11 = load double, ptr %6, align 8, !tbaa !9
  store double %11, ptr %10, align 8, !tbaa !17
  %12 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 2
  %13 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %13, ptr %12, align 8, !tbaa !20
  %14 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 3
  %15 = load i32, ptr %8, align 4, !tbaa !13
  store i32 %15, ptr %14, align 4, !tbaa !21
  %16 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 4
  store i8 1, ptr %16, align 8, !tbaa !22
  %17 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 1
  %18 = load double, ptr %17, align 8, !tbaa !17
  %19 = fcmp ole double %18, 0.000000e+00
  br i1 %19, label %24, label %20

20:                                               ; preds = %4
  %21 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !20
  %23 = icmp sle i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %20, %4
  %25 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 4
  store i8 0, ptr %25, align 8, !tbaa !22
  br label %53

26:                                               ; preds = %20
  %27 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !21
  switch i32 %28, label %42 [
    i32 0, label %29
    i32 1, label %35
  ]

29:                                               ; preds = %26
  %30 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !20
  %32 = call noundef double @_ZSt3powIdiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(double noundef 2.000000e+00, i32 noundef %31)
  %33 = fptosi double %32 to i32
  %34 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 5
  store i32 %33, ptr %34, align 4, !tbaa !23
  br label %44

35:                                               ; preds = %26
  %36 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 2
  %37 = load i32, ptr %36, align 8, !tbaa !20
  %38 = call noundef double @_ZSt3powIdiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(double noundef 2.000000e+00, i32 noundef %37)
  %39 = fptosi double %38 to i32
  %40 = sub nsw i32 %39, 1
  %41 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 5
  store i32 %40, ptr %41, align 4, !tbaa !23
  br label %44

42:                                               ; preds = %26
  %43 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 4
  store i8 0, ptr %43, align 8, !tbaa !22
  br label %53

44:                                               ; preds = %35, %29
  %45 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 1
  %46 = load double, ptr %45, align 8, !tbaa !17
  %47 = fmul double 2.000000e+00, %46
  %48 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 5
  %49 = load i32, ptr %48, align 4, !tbaa !23
  %50 = sitofp i32 %49 to double
  %51 = fdiv double %47, %50
  %52 = getelementptr inbounds %"class.sptk::InverseUniformQuantization", ptr %9, i32 0, i32 6
  store double %51, ptr %52, align 8, !tbaa !24
  br label %53

53:                                               ; preds = %44, %42, %24
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIdiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(double noundef, i32 noundef) #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTSN4sptk19UniformQuantization16QuantizationTypeE", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !10, i64 8}
!18 = !{!"_ZTSN4sptk26InverseUniformQuantizationE", !10, i64 8, !12, i64 16, !14, i64 20, !19, i64 24, !12, i64 28, !10, i64 32}
!19 = !{!"bool", !7, i64 0}
!20 = !{!18, !12, i64 16}
!21 = !{!18, !14, i64 20}
!22 = !{!18, !19, i64 24}
!23 = !{!18, !12, i64 28}
!24 = !{!18, !10, i64 32}


; 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"

@_ZTVN4sptk26InverseUniformQuantizationE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk26InverseUniformQuantizationC2EdiNS_19UniformQuantization16QuantizationTypeE(ptr nocapture noundef nonnull align 8 dereferenceable(40) %0, double noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk26InverseUniformQuantizationE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store double %1, ptr %5, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %2, ptr %6, align 8, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %3, ptr %7, align 4, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 1, ptr %8, align 8, !tbaa !17
  %9 = fcmp ole double %1, 0.000000e+00
  %10 = icmp slt i32 %2, 1
  %or.cond = or i1 %9, %10
  br i1 %or.cond, label %11, label %12

11:                                               ; preds = %4
  store i8 0, ptr %8, align 8, !tbaa !17
  br label %28

12:                                               ; preds = %4
  switch i32 %3, label %20 [
    i32 0, label %13
    i32 1, label %16
  ]

13:                                               ; preds = %12
  %14 = tail call noundef double @_ZSt3powIdiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(double noundef 2.000000e+00, i32 noundef %2)
  %15 = fptosi double %14 to i32
  br label %21

16:                                               ; preds = %12
  %17 = tail call noundef double @_ZSt3powIdiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(double noundef 2.000000e+00, i32 noundef %2)
  %18 = fptosi double %17 to i32
  %19 = add nsw i32 %18, -1
  br label %21

20:                                               ; preds = %12
  store i8 0, ptr %8, align 8, !tbaa !17
  br label %28

21:                                               ; preds = %16, %13
  %.sink = phi i32 [ %19, %16 ], [ %15, %13 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %.sink, ptr %22, align 4, !tbaa !18
  %23 = load double, ptr %5, align 8, !tbaa !8
  %24 = fmul double %23, 2.000000e+00
  %25 = sitofp i32 %.sink to double
  %26 = fdiv double %24, %25
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  store double %26, ptr %27, align 8, !tbaa !19
  br label %28

28:                                               ; preds = %21, %20, %11
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIdiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(double noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTSN4sptk26InverseUniformQuantizationE", !10, i64 8, !12, i64 16, !13, i64 20, !14, i64 24, !12, i64 28, !10, i64 32}
!10 = !{!"double", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"_ZTSN4sptk19UniformQuantization16QuantizationTypeE", !11, i64 0}
!14 = !{!"bool", !11, i64 0}
!15 = !{!9, !12, i64 16}
!16 = !{!9, !13, i64 20}
!17 = !{!9, !14, i64 24}
!18 = !{!9, !12, i64 28}
!19 = !{!9, !10, i64 32}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass