; LLVM IR from kmilo17pet/qlibs :: qpid (qPID_AutoTuningSetParameters)

; 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.qPID_controller_t = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, ptr, float, float, %struct._qNumA_state_s, %struct._qNumA_state_s, %struct._qNumA_state_s, ptr, ptr, i32, i32, i32, i8 }
%struct._qNumA_state_s = type { [3 x float] }
%struct.qPID_AutoTuning_t = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, i32 }

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

12:                                               ; preds = %4
  %13 = load float, ptr %6, align 4, !tbaa !9
  %14 = fcmp ogt float %13, 0.000000e+00
  br i1 %14, label %15, label %52

15:                                               ; preds = %12
  %16 = load float, ptr %6, align 4, !tbaa !9
  %17 = fcmp ole float %16, 1.000000e+00
  br i1 %17, label %18, label %52

18:                                               ; preds = %15
  %19 = load float, ptr %7, align 4, !tbaa !9
  %20 = fcmp ogt float %19, 0.000000e+00
  br i1 %20, label %21, label %52

21:                                               ; preds = %18
  %22 = load float, ptr %7, align 4, !tbaa !9
  %23 = fcmp ole float %22, 1.000000e+00
  br i1 %23, label %24, label %52

24:                                               ; preds = %21
  %25 = load float, ptr %8, align 4, !tbaa !9
  %26 = fcmp oge float %25, 0x3FE99999A0000000
  br i1 %26, label %27, label %52

27:                                               ; preds = %24
  %28 = load float, ptr %8, align 4, !tbaa !9
  %29 = fcmp ole float %28, 1.000000e+00
  br i1 %29, label %30, label %52

30:                                               ; preds = %27
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.qPID_controller_t, ptr %31, i32 0, i32 23
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = icmp ne ptr null, %33
  br i1 %34, label %35, label %51

35:                                               ; preds = %30
  %36 = load float, ptr %8, align 4, !tbaa !9
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.qPID_controller_t, ptr %37, i32 0, i32 23
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %39, i32 0, i32 8
  store float %36, ptr %40, align 4, !tbaa !16
  %41 = load float, ptr %6, align 4, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.qPID_controller_t, ptr %42, i32 0, i32 23
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %44, i32 0, i32 12
  store float %41, ptr %45, align 4, !tbaa !18
  %46 = load float, ptr %7, align 4, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.qPID_controller_t, ptr %47, i32 0, i32 23
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %49, i32 0, i32 13
  store float %46, ptr %50, align 4, !tbaa !19
  store i32 1, ptr %9, align 4, !tbaa !11
  br label %51

51:                                               ; preds = %35, %30
  br label %52

52:                                               ; preds = %51, %27, %24, %21, %18, %15, %12, %4
  %53 = load i32, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret i32 %53
}

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, !6, i64 128}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !15, i64 88, !15, i64 100, !15, i64 112, !6, i64 128, !6, i64 136, !12, i64 144, !12, i64 148, !12, i64 152, !7, i64 156}
!15 = !{!"_qNumA_state_s", !7, i64 0}
!16 = !{!17, !10, i64 32}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !12, i64 56}
!18 = !{!17, !10, i64 48}
!19 = !{!17, !10, i64 52}


; 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(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @qPID_AutoTuningSetParameters(ptr noundef readonly %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = icmp ne ptr %0, null
  %6 = fcmp ogt float %1, 0.000000e+00
  %or.cond = and i1 %5, %6
  %7 = fcmp ole float %1, 1.000000e+00
  %or.cond3 = and i1 %7, %or.cond
  %8 = fcmp ogt float %2, 0.000000e+00
  %or.cond5 = and i1 %8, %or.cond3
  %9 = fcmp ole float %2, 1.000000e+00
  %or.cond7 = and i1 %9, %or.cond5
  %10 = fcmp oge float %3, 0x3FE99999A0000000
  %or.cond9 = and i1 %10, %or.cond7
  %11 = fcmp ole float %3, 1.000000e+00
  %or.cond11 = and i1 %11, %or.cond9
  br i1 %or.cond11, label %12, label %19

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %0, i64 128
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %19, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %14, i64 32
  store float %3, ptr %16, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %14, i64 48
  store float %1, ptr %17, align 4, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %14, i64 52
  store float %2, ptr %18, align 4, !tbaa !16
  br label %19

19:                                               ; preds = %12, %15, %4
  %.0 = phi i32 [ 1, %15 ], [ 0, %12 ], [ 0, %4 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: 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, !10, i64 128}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !10, i64 72, !7, i64 80, !7, i64 84, !11, i64 88, !11, i64 100, !11, i64 112, !10, i64 128, !10, i64 136, !12, i64 144, !12, i64 148, !12, i64 152, !8, i64 156}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_qNumA_state_s", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!14, !7, i64 32}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !12, i64 56}
!15 = !{!14, !7, i64 48}
!16 = !{!14, !7, i64 52}


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