; LLVM IR from kdrag0n/fxdsp :: external/oboe/apps/OboeTester/app/src/main/cpp/flowunits (ExponentialShape)

; 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.oboe::flowgraph::FlowGraphFilter" = type { %"class.oboe::flowgraph::FlowGraphNode", %"class.oboe::flowgraph::FlowGraphPortFloatInput", %"class.oboe::flowgraph::FlowGraphPortFloatOutput" }
%"class.oboe::flowgraph::FlowGraphNode" = type { ptr, i64, %"class.std::vector", i8, i8, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>, std::allocator<std::reference_wrapper<oboe::flowgraph::FlowGraphPort>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.oboe::flowgraph::FlowGraphPortFloatInput" = type { %"class.oboe::flowgraph::FlowGraphPortFloat", ptr }
%"class.oboe::flowgraph::FlowGraphPortFloat" = type { %"class.oboe::flowgraph::FlowGraphPort.base", i32, %"class.std::unique_ptr" }
%"class.oboe::flowgraph::FlowGraphPort.base" = type <{ ptr, ptr, i32 }>
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"class.oboe::flowgraph::FlowGraphPortFloatOutput" = type { %"class.oboe::flowgraph::FlowGraphPortFloat" }
%class.ExponentialShape = type <{ %"class.oboe::flowgraph::FlowGraphFilter", float, float, float, [4 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN16ExponentialShape9onProcessEi(ptr noundef nonnull align 8 dereferenceable(132) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %10 = getelementptr inbounds %"class.oboe::flowgraph::FlowGraphFilter", ptr %9, i32 0, i32 1
  %11 = call noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40) %10)
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %12 = getelementptr inbounds %"class.oboe::flowgraph::FlowGraphFilter", ptr %9, i32 0, i32 2
  %13 = call noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %39, %2
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %42

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %20, i64 %22
  %24 = load float, ptr %23, align 4, !tbaa !11
  %25 = fpext float %24 to double
  %26 = call double @llvm.fmuladd.f64(double %25, double 5.000000e-01, double 5.000000e-01)
  %27 = fptrunc double %26 to float
  store float %27, ptr %8, align 4, !tbaa !11
  %28 = getelementptr inbounds %class.ExponentialShape, ptr %9, i32 0, i32 1
  %29 = load float, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %class.ExponentialShape, ptr %9, i32 0, i32 3
  %31 = load float, ptr %30, align 8, !tbaa !33
  %32 = load float, ptr %8, align 4, !tbaa !11
  %33 = call float @powf(float noundef %31, float noundef %32) #6
  %34 = fmul float %29, %33
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds float, ptr %35, i64 %37
  store float %34, ptr %38, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %39

39:                                               ; preds = %19
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !9
  br label %14, !llvm.loop !34

42:                                               ; preds = %18
  %43 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret i32 %43
}

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

declare noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 120}
!14 = !{!"_ZTS16ExponentialShape", !15, i64 0, !12, i64 120, !12, i64 124, !12, i64 128}
!15 = !{!"_ZTSN4oboe9flowgraph15FlowGraphFilterE", !16, i64 0, !23, i64 48, !32, i64 88}
!16 = !{!"_ZTSN4oboe9flowgraph13FlowGraphNodeE", !17, i64 8, !18, i64 16, !22, i64 40, !22, i64 41, !10, i64 44}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSSt6vectorISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"bool", !7, i64 0}
!23 = !{!"_ZTSN4oboe9flowgraph23FlowGraphPortFloatInputE", !24, i64 0, !6, i64 32}
!24 = !{!"_ZTSN4oboe9flowgraph18FlowGraphPortFloatE", !25, i64 0, !10, i64 20, !26, i64 24}
!25 = !{!"_ZTSN4oboe9flowgraph13FlowGraphPortE", !6, i64 8, !10, i64 16}
!26 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !27, i64 0}
!27 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !28, i64 0}
!28 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !29, i64 0}
!29 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !30, i64 0}
!30 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !31, i64 0}
!31 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !6, i64 0}
!32 = !{!"_ZTSN4oboe9flowgraph24FlowGraphPortFloatOutputE", !24, i64 0}
!33 = !{!14, !12, i64 128}
!34 = distinct !{!34, !35}
!35 = !{!"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 uwtable
define dso_local noundef i32 @_ZN16ExponentialShape9onProcessEi(ptr noundef nonnull align 8 dereferenceable(132) %0, i32 noundef returned %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = tail call noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40) %3)
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = tail call noundef ptr @_ZN4oboe9flowgraph18FlowGraphPortFloat9getBufferEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %7 = icmp sgt i32 %1, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  %9 = getelementptr inbounds i8, ptr %0, i64 128
  %wide.trip.count = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %10 = icmp eq i32 %1, 1
  br i1 %10, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %21

._crit_edge.loopexit.unr-lcssa:                   ; preds = %21, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %21 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %11 = getelementptr inbounds float, ptr %4, i64 %indvars.iv.unr
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = fpext float %12 to double
  %14 = tail call double @llvm.fmuladd.f64(double %13, double 5.000000e-01, double 5.000000e-01)
  %15 = fptrunc double %14 to float
  %16 = load float, ptr %8, align 8, !tbaa !9
  %17 = load float, ptr %9, align 8, !tbaa !31
  %18 = tail call float @powf(float noundef %17, float noundef %15) #5
  %19 = fmul float %16, %18
  %20 = getelementptr inbounds float, ptr %6, i64 %indvars.iv.unr
  store float %19, ptr %20, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %2
  ret i32 %1

21:                                               ; preds = %21, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %21 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %21 ]
  %22 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = fpext float %23 to double
  %25 = tail call double @llvm.fmuladd.f64(double %24, double 5.000000e-01, double 5.000000e-01)
  %26 = fptrunc double %25 to float
  %27 = load float, ptr %8, align 8, !tbaa !9
  %28 = load float, ptr %9, align 8, !tbaa !31
  %29 = tail call float @powf(float noundef %28, float noundef %26) #5
  %30 = fmul float %27, %29
  %31 = getelementptr inbounds float, ptr %6, i64 %indvars.iv
  store float %30, ptr %31, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %32 = getelementptr inbounds float, ptr %4, i64 %indvars.iv.next
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = fpext float %33 to double
  %35 = tail call double @llvm.fmuladd.f64(double %34, double 5.000000e-01, double 5.000000e-01)
  %36 = fptrunc double %35 to float
  %37 = load float, ptr %8, align 8, !tbaa !9
  %38 = load float, ptr %9, align 8, !tbaa !31
  %39 = tail call float @powf(float noundef %38, float noundef %36) #5
  %40 = fmul float %37, %39
  %41 = getelementptr inbounds float, ptr %6, i64 %indvars.iv.next
  store float %40, ptr %41, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %21, !llvm.loop !32
}

declare noundef ptr @_ZN4oboe9flowgraph23FlowGraphPortFloatInput9getBufferEv(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @powf(float noundef, float noundef) local_unnamed_addr #4

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 = { "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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 120}
!10 = !{!"_ZTS16ExponentialShape", !11, i64 0, !6, i64 120, !6, i64 124, !6, i64 128}
!11 = !{!"_ZTSN4oboe9flowgraph15FlowGraphFilterE", !12, i64 0, !21, i64 48, !30, i64 88}
!12 = !{!"_ZTSN4oboe9flowgraph13FlowGraphNodeE", !13, i64 8, !14, i64 16, !19, i64 40, !19, i64 41, !20, i64 44}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSSt6vectorISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt17reference_wrapperIN4oboe9flowgraph13FlowGraphPortEESaIS4_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!18 = !{!"any pointer", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTSN4oboe9flowgraph23FlowGraphPortFloatInputE", !22, i64 0, !18, i64 32}
!22 = !{!"_ZTSN4oboe9flowgraph18FlowGraphPortFloatE", !23, i64 0, !20, i64 20, !24, i64 24}
!23 = !{!"_ZTSN4oboe9flowgraph13FlowGraphPortE", !18, i64 8, !20, i64 16}
!24 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !25, i64 0}
!25 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !26, i64 0}
!26 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !27, i64 0}
!27 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !28, i64 0}
!28 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !29, i64 0}
!29 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !18, i64 0}
!30 = !{!"_ZTSN4oboe9flowgraph24FlowGraphPortFloatOutputE", !22, i64 0}
!31 = !{!10, !6, i64 128}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


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