; 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_TimedTriggerCounter = type { %struct.sig_dsp_Signal, %struct.sig_dsp_TimedTriggerCounter_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput, i32, i64, i8, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_TimedTriggerCounter_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_TimedTriggerCounter_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 i64, align 8
  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 = %119, %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_TimedTriggerCounter, 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 !19
  %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 %122

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_TimedTriggerCounter, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter_Inputs, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  %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 !22
  store float %26, ptr %5, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store float 0.000000e+00, ptr %6, align 4, !tbaa !22
  %27 = load float, ptr %5, align 4, !tbaa !22
  %28 = fcmp ogt float %27, 0.000000e+00
  br i1 %28, label %29, label %43

29:                                               ; preds = %19
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %30, i32 0, i32 6
  %32 = load float, ptr %31, align 4, !tbaa !23
  %33 = fcmp oeq float %32, 0.000000e+00
  br i1 %33, label %34, label %43

34:                                               ; preds = %29
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %35, i32 0, i32 5
  %37 = load i8, ptr %36, align 8, !tbaa !24, !range !25, !noundef !26
  %38 = trunc i8 %37 to i1
  br i1 %38, label %42, label %39

39:                                               ; preds = %34
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %40, i32 0, i32 5
  store i8 1, ptr %41, align 8, !tbaa !24
  br label %42

42:                                               ; preds = %39, %34
  br label %43

43:                                               ; preds = %42, %29, %19
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %44, i32 0, i32 5
  %46 = load i8, ptr %45, align 8, !tbaa !24, !range !25, !noundef !26
  %47 = trunc i8 %46 to i1
  br i1 %47, label %48, label %108

48:                                               ; preds = %43
  %49 = load float, ptr %5, align 4, !tbaa !22
  %50 = fcmp ole float %49, 0.000000e+00
  br i1 %50, label %51, label %61

51:                                               ; preds = %48
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %52, i32 0, i32 6
  %54 = load float, ptr %53, align 4, !tbaa !23
  %55 = fcmp ogt float %54, 0.000000e+00
  br i1 %55, label %56, label %61

56:                                               ; preds = %51
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 8, !tbaa !27
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %58, align 8, !tbaa !27
  br label %61

61:                                               ; preds = %56, %51, %48
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %62, i32 0, i32 4
  %64 = load i64, ptr %63, align 8, !tbaa !28
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %63, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter_Inputs, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !29
  %70 = load i64, ptr %4, align 8, !tbaa !9
  %71 = getelementptr inbounds float, ptr %69, i64 %70
  %72 = load float, ptr %71, align 4, !tbaa !22
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !11
  %77 = getelementptr inbounds %struct.sig_AudioSettings, ptr %76, i32 0, i32 0
  %78 = load float, ptr %77, align 8, !tbaa !30
  %79 = fmul float %72, %78
  %80 = fptosi float %79 to i64
  store i64 %80, ptr %7, align 8, !tbaa !9
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %81, i32 0, i32 4
  %83 = load i64, ptr %82, align 8, !tbaa !28
  %84 = load i64, ptr %7, align 8, !tbaa !9
  %85 = icmp sge i64 %83, %84
  br i1 %85, label %86, label %107

86:                                               ; preds = %61
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %87, i32 0, i32 3
  %89 = load i32, ptr %88, align 8, !tbaa !27
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %90, i32 0, i32 1
  %92 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter_Inputs, ptr %91, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !31
  %94 = load i64, ptr %4, align 8, !tbaa !9
  %95 = getelementptr inbounds float, ptr %93, i64 %94
  %96 = load float, ptr %95, align 4, !tbaa !22
  %97 = fptosi float %96 to i32
  %98 = icmp eq i32 %89, %97
  br i1 %98, label %99, label %100

99:                                               ; preds = %86
  store float 1.000000e+00, ptr %6, align 4, !tbaa !22
  br label %100

100:                                              ; preds = %99, %86
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %101, i32 0, i32 5
  store i8 0, ptr %102, align 8, !tbaa !24
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %103, i32 0, i32 3
  store i32 0, ptr %104, align 8, !tbaa !27
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %105, i32 0, i32 4
  store i64 0, ptr %106, align 8, !tbaa !28
  br label %107

107:                                              ; preds = %100, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %108

108:                                              ; preds = %107, %43
  %109 = load float, ptr %5, align 4, !tbaa !22
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %110, i32 0, i32 6
  store float %109, ptr %111, align 4, !tbaa !23
  %112 = load float, ptr %6, align 4, !tbaa !22
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.sig_dsp_TimedTriggerCounter, ptr %113, i32 0, i32 2
  %115 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %114, i32 0, i32 0
  %116 = load ptr, ptr %115, align 8, !tbaa !32
  %117 = load i64, ptr %4, align 8, !tbaa !9
  %118 = getelementptr inbounds float, ptr %116, i64 %117
  store float %112, ptr %118, align 4, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %119

119:                                              ; preds = %108
  %120 = load i64, ptr %4, align 8, !tbaa !9
  %121 = add i64 %120, 1
  store i64 %121, ptr %4, align 8, !tbaa !9
  br label %9, !llvm.loop !33

122:                                              ; 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_TimedTriggerCounter", !13, i64 0, !14, i64 16, !15, i64 40, !16, i64 48, !10, i64 56, !17, i64 64, !18, i64 68}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_TimedTriggerCounter_Inputs", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!20, !10, i64 16}
!20 = !{!"sig_AudioSettings", !18, i64 0, !10, i64 8, !10, i64 16}
!21 = !{!12, !6, i64 16}
!22 = !{!18, !18, i64 0}
!23 = !{!12, !18, i64 68}
!24 = !{!12, !17, i64 64}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!12, !16, i64 48}
!28 = !{!12, !10, i64 56}
!29 = !{!12, !6, i64 24}
!30 = !{!20, !18, i64 0}
!31 = !{!12, !6, i64 32}
!32 = !{!12, !6, i64 40}
!33 = distinct !{!33, !34}
!34 = !{!"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_TimedTriggerCounter_generate(ptr nocapture noundef %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 !17
  %.not32 = icmp eq i64 %4, 0
  br i1 %.not32, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !19
  %7 = getelementptr inbounds i8, ptr %0, i64 68
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = load ptr, ptr %13, align 8, !tbaa !20
  %.promoted = load i8, ptr %8, align 8, !tbaa !21
  br label %15

._crit_edge:                                      ; preds = %52, %1
  ret void

15:                                               ; preds = %.lr.ph, %52
  %16 = phi i8 [ %.promoted, %.lr.ph ], [ %53, %52 ]
  %.031 = phi i64 [ 0, %.lr.ph ], [ %55, %52 ]
  %17 = getelementptr inbounds float, ptr %6, i64 %.031
  %18 = load float, ptr %17, align 4, !tbaa !22
  %19 = fcmp ogt float %18, 0.000000e+00
  br i1 %19, label %20, label %25

20:                                               ; preds = %15
  %21 = load float, ptr %7, align 4, !tbaa !23
  %22 = fcmp oeq float %21, 0.000000e+00
  br i1 %22, label %23, label %25

23:                                               ; preds = %20
  %24 = trunc nuw i8 %16 to i1
  br i1 %24, label %25, label %.thread

.thread:                                          ; preds = %23
  store i8 1, ptr %8, align 8, !tbaa !21
  br label %27

25:                                               ; preds = %23, %20, %15
  %26 = trunc nuw i8 %16 to i1
  br i1 %26, label %27, label %52

27:                                               ; preds = %.thread, %25
  %28 = phi i8 [ 1, %.thread ], [ %16, %25 ]
  %29 = fcmp ugt float %18, 0.000000e+00
  br i1 %29, label %36, label %30

30:                                               ; preds = %27
  %31 = load float, ptr %7, align 4, !tbaa !23
  %32 = fcmp ogt float %31, 0.000000e+00
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load i32, ptr %9, align 8, !tbaa !24
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %9, align 8, !tbaa !24
  br label %36

36:                                               ; preds = %33, %30, %27
  %37 = load i64, ptr %10, align 8, !tbaa !25
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %10, align 8, !tbaa !25
  %39 = load ptr, ptr %11, align 8, !tbaa !26
  %40 = getelementptr inbounds float, ptr %39, i64 %.031
  %41 = load float, ptr %40, align 4, !tbaa !22
  %42 = load float, ptr %2, align 8, !tbaa !27
  %43 = fmul float %41, %42
  %44 = fptosi float %43 to i64
  %.not = icmp slt i64 %38, %44
  br i1 %.not, label %52, label %45

45:                                               ; preds = %36
  %46 = load i32, ptr %9, align 8, !tbaa !24
  %47 = load ptr, ptr %12, align 8, !tbaa !28
  %48 = getelementptr inbounds float, ptr %47, i64 %.031
  %49 = load float, ptr %48, align 4, !tbaa !22
  %50 = fptosi float %49 to i32
  %51 = icmp eq i32 %46, %50
  %.030 = select i1 %51, float 1.000000e+00, float 0.000000e+00
  store i8 0, ptr %8, align 8, !tbaa !21
  store i32 0, ptr %9, align 8, !tbaa !24
  store i64 0, ptr %10, align 8, !tbaa !25
  br label %52

52:                                               ; preds = %36, %45, %25
  %53 = phi i8 [ %16, %25 ], [ 0, %45 ], [ %28, %36 ]
  %.2 = phi float [ 0.000000e+00, %25 ], [ %.030, %45 ], [ 0.000000e+00, %36 ]
  store float %18, ptr %7, align 4, !tbaa !23
  %54 = getelementptr inbounds float, ptr %14, i64 %.031
  store float %.2, ptr %54, align 4, !tbaa !22
  %55 = add nuw i64 %.031, 1
  %exitcond.not = icmp eq i64 %55, %4
  br i1 %exitcond.not, label %._crit_edge, label %15, !llvm.loop !29
}

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_TimedTriggerCounter", !7, i64 0, !11, i64 16, !12, i64 40, !13, i64 48, !14, i64 56, !15, i64 64, !16, i64 68}
!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_TimedTriggerCounter_Inputs", !8, i64 0, !8, i64 8, !8, i64 16}
!12 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"long", !9, i64 0}
!15 = !{!"_Bool", !9, i64 0}
!16 = !{!"float", !9, i64 0}
!17 = !{!18, !14, i64 16}
!18 = !{!"sig_AudioSettings", !16, i64 0, !14, i64 8, !14, i64 16}
!19 = !{!6, !8, i64 16}
!20 = !{!6, !8, i64 40}
!21 = !{!6, !15, i64 64}
!22 = !{!16, !16, i64 0}
!23 = !{!6, !16, i64 68}
!24 = !{!6, !13, i64 48}
!25 = !{!6, !14, i64 56}
!26 = !{!6, !8, i64 24}
!27 = !{!18, !16, i64 0}
!28 = !{!6, !8, i64 32}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


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