; LLVM IR from sp-nitech/SPTK :: src/math/matrix2d.ll (ZN4sptk8Matrix2D8MultiplyERKS0_S2_PS0_)

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

%"class.sptk::Matrix2D" = type { ptr, %union.anon }
%union.anon = type { [4 x double] }
%struct.anon = type { double, double, double, double }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4sptk8Matrix2D8MultiplyERKS0_S2_PS0_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, ptr noundef %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr null, %8
  br i1 %9, label %18, label %10

10:                                               ; preds = %3
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp eq ptr %11, %12
  br i1 %13, label %18, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %14, %10, %3
  store i1 false, ptr %4, align 1
  br label %104

19:                                               ; preds = %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.anon, ptr %21, i32 0, i32 0
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds %struct.anon, ptr %25, i32 0, i32 0
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.anon, ptr %29, i32 0, i32 1
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.anon, ptr %33, i32 0, i32 2
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fmul double %31, %35
  %37 = call double @llvm.fmuladd.f64(double %23, double %27, double %36)
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds %struct.anon, ptr %39, i32 0, i32 0
  store double %37, ptr %40, align 8, !tbaa !9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds %struct.anon, ptr %42, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.anon, ptr %46, i32 0, i32 1
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.anon, ptr %50, i32 0, i32 1
  %52 = load double, ptr %51, align 8, !tbaa !9
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 3
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = fmul double %52, %56
  %58 = call double @llvm.fmuladd.f64(double %44, double %48, double %57)
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.anon, ptr %60, i32 0, i32 1
  store double %58, ptr %61, align 8, !tbaa !9
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.anon, ptr %63, i32 0, i32 2
  %65 = load double, ptr %64, align 8, !tbaa !9
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.anon, ptr %67, i32 0, i32 0
  %69 = load double, ptr %68, align 8, !tbaa !9
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds %struct.anon, ptr %71, i32 0, i32 3
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %struct.anon, ptr %75, i32 0, i32 2
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = fmul double %73, %77
  %79 = call double @llvm.fmuladd.f64(double %65, double %69, double %78)
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %80, i32 0, i32 1
  %82 = getelementptr inbounds %struct.anon, ptr %81, i32 0, i32 2
  store double %79, ptr %82, align 8, !tbaa !9
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %83, i32 0, i32 1
  %85 = getelementptr inbounds %struct.anon, ptr %84, i32 0, i32 2
  %86 = load double, ptr %85, align 8, !tbaa !9
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %87, i32 0, i32 1
  %89 = getelementptr inbounds %struct.anon, ptr %88, i32 0, i32 1
  %90 = load double, ptr %89, align 8, !tbaa !9
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %91, i32 0, i32 1
  %93 = getelementptr inbounds %struct.anon, ptr %92, i32 0, i32 3
  %94 = load double, ptr %93, align 8, !tbaa !9
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %95, i32 0, i32 1
  %97 = getelementptr inbounds %struct.anon, ptr %96, i32 0, i32 3
  %98 = load double, ptr %97, align 8, !tbaa !9
  %99 = fmul double %94, %98
  %100 = call double @llvm.fmuladd.f64(double %86, double %90, double %99)
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %"class.sptk::Matrix2D", ptr %101, i32 0, i32 1
  %103 = getelementptr inbounds %struct.anon, ptr %102, i32 0, i32 3
  store double %100, ptr %103, align 8, !tbaa !9
  store i1 true, ptr %4, align 1
  br label %104

104:                                              ; preds = %19, %18
  %105 = load i1, ptr %4, align 1
  ret i1 %105
}

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

!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++ TBAA"}
!9 = !{!7, !7, i64 0}


; 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 noundef zeroext i1 @_ZN4sptk8Matrix2D8MultiplyERKS0_S2_PS0_(ptr noundef nonnull readonly align 8 dereferenceable(40) %0, ptr noundef nonnull readonly align 8 dereferenceable(40) %1, ptr noundef writeonly %2) local_unnamed_addr #1 align 2 {
  %4 = icmp ne ptr %2, null
  %5 = icmp ne ptr %2, %0
  %or.cond.not32 = and i1 %4, %5
  %6 = icmp ne ptr %2, %1
  %or.cond29.not = and i1 %6, %or.cond.not32
  br i1 %or.cond29.not, label %7, label %44

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fmul double %13, %15
  %17 = tail call double @llvm.fmuladd.f64(double %9, double %11, double %16)
  %18 = getelementptr inbounds i8, ptr %2, i64 8
  store double %17, ptr %18, align 8, !tbaa !5
  %19 = load double, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 16
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = load double, ptr %12, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 32
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fmul double %22, %24
  %26 = tail call double @llvm.fmuladd.f64(double %19, double %21, double %25)
  %27 = getelementptr inbounds i8, ptr %2, i64 16
  store double %26, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = load double, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 32
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = load double, ptr %14, align 8, !tbaa !5
  %34 = fmul double %32, %33
  %35 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %34)
  %36 = getelementptr inbounds i8, ptr %2, i64 24
  store double %35, ptr %36, align 8, !tbaa !5
  %37 = load double, ptr %28, align 8, !tbaa !5
  %38 = load double, ptr %20, align 8, !tbaa !5
  %39 = load double, ptr %31, align 8, !tbaa !5
  %40 = load double, ptr %23, align 8, !tbaa !5
  %41 = fmul double %39, %40
  %42 = tail call double @llvm.fmuladd.f64(double %37, double %38, double %41)
  %43 = getelementptr inbounds i8, ptr %2, i64 32
  store double %42, ptr %43, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %3, %7
  ret i1 %or.cond29.not
}

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

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


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