; LLVM IR from googlecreativelab/open-nsynth-super :: app/open-nsynth/third_party/ADSR.ll (ZN4ADSR12get_envelopeEffPb)

; 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.ADSR = type { %"struct.ADSR::adr", %"struct.ADSR::adr", float }
%"struct.ADSR::adr" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN4ADSR12get_envelopeEffPb(ptr noundef nonnull align 4 dereferenceable(28) %0, float noundef %1, float noundef %2, ptr noundef %3) #2 align 2 {
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 0, ptr %21, align 1, !tbaa !11
  %22 = load float, ptr %8, align 4, !tbaa !9
  %23 = fcmp ogt float %22, 0.000000e+00
  br i1 %23, label %24, label %45

24:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %25 = load float, ptr %8, align 4, !tbaa !9
  %26 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %27 = getelementptr inbounds %"struct.ADSR::adr", ptr %26, i32 0, i32 2
  %28 = load float, ptr %27, align 4, !tbaa !13
  %29 = fadd float %25, %28
  store float %29, ptr %10, align 4, !tbaa !9
  %30 = load float, ptr %10, align 4, !tbaa !9
  %31 = fcmp ogt float %30, 1.000000e+00
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  store float 1.000000e+00, ptr %10, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %32, %24
  %34 = load float, ptr %7, align 4, !tbaa !9
  %35 = load float, ptr %10, align 4, !tbaa !9
  %36 = fcmp oge float %34, %35
  br i1 %36, label %37, label %39

37:                                               ; preds = %33
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 1, ptr %38, align 1, !tbaa !11
  store float 0.000000e+00, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %44

39:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %40 = load float, ptr %8, align 4, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = call noundef float @_ZN4ADSR12get_envelopeEffPb(ptr noundef nonnull align 4 dereferenceable(28) %20, float noundef %40, float noundef 0.000000e+00, ptr noundef %41)
  store float %42, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store float 0.000000e+00, ptr %13, align 4, !tbaa !9
  %43 = call noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  store float %43, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %44

44:                                               ; preds = %39, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %99

45:                                               ; preds = %4
  %46 = load float, ptr %7, align 4, !tbaa !9
  %47 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %48 = getelementptr inbounds %"struct.ADSR::adr", ptr %47, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !16
  %50 = fcmp ole float %46, %49
  br i1 %50, label %51, label %57

51:                                               ; preds = %45
  %52 = load float, ptr %7, align 4, !tbaa !9
  %53 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %54 = getelementptr inbounds %"struct.ADSR::adr", ptr %53, i32 0, i32 0
  %55 = load float, ptr %54, align 4, !tbaa !16
  %56 = fdiv float %52, %55
  store float %56, ptr %5, align 4
  br label %99

57:                                               ; preds = %45
  %58 = load float, ptr %7, align 4, !tbaa !9
  %59 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %60 = getelementptr inbounds %"struct.ADSR::adr", ptr %59, i32 0, i32 0
  %61 = load float, ptr %60, align 4, !tbaa !16
  %62 = fsub float %58, %61
  %63 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %64 = getelementptr inbounds %"struct.ADSR::adr", ptr %63, i32 0, i32 1
  %65 = load float, ptr %64, align 4, !tbaa !17
  %66 = fcmp ole float %62, %65
  br i1 %66, label %67, label %77

67:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %68 = load float, ptr %7, align 4, !tbaa !9
  %69 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %70 = getelementptr inbounds %"struct.ADSR::adr", ptr %69, i32 0, i32 0
  %71 = load float, ptr %70, align 4, !tbaa !16
  %72 = fsub float %68, %71
  store float %72, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store float 0.000000e+00, ptr %15, align 4, !tbaa !9
  %73 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %74 = getelementptr inbounds %"struct.ADSR::adr", ptr %73, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store float 1.000000e+00, ptr %16, align 4, !tbaa !9
  %75 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 2
  %76 = call noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %74, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %75)
  store float %76, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %99

77:                                               ; preds = %57
  %78 = load float, ptr %7, align 4, !tbaa !9
  %79 = fsub float 1.000000e+00, %78
  %80 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %81 = getelementptr inbounds %"struct.ADSR::adr", ptr %80, i32 0, i32 2
  %82 = load float, ptr %81, align 4, !tbaa !13
  %83 = fcmp ole float %79, %82
  br i1 %83, label %84, label %96

84:                                               ; preds = %77
  %85 = load float, ptr %7, align 4, !tbaa !9
  %86 = fcmp oge float %85, 1.000000e+00
  br i1 %86, label %87, label %89

87:                                               ; preds = %84
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 1, ptr %88, align 1, !tbaa !11
  store float 0.000000e+00, ptr %5, align 4
  br label %99

89:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %90 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 1
  %91 = getelementptr inbounds %"struct.ADSR::adr", ptr %90, i32 0, i32 2
  %92 = load float, ptr %91, align 4, !tbaa !13
  %93 = fsub float 1.000000e+00, %92
  store float %93, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store float 1.000000e+00, ptr %18, align 4, !tbaa !9
  %94 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store float 0.000000e+00, ptr %19, align 4, !tbaa !9
  %95 = call noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %94, ptr noundef nonnull align 4 dereferenceable(4) %19)
  store float %95, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %99

96:                                               ; preds = %77
  %97 = getelementptr inbounds %class.ADSR, ptr %20, i32 0, i32 2
  %98 = load float, ptr %97, align 4, !tbaa !18
  store float %98, ptr %5, align 4
  br label %99

99:                                               ; preds = %96, %89, %87, %67, %51, %44
  %100 = load float, ptr %5, align 4
  ret float %100
}

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 = { 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 #3 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 20}
!14 = !{!"_ZTS4ADSR", !15, i64 0, !15, i64 12, !10, i64 24}
!15 = !{!"_ZTSN4ADSR3adrE", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!14, !10, i64 12}
!17 = !{!14, !10, i64 16}
!18 = !{!14, !10, i64 24}


; 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
declare dso_local noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN4ADSR12get_envelopeEffPb(ptr noundef nonnull align 4 dereferenceable(28) %0, float noundef %1, float noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 align 2 {
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  store float %1, ptr %5, align 4, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !9
  %16 = fcmp ogt float %2, 0.000000e+00
  br i1 %16, label %17, label %28

17:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #2
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  %19 = load float, ptr %18, align 4, !tbaa !11
  %20 = fadd float %19, %2
  %21 = fcmp ogt float %20, 1.000000e+00
  %storemerge = select i1 %21, float 1.000000e+00, float %20
  store float %storemerge, ptr %7, align 4, !tbaa !5
  %22 = fcmp ugt float %storemerge, %1
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %27

24:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #2
  %25 = tail call noundef float @_ZN4ADSR12get_envelopeEffPb(ptr noundef nonnull align 4 dereferenceable(28) %0, float noundef %2, float noundef 0.000000e+00, ptr noundef nonnull %3)
  store float %25, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #2
  store float 0.000000e+00, ptr %9, align 4, !tbaa !5
  %26 = call noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #2
  br label %27

27:                                               ; preds = %24, %23
  %.0 = phi float [ 0.000000e+00, %23 ], [ %26, %24 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #2
  br label %57

28:                                               ; preds = %4
  %29 = getelementptr inbounds i8, ptr %0, i64 12
  %30 = load float, ptr %29, align 4, !tbaa !14
  %31 = fcmp ult float %30, %1
  br i1 %31, label %34, label %32

32:                                               ; preds = %28
  %33 = fdiv float %1, %30
  br label %57

34:                                               ; preds = %28
  %35 = fsub float %1, %30
  %36 = getelementptr inbounds i8, ptr %0, i64 16
  %37 = load float, ptr %36, align 4, !tbaa !15
  %38 = fcmp ugt float %35, %37
  br i1 %38, label %42, label %39

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #2
  store float %35, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #2
  store float 0.000000e+00, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #2
  store float 1.000000e+00, ptr %12, align 4, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = call noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %36, ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %40)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #2
  br label %57

42:                                               ; preds = %34
  %43 = fsub float 1.000000e+00, %1
  %44 = getelementptr inbounds i8, ptr %0, i64 20
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = fcmp ugt float %43, %45
  br i1 %46, label %54, label %47

47:                                               ; preds = %42
  %48 = fcmp ult float %1, 1.000000e+00
  br i1 %48, label %50, label %49

49:                                               ; preds = %47
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %57

50:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #2
  %51 = fsub float 1.000000e+00, %45
  store float %51, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #2
  store float 1.000000e+00, ptr %14, align 4, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %0, i64 24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #2
  store float 0.000000e+00, ptr %15, align 4, !tbaa !5
  %53 = call noundef float @_Z5remapRKfS0_S0_S0_S0_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %52, ptr noundef nonnull align 4 dereferenceable(4) %15)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #2
  br label %57

54:                                               ; preds = %42
  %55 = getelementptr inbounds i8, ptr %0, i64 24
  %56 = load float, ptr %55, align 4, !tbaa !16
  br label %57

57:                                               ; preds = %54, %50, %49, %39, %32, %27
  %.1 = phi float [ %.0, %27 ], [ %33, %32 ], [ %41, %39 ], [ 0.000000e+00, %49 ], [ %53, %50 ], [ %56, %54 ]
  ret float %.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 = { mustprogress 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 20}
!12 = !{!"_ZTS4ADSR", !13, i64 0, !13, i64 12, !6, i64 24}
!13 = !{!"_ZTSN4ADSR3adrE", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!12, !6, i64 12}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}


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