; LLVM IR from sourceryinstitute/MORFEUS-Source :: src/FV/src/mesh_optimize/OptMS (SMgrad3d)

; 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.DERIV_TYPE = type { double, [3 x 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; 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 @g_ad_dDot(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 i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  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 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.DERIV_TYPE, ptr %15, i64 2
  %17 = getelementptr inbounds %struct.DERIV_TYPE, ptr %16, i32 0, i32 0
  %18 = load double, ptr %17, align 8, !tbaa !9
  store double %18, ptr %13, align 8, !tbaa !12
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DERIV_TYPE, ptr %19, i64 2
  %21 = getelementptr inbounds %struct.DERIV_TYPE, ptr %20, i32 0, i32 0
  %22 = load double, ptr %21, align 8, !tbaa !9
  store double %22, ptr %12, align 8, !tbaa !12
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.DERIV_TYPE, ptr %23, i64 1
  %25 = getelementptr inbounds %struct.DERIV_TYPE, ptr %24, i32 0, i32 0
  %26 = load double, ptr %25, align 8, !tbaa !9
  store double %26, ptr %11, align 8, !tbaa !12
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DERIV_TYPE, ptr %27, i64 1
  %29 = getelementptr inbounds %struct.DERIV_TYPE, ptr %28, i32 0, i32 0
  %30 = load double, ptr %29, align 8, !tbaa !9
  store double %30, ptr %10, align 8, !tbaa !12
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.DERIV_TYPE, ptr %31, i64 0
  %33 = getelementptr inbounds %struct.DERIV_TYPE, ptr %32, i32 0, i32 0
  %34 = load double, ptr %33, align 8, !tbaa !9
  store double %34, ptr %9, align 8, !tbaa !12
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.DERIV_TYPE, ptr %35, i64 0
  %37 = getelementptr inbounds %struct.DERIV_TYPE, ptr %36, i32 0, i32 0
  %38 = load double, ptr %37, align 8, !tbaa !9
  store double %38, ptr %8, align 8, !tbaa !12
  store i32 0, ptr %14, align 4, !tbaa !13
  br label %39

39:                                               ; preds = %102, %3
  %40 = load i32, ptr %14, align 4, !tbaa !13
  %41 = icmp slt i32 %40, 3
  br i1 %41, label %42, label %105

42:                                               ; preds = %39
  %43 = load double, ptr %8, align 8, !tbaa !12
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.DERIV_TYPE, ptr %44, i64 0
  %46 = getelementptr inbounds %struct.DERIV_TYPE, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %14, align 4, !tbaa !13
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [3 x double], ptr %46, i64 0, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !12
  %51 = load double, ptr %9, align 8, !tbaa !12
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.DERIV_TYPE, ptr %52, i64 0
  %54 = getelementptr inbounds %struct.DERIV_TYPE, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %14, align 4, !tbaa !13
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [3 x double], ptr %54, i64 0, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !12
  %59 = fmul double %51, %58
  %60 = call double @llvm.fmuladd.f64(double %43, double %50, double %59)
  %61 = load double, ptr %10, align 8, !tbaa !12
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.DERIV_TYPE, ptr %62, i64 1
  %64 = getelementptr inbounds %struct.DERIV_TYPE, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %14, align 4, !tbaa !13
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [3 x double], ptr %64, i64 0, i64 %66
  %68 = load double, ptr %67, align 8, !tbaa !12
  %69 = call double @llvm.fmuladd.f64(double %61, double %68, double %60)
  %70 = load double, ptr %11, align 8, !tbaa !12
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.DERIV_TYPE, ptr %71, i64 1
  %73 = getelementptr inbounds %struct.DERIV_TYPE, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %14, align 4, !tbaa !13
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [3 x double], ptr %73, i64 0, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !12
  %78 = call double @llvm.fmuladd.f64(double %70, double %77, double %69)
  %79 = load double, ptr %12, align 8, !tbaa !12
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.DERIV_TYPE, ptr %80, i64 2
  %82 = getelementptr inbounds %struct.DERIV_TYPE, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %14, align 4, !tbaa !13
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [3 x double], ptr %82, i64 0, i64 %84
  %86 = load double, ptr %85, align 8, !tbaa !12
  %87 = call double @llvm.fmuladd.f64(double %79, double %86, double %78)
  %88 = load double, ptr %13, align 8, !tbaa !12
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.DERIV_TYPE, ptr %89, i64 2
  %91 = getelementptr inbounds %struct.DERIV_TYPE, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %14, align 4, !tbaa !13
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [3 x double], ptr %91, i64 0, i64 %93
  %95 = load double, ptr %94, align 8, !tbaa !12
  %96 = call double @llvm.fmuladd.f64(double %88, double %95, double %87)
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.DERIV_TYPE, ptr %97, i32 0, i32 1
  %99 = load i32, ptr %14, align 4, !tbaa !13
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [3 x double], ptr %98, i64 0, i64 %100
  store double %96, ptr %101, align 8, !tbaa !12
  br label %102

102:                                              ; preds = %42
  %103 = load i32, ptr %14, align 4, !tbaa !13
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %14, align 4, !tbaa !13
  br label %39, !llvm.loop !15

105:                                              ; preds = %39
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.DERIV_TYPE, ptr %106, i64 0
  %108 = getelementptr inbounds %struct.DERIV_TYPE, ptr %107, i32 0, i32 0
  %109 = load double, ptr %108, align 8, !tbaa !9
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.DERIV_TYPE, ptr %110, i64 0
  %112 = getelementptr inbounds %struct.DERIV_TYPE, ptr %111, i32 0, i32 0
  %113 = load double, ptr %112, align 8, !tbaa !9
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.DERIV_TYPE, ptr %114, i64 1
  %116 = getelementptr inbounds %struct.DERIV_TYPE, ptr %115, i32 0, i32 0
  %117 = load double, ptr %116, align 8, !tbaa !9
  %118 = load ptr, ptr %6, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.DERIV_TYPE, ptr %118, i64 1
  %120 = getelementptr inbounds %struct.DERIV_TYPE, ptr %119, i32 0, i32 0
  %121 = load double, ptr %120, align 8, !tbaa !9
  %122 = fmul double %117, %121
  %123 = call double @llvm.fmuladd.f64(double %109, double %113, double %122)
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.DERIV_TYPE, ptr %124, i64 2
  %126 = getelementptr inbounds %struct.DERIV_TYPE, ptr %125, i32 0, i32 0
  %127 = load double, ptr %126, align 8, !tbaa !9
  %128 = load ptr, ptr %6, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.DERIV_TYPE, ptr %128, i64 2
  %130 = getelementptr inbounds %struct.DERIV_TYPE, ptr %129, i32 0, i32 0
  %131 = load double, ptr %130, align 8, !tbaa !9
  %132 = call double @llvm.fmuladd.f64(double %127, double %131, double %123)
  %133 = load ptr, ptr %4, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.DERIV_TYPE, ptr %133, i32 0, i32 0
  store double %132, ptr %134, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 0
}

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 = { 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 = !{!"DERIV_TYPE", !11, i64 0, !7, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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 i32 @g_ad_dDot(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %1, i64 64
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 64
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 32
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 32
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = load double, ptr %1, align 8, !tbaa !5
  %13 = load double, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = getelementptr inbounds i8, ptr %2, i64 8
  %16 = getelementptr inbounds i8, ptr %1, i64 40
  %17 = getelementptr inbounds i8, ptr %2, i64 40
  %18 = getelementptr inbounds i8, ptr %1, i64 72
  %19 = getelementptr inbounds i8, ptr %2, i64 72
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load double, ptr %14, align 8, !tbaa !10
  %22 = load double, ptr %15, align 8, !tbaa !10
  %23 = fmul double %12, %22
  %24 = tail call double @llvm.fmuladd.f64(double %13, double %21, double %23)
  %25 = load double, ptr %16, align 8, !tbaa !10
  %26 = tail call double @llvm.fmuladd.f64(double %11, double %25, double %24)
  %27 = load double, ptr %17, align 8, !tbaa !10
  %28 = tail call double @llvm.fmuladd.f64(double %9, double %27, double %26)
  %29 = load double, ptr %18, align 8, !tbaa !10
  %30 = tail call double @llvm.fmuladd.f64(double %7, double %29, double %28)
  %31 = load double, ptr %19, align 8, !tbaa !10
  %32 = tail call double @llvm.fmuladd.f64(double %5, double %31, double %30)
  store double %32, ptr %20, align 8, !tbaa !10
  %33 = getelementptr inbounds i8, ptr %1, i64 16
  %34 = load double, ptr %33, align 8, !tbaa !10
  %35 = getelementptr inbounds i8, ptr %2, i64 16
  %36 = load double, ptr %35, align 8, !tbaa !10
  %37 = fmul double %12, %36
  %38 = tail call double @llvm.fmuladd.f64(double %13, double %34, double %37)
  %39 = getelementptr inbounds i8, ptr %1, i64 48
  %40 = load double, ptr %39, align 8, !tbaa !10
  %41 = tail call double @llvm.fmuladd.f64(double %11, double %40, double %38)
  %42 = getelementptr inbounds i8, ptr %2, i64 48
  %43 = load double, ptr %42, align 8, !tbaa !10
  %44 = tail call double @llvm.fmuladd.f64(double %9, double %43, double %41)
  %45 = getelementptr inbounds i8, ptr %1, i64 80
  %46 = load double, ptr %45, align 8, !tbaa !10
  %47 = tail call double @llvm.fmuladd.f64(double %7, double %46, double %44)
  %48 = getelementptr inbounds i8, ptr %2, i64 80
  %49 = load double, ptr %48, align 8, !tbaa !10
  %50 = tail call double @llvm.fmuladd.f64(double %5, double %49, double %47)
  %51 = getelementptr inbounds i8, ptr %0, i64 16
  store double %50, ptr %51, align 8, !tbaa !10
  %52 = getelementptr inbounds i8, ptr %1, i64 24
  %53 = load double, ptr %52, align 8, !tbaa !10
  %54 = getelementptr inbounds i8, ptr %2, i64 24
  %55 = load double, ptr %54, align 8, !tbaa !10
  %56 = fmul double %12, %55
  %57 = tail call double @llvm.fmuladd.f64(double %13, double %53, double %56)
  %58 = getelementptr inbounds i8, ptr %1, i64 56
  %59 = load double, ptr %58, align 8, !tbaa !10
  %60 = tail call double @llvm.fmuladd.f64(double %11, double %59, double %57)
  %61 = getelementptr inbounds i8, ptr %2, i64 56
  %62 = load double, ptr %61, align 8, !tbaa !10
  %63 = tail call double @llvm.fmuladd.f64(double %9, double %62, double %60)
  %64 = getelementptr inbounds i8, ptr %1, i64 88
  %65 = load double, ptr %64, align 8, !tbaa !10
  %66 = tail call double @llvm.fmuladd.f64(double %7, double %65, double %63)
  %67 = getelementptr inbounds i8, ptr %2, i64 88
  %68 = load double, ptr %67, align 8, !tbaa !10
  %69 = tail call double @llvm.fmuladd.f64(double %5, double %68, double %66)
  %70 = getelementptr inbounds i8, ptr %0, i64 24
  store double %69, ptr %70, align 8, !tbaa !10
  %71 = load double, ptr %1, align 8, !tbaa !5
  %72 = load double, ptr %2, align 8, !tbaa !5
  %73 = load double, ptr %8, align 8, !tbaa !5
  %74 = load double, ptr %10, align 8, !tbaa !5
  %75 = fmul double %73, %74
  %76 = tail call double @llvm.fmuladd.f64(double %71, double %72, double %75)
  %77 = load double, ptr %4, align 8, !tbaa !5
  %78 = load double, ptr %6, align 8, !tbaa !5
  %79 = tail call double @llvm.fmuladd.f64(double %77, double %78, double %76)
  store double %79, ptr %0, align 8, !tbaa !5
  ret i32 0
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass