; 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_dNegDot(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 = %103, %3
  %40 = load i32, ptr %14, align 4, !tbaa !13
  %41 = icmp slt i32 %40, 3
  br i1 %41, label %42, label %106

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 = fneg double %96
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.DERIV_TYPE, ptr %98, i32 0, i32 1
  %100 = load i32, ptr %14, align 4, !tbaa !13
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [3 x double], ptr %99, i64 0, i64 %101
  store double %97, ptr %102, align 8, !tbaa !12
  br label %103

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

106:                                              ; preds = %39
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.DERIV_TYPE, ptr %107, i64 0
  %109 = getelementptr inbounds %struct.DERIV_TYPE, ptr %108, i32 0, i32 0
  %110 = load double, ptr %109, align 8, !tbaa !9
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.DERIV_TYPE, ptr %111, i64 0
  %113 = getelementptr inbounds %struct.DERIV_TYPE, ptr %112, i32 0, i32 0
  %114 = load double, ptr %113, align 8, !tbaa !9
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.DERIV_TYPE, ptr %115, i64 1
  %117 = getelementptr inbounds %struct.DERIV_TYPE, ptr %116, i32 0, i32 0
  %118 = load double, ptr %117, align 8, !tbaa !9
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.DERIV_TYPE, ptr %119, i64 1
  %121 = getelementptr inbounds %struct.DERIV_TYPE, ptr %120, i32 0, i32 0
  %122 = load double, ptr %121, align 8, !tbaa !9
  %123 = fmul double %118, %122
  %124 = call double @llvm.fmuladd.f64(double %110, double %114, double %123)
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.DERIV_TYPE, ptr %125, i64 2
  %127 = getelementptr inbounds %struct.DERIV_TYPE, ptr %126, i32 0, i32 0
  %128 = load double, ptr %127, align 8, !tbaa !9
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.DERIV_TYPE, ptr %129, i64 2
  %131 = getelementptr inbounds %struct.DERIV_TYPE, ptr %130, i32 0, i32 0
  %132 = load double, ptr %131, align 8, !tbaa !9
  %133 = call double @llvm.fmuladd.f64(double %128, double %132, double %124)
  %134 = fneg double %133
  %135 = load ptr, ptr %4, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.DERIV_TYPE, ptr %135, i32 0, i32 0
  store double %134, ptr %136, 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_dNegDot(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)
  %33 = fneg double %32
  store double %33, ptr %20, align 8, !tbaa !10
  %34 = getelementptr inbounds i8, ptr %1, i64 16
  %35 = load double, ptr %34, align 8, !tbaa !10
  %36 = getelementptr inbounds i8, ptr %2, i64 16
  %37 = load double, ptr %36, align 8, !tbaa !10
  %38 = fmul double %12, %37
  %39 = tail call double @llvm.fmuladd.f64(double %13, double %35, double %38)
  %40 = getelementptr inbounds i8, ptr %1, i64 48
  %41 = load double, ptr %40, align 8, !tbaa !10
  %42 = tail call double @llvm.fmuladd.f64(double %11, double %41, double %39)
  %43 = getelementptr inbounds i8, ptr %2, i64 48
  %44 = load double, ptr %43, align 8, !tbaa !10
  %45 = tail call double @llvm.fmuladd.f64(double %9, double %44, double %42)
  %46 = getelementptr inbounds i8, ptr %1, i64 80
  %47 = load double, ptr %46, align 8, !tbaa !10
  %48 = tail call double @llvm.fmuladd.f64(double %7, double %47, double %45)
  %49 = getelementptr inbounds i8, ptr %2, i64 80
  %50 = load double, ptr %49, align 8, !tbaa !10
  %51 = tail call double @llvm.fmuladd.f64(double %5, double %50, double %48)
  %52 = fneg double %51
  %53 = getelementptr inbounds i8, ptr %0, i64 16
  store double %52, ptr %53, align 8, !tbaa !10
  %54 = getelementptr inbounds i8, ptr %1, i64 24
  %55 = load double, ptr %54, align 8, !tbaa !10
  %56 = getelementptr inbounds i8, ptr %2, i64 24
  %57 = load double, ptr %56, align 8, !tbaa !10
  %58 = fmul double %12, %57
  %59 = tail call double @llvm.fmuladd.f64(double %13, double %55, double %58)
  %60 = getelementptr inbounds i8, ptr %1, i64 56
  %61 = load double, ptr %60, align 8, !tbaa !10
  %62 = tail call double @llvm.fmuladd.f64(double %11, double %61, double %59)
  %63 = getelementptr inbounds i8, ptr %2, i64 56
  %64 = load double, ptr %63, align 8, !tbaa !10
  %65 = tail call double @llvm.fmuladd.f64(double %9, double %64, double %62)
  %66 = getelementptr inbounds i8, ptr %1, i64 88
  %67 = load double, ptr %66, align 8, !tbaa !10
  %68 = tail call double @llvm.fmuladd.f64(double %7, double %67, double %65)
  %69 = getelementptr inbounds i8, ptr %2, i64 88
  %70 = load double, ptr %69, align 8, !tbaa !10
  %71 = tail call double @llvm.fmuladd.f64(double %5, double %70, double %68)
  %72 = fneg double %71
  %73 = getelementptr inbounds i8, ptr %0, i64 24
  store double %72, ptr %73, align 8, !tbaa !10
  %74 = load double, ptr %1, align 8, !tbaa !5
  %75 = load double, ptr %2, align 8, !tbaa !5
  %76 = load double, ptr %8, align 8, !tbaa !5
  %77 = load double, ptr %10, align 8, !tbaa !5
  %78 = fmul double %76, %77
  %79 = tail call double @llvm.fmuladd.f64(double %74, double %75, double %78)
  %80 = load double, ptr %4, align 8, !tbaa !5
  %81 = load double, ptr %6, align 8, !tbaa !5
  %82 = tail call double @llvm.fmuladd.f64(double %80, double %81, double %79)
  %83 = fneg double %82
  store double %83, 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