; 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_Buffer = type { i64, ptr }

; 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_Buffer_fillWithWaveform(ptr noundef %0, ptr noundef %1, float noundef %2, float noundef %3, float noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %13 = load float, ptr %10, align 4, !tbaa !9
  %14 = fmul float %13, 0x401921FB60000000
  %15 = load float, ptr %8, align 4, !tbaa !9
  %16 = fdiv float %14, %15
  store float %16, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %50, %5
  %18 = load i64, ptr %12, align 8, !tbaa !11
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_Buffer, ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = icmp ult i64 %18, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %53

24:                                               ; preds = %17
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load float, ptr %9, align 4, !tbaa !9
  %27 = call float %25(float noundef %26)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_Buffer, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = load i64, ptr %12, align 8, !tbaa !11
  %32 = getelementptr inbounds float, ptr %30, i64 %31
  store float %27, ptr %32, align 4, !tbaa !9
  %33 = load float, ptr %11, align 4, !tbaa !9
  %34 = load float, ptr %9, align 4, !tbaa !9
  %35 = fadd float %34, %33
  store float %35, ptr %9, align 4, !tbaa !9
  %36 = load float, ptr %9, align 4, !tbaa !9
  %37 = fcmp oge float %36, 0x401921FB60000000
  br i1 %37, label %38, label %41

38:                                               ; preds = %24
  %39 = load float, ptr %9, align 4, !tbaa !9
  %40 = fsub float %39, 0x401921FB60000000
  store float %40, ptr %9, align 4, !tbaa !9
  br label %49

41:                                               ; preds = %24
  %42 = load float, ptr %9, align 4, !tbaa !9
  %43 = fpext float %42 to double
  %44 = fcmp olt double %43, 0.000000e+00
  br i1 %44, label %45, label %48

45:                                               ; preds = %41
  %46 = load float, ptr %9, align 4, !tbaa !9
  %47 = fadd float %46, 0x401921FB60000000
  store float %47, ptr %9, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %45, %41
  br label %49

49:                                               ; preds = %48, %38
  br label %50

50:                                               ; preds = %49
  %51 = load i64, ptr %12, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %12, align 8, !tbaa !11
  br label %17, !llvm.loop !16

53:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"sig_Buffer", !12, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"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: nounwind uwtable
define dso_local void @sig_Buffer_fillWithWaveform(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #0 {
  %6 = fmul float %4, 0x401921FB60000000
  %7 = fdiv float %6, %2
  %8 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  br label %10

._crit_edge:                                      ; preds = %22, %5
  ret void

10:                                               ; preds = %.lr.ph, %22
  %.018 = phi i64 [ 0, %.lr.ph ], [ %23, %22 ]
  %.01417 = phi float [ %3, %.lr.ph ], [ %.1, %22 ]
  %11 = tail call float %1(float noundef %.01417) #1
  %12 = load ptr, ptr %9, align 8, !tbaa !11
  %13 = getelementptr inbounds float, ptr %12, i64 %.018
  store float %11, ptr %13, align 4, !tbaa !12
  %14 = fadd float %7, %.01417
  %15 = fcmp ult float %14, 0x401921FB60000000
  br i1 %15, label %18, label %16

16:                                               ; preds = %10
  %17 = fadd float %14, 0xC01921FB60000000
  br label %22

18:                                               ; preds = %10
  %19 = fcmp olt float %14, 0.000000e+00
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = fadd float %14, 0x401921FB60000000
  br label %22

22:                                               ; preds = %16, %20, %18
  %.1 = phi float [ %17, %16 ], [ %21, %20 ], [ %14, %18 ]
  %23 = add nuw i64 %.018, 1
  %24 = load i64, ptr %0, align 8, !tbaa !5
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %10, label %._crit_edge, !llvm.loop !14
}

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 = { 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, !7, i64 0}
!6 = !{!"sig_Buffer", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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