; LLVM IR from sp-nitech/SPTK :: src/analysis/spectrum_extraction_by_world.ll (ZN4sptk25SpectrumExtractionByWorldC2Eiidb)

; 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::SpectrumExtractionByWorld" = type <{ %"class.sptk::SpectrumExtractionInterface", i32, i32, double, i8, i8, [6 x i8] }>
%"class.sptk::SpectrumExtractionInterface" = type { ptr }

@_ZTVN4sptk25SpectrumExtractionByWorldE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk25SpectrumExtractionByWorldC2Eiidb(ptr noundef nonnull align 8 dereferenceable(26) %0, i32 noundef %1, i32 noundef %2, double noundef %3, i1 noundef zeroext %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !11
  %13 = zext i1 %4 to i8
  store i8 %13, ptr %10, align 1, !tbaa !13
  %14 = load ptr, ptr %6, align 8
  call void @_ZN4sptk27SpectrumExtractionInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  store ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTVN4sptk25SpectrumExtractionByWorldE, i32 0, i32 0, i32 2), ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 1
  %16 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %16, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 2
  %18 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %18, ptr %17, align 4, !tbaa !20
  %19 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 3
  %20 = load double, ptr %9, align 8, !tbaa !11
  store double %20, ptr %19, align 8, !tbaa !21
  %21 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 4
  %22 = load i8, ptr %10, align 1, !tbaa !13, !range !22, !noundef !23
  %23 = trunc i8 %22 to i1
  %24 = zext i1 %23 to i8
  store i8 %24, ptr %21, align 8, !tbaa !24
  %25 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 5
  store i8 1, ptr %25, align 1, !tbaa !25
  %26 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !17
  %28 = invoke noundef zeroext i1 @_ZN4sptk12IsPowerOfTwoEi(i32 noundef %27)
          to label %29 unwind label %44

29:                                               ; preds = %5
  br i1 %28, label %30, label %42

30:                                               ; preds = %29
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp sle i32 %31, 3
  br i1 %32, label %42, label %33

33:                                               ; preds = %30
  %34 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !20
  %36 = icmp sle i32 %35, 0
  br i1 %36, label %42, label %37

37:                                               ; preds = %33
  %38 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 3
  %39 = load double, ptr %38, align 8, !tbaa !21
  %40 = invoke noundef zeroext i1 @_ZN4sptk9IsInRangeEddd(double noundef %39, double noundef 8.000000e+03, double noundef 9.800000e+04)
          to label %41 unwind label %44

41:                                               ; preds = %37
  br i1 %40, label %48, label %42

42:                                               ; preds = %41, %33, %30, %29
  %43 = getelementptr inbounds %"class.sptk::SpectrumExtractionByWorld", ptr %14, i32 0, i32 5
  store i8 0, ptr %43, align 1, !tbaa !25
  br label %48

44:                                               ; preds = %37, %5
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %11, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %12, align 4
  call void @_ZN4sptk27SpectrumExtractionInterfaceD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  br label %49

48:                                               ; preds = %42, %41
  ret void

49:                                               ; preds = %44
  %50 = load ptr, ptr %11, align 8
  %51 = load i32, ptr %12, align 4
  %52 = insertvalue { ptr, i32 } poison, ptr %50, 0
  %53 = insertvalue { ptr, i32 } %52, i32 %51, 1
  resume { ptr, i32 } %53
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk27SpectrumExtractionInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZN4sptk12IsPowerOfTwoEi(i32 noundef) #2

declare i32 @__gxx_personality_v0(...)

declare noundef zeroext i1 @_ZN4sptk9IsInRangeEddd(double noundef, double noundef, double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk27SpectrumExtractionInterfaceD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

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" }
attributes #2 = { "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 #3 = { 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 #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !10, i64 8}
!18 = !{!"_ZTSN4sptk25SpectrumExtractionByWorldE", !19, i64 0, !10, i64 8, !10, i64 12, !12, i64 16, !14, i64 24, !14, i64 25}
!19 = !{!"_ZTSN4sptk27SpectrumExtractionInterfaceE"}
!20 = !{!18, !10, i64 12}
!21 = !{!18, !12, i64 16}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!18, !14, i64 24}
!25 = !{!18, !14, i64 25}


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

@_ZTVN4sptk25SpectrumExtractionByWorldE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk25SpectrumExtractionByWorldC2Eiidb(ptr noundef nonnull align 8 dereferenceable(26) %0, i32 noundef %1, i32 noundef %2, double noundef %3, i1 noundef zeroext %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = zext i1 %4 to i8
  tail call void @_ZN4sptk27SpectrumExtractionInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  store ptr getelementptr inbounds inrange(-16, 40) (i8, ptr @_ZTVN4sptk25SpectrumExtractionByWorldE, i64 16), ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %7, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %2, ptr %8, align 4, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store double %3, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %6, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 25
  store i8 1, ptr %11, align 1, !tbaa !18
  %12 = invoke noundef zeroext i1 @_ZN4sptk12IsPowerOfTwoEi(i32 noundef %1)
          to label %13 unwind label %22

13:                                               ; preds = %5
  %14 = icmp sgt i32 %1, 3
  %or.cond.not = and i1 %14, %12
  %15 = load i32, ptr %8, align 4
  %16 = icmp sgt i32 %15, 0
  %or.cond.not10 = select i1 %or.cond.not, i1 %16, i1 false
  br i1 %or.cond.not10, label %17, label %21

17:                                               ; preds = %13
  %18 = load double, ptr %9, align 8, !tbaa !16
  %19 = invoke noundef zeroext i1 @_ZN4sptk9IsInRangeEddd(double noundef %18, double noundef 8.000000e+03, double noundef 9.800000e+04)
          to label %20 unwind label %22

20:                                               ; preds = %17
  br i1 %19, label %24, label %21

21:                                               ; preds = %20, %13
  store i8 0, ptr %11, align 1, !tbaa !18
  br label %24

22:                                               ; preds = %17, %5
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN4sptk27SpectrumExtractionInterfaceD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  resume { ptr, i32 } %23

24:                                               ; preds = %21, %20
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk27SpectrumExtractionInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZN4sptk12IsPowerOfTwoEi(i32 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

declare noundef zeroext i1 @_ZN4sptk9IsInRangeEddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk27SpectrumExtractionInterfaceD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

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" }
attributes #2 = { "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 #3 = { 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 #4 = { 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, !11, i64 8}
!9 = !{!"_ZTSN4sptk25SpectrumExtractionByWorldE", !10, i64 0, !11, i64 8, !11, i64 12, !13, i64 16, !14, i64 24, !14, i64 25}
!10 = !{!"_ZTSN4sptk27SpectrumExtractionInterfaceE"}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"double", !12, i64 0}
!14 = !{!"bool", !12, i64 0}
!15 = !{!9, !11, i64 12}
!16 = !{!9, !13, i64 16}
!17 = !{!9, !14, i64 24}
!18 = !{!9, !14, i64 25}


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