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

; 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.maxiOsc = type { double, double, double, double, double, double }

@_ZN12maxiSettings10sampleRateE = external dso_local global i64, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN7maxiOsc5pulseEdd(ptr noundef nonnull align 8 dereferenceable(48) %0, double noundef %1, double noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = load double, ptr %6, align 8, !tbaa !9
  %9 = fcmp olt double %8, 0.000000e+00
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %10, %3
  %12 = load double, ptr %6, align 8, !tbaa !9
  %13 = fcmp ogt double %12, 1.000000e+00
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  store double 1.000000e+00, ptr %6, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %14, %11
  %16 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 1
  %17 = load double, ptr %16, align 8, !tbaa !11
  %18 = fcmp oge double %17, 1.000000e+00
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  %20 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !11
  %22 = fsub double %21, 1.000000e+00
  store double %22, ptr %20, align 8, !tbaa !11
  br label %23

23:                                               ; preds = %19, %15
  %24 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !13
  %25 = uitofp i64 %24 to double
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = fdiv double %25, %26
  %28 = fdiv double 1.000000e+00, %27
  %29 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 1
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fadd double %30, %28
  store double %31, ptr %29, align 8, !tbaa !11
  %32 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 1
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = fcmp olt double %33, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %23
  %37 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 4
  store double -1.000000e+00, ptr %37, align 8, !tbaa !15
  br label %38

38:                                               ; preds = %36, %23
  %39 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 1
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load double, ptr %6, align 8, !tbaa !9
  %42 = fcmp ogt double %40, %41
  br i1 %42, label %43, label %45

43:                                               ; preds = %38
  %44 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 4
  store double 1.000000e+00, ptr %44, align 8, !tbaa !15
  br label %45

45:                                               ; preds = %43, %38
  %46 = getelementptr inbounds %class.maxiOsc, ptr %7, i32 0, i32 4
  %47 = load double, ptr %46, align 8, !tbaa !15
  ret double %47
}

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

!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, !10, i64 8}
!12 = !{!"_ZTS7maxiOsc", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !10, i64 32}


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

@_ZN12maxiSettings10sampleRateE = external dso_local local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZN7maxiOsc5pulseEdd(ptr nocapture noundef nonnull align 8 dereferenceable(48) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = fcmp olt double %2, 0.000000e+00
  %.0 = select i1 %4, double 0.000000e+00, double %2
  %5 = fcmp ogt double %.0, 1.000000e+00
  %.1 = select i1 %5, double 1.000000e+00, double %.0
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = fcmp ult double %7, 1.000000e+00
  %9 = fadd double %7, -1.000000e+00
  %10 = select i1 %8, double %7, double %9
  %11 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !10
  %12 = uitofp i64 %11 to double
  %13 = fdiv double %12, %1
  %14 = fdiv double 1.000000e+00, %13
  %15 = fadd double %10, %14
  store double %15, ptr %6, align 8, !tbaa !5
  %16 = fcmp olt double %15, %.1
  br i1 %16, label %17, label %19

17:                                               ; preds = %3
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  store double -1.000000e+00, ptr %18, align 8, !tbaa !12
  br label %19

19:                                               ; preds = %17, %3
  %20 = fcmp ogt double %15, %.1
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %20, label %22, label %._crit_edge

._crit_edge:                                      ; preds = %19
  %.pre = load double, ptr %21, align 8, !tbaa !12
  br label %23

22:                                               ; preds = %19
  store double 1.000000e+00, ptr %21, align 8, !tbaa !12
  br label %23

23:                                               ; preds = %._crit_edge, %22
  %24 = phi double [ %.pre, %._crit_edge ], [ 1.000000e+00, %22 ]
  ret double %24
}

attributes #0 = { 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, !7, i64 8}
!6 = !{!"_ZTS7maxiOsc", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !7, i64 32}


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