; LLVM IR from xboot/libcg :: src (cg)

; 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.cg_matrix_t = type { double, double, double, double, double, double }

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @cg_matrix_multiply(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.cg_matrix_t, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %7) #4
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.cg_matrix_t, ptr %8, i32 0, i32 0
  %10 = load double, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.cg_matrix_t, ptr %11, i32 0, i32 0
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = fmul double %10, %13
  %15 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 0
  store double %14, ptr %15, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 1
  store double 0.000000e+00, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 2
  store double 0.000000e+00, ptr %17, align 8, !tbaa !13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.cg_matrix_t, ptr %18, i32 0, i32 3
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.cg_matrix_t, ptr %21, i32 0, i32 3
  %23 = load double, ptr %22, align 8, !tbaa !14
  %24 = fmul double %20, %23
  %25 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 3
  store double %24, ptr %25, align 8, !tbaa !14
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.cg_matrix_t, ptr %26, i32 0, i32 4
  %28 = load double, ptr %27, align 8, !tbaa !15
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.cg_matrix_t, ptr %29, i32 0, i32 0
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.cg_matrix_t, ptr %32, i32 0, i32 4
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = call double @llvm.fmuladd.f64(double %28, double %31, double %34)
  %36 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 4
  store double %35, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.cg_matrix_t, ptr %37, i32 0, i32 5
  %39 = load double, ptr %38, align 8, !tbaa !16
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.cg_matrix_t, ptr %40, i32 0, i32 3
  %42 = load double, ptr %41, align 8, !tbaa !14
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.cg_matrix_t, ptr %43, i32 0, i32 5
  %45 = load double, ptr %44, align 8, !tbaa !16
  %46 = call double @llvm.fmuladd.f64(double %39, double %42, double %45)
  %47 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 5
  store double %46, ptr %47, align 8, !tbaa !16
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.cg_matrix_t, ptr %48, i32 0, i32 1
  %50 = load double, ptr %49, align 8, !tbaa !12
  %51 = fcmp une double %50, 0.000000e+00
  br i1 %51, label %67, label %52

52:                                               ; preds = %3
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.cg_matrix_t, ptr %53, i32 0, i32 2
  %55 = load double, ptr %54, align 8, !tbaa !13
  %56 = fcmp une double %55, 0.000000e+00
  br i1 %56, label %67, label %57

57:                                               ; preds = %52
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.cg_matrix_t, ptr %58, i32 0, i32 1
  %60 = load double, ptr %59, align 8, !tbaa !12
  %61 = fcmp une double %60, 0.000000e+00
  br i1 %61, label %67, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.cg_matrix_t, ptr %63, i32 0, i32 2
  %65 = load double, ptr %64, align 8, !tbaa !13
  %66 = fcmp une double %65, 0.000000e+00
  br i1 %66, label %67, label %138

67:                                               ; preds = %62, %57, %52, %3
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.cg_matrix_t, ptr %68, i32 0, i32 1
  %70 = load double, ptr %69, align 8, !tbaa !12
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.cg_matrix_t, ptr %71, i32 0, i32 2
  %73 = load double, ptr %72, align 8, !tbaa !13
  %74 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 0
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = call double @llvm.fmuladd.f64(double %70, double %73, double %75)
  store double %76, ptr %74, align 8, !tbaa !9
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.cg_matrix_t, ptr %77, i32 0, i32 0
  %79 = load double, ptr %78, align 8, !tbaa !9
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.cg_matrix_t, ptr %80, i32 0, i32 1
  %82 = load double, ptr %81, align 8, !tbaa !12
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.cg_matrix_t, ptr %83, i32 0, i32 1
  %85 = load double, ptr %84, align 8, !tbaa !12
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.cg_matrix_t, ptr %86, i32 0, i32 3
  %88 = load double, ptr %87, align 8, !tbaa !14
  %89 = fmul double %85, %88
  %90 = call double @llvm.fmuladd.f64(double %79, double %82, double %89)
  %91 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 1
  %92 = load double, ptr %91, align 8, !tbaa !12
  %93 = fadd double %92, %90
  store double %93, ptr %91, align 8, !tbaa !12
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.cg_matrix_t, ptr %94, i32 0, i32 2
  %96 = load double, ptr %95, align 8, !tbaa !13
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.cg_matrix_t, ptr %97, i32 0, i32 0
  %99 = load double, ptr %98, align 8, !tbaa !9
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.cg_matrix_t, ptr %100, i32 0, i32 3
  %102 = load double, ptr %101, align 8, !tbaa !14
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.cg_matrix_t, ptr %103, i32 0, i32 2
  %105 = load double, ptr %104, align 8, !tbaa !13
  %106 = fmul double %102, %105
  %107 = call double @llvm.fmuladd.f64(double %96, double %99, double %106)
  %108 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 2
  %109 = load double, ptr %108, align 8, !tbaa !13
  %110 = fadd double %109, %107
  store double %110, ptr %108, align 8, !tbaa !13
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.cg_matrix_t, ptr %111, i32 0, i32 2
  %113 = load double, ptr %112, align 8, !tbaa !13
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.cg_matrix_t, ptr %114, i32 0, i32 1
  %116 = load double, ptr %115, align 8, !tbaa !12
  %117 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 3
  %118 = load double, ptr %117, align 8, !tbaa !14
  %119 = call double @llvm.fmuladd.f64(double %113, double %116, double %118)
  store double %119, ptr %117, align 8, !tbaa !14
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.cg_matrix_t, ptr %120, i32 0, i32 5
  %122 = load double, ptr %121, align 8, !tbaa !16
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.cg_matrix_t, ptr %123, i32 0, i32 2
  %125 = load double, ptr %124, align 8, !tbaa !13
  %126 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 4
  %127 = load double, ptr %126, align 8, !tbaa !15
  %128 = call double @llvm.fmuladd.f64(double %122, double %125, double %127)
  store double %128, ptr %126, align 8, !tbaa !15
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.cg_matrix_t, ptr %129, i32 0, i32 4
  %131 = load double, ptr %130, align 8, !tbaa !15
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.cg_matrix_t, ptr %132, i32 0, i32 1
  %134 = load double, ptr %133, align 8, !tbaa !12
  %135 = getelementptr inbounds %struct.cg_matrix_t, ptr %7, i32 0, i32 5
  %136 = load double, ptr %135, align 8, !tbaa !16
  %137 = call double @llvm.fmuladd.f64(double %131, double %134, double %136)
  store double %137, ptr %135, align 8, !tbaa !16
  br label %138

138:                                              ; preds = %67, %62
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %139, ptr align 8 %7, i64 48, i1 false)
  call void @llvm.lifetime.end.p0(i64 48, ptr %7) #4
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !11, i64 0}
!10 = !{!"cg_matrix_t", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !11, i64 32}
!16 = !{!10, !11, i64 40}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @cg_matrix_multiply(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = fmul double %4, %5
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load double, ptr %7, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %2, i64 24
  %10 = load double, ptr %9, align 8, !tbaa !10
  %11 = fmul double %8, %10
  %12 = getelementptr inbounds i8, ptr %1, i64 32
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %2, i64 32
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = tail call double @llvm.fmuladd.f64(double %13, double %5, double %15)
  %17 = getelementptr inbounds i8, ptr %1, i64 40
  %18 = load double, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %2, i64 40
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = tail call double @llvm.fmuladd.f64(double %18, double %10, double %20)
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  %23 = load double, ptr %22, align 8, !tbaa !13
  %24 = fcmp une double %23, 0.000000e+00
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 16
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !14
  %25 = fcmp une double %.pre, 0.000000e+00
  %or.cond = select i1 %24, i1 true, i1 %25
  br i1 %or.cond, label %._crit_edge, label %26

26:                                               ; preds = %3
  %27 = getelementptr inbounds i8, ptr %2, i64 8
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = fcmp une double %28, 0.000000e+00
  br i1 %29, label %._crit_edge, label %30

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %2, i64 16
  %32 = load double, ptr %31, align 8, !tbaa !14
  %33 = fcmp une double %32, 0.000000e+00
  %34 = insertelement <2 x double> poison, double %11, i64 0
  %35 = insertelement <2 x double> %34, double %16, i64 1
  %36 = insertelement <2 x double> poison, double %21, i64 0
  %37 = insertelement <2 x double> %36, double %6, i64 1
  br i1 %33, label %._crit_edge, label %59

._crit_edge:                                      ; preds = %3, %30, %26
  %38 = getelementptr inbounds i8, ptr %2, i64 8
  %39 = load <2 x double>, ptr %38, align 8, !tbaa !15
  %40 = insertelement <2 x double> poison, double %23, i64 0
  %41 = insertelement <2 x double> %40, double %8, i64 1
  %42 = insertelement <2 x double> %39, double %10, i64 0
  %43 = fmul <2 x double> %41, %42
  %44 = insertelement <2 x double> poison, double %4, i64 0
  %45 = insertelement <2 x double> %44, double %.pre, i64 1
  %46 = insertelement <2 x double> %39, double %5, i64 1
  %47 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %45, <2 x double> %46, <2 x double> %43)
  %48 = fadd <2 x double> %47, zeroinitializer
  %49 = insertelement <2 x double> poison, double %.pre, i64 0
  %50 = insertelement <2 x double> %49, double %18, i64 1
  %51 = insertelement <2 x double> poison, double %11, i64 0
  %52 = insertelement <2 x double> %51, double %16, i64 1
  %53 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %50, <2 x double> %39, <2 x double> %52)
  %54 = insertelement <2 x double> poison, double %13, i64 0
  %55 = insertelement <2 x double> %54, double %23, i64 1
  %56 = insertelement <2 x double> poison, double %21, i64 0
  %57 = insertelement <2 x double> %56, double %6, i64 1
  %58 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %39, <2 x double> %57)
  br label %59

59:                                               ; preds = %._crit_edge, %30
  %60 = phi <2 x double> [ %48, %._crit_edge ], [ zeroinitializer, %30 ]
  %61 = phi <2 x double> [ %53, %._crit_edge ], [ %35, %30 ]
  %62 = phi <2 x double> [ %58, %._crit_edge ], [ %37, %30 ]
  %63 = extractelement <2 x double> %62, i64 1
  store double %63, ptr %0, align 8
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store <2 x double> %60, ptr %.sroa.6.0..sroa_idx, align 8
  %.sroa.12.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 24
  store <2 x double> %61, ptr %.sroa.12.0..sroa_idx, align 8
  %.sroa.18.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  %64 = extractelement <2 x double> %62, i64 0
  store double %64, ptr %.sroa.18.0..sroa_idx, align 8
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

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

!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 = !{!"cg_matrix_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 24}
!11 = !{!6, !7, i64 32}
!12 = !{!6, !7, i64 40}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 16}
!15 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass