; LLVM IR from acids-ircam/ddsp_pytorch :: realtime/ddsp_tilde (signal_in_out_base)

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

%struct._pan_tilde = type { %struct._text, float, float, ptr, ptr, ptr }
%struct._text = type { %struct._gobj, ptr, ptr, ptr, i16, i16, i16, i8 }
%struct._gobj = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @pan_tilde_perform(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i64, ptr %9, i64 1
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = inttoptr i64 %11 to ptr
  store ptr %12, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds i64, ptr %13, i64 2
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = inttoptr i64 %15 to ptr
  store ptr %16, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i64, ptr %17, i64 3
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = inttoptr i64 %19 to ptr
  store ptr %20, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %21, i64 4
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = inttoptr i64 %23 to ptr
  store ptr %24, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds i64, ptr %25, i64 5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._pan_tilde, ptr %29, i32 0, i32 1
  %31 = load float, ptr %30, align 8, !tbaa !13
  %32 = fcmp olt float %31, 0.000000e+00
  br i1 %32, label %33, label %34

33:                                               ; preds = %1
  br label %47

34:                                               ; preds = %1
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._pan_tilde, ptr %35, i32 0, i32 1
  %37 = load float, ptr %36, align 8, !tbaa !13
  %38 = fcmp ogt float %37, 1.000000e+00
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  br label %45

40:                                               ; preds = %34
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._pan_tilde, ptr %41, i32 0, i32 1
  %43 = load float, ptr %42, align 8, !tbaa !13
  %44 = fpext float %43 to double
  br label %45

45:                                               ; preds = %40, %39
  %46 = phi double [ 1.000000e+00, %39 ], [ %44, %40 ]
  br label %47

47:                                               ; preds = %45, %33
  %48 = phi double [ 0.000000e+00, %33 ], [ %46, %45 ]
  %49 = fptrunc double %48 to float
  store float %49, ptr %8, align 4, !tbaa !19
  br label %50

50:                                               ; preds = %54, %47
  %51 = load i32, ptr %7, align 4, !tbaa !11
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %7, align 4, !tbaa !11
  %53 = icmp ne i32 %51, 0
  br i1 %53, label %54, label %68

54:                                               ; preds = %50
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds float, ptr %55, i32 1
  store ptr %56, ptr %4, align 8, !tbaa !5
  %57 = load float, ptr %55, align 4, !tbaa !19
  %58 = load float, ptr %8, align 4, !tbaa !19
  %59 = fsub float 1.000000e+00, %58
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds float, ptr %60, i32 1
  store ptr %61, ptr %5, align 8, !tbaa !5
  %62 = load float, ptr %60, align 4, !tbaa !19
  %63 = load float, ptr %8, align 4, !tbaa !19
  %64 = fmul float %62, %63
  %65 = call float @llvm.fmuladd.f32(float %57, float %59, float %64)
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds float, ptr %66, i32 1
  store ptr %67, ptr %6, align 8, !tbaa !5
  store float %65, ptr %66, align 4, !tbaa !19
  br label %50, !llvm.loop !20

68:                                               ; preds = %50
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds i64, ptr %69, i64 6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %70
}

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !18, i64 48}
!14 = !{!"_pan_tilde", !15, i64 0, !18, i64 48, !18, i64 52, !6, i64 56, !6, i64 64, !6, i64 72}
!15 = !{!"_text", !16, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !17, i64 40, !17, i64 42, !17, i64 44, !12, i64 46}
!16 = !{!"_gobj", !6, i64 0, !6, i64 8}
!17 = !{!"short", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local nonnull ptr @pan_tilde_perform(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = inttoptr i64 %3 to ptr
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = inttoptr i64 %6 to ptr
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = inttoptr i64 %9 to ptr
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = inttoptr i64 %12 to ptr
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = trunc i64 %15 to i32
  %17 = getelementptr inbounds i8, ptr %4, i64 48
  %18 = load float, ptr %17, align 8, !tbaa !9
  %19 = fcmp olt float %18, 0.000000e+00
  br i1 %19, label %23, label %20

20:                                               ; preds = %1
  %21 = fcmp ogt float %18, 1.000000e+00
  br i1 %21, label %23, label %22

22:                                               ; preds = %20
  br label %23

23:                                               ; preds = %22, %20, %1
  %24 = phi float [ 0.000000e+00, %1 ], [ %18, %22 ], [ 1.000000e+00, %20 ]
  %.not18 = icmp eq i32 %16, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %23
  %25 = fsub float 1.000000e+00, %24
  %26 = and i64 %15, 4294967295
  %min.iters.check = icmp ult i64 %26, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %27 = sub i64 %12, %6
  %diff.check = icmp ult i64 %27, 32
  %28 = sub i64 %12, %9
  %diff.check23 = icmp ult i64 %28, 32
  %conflict.rdx = or i1 %diff.check, %diff.check23
  br i1 %conflict.rdx, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.mod.vf = and i64 %15, 7
  %n.vec = sub nsw i64 %26, %n.mod.vf
  %29 = shl nsw i64 %n.vec, 2
  %ind.end = getelementptr i8, ptr %7, i64 %29
  %.cast = trunc i64 %n.vec to i32
  %ind.end24 = sub i32 %16, %.cast
  %30 = shl nsw i64 %n.vec, 2
  %ind.end26 = getelementptr i8, ptr %13, i64 %30
  %31 = shl nsw i64 %n.vec, 2
  %ind.end28 = getelementptr i8, ptr %10, i64 %31
  %broadcast.splatinsert = insertelement <4 x float> poison, float %24, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert40 = insertelement <4 x float> poison, float %25, i64 0
  %broadcast.splat41 = shufflevector <4 x float> %broadcast.splatinsert40, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 2
  %next.gep = getelementptr i8, ptr %7, i64 %offset.idx
  %offset.idx31 = shl i64 %index, 2
  %next.gep32 = getelementptr i8, ptr %13, i64 %offset.idx31
  %offset.idx34 = shl i64 %index, 2
  %next.gep35 = getelementptr i8, ptr %10, i64 %offset.idx34
  %32 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <4 x float>, ptr %next.gep, align 4, !tbaa !17
  %wide.load37 = load <4 x float>, ptr %32, align 4, !tbaa !17
  %33 = getelementptr i8, ptr %next.gep35, i64 16
  %wide.load38 = load <4 x float>, ptr %next.gep35, align 4, !tbaa !17
  %wide.load39 = load <4 x float>, ptr %33, align 4, !tbaa !17
  %34 = fmul <4 x float> %broadcast.splat, %wide.load38
  %35 = fmul <4 x float> %broadcast.splat, %wide.load39
  %36 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %broadcast.splat41, <4 x float> %34)
  %37 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load37, <4 x float> %broadcast.splat41, <4 x float> %35)
  %38 = getelementptr i8, ptr %next.gep32, i64 16
  store <4 x float> %36, ptr %next.gep32, align 4, !tbaa !17
  store <4 x float> %37, ptr %38, align 4, !tbaa !17
  %index.next = add nuw i64 %index, 8
  %39 = icmp eq i64 %index.next, %n.vec
  br i1 %39, label %middle.block, label %vector.body, !llvm.loop !18

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.mod.vf, 0
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.022.ph = phi ptr [ %7, %vector.memcheck ], [ %7, %.lr.ph ], [ %ind.end, %middle.block ]
  %.01421.ph = phi i32 [ %16, %vector.memcheck ], [ %16, %.lr.ph ], [ %ind.end24, %middle.block ]
  %.01520.ph = phi ptr [ %13, %vector.memcheck ], [ %13, %.lr.ph ], [ %ind.end26, %middle.block ]
  %.01619.ph = phi ptr [ %10, %vector.memcheck ], [ %10, %.lr.ph ], [ %ind.end28, %middle.block ]
  %xtraiter = and i32 %.01421.ph, 1
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %40 = add nsw i32 %.01421.ph, -1
  %41 = getelementptr inbounds i8, ptr %.022.ph, i64 4
  %42 = load float, ptr %.022.ph, align 4, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %.01619.ph, i64 4
  %44 = load float, ptr %.01619.ph, align 4, !tbaa !17
  %45 = fmul float %24, %44
  %46 = tail call float @llvm.fmuladd.f32(float %42, float %25, float %45)
  %47 = getelementptr inbounds i8, ptr %.01520.ph, i64 4
  store float %46, ptr %.01520.ph, align 4, !tbaa !17
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.022.unr = phi ptr [ %.022.ph, %scalar.ph.preheader ], [ %41, %scalar.ph.prol ]
  %.01421.unr = phi i32 [ %.01421.ph, %scalar.ph.preheader ], [ %40, %scalar.ph.prol ]
  %.01520.unr = phi ptr [ %.01520.ph, %scalar.ph.preheader ], [ %47, %scalar.ph.prol ]
  %.01619.unr = phi ptr [ %.01619.ph, %scalar.ph.preheader ], [ %43, %scalar.ph.prol ]
  %48 = icmp eq i32 %.01421.ph, 1
  br i1 %48, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.022 = phi ptr [ %57, %scalar.ph ], [ %.022.unr, %scalar.ph.prol.loopexit ]
  %.01421 = phi i32 [ %56, %scalar.ph ], [ %.01421.unr, %scalar.ph.prol.loopexit ]
  %.01520 = phi ptr [ %63, %scalar.ph ], [ %.01520.unr, %scalar.ph.prol.loopexit ]
  %.01619 = phi ptr [ %59, %scalar.ph ], [ %.01619.unr, %scalar.ph.prol.loopexit ]
  %49 = getelementptr inbounds i8, ptr %.022, i64 4
  %50 = load float, ptr %.022, align 4, !tbaa !17
  %51 = getelementptr inbounds i8, ptr %.01619, i64 4
  %52 = load float, ptr %.01619, align 4, !tbaa !17
  %53 = fmul float %24, %52
  %54 = tail call float @llvm.fmuladd.f32(float %50, float %25, float %53)
  %55 = getelementptr inbounds i8, ptr %.01520, i64 4
  store float %54, ptr %.01520, align 4, !tbaa !17
  %56 = add nsw i32 %.01421, -2
  %57 = getelementptr inbounds i8, ptr %.022, i64 8
  %58 = load float, ptr %49, align 4, !tbaa !17
  %59 = getelementptr inbounds i8, ptr %.01619, i64 8
  %60 = load float, ptr %51, align 4, !tbaa !17
  %61 = fmul float %24, %60
  %62 = tail call float @llvm.fmuladd.f32(float %58, float %25, float %61)
  %63 = getelementptr inbounds i8, ptr %.01520, i64 8
  store float %62, ptr %55, align 4, !tbaa !17
  %.not.1 = icmp eq i32 %56, 0
  br i1 %.not.1, label %._crit_edge, label %scalar.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %23
  %64 = getelementptr inbounds i8, ptr %0, i64 48
  ret ptr %64
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #2

attributes #0 = { nofree norecurse nosync nounwind memory(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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !16, i64 48}
!10 = !{!"_pan_tilde", !11, i64 0, !16, i64 48, !16, i64 52, !13, i64 56, !13, i64 64, !13, i64 72}
!11 = !{!"_text", !12, i64 0, !13, i64 16, !13, i64 24, !13, i64 32, !14, i64 40, !14, i64 42, !14, i64 44, !15, i64 46}
!12 = !{!"_gobj", !13, i64 0, !13, i64 8}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = distinct !{!18, !19, !20, !21}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.isvectorized", i32 1}
!21 = !{!"llvm.loop.unroll.runtime.disable"}
!22 = distinct !{!22, !19, !20}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass