; LLVM IR from pms67/HadesFCS :: Firmware/F4/HadesF4Testbed/Core/Src (KalmanQuatAtt)

; 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"

@updateEKFQuatAtt_initialize.dv4 = external hidden constant [7 x float], align 16
@updateEKFQuatAtt_initialize.dv5 = external hidden constant [7 x float], align 16
@updateEKFQuatAtt_initialize.dv6 = external hidden constant [6 x float], align 16
@g = external hidden global float, align 4
@p = external hidden global float, align 4
@q = external hidden global float, align 4
@r = external hidden global float, align 4
@ax = external hidden global float, align 4
@ay = external hidden global float, align 4
@az = external hidden global float, align 4
@mx = external hidden global float, align 4
@my = external hidden global float, align 4
@mz = external hidden global float, align 4
@Va = external hidden global float, align 4
@lpfGyr = external hidden global float, align 4
@lpfAcc = external hidden global float, align 4
@lpfMag = external hidden global float, align 4
@lpfVa = external hidden global float, align 4
@x = external hidden global [7 x float], align 16
@P = external hidden global [49 x float], align 16
@Q = external hidden global [49 x float], align 16
@R = external hidden global [36 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local void @updateEKFQuatAtt_initialize() #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store float 0x40239EB860000000, ptr @g, align 4, !tbaa !5
  store float 0.000000e+00, ptr @p, align 4, !tbaa !5
  store float 0.000000e+00, ptr @q, align 4, !tbaa !5
  store float 0.000000e+00, ptr @r, align 4, !tbaa !5
  store float 0.000000e+00, ptr @ax, align 4, !tbaa !5
  store float 0.000000e+00, ptr @ay, align 4, !tbaa !5
  store float 0.000000e+00, ptr @az, align 4, !tbaa !5
  store float 0.000000e+00, ptr @mx, align 4, !tbaa !5
  store float 0.000000e+00, ptr @my, align 4, !tbaa !5
  store float 0.000000e+00, ptr @mz, align 4, !tbaa !5
  store float 0.000000e+00, ptr @Va, align 4, !tbaa !5
  store float 0x3FE6666660000000, ptr @lpfGyr, align 4, !tbaa !5
  store float 0x3FECCCCCC0000000, ptr @lpfAcc, align 4, !tbaa !5
  store float 0x3FD99999A0000000, ptr @lpfMag, align 4, !tbaa !5
  store float 0x3FE6666660000000, ptr @lpfVa, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %2

2:                                                ; preds = %9, %0
  %3 = load i32, ptr %1, align 4, !tbaa !9
  %4 = icmp slt i32 %3, 7
  br i1 %4, label %5, label %12

5:                                                ; preds = %2
  %6 = load i32, ptr %1, align 4, !tbaa !9
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [7 x float], ptr @x, i64 0, i64 %7
  store float 0.000000e+00, ptr %8, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %5
  %10 = load i32, ptr %1, align 4, !tbaa !9
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr %1, align 4, !tbaa !9
  br label %2, !llvm.loop !11

12:                                               ; preds = %2
  store float 1.000000e+00, ptr @x, align 16, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @P, i8 0, i64 196, i1 false)
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %27, %12
  %14 = load i32, ptr %1, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 7
  br i1 %15, label %16, label %30

16:                                               ; preds = %13
  %17 = load i32, ptr %1, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [7 x float], ptr @updateEKFQuatAtt_initialize.dv4, i64 0, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = load i32, ptr %1, align 4, !tbaa !9
  %22 = load i32, ptr %1, align 4, !tbaa !9
  %23 = mul nsw i32 7, %22
  %24 = add nsw i32 %21, %23
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [49 x float], ptr @P, i64 0, i64 %25
  store float %20, ptr %26, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %16
  %28 = load i32, ptr %1, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %1, align 4, !tbaa !9
  br label %13, !llvm.loop !13

30:                                               ; preds = %13
  call void @llvm.memset.p0.i64(ptr align 16 @Q, i8 0, i64 196, i1 false)
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %45, %30
  %32 = load i32, ptr %1, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 7
  br i1 %33, label %34, label %48

34:                                               ; preds = %31
  %35 = load i32, ptr %1, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [7 x float], ptr @updateEKFQuatAtt_initialize.dv5, i64 0, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %1, align 4, !tbaa !9
  %40 = load i32, ptr %1, align 4, !tbaa !9
  %41 = mul nsw i32 7, %40
  %42 = add nsw i32 %39, %41
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [49 x float], ptr @Q, i64 0, i64 %43
  store float %38, ptr %44, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %34
  %46 = load i32, ptr %1, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %1, align 4, !tbaa !9
  br label %31, !llvm.loop !14

48:                                               ; preds = %31
  call void @llvm.memset.p0.i64(ptr align 16 @R, i8 0, i64 144, i1 false)
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %63, %48
  %50 = load i32, ptr %1, align 4, !tbaa !9
  %51 = icmp slt i32 %50, 6
  br i1 %51, label %52, label %66

52:                                               ; preds = %49
  %53 = load i32, ptr %1, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [6 x float], ptr @updateEKFQuatAtt_initialize.dv6, i64 0, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr %1, align 4, !tbaa !9
  %58 = load i32, ptr %1, align 4, !tbaa !9
  %59 = mul nsw i32 6, %58
  %60 = add nsw i32 %57, %59
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [36 x float], ptr @R, i64 0, i64 %61
  store float %56, ptr %62, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %52
  %64 = load i32, ptr %1, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %1, align 4, !tbaa !9
  br label %49, !llvm.loop !15

66:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; 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"

@updateEKFQuatAtt_initialize.dv4 = external hidden local_unnamed_addr constant [7 x float], align 16
@updateEKFQuatAtt_initialize.dv5 = external hidden local_unnamed_addr constant [7 x float], align 16
@updateEKFQuatAtt_initialize.dv6 = external hidden local_unnamed_addr constant [6 x float], align 16
@g = external hidden local_unnamed_addr global float, align 4
@p = external hidden local_unnamed_addr global float, align 4
@q = external hidden local_unnamed_addr global float, align 4
@r = external hidden local_unnamed_addr global float, align 4
@ax = external hidden local_unnamed_addr global float, align 4
@ay = external hidden local_unnamed_addr global float, align 4
@az = external hidden local_unnamed_addr global float, align 4
@mx = external hidden local_unnamed_addr global float, align 4
@my = external hidden local_unnamed_addr global float, align 4
@mz = external hidden local_unnamed_addr global float, align 4
@Va = external hidden local_unnamed_addr global float, align 4
@lpfGyr = external hidden local_unnamed_addr global float, align 4
@lpfAcc = external hidden local_unnamed_addr global float, align 4
@lpfMag = external hidden local_unnamed_addr global float, align 4
@lpfVa = external hidden local_unnamed_addr global float, align 4
@x = external hidden local_unnamed_addr global [7 x float], align 16
@P = external hidden local_unnamed_addr global [49 x float], align 16
@Q = external hidden local_unnamed_addr global [49 x float], align 16
@R = external hidden local_unnamed_addr global [36 x float], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @updateEKFQuatAtt_initialize() local_unnamed_addr #0 {
  store float 0x40239EB860000000, ptr @g, align 4, !tbaa !5
  store float 0.000000e+00, ptr @p, align 4, !tbaa !5
  store float 0.000000e+00, ptr @q, align 4, !tbaa !5
  store float 0.000000e+00, ptr @r, align 4, !tbaa !5
  store float 0.000000e+00, ptr @ax, align 4, !tbaa !5
  store float 0.000000e+00, ptr @ay, align 4, !tbaa !5
  store float 0.000000e+00, ptr @az, align 4, !tbaa !5
  store float 0.000000e+00, ptr @mx, align 4, !tbaa !5
  store float 0.000000e+00, ptr @my, align 4, !tbaa !5
  store float 0.000000e+00, ptr @mz, align 4, !tbaa !5
  store float 0.000000e+00, ptr @Va, align 4, !tbaa !5
  store float 0x3FE6666660000000, ptr @lpfGyr, align 4, !tbaa !5
  store float 0x3FECCCCCC0000000, ptr @lpfAcc, align 4, !tbaa !5
  store float 0x3FD99999A0000000, ptr @lpfMag, align 4, !tbaa !5
  store float 0x3FE6666660000000, ptr @lpfVa, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(28) @x, i8 0, i64 28, i1 false), !tbaa !5
  store float 1.000000e+00, ptr @x, align 16, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(196) @P, i8 0, i64 192, i1 false)
  %1 = load float, ptr @updateEKFQuatAtt_initialize.dv4, align 16, !tbaa !5
  store float %1, ptr @P, align 16, !tbaa !5
  %2 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv4, i64 4), align 4, !tbaa !5
  store float %2, ptr getelementptr inbounds (i8, ptr @P, i64 32), align 16, !tbaa !5
  %3 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv4, i64 8), align 8, !tbaa !5
  store float %3, ptr getelementptr inbounds (i8, ptr @P, i64 64), align 16, !tbaa !5
  %4 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv4, i64 12), align 4, !tbaa !5
  store float %4, ptr getelementptr inbounds (i8, ptr @P, i64 96), align 16, !tbaa !5
  %5 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv4, i64 16), align 16, !tbaa !5
  store float %5, ptr getelementptr inbounds (i8, ptr @P, i64 128), align 16, !tbaa !5
  %6 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv4, i64 20), align 4, !tbaa !5
  store float %6, ptr getelementptr inbounds (i8, ptr @P, i64 160), align 16, !tbaa !5
  %7 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv4, i64 24), align 8, !tbaa !5
  store float %7, ptr getelementptr inbounds (i8, ptr @P, i64 192), align 16, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(196) @Q, i8 0, i64 192, i1 false)
  %8 = load float, ptr @updateEKFQuatAtt_initialize.dv5, align 16, !tbaa !5
  store float %8, ptr @Q, align 16, !tbaa !5
  %9 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv5, i64 4), align 4, !tbaa !5
  store float %9, ptr getelementptr inbounds (i8, ptr @Q, i64 32), align 16, !tbaa !5
  %10 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv5, i64 8), align 8, !tbaa !5
  store float %10, ptr getelementptr inbounds (i8, ptr @Q, i64 64), align 16, !tbaa !5
  %11 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv5, i64 12), align 4, !tbaa !5
  store float %11, ptr getelementptr inbounds (i8, ptr @Q, i64 96), align 16, !tbaa !5
  %12 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv5, i64 16), align 16, !tbaa !5
  store float %12, ptr getelementptr inbounds (i8, ptr @Q, i64 128), align 16, !tbaa !5
  %13 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv5, i64 20), align 4, !tbaa !5
  store float %13, ptr getelementptr inbounds (i8, ptr @Q, i64 160), align 16, !tbaa !5
  %14 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv5, i64 24), align 8, !tbaa !5
  store float %14, ptr getelementptr inbounds (i8, ptr @Q, i64 192), align 16, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(144) @R, i8 0, i64 144, i1 false)
  %15 = load float, ptr @updateEKFQuatAtt_initialize.dv6, align 16, !tbaa !5
  store float %15, ptr @R, align 16, !tbaa !5
  %16 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv6, i64 4), align 4, !tbaa !5
  store float %16, ptr getelementptr inbounds (i8, ptr @R, i64 28), align 4, !tbaa !5
  %17 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv6, i64 8), align 8, !tbaa !5
  store float %17, ptr getelementptr inbounds (i8, ptr @R, i64 56), align 8, !tbaa !5
  %18 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv6, i64 12), align 4, !tbaa !5
  store float %18, ptr getelementptr inbounds (i8, ptr @R, i64 84), align 4, !tbaa !5
  %19 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv6, i64 16), align 16, !tbaa !5
  store float %19, ptr getelementptr inbounds (i8, ptr @R, i64 112), align 16, !tbaa !5
  %20 = load float, ptr getelementptr inbounds (i8, ptr @updateEKFQuatAtt_initialize.dv6, i64 20), align 4, !tbaa !5
  store float %20, ptr getelementptr inbounds (i8, ptr @R, i64 140), align 4, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: DSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass