; 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_GatedTimer = type { %struct.sig_dsp_Signal, %struct.sig_dsp_GatedTimer_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput, i64, i8, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_GatedTimer_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_GatedTimer_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %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 = %108, %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_GatedTimer, 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 !18
  %17 = icmp ult i64 %10, %16
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.sig_dsp_GatedTimer_Inputs, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  %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 !21
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.sig_AudioSettings, ptr %30, i32 0, i32 0
  %32 = load float, ptr %31, align 8, !tbaa !22
  %33 = fmul float %26, %32
  %34 = fptoui float %33 to i64
  store i64 %34, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds %struct.sig_dsp_GatedTimer_Inputs, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !23
  %39 = load i64, ptr %4, align 8, !tbaa !9
  %40 = getelementptr inbounds float, ptr %38, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !21
  store float %41, ptr %7, align 4, !tbaa !21
  %42 = load float, ptr %7, align 4, !tbaa !21
  %43 = fcmp ogt float %42, 0.000000e+00
  br i1 %43, label %44, label %81

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

49:                                               ; preds = %44
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.sig_dsp_GatedTimer_Inputs, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !27
  %54 = load i64, ptr %4, align 8, !tbaa !9
  %55 = getelementptr inbounds float, ptr %53, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !21
  %57 = fcmp ogt float %56, 0.000000e+00
  br i1 %57, label %58, label %63

58:                                               ; preds = %49, %44
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %59, i32 0, i32 3
  %61 = load i64, ptr %60, align 8, !tbaa !28
  %62 = add i64 %61, 1
  store i64 %62, ptr %60, align 8, !tbaa !28
  br label %63

63:                                               ; preds = %58, %49
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %64, i32 0, i32 3
  %66 = load i64, ptr %65, align 8, !tbaa !28
  %67 = load i64, ptr %6, align 8, !tbaa !9
  %68 = icmp uge i64 %66, %67
  br i1 %68, label %69, label %80

69:                                               ; preds = %63
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %70, i32 0, i32 2
  %72 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !29
  %74 = load i64, ptr %4, align 8, !tbaa !9
  %75 = getelementptr inbounds float, ptr %73, i64 %74
  store float 1.000000e+00, ptr %75, align 4, !tbaa !21
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %76, i32 0, i32 3
  store i64 0, ptr %77, align 8, !tbaa !28
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %78, i32 0, i32 4
  store i8 1, ptr %79, align 8, !tbaa !24
  store i32 4, ptr %5, align 4
  br label %105

80:                                               ; preds = %63
  br label %95

81:                                               ; preds = %19
  %82 = load float, ptr %7, align 4, !tbaa !21
  %83 = fcmp ole float %82, 0.000000e+00
  br i1 %83, label %84, label %94

84:                                               ; preds = %81
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %85, i32 0, i32 5
  %87 = load float, ptr %86, align 4, !tbaa !30
  %88 = fcmp ogt float %87, 0.000000e+00
  br i1 %88, label %89, label %94

89:                                               ; preds = %84
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %90, i32 0, i32 3
  store i64 0, ptr %91, align 8, !tbaa !28
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %92, i32 0, i32 4
  store i8 0, ptr %93, align 8, !tbaa !24
  br label %94

94:                                               ; preds = %89, %84, %81
  br label %95

95:                                               ; preds = %94, %80
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !29
  %100 = load i64, ptr %4, align 8, !tbaa !9
  %101 = getelementptr inbounds float, ptr %99, i64 %100
  store float 0.000000e+00, ptr %101, align 4, !tbaa !21
  %102 = load float, ptr %7, align 4, !tbaa !21
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.sig_dsp_GatedTimer, ptr %103, i32 0, i32 5
  store float %102, ptr %104, align 4, !tbaa !30
  store i32 0, ptr %5, align 4
  br label %105

105:                                              ; preds = %95, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %106 = load i32, ptr %5, align 4
  switch i32 %106, label %112 [
    i32 0, label %107
    i32 4, label %108
  ]

107:                                              ; preds = %105
  br label %108

108:                                              ; preds = %107, %105
  %109 = load i64, ptr %4, align 8, !tbaa !9
  %110 = add i64 %109, 1
  store i64 %110, ptr %4, align 8, !tbaa !9
  br label %9, !llvm.loop !31

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

112:                                              ; preds = %105
  unreachable
}

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_GatedTimer", !13, i64 0, !14, i64 16, !15, i64 40, !10, i64 48, !16, i64 56, !17, i64 60}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_GatedTimer_Inputs", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!19, !10, i64 16}
!19 = !{!"sig_AudioSettings", !17, i64 0, !10, i64 8, !10, i64 16}
!20 = !{!12, !6, i64 24}
!21 = !{!17, !17, i64 0}
!22 = !{!19, !17, i64 0}
!23 = !{!12, !6, i64 16}
!24 = !{!12, !16, i64 56}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!12, !6, i64 32}
!28 = !{!12, !10, i64 48}
!29 = !{!12, !6, i64 40}
!30 = !{!12, !17, i64 60}
!31 = distinct !{!31, !32}
!32 = !{!"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_GatedTimer_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 !16
  %.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 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !18
  %8 = load ptr, ptr %5, align 8, !tbaa !19
  %9 = getelementptr inbounds i8, ptr %0, i64 60
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  br label %14

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

14:                                               ; preds = %.lr.ph, %47
  %.028 = phi i64 [ 0, %.lr.ph ], [ %48, %47 ]
  %15 = getelementptr inbounds float, ptr %7, i64 %.028
  %16 = load float, ptr %15, align 4, !tbaa !20
  %17 = load float, ptr %2, align 8, !tbaa !21
  %18 = fmul float %16, %17
  %19 = fptoui float %18 to i64
  %20 = getelementptr inbounds float, ptr %8, i64 %.028
  %21 = load float, ptr %20, align 4, !tbaa !20
  %22 = fcmp ogt float %21, 0.000000e+00
  br i1 %22, label %23, label %38

23:                                               ; preds = %14
  %24 = load i8, ptr %11, align 8, !tbaa !22, !range !23, !noundef !24
  %25 = trunc nuw i8 %24 to i1
  br i1 %25, label %26, label %._crit_edge34

._crit_edge34:                                    ; preds = %23
  %.pre35 = load i64, ptr %10, align 8, !tbaa !25
  br label %31

26:                                               ; preds = %23
  %27 = load ptr, ptr %12, align 8, !tbaa !26
  %28 = getelementptr inbounds float, ptr %27, i64 %.028
  %29 = load float, ptr %28, align 4, !tbaa !20
  %30 = fcmp ogt float %29, 0.000000e+00
  %.pre36 = load i64, ptr %10, align 8, !tbaa !25
  br i1 %30, label %31, label %._crit_edge33

31:                                               ; preds = %._crit_edge34, %26
  %32 = phi i64 [ %.pre35, %._crit_edge34 ], [ %.pre36, %26 ]
  %33 = add i64 %32, 1
  store i64 %33, ptr %10, align 8, !tbaa !25
  br label %._crit_edge33

._crit_edge33:                                    ; preds = %26, %31
  %34 = phi i64 [ %33, %31 ], [ %.pre36, %26 ]
  %.not = icmp ult i64 %34, %19
  br i1 %.not, label %44, label %35

35:                                               ; preds = %._crit_edge33
  %36 = load ptr, ptr %13, align 8, !tbaa !27
  %37 = getelementptr inbounds float, ptr %36, i64 %.028
  store float 1.000000e+00, ptr %37, align 4, !tbaa !20
  store i64 0, ptr %10, align 8, !tbaa !25
  store i8 1, ptr %11, align 8, !tbaa !22
  br label %47

38:                                               ; preds = %14
  %39 = fcmp ugt float %21, 0.000000e+00
  br i1 %39, label %44, label %40

40:                                               ; preds = %38
  %41 = load float, ptr %9, align 4, !tbaa !28
  %42 = fcmp ogt float %41, 0.000000e+00
  br i1 %42, label %43, label %44

43:                                               ; preds = %40
  store i64 0, ptr %10, align 8, !tbaa !25
  store i8 0, ptr %11, align 8, !tbaa !22
  br label %44

44:                                               ; preds = %38, %40, %43, %._crit_edge33
  %45 = load ptr, ptr %13, align 8, !tbaa !27
  %46 = getelementptr inbounds float, ptr %45, i64 %.028
  store float 0.000000e+00, ptr %46, align 4, !tbaa !20
  store float %21, ptr %9, align 4, !tbaa !28
  br label %47

47:                                               ; preds = %44, %35
  %48 = add nuw i64 %.028, 1
  %exitcond.not = icmp eq i64 %48, %4
  br i1 %exitcond.not, label %._crit_edge, label %14, !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_GatedTimer", !7, i64 0, !11, i64 16, !12, i64 40, !13, i64 48, !14, i64 56, !15, i64 60}
!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_GatedTimer_Inputs", !8, i64 0, !8, i64 8, !8, i64 16}
!12 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!"_Bool", !9, i64 0}
!15 = !{!"float", !9, i64 0}
!16 = !{!17, !13, i64 16}
!17 = !{!"sig_AudioSettings", !15, i64 0, !13, i64 8, !13, i64 16}
!18 = !{!6, !8, i64 24}
!19 = !{!6, !8, i64 16}
!20 = !{!15, !15, i64 0}
!21 = !{!17, !15, i64 0}
!22 = !{!6, !14, i64 56}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!6, !13, i64 48}
!26 = !{!6, !8, i64 32}
!27 = !{!6, !8, i64 40}
!28 = !{!6, !15, i64 60}
!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