; LLVM IR from sp-nitech/SPTK :: src/input (input_source_interpolation_with_magic_number)

; 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::InputSourceInterpolationWithMagicNumber" = type { %"class.sptk::InputSourceInterface", i32, i32, i32, i8, double, i32, i32, i32, ptr, i8, %"class.std::vector", %"class.std::vector", %"class.std::vector" }
%"class.sptk::InputSourceInterface" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk39InputSourceInterpolationWithMagicNumber18CalculateIncrementEv(ptr noundef nonnull align 8 dereferenceable(136) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %6 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 2
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = sitofp i32 %7 to double
  %9 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 1
  %10 = load i32, ptr %9, align 8, !tbaa !19
  %11 = sitofp i32 %10 to double
  %12 = fdiv double %8, %11
  store double %12, ptr %3, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !21
  br label %13

13:                                               ; preds = %61, %1
  %14 = load i32, ptr %4, align 4, !tbaa !21
  %15 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 7
  %16 = load i32, ptr %15, align 4, !tbaa !22
  %17 = icmp slt i32 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %64

19:                                               ; preds = %13
  %20 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 5
  %21 = load double, ptr %20, align 8, !tbaa !23
  %22 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 12
  %23 = load i32, ptr %4, align 4, !tbaa !21
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %24) #2
  %26 = load double, ptr %25, align 8, !tbaa !20
  %27 = fcmp oeq double %21, %26
  br i1 %27, label %37, label %28

28:                                               ; preds = %19
  %29 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 5
  %30 = load double, ptr %29, align 8, !tbaa !23
  %31 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 11
  %32 = load i32, ptr %4, align 4, !tbaa !21
  %33 = sext i32 %32 to i64
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %33) #2
  %35 = load double, ptr %34, align 8, !tbaa !20
  %36 = fcmp oeq double %30, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %28, %19
  %38 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 13
  %39 = load i32, ptr %4, align 4, !tbaa !21
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %40) #2
  store double 0x7FEFFFFFFFFFFFFF, ptr %41, align 8, !tbaa !20
  br label %60

42:                                               ; preds = %28
  %43 = load double, ptr %3, align 8, !tbaa !20
  %44 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 12
  %45 = load i32, ptr %4, align 4, !tbaa !21
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %44, i64 noundef %46) #2
  %48 = load double, ptr %47, align 8, !tbaa !20
  %49 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 11
  %50 = load i32, ptr %4, align 4, !tbaa !21
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %51) #2
  %53 = load double, ptr %52, align 8, !tbaa !20
  %54 = fsub double %48, %53
  %55 = fmul double %43, %54
  %56 = getelementptr inbounds %"class.sptk::InputSourceInterpolationWithMagicNumber", ptr %5, i32 0, i32 13
  %57 = load i32, ptr %4, align 4, !tbaa !21
  %58 = sext i32 %57 to i64
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %56, i64 noundef %58) #2
  store double %55, ptr %59, align 8, !tbaa !20
  br label %60

60:                                               ; preds = %42, %37
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %4, align 4, !tbaa !21
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %4, align 4, !tbaa !21
  br label %13, !llvm.loop !24

64:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 12}
!10 = !{!"_ZTSN4sptk39InputSourceInterpolationWithMagicNumberE", !11, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !13, i64 20, !14, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !6, i64 48, !13, i64 56, !15, i64 64, !15, i64 88, !15, i64 112}
!11 = !{!"_ZTSN4sptk20InputSourceInterfaceE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTSSt6vectorIdSaIdEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!10, !12, i64 8}
!20 = !{!14, !14, i64 0}
!21 = !{!12, !12, i64 0}
!22 = !{!10, !12, i64 36}
!23 = !{!10, !14, i64 24}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk39InputSourceInterpolationWithMagicNumber18CalculateIncrementEv(ptr noundef nonnull align 8 dereferenceable(136) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = sitofp i32 %3 to double
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !18
  %7 = sitofp i32 %6 to double
  %8 = fdiv double %4, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 36
  %10 = load i32, ptr %9, align 4, !tbaa !19
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = getelementptr inbounds i8, ptr %0, i64 112
  br label %16

._crit_edge:                                      ; preds = %33, %1
  ret void

16:                                               ; preds = %.lr.ph, %33
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %33 ]
  %17 = load double, ptr %12, align 8, !tbaa !20
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %indvars.iv) #1
  %19 = load double, ptr %18, align 8, !tbaa !21
  %20 = fcmp oeq double %17, %19
  br i1 %20, label %33, label %21

21:                                               ; preds = %16
  %22 = load double, ptr %12, align 8, !tbaa !20
  %23 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %indvars.iv) #1
  %24 = load double, ptr %23, align 8, !tbaa !21
  %25 = fcmp oeq double %22, %24
  br i1 %25, label %33, label %26

26:                                               ; preds = %21
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %indvars.iv) #1
  %28 = load double, ptr %27, align 8, !tbaa !21
  %29 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %indvars.iv) #1
  %30 = load double, ptr %29, align 8, !tbaa !21
  %31 = fsub double %28, %30
  %32 = fmul double %8, %31
  br label %33

33:                                               ; preds = %16, %21, %26
  %.sink = phi double [ %32, %26 ], [ 0x7FEFFFFFFFFFFFFF, %21 ], [ 0x7FEFFFFFFFFFFFFF, %16 ]
  %34 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %indvars.iv) #1
  store double %.sink, ptr %34, align 8, !tbaa !21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr %9, align 4, !tbaa !19
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next, %36
  br i1 %37, label %16, label %._crit_edge, !llvm.loop !22
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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 }

!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, !8, i64 12}
!6 = !{!"_ZTSN4sptk39InputSourceInterpolationWithMagicNumberE", !7, i64 0, !8, i64 8, !8, i64 12, !8, i64 16, !11, i64 20, !12, i64 24, !8, i64 32, !8, i64 36, !8, i64 40, !13, i64 48, !11, i64 56, !14, i64 64, !14, i64 88, !14, i64 112}
!7 = !{!"_ZTSN4sptk20InputSourceInterfaceE"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"_ZTSSt6vectorIdSaIdEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}
!18 = !{!6, !8, i64 8}
!19 = !{!6, !8, i64 36}
!20 = !{!6, !12, i64 24}
!21 = !{!12, !12, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass