; LLVM IR from chriskiefer/libcccrt :: benchmarks/maximilian.ll (ZN13maxiDelayline14dlFromPositionEdidi)

; 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.maxiDelayline = type { double, i32, double, double, double, [705600 x double] }

@chandiv = external dso_local global float, align 4

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN13maxiDelayline14dlFromPositionEdidi(ptr noundef nonnull align 8 dereferenceable(5644840) %0, double noundef %1, i32 noundef %2, double noundef %3, i32 noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store double %3, ptr %9, align 8, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  %11 = load ptr, ptr %6, align 8
  %12 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = load i32, ptr %8, align 4, !tbaa !11
  %15 = icmp sge i32 %13, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %5
  %17 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 1
  store i32 0, ptr %17, align 8, !tbaa !13
  br label %18

18:                                               ; preds = %16, %5
  %19 = load i32, ptr %10, align 4, !tbaa !11
  %20 = load i32, ptr %8, align 4, !tbaa !11
  %21 = icmp sge i32 %19, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %23

23:                                               ; preds = %22, %18
  %24 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 5
  %25 = load i32, ptr %10, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [705600 x double], ptr %24, i64 0, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 4
  store double %28, ptr %29, align 8, !tbaa !15
  %30 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 5
  %31 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [705600 x double], ptr %30, i64 0, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = load double, ptr %9, align 8, !tbaa !9
  %37 = load double, ptr %7, align 8, !tbaa !9
  %38 = load double, ptr %9, align 8, !tbaa !9
  %39 = fmul double %37, %38
  %40 = load float, ptr @chandiv, align 4, !tbaa !16
  %41 = fpext float %40 to double
  %42 = fmul double %39, %41
  %43 = call double @llvm.fmuladd.f64(double %35, double %36, double %42)
  %44 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 5
  %45 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [705600 x double], ptr %44, i64 0, i64 %47
  store double %43, ptr %48, align 8, !tbaa !9
  %49 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %49, align 8, !tbaa !13
  %52 = getelementptr inbounds %class.maxiDelayline, ptr %11, i32 0, i32 4
  %53 = load double, ptr %52, align 8, !tbaa !15
  ret double %53
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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, !12, i64 8}
!14 = !{!"_ZTS13maxiDelayline", !10, i64 0, !12, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40}
!15 = !{!14, !10, i64 32}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}


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

@chandiv = external dso_local local_unnamed_addr global float, align 4

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZN13maxiDelayline14dlFromPositionEdidi(ptr nocapture noundef nonnull align 8 dereferenceable(5644840) %0, double noundef %1, i32 noundef %2, double noundef %3, i32 noundef %4) local_unnamed_addr #1 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp slt i32 %7, %2
  %spec.select = select i1 %.not, i32 %7, i32 0
  %.not7 = icmp slt i32 %4, %2
  %spec.store.select = select i1 %.not7, i32 %4, i32 0
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = sext i32 %spec.store.select to i64
  %10 = getelementptr inbounds [705600 x double], ptr %8, i64 0, i64 %9
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store double %11, ptr %12, align 8, !tbaa !12
  %13 = sext i32 %spec.select to i64
  %14 = getelementptr inbounds [705600 x double], ptr %8, i64 0, i64 %13
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = fmul double %1, %3
  %17 = load float, ptr @chandiv, align 4, !tbaa !13
  %18 = fpext float %17 to double
  %19 = fmul double %16, %18
  %20 = tail call double @llvm.fmuladd.f64(double %15, double %3, double %19)
  store double %20, ptr %14, align 8, !tbaa !11
  %21 = add nsw i32 %spec.select, 1
  store i32 %21, ptr %6, align 8, !tbaa !5
  %22 = load double, ptr %12, align 8, !tbaa !12
  ret double %22
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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, !10, i64 8}
!6 = !{!"_ZTS13maxiDelayline", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !8, i64 40}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}


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