; LLVM IR from kmilo17pet/qlibs :: qrms (qRMS_SetParams)

; 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.qRMS_t = type { %struct.qSSmoother_EXPW_t, %struct.qSSmoother_MWM2_t, %struct.qSSmoother_LPF1_t }
%struct.qSSmoother_EXPW_t = type { %struct._qSSmoother_s, float, float, float }
%struct._qSSmoother_s = type { ptr, i8 }
%struct.qSSmoother_MWM2_t = type { %struct._qSSmoother_s, %struct.qTDL_t, float }
%struct.qTDL_t = type { ptr, ptr, ptr, ptr, i64 }
%struct.qSSmoother_LPF1_t = type { %struct._qSSmoother_s, float, float }

; 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 i32 @qRMS_SetParams(ptr noundef %0, float noundef %1, float noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !11
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %31

10:                                               ; preds = %3
  %11 = load float, ptr %5, align 4, !tbaa !9
  %12 = fcmp ogt float %11, 0.000000e+00
  br i1 %12, label %13, label %31

13:                                               ; preds = %10
  %14 = load float, ptr %5, align 4, !tbaa !9
  %15 = fcmp ole float %14, 1.000000e+00
  br i1 %15, label %16, label %31

16:                                               ; preds = %13
  %17 = load float, ptr %6, align 4, !tbaa !9
  %18 = fcmp ogt float %17, 0.000000e+00
  br i1 %18, label %19, label %31

19:                                               ; preds = %16
  %20 = load float, ptr %6, align 4, !tbaa !9
  %21 = fcmp ole float %20, 1.000000e+00
  br i1 %21, label %22, label %31

22:                                               ; preds = %19
  %23 = load float, ptr %5, align 4, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.qRMS_t, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds %struct.qSSmoother_EXPW_t, ptr %25, i32 0, i32 1
  store float %23, ptr %26, align 8, !tbaa !13
  %27 = load float, ptr %6, align 4, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.qRMS_t, ptr %28, i32 0, i32 2
  %30 = getelementptr inbounds %struct.qSSmoother_LPF1_t, ptr %29, i32 0, i32 1
  store float %27, ptr %30, align 8, !tbaa !21
  store i32 1, ptr %7, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %22, %19, %16, %13, %10, %3
  %32 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret i32 %32
}

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 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"", !15, i64 0, !17, i64 32, !20, i64 96}
!15 = !{!"", !16, i64 0, !10, i64 16, !10, i64 20, !10, i64 24}
!16 = !{!"_qSSmoother_s", !6, i64 0, !7, i64 8}
!17 = !{!"", !16, i64 0, !18, i64 16, !10, i64 56}
!18 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !19, i64 32}
!19 = !{!"long", !7, i64 0}
!20 = !{!"", !16, i64 0, !10, i64 16, !10, i64 20}
!21 = !{!14, !10, i64 112}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local range(i32 0, 2) i32 @qRMS_SetParams(ptr noundef writeonly %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = icmp ne ptr %0, null
  %5 = fcmp ogt float %1, 0.000000e+00
  %or.cond = and i1 %4, %5
  %6 = fcmp ole float %1, 1.000000e+00
  %or.cond3 = and i1 %6, %or.cond
  %7 = fcmp ogt float %2, 0.000000e+00
  %or.cond5 = and i1 %7, %or.cond3
  %8 = fcmp ole float %2, 1.000000e+00
  %or.cond7 = and i1 %8, %or.cond5
  br i1 %or.cond7, label %9, label %12

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store float %1, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  store float %2, ptr %11, align 8, !tbaa !17
  br label %12

12:                                               ; preds = %9, %3
  %.0 = phi i32 [ 1, %9 ], [ 0, %3 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !12, i64 16}
!6 = !{!"", !7, i64 0, !13, i64 32, !16, i64 96}
!7 = !{!"", !8, i64 0, !12, i64 16, !12, i64 20, !12, i64 24}
!8 = !{!"_qSSmoother_s", !9, i64 0, !10, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"float", !10, i64 0}
!13 = !{!"", !8, i64 0, !14, i64 16, !12, i64 56}
!14 = !{!"", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !15, i64 32}
!15 = !{!"long", !10, i64 0}
!16 = !{!"", !8, i64 0, !12, i64 16, !12, i64 20}
!17 = !{!6, !12, i64 112}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass