; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/src (libsignaletic)

; 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.sig_dsp_Branch = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Branch_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Branch_Inputs = type { ptr, ptr, ptr }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_AudioSettings = type { float, i64, i64 }

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

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

; Function Attrs: nounwind uwtable
define dso_local void @sig_dsp_Branch_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %55, %1
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.sig_dsp_Branch, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds %struct.sig_AudioSettings, ptr %14, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !16
  %17 = icmp ult i64 %10, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %58

19:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.sig_dsp_Branch, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.sig_dsp_Branch_Inputs, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !19
  %24 = load i64, ptr %4, align 8, !tbaa !9
  %25 = getelementptr inbounds float, ptr %23, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !20
  store float %26, ptr %5, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.sig_dsp_Branch, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.sig_dsp_Branch_Inputs, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = load i64, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds float, ptr %30, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !20
  store float %33, ptr %6, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.sig_dsp_Branch, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %struct.sig_dsp_Branch_Inputs, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !22
  %38 = load i64, ptr %4, align 8, !tbaa !9
  %39 = getelementptr inbounds float, ptr %37, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !20
  store float %40, ptr %7, align 4, !tbaa !20
  %41 = load float, ptr %5, align 4, !tbaa !20
  %42 = fcmp ogt float %41, 0.000000e+00
  br i1 %42, label %43, label %45

43:                                               ; preds = %19
  %44 = load float, ptr %7, align 4, !tbaa !20
  br label %47

45:                                               ; preds = %19
  %46 = load float, ptr %6, align 4, !tbaa !20
  br label %47

47:                                               ; preds = %45, %43
  %48 = phi float [ %44, %43 ], [ %46, %45 ]
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.sig_dsp_Branch, ptr %49, i32 0, i32 2
  %51 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !23
  %53 = load i64, ptr %4, align 8, !tbaa !9
  %54 = getelementptr inbounds float, ptr %52, i64 %53
  store float %48, ptr %54, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %55

55:                                               ; preds = %47
  %56 = load i64, ptr %4, align 8, !tbaa !9
  %57 = add i64 %56, 1
  store i64 %57, ptr %4, align 8, !tbaa !9
  br label %9, !llvm.loop !24

58:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"sig_dsp_Branch", !13, i64 0, !14, i64 16, !15, i64 40}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_Branch_Inputs", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!17, !10, i64 16}
!17 = !{!"sig_AudioSettings", !18, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"float", !7, i64 0}
!19 = !{!12, !6, i64 32}
!20 = !{!18, !18, i64 0}
!21 = !{!12, !6, i64 16}
!22 = !{!12, !6, i64 24}
!23 = !{!12, !6, i64 40}
!24 = distinct !{!24, !25}
!25 = !{!"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 void @sig_dsp_Branch_generate(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !13
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !17
  %8 = load ptr, ptr %5, align 8, !tbaa !18
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !20
  %min.iters.check = icmp ult i64 %4, 12
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.014.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %.neg = or disjoint i64 %.014.ph, 1
  %xtraiter = and i64 %4, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %13 = getelementptr inbounds float, ptr %7, i64 %.014.ph
  %14 = load float, ptr %13, align 4, !tbaa !21
  %15 = getelementptr inbounds float, ptr %8, i64 %.014.ph
  %16 = load float, ptr %15, align 4, !tbaa !21
  %17 = getelementptr inbounds float, ptr %10, i64 %.014.ph
  %18 = load float, ptr %17, align 4, !tbaa !21
  %19 = fcmp ogt float %14, 0.000000e+00
  %20 = select i1 %19, float %18, float %16
  %21 = getelementptr inbounds float, ptr %12, i64 %.014.ph
  store float %20, ptr %21, align 4, !tbaa !21
  %22 = or disjoint i64 %.014.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.014.unr = phi i64 [ %.014.ph, %scalar.ph.preheader ], [ %22, %scalar.ph.prol ]
  %23 = icmp eq i64 %4, %.neg
  br i1 %23, label %._crit_edge, label %scalar.ph

vector.memcheck:                                  ; preds = %.lr.ph
  %24 = ptrtoint ptr %12 to i64
  %25 = ptrtoint ptr %10 to i64
  %26 = ptrtoint ptr %8 to i64
  %27 = ptrtoint ptr %7 to i64
  %28 = sub i64 %24, %27
  %diff.check = icmp ult i64 %28, 32
  %29 = sub i64 %24, %26
  %diff.check15 = icmp ult i64 %29, 32
  %conflict.rdx = or i1 %diff.check, %diff.check15
  %30 = sub i64 %24, %25
  %diff.check16 = icmp ult i64 %30, 32
  %conflict.rdx17 = or i1 %conflict.rdx, %diff.check16
  br i1 %conflict.rdx17, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %4, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %31 = getelementptr inbounds float, ptr %7, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %wide.load = load <4 x float>, ptr %31, align 4, !tbaa !21
  %wide.load18 = load <4 x float>, ptr %32, align 4, !tbaa !21
  %33 = getelementptr inbounds float, ptr %8, i64 %index
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %wide.load19 = load <4 x float>, ptr %33, align 4, !tbaa !21
  %wide.load20 = load <4 x float>, ptr %34, align 4, !tbaa !21
  %35 = getelementptr inbounds float, ptr %10, i64 %index
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  %wide.load21 = load <4 x float>, ptr %35, align 4, !tbaa !21
  %wide.load22 = load <4 x float>, ptr %36, align 4, !tbaa !21
  %37 = fcmp ogt <4 x float> %wide.load, zeroinitializer
  %38 = fcmp ogt <4 x float> %wide.load18, zeroinitializer
  %39 = select <4 x i1> %37, <4 x float> %wide.load21, <4 x float> %wide.load19
  %40 = select <4 x i1> %38, <4 x float> %wide.load22, <4 x float> %wide.load20
  %41 = getelementptr inbounds float, ptr %12, i64 %index
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  store <4 x float> %39, ptr %41, align 4, !tbaa !21
  store <4 x float> %40, ptr %42, align 4, !tbaa !21
  %index.next = add nuw i64 %index, 8
  %43 = icmp eq i64 %index.next, %n.vec
  br i1 %43, label %middle.block, label %vector.body, !llvm.loop !22

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

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %1
  ret void

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.014 = phi i64 [ %63, %scalar.ph ], [ %.014.unr, %scalar.ph.prol.loopexit ]
  %44 = getelementptr inbounds float, ptr %7, i64 %.014
  %45 = load float, ptr %44, align 4, !tbaa !21
  %46 = getelementptr inbounds float, ptr %8, i64 %.014
  %47 = load float, ptr %46, align 4, !tbaa !21
  %48 = getelementptr inbounds float, ptr %10, i64 %.014
  %49 = load float, ptr %48, align 4, !tbaa !21
  %50 = fcmp ogt float %45, 0.000000e+00
  %51 = select i1 %50, float %49, float %47
  %52 = getelementptr inbounds float, ptr %12, i64 %.014
  store float %51, ptr %52, align 4, !tbaa !21
  %53 = add nuw i64 %.014, 1
  %54 = getelementptr inbounds float, ptr %7, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !21
  %56 = getelementptr inbounds float, ptr %8, i64 %53
  %57 = load float, ptr %56, align 4, !tbaa !21
  %58 = getelementptr inbounds float, ptr %10, i64 %53
  %59 = load float, ptr %58, align 4, !tbaa !21
  %60 = fcmp ogt float %55, 0.000000e+00
  %61 = select i1 %60, float %59, float %57
  %62 = getelementptr inbounds float, ptr %12, i64 %53
  store float %61, ptr %62, align 4, !tbaa !21
  %63 = add nuw i64 %.014, 2
  %exitcond.not.1 = icmp eq i64 %63, %4
  br i1 %exitcond.not.1, label %._crit_edge, label %scalar.ph, !llvm.loop !26
}

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

!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, !8, i64 0}
!6 = !{!"sig_dsp_Branch", !7, i64 0, !11, i64 16, !12, i64 40}
!7 = !{!"sig_dsp_Signal", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"sig_dsp_Branch_Inputs", !8, i64 0, !8, i64 8, !8, i64 16}
!12 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!13 = !{!14, !16, i64 16}
!14 = !{!"sig_AudioSettings", !15, i64 0, !16, i64 8, !16, i64 16}
!15 = !{!"float", !9, i64 0}
!16 = !{!"long", !9, i64 0}
!17 = !{!6, !8, i64 32}
!18 = !{!6, !8, i64 16}
!19 = !{!6, !8, i64 24}
!20 = !{!6, !8, i64 40}
!21 = !{!15, !15, i64 0}
!22 = distinct !{!22, !23, !24, !25}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !23, !24}


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