; LLVM IR from hasseily/SuperDuperDisplay :: Ayumi.ll (ZN5Ayumi6SetPanEidb)

; 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.Ayumi = type <{ i8, [7 x i8], [3 x %"struct.Ayumi::tone_channel"], i32, i32, i32, i32, i32, i32, i32, i32, ptr, double, double, %"struct.Ayumi::interpolator", %"struct.Ayumi::interpolator", [384 x double], [384 x double], i32, [4 x i8], %"struct.Ayumi::dc_filter", %"struct.Ayumi::dc_filter", i32, [4 x i8], double, double, i8, [7 x i8] }>
%"struct.Ayumi::tone_channel" = type { i32, i32, i32, i8, i8, i8, i32, double, double }
%"struct.Ayumi::interpolator" = type { [4 x double], [4 x double] }
%"struct.Ayumi::dc_filter" = type { double, [1024 x double] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5Ayumi6SetPanEidb(ptr noundef nonnull align 8 dereferenceable(22889) %0, i32 noundef %1, double noundef %2, i1 noundef zeroext %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  %9 = zext i1 %3 to i8
  store i8 %9, ptr %8, align 1, !tbaa !13
  %10 = load ptr, ptr %5, align 8
  %11 = load i8, ptr %8, align 1, !tbaa !13, !range !15, !noundef !16
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %29

13:                                               ; preds = %4
  %14 = load double, ptr %7, align 8, !tbaa !11
  %15 = fsub double 1.000000e+00, %14
  %16 = call double @sqrt(double noundef %15) #2
  %17 = getelementptr inbounds %class.Ayumi, ptr %10, i32 0, i32 2
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [3 x %"struct.Ayumi::tone_channel"], ptr %17, i64 0, i64 %19
  %21 = getelementptr inbounds %"struct.Ayumi::tone_channel", ptr %20, i32 0, i32 7
  store double %16, ptr %21, align 8, !tbaa !17
  %22 = load double, ptr %7, align 8, !tbaa !11
  %23 = call double @sqrt(double noundef %22) #2
  %24 = getelementptr inbounds %class.Ayumi, ptr %10, i32 0, i32 2
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3 x %"struct.Ayumi::tone_channel"], ptr %24, i64 0, i64 %26
  %28 = getelementptr inbounds %"struct.Ayumi::tone_channel", ptr %27, i32 0, i32 8
  store double %23, ptr %28, align 8, !tbaa !19
  br label %43

29:                                               ; preds = %4
  %30 = load double, ptr %7, align 8, !tbaa !11
  %31 = fsub double 1.000000e+00, %30
  %32 = getelementptr inbounds %class.Ayumi, ptr %10, i32 0, i32 2
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [3 x %"struct.Ayumi::tone_channel"], ptr %32, i64 0, i64 %34
  %36 = getelementptr inbounds %"struct.Ayumi::tone_channel", ptr %35, i32 0, i32 7
  store double %31, ptr %36, align 8, !tbaa !17
  %37 = load double, ptr %7, align 8, !tbaa !11
  %38 = getelementptr inbounds %class.Ayumi, ptr %10, i32 0, i32 2
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [3 x %"struct.Ayumi::tone_channel"], ptr %38, i64 0, i64 %40
  %42 = getelementptr inbounds %"struct.Ayumi::tone_channel", ptr %41, i32 0, i32 8
  store double %37, ptr %42, align 8, !tbaa !19
  br label %43

43:                                               ; preds = %29, %13
  ret void
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !12, i64 24}
!18 = !{!"_ZTSN5Ayumi12tone_channelE", !10, i64 0, !10, i64 4, !10, i64 8, !14, i64 12, !14, i64 13, !14, i64 14, !10, i64 16, !12, i64 24, !12, i64 32}
!19 = !{!18, !12, 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"

%"struct.Ayumi::tone_channel" = type { i32, i32, i32, i8, i8, i8, i32, double, double }

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local void @_ZN5Ayumi6SetPanEidb(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(22889) %0, i32 noundef %1, double noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 align 2 {
  %5 = fsub double 1.000000e+00, %2
  br i1 %3, label %6, label %13

6:                                                ; preds = %4
  %7 = tail call double @sqrt(double noundef %5) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = sext i32 %1 to i64
  %10 = getelementptr inbounds [3 x %"struct.Ayumi::tone_channel"], ptr %8, i64 0, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 24
  store double %7, ptr %11, align 8, !tbaa !5
  %12 = tail call double @sqrt(double noundef %2) #2
  br label %18

13:                                               ; preds = %4
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = sext i32 %1 to i64
  %16 = getelementptr inbounds [3 x %"struct.Ayumi::tone_channel"], ptr %14, i64 0, i64 %15
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  store double %5, ptr %17, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %13, %6
  %.sink10 = phi ptr [ %16, %13 ], [ %10, %6 ]
  %.sink = phi double [ %2, %13 ], [ %12, %6 ]
  %19 = getelementptr inbounds i8, ptr %.sink10, i64 32
  store double %.sink, ptr %19, align 8, !tbaa !12
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) 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 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 #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, !11, i64 24}
!6 = !{!"_ZTSN5Ayumi12tone_channelE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 13, !10, i64 14, !7, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !11, i64 32}


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