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

; 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::DynamicRangeCompression" = type <{ ptr, double, double, double, double, double, double, double, double, i32, [4 x i8], double, double, i8, [7 x i8] }>

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk23DynamicRangeCompressionC2EddddddddNS0_12DetectorTypeE(ptr noundef nonnull align 8 dereferenceable(97) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, i32 noundef %9) unnamed_addr #0 align 2 {
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store double %1, ptr %12, align 8, !tbaa !9
  store double %2, ptr %13, align 8, !tbaa !9
  store double %3, ptr %14, align 8, !tbaa !9
  store double %4, ptr %15, align 8, !tbaa !9
  store double %5, ptr %16, align 8, !tbaa !9
  store double %6, ptr %17, align 8, !tbaa !9
  store double %7, ptr %18, align 8, !tbaa !9
  store double %8, ptr %19, align 8, !tbaa !9
  store i32 %9, ptr %20, align 4, !tbaa !11
  %21 = load ptr, ptr %11, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk23DynamicRangeCompressionE, i32 0, i32 0, i32 2), ptr %21, align 8, !tbaa !13
  %22 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 1
  %23 = load double, ptr %12, align 8, !tbaa !9
  store double %23, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 2
  %25 = load double, ptr %13, align 8, !tbaa !9
  store double %25, ptr %24, align 8, !tbaa !18
  %26 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 3
  %27 = load double, ptr %14, align 8, !tbaa !9
  store double %27, ptr %26, align 8, !tbaa !19
  %28 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 4
  %29 = load double, ptr %15, align 8, !tbaa !9
  store double %29, ptr %28, align 8, !tbaa !20
  %30 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 5
  %31 = load double, ptr %16, align 8, !tbaa !9
  store double %31, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 6
  %33 = load double, ptr %17, align 8, !tbaa !9
  store double %33, ptr %32, align 8, !tbaa !22
  %34 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 7
  %35 = load double, ptr %18, align 8, !tbaa !9
  store double %35, ptr %34, align 8, !tbaa !23
  %36 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 8
  %37 = load double, ptr %19, align 8, !tbaa !9
  store double %37, ptr %36, align 8, !tbaa !24
  %38 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 9
  %39 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %39, ptr %38, align 8, !tbaa !25
  %40 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 11
  %41 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 2
  %42 = load double, ptr %41, align 8, !tbaa !18
  %43 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 6
  %44 = load double, ptr %43, align 8, !tbaa !22
  %45 = fmul double %42, %44
  %46 = fdiv double -1.000000e+03, %45
  %47 = call double @exp(double noundef %46) #2
  store double %47, ptr %40, align 8, !tbaa !26
  %48 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 12
  %49 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 2
  %50 = load double, ptr %49, align 8, !tbaa !18
  %51 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 7
  %52 = load double, ptr %51, align 8, !tbaa !23
  %53 = fmul double %50, %52
  %54 = fdiv double -1.000000e+03, %53
  %55 = call double @exp(double noundef %54) #2
  store double %55, ptr %48, align 8, !tbaa !27
  %56 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 13
  store i8 1, ptr %56, align 8, !tbaa !28
  %57 = load double, ptr %12, align 8, !tbaa !9
  %58 = fcmp ole double %57, 0.000000e+00
  br i1 %58, label %87, label %59

59:                                               ; preds = %10
  %60 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 2
  %61 = load double, ptr %60, align 8, !tbaa !18
  %62 = fcmp ole double %61, 0.000000e+00
  br i1 %62, label %87, label %63

63:                                               ; preds = %59
  %64 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 3
  %65 = load double, ptr %64, align 8, !tbaa !19
  %66 = fcmp olt double 0.000000e+00, %65
  br i1 %66, label %87, label %67

67:                                               ; preds = %63
  %68 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 4
  %69 = load double, ptr %68, align 8, !tbaa !20
  %70 = fcmp olt double %69, 1.000000e+00
  br i1 %70, label %87, label %71

71:                                               ; preds = %67
  %72 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 5
  %73 = load double, ptr %72, align 8, !tbaa !21
  %74 = fcmp olt double %73, 0.000000e+00
  br i1 %74, label %87, label %75

75:                                               ; preds = %71
  %76 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 6
  %77 = load double, ptr %76, align 8, !tbaa !22
  %78 = fcmp ole double %77, 0.000000e+00
  br i1 %78, label %87, label %79

79:                                               ; preds = %75
  %80 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 7
  %81 = load double, ptr %80, align 8, !tbaa !23
  %82 = fcmp ole double %81, 0.000000e+00
  br i1 %82, label %87, label %83

83:                                               ; preds = %79
  %84 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 8
  %85 = load double, ptr %84, align 8, !tbaa !24
  %86 = fcmp olt double %85, 0.000000e+00
  br i1 %86, label %87, label %89

87:                                               ; preds = %83, %79, %75, %71, %67, %63, %59, %10
  %88 = getelementptr inbounds %"class.sptk::DynamicRangeCompression", ptr %21, i32 0, i32 13
  store i8 0, ptr %88, align 8, !tbaa !28
  br label %89

89:                                               ; preds = %87, %83
  ret void
}

; Function Attrs: nounwind
declare double @exp(double noundef) #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 = { nounwind "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 #2 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN4sptk23DynamicRangeCompression12DetectorTypeE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !10, i64 8}
!16 = !{!"_ZTSN4sptk23DynamicRangeCompressionE", !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !12, i64 72, !10, i64 80, !10, i64 88, !17, i64 96}
!17 = !{!"bool", !7, i64 0}
!18 = !{!16, !10, i64 16}
!19 = !{!16, !10, i64 24}
!20 = !{!16, !10, i64 32}
!21 = !{!16, !10, i64 40}
!22 = !{!16, !10, i64 48}
!23 = !{!16, !10, i64 56}
!24 = !{!16, !10, i64 64}
!25 = !{!16, !12, i64 72}
!26 = !{!16, !10, i64 80}
!27 = !{!16, !10, i64 88}
!28 = !{!16, !17, i64 96}


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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @_ZN4sptk23DynamicRangeCompressionC2EddddddddNS0_12DetectorTypeE(ptr nocapture noundef nonnull align 8 dereferenceable(97) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, i32 noundef %9) unnamed_addr #0 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk23DynamicRangeCompressionE, i64 16), ptr %0, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  store double %1, ptr %11, align 8, !tbaa !8
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store double %2, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  store double %3, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  store double %4, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  store double %5, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  store double %6, ptr %16, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  store double %7, ptr %17, align 8, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  store double %8, ptr %18, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 %9, ptr %19, align 8, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %0, i64 80
  %21 = fmul double %2, %6
  %22 = fdiv double -1.000000e+03, %21
  %23 = tail call double @exp(double noundef %22) #2
  store double %23, ptr %20, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %0, i64 88
  %25 = load double, ptr %12, align 8, !tbaa !14
  %26 = load double, ptr %17, align 8, !tbaa !19
  %27 = fmul double %25, %26
  %28 = fdiv double -1.000000e+03, %27
  %29 = tail call double @exp(double noundef %28) #2
  store double %29, ptr %24, align 8, !tbaa !23
  %30 = getelementptr inbounds i8, ptr %0, i64 96
  store i8 1, ptr %30, align 8, !tbaa !24
  %31 = load double, ptr %12, align 8
  %32 = load double, ptr %13, align 8
  %33 = fcmp ogt double %32, 0.000000e+00
  %34 = load double, ptr %14, align 8
  %.fr50 = freeze double %34
  %35 = fcmp olt double %.fr50, 1.000000e+00
  %36 = load double, ptr %15, align 8
  %.fr48 = freeze double %36
  %37 = fcmp olt double %.fr48, 0.000000e+00
  %38 = load <2 x double>, ptr %16, align 8
  %39 = insertelement <4 x double> poison, double %1, i64 0
  %40 = insertelement <4 x double> %39, double %31, i64 1
  %41 = shufflevector <2 x double> %38, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
  %42 = shufflevector <4 x double> %40, <4 x double> %41, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
  %.fr = freeze <4 x double> %42
  %43 = fcmp ole <4 x double> %.fr, zeroinitializer
  %44 = load double, ptr %18, align 8
  %.fr52 = freeze double %44
  %45 = fcmp olt double %.fr52, 0.000000e+00
  %46 = bitcast <4 x i1> %43 to i4
  %47 = icmp ne i4 %46, 0
  %op.rdx = or i1 %47, %35
  %48 = or i1 %op.rdx, %37
  %op.rdx46 = or i1 %48, %45
  %op.rdx47 = select i1 %op.rdx46, i1 true, i1 %33
  br i1 %op.rdx47, label %49, label %50

49:                                               ; preds = %10
  store i8 0, ptr %30, align 8, !tbaa !24
  br label %50

50:                                               ; preds = %10, %49
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 = { mustprogress nofree nounwind willreturn memory(write) "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 #2 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTSN4sptk23DynamicRangeCompressionE", !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !12, i64 72, !10, i64 80, !10, i64 88, !13, i64 96}
!10 = !{!"double", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"_ZTSN4sptk23DynamicRangeCompression12DetectorTypeE", !11, i64 0}
!13 = !{!"bool", !11, i64 0}
!14 = !{!9, !10, i64 16}
!15 = !{!9, !10, i64 24}
!16 = !{!9, !10, i64 32}
!17 = !{!9, !10, i64 40}
!18 = !{!9, !10, i64 48}
!19 = !{!9, !10, i64 56}
!20 = !{!9, !10, i64 64}
!21 = !{!9, !12, i64 72}
!22 = !{!9, !10, i64 80}
!23 = !{!9, !10, i64 88}
!24 = !{!9, !13, i64 96}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass