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

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

@.str.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [16 x i8], align 1

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

declare i32 @SMerror(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #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 @vNormJacSquared(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca [3 x double], align 16
  %16 = alloca [3 x double], align 16
  %17 = alloca [3 x double], align 16
  %18 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #3
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i64 0
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 0
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = fsub double %21, %24
  %26 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  store double %25, ptr %26, align 16, !tbaa !9
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds double, ptr %27, i64 1
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 1
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = fsub double %29, %32
  %34 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 1
  store double %33, ptr %34, align 8, !tbaa !9
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 2
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 2
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = fsub double %37, %40
  %42 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 2
  store double %41, ptr %42, align 16, !tbaa !9
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %43, i64 0
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds double, ptr %46, i64 0
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = fsub double %45, %48
  %50 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  store double %49, ptr %50, align 16, !tbaa !9
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = getelementptr inbounds double, ptr %51, i64 1
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %54, i64 1
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = fsub double %53, %56
  %58 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 1
  store double %57, ptr %58, align 8, !tbaa !9
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 2
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %62, i64 2
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = fsub double %61, %64
  %66 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 2
  store double %65, ptr %66, align 16, !tbaa !9
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 0
  %69 = load double, ptr %68, align 8, !tbaa !9
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds double, ptr %70, i64 0
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = fsub double %69, %72
  %74 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  store double %73, ptr %74, align 16, !tbaa !9
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds double, ptr %75, i64 1
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds double, ptr %78, i64 1
  %80 = load double, ptr %79, align 8, !tbaa !9
  %81 = fsub double %77, %80
  %82 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 1
  store double %81, ptr %82, align 8, !tbaa !9
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = getelementptr inbounds double, ptr %83, i64 2
  %85 = load double, ptr %84, align 8, !tbaa !9
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds double, ptr %86, i64 2
  %88 = load double, ptr %87, align 8, !tbaa !9
  %89 = fsub double %85, %88
  %90 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 2
  store double %89, ptr %90, align 16, !tbaa !9
  %91 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  %92 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  %93 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds double, ptr %94, i64 0
  %96 = call i32 @SMfrobenius_norm_squared3x3(ptr noundef %91, ptr noundef %92, ptr noundef %93, ptr noundef %95)
  store i32 %96, ptr %14, align 4, !tbaa !11
  %97 = load i32, ptr %14, align 4, !tbaa !11
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %102

99:                                               ; preds = %6
  %100 = load i32, ptr %14, align 4, !tbaa !11
  %101 = call i32 @SMerror(i32 noundef 670, ptr noundef @.str.23, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %100, i32 noundef 0, ptr noundef null)
  store i32 %101, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %108

102:                                              ; preds = %6
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds double, ptr %103, i64 0
  %105 = load double, ptr %104, align 8, !tbaa !9
  %106 = fmul double %105, -1.000000e+00
  store double %106, ptr %104, align 8, !tbaa !9
  %107 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 1, ptr %107, align 4, !tbaa !11
  store i32 0, ptr %14, align 4, !tbaa !11
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %108

108:                                              ; preds = %102, %99
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %109 = load i32, ptr %7, align 4
  ret i32 %109
}

declare i32 @SMfrobenius_norm_squared3x3(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

@.str.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [16 x i8], align 1

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

declare i32 @SMerror(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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 @vNormJacSquared(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr noundef %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #2 {
  %7 = alloca [3 x double], align 16
  %8 = alloca [3 x double], align 16
  %9 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #3
  %10 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %11 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %12 = fsub <2 x double> %10, %11
  store <2 x double> %12, ptr %7, align 16, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fsub double %14, %16
  %18 = getelementptr inbounds i8, ptr %7, i64 16
  store double %17, ptr %18, align 16, !tbaa !5
  %19 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %20 = fsub <2 x double> %19, %11
  store <2 x double> %20, ptr %8, align 16, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %2, i64 16
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = fsub double %22, %16
  %24 = getelementptr inbounds i8, ptr %8, i64 16
  store double %23, ptr %24, align 16, !tbaa !5
  %25 = load <2 x double>, ptr %3, align 8, !tbaa !5
  %26 = fsub <2 x double> %25, %11
  store <2 x double> %26, ptr %9, align 16, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %3, i64 16
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fsub double %28, %16
  %30 = getelementptr inbounds i8, ptr %9, i64 16
  store double %29, ptr %30, align 16, !tbaa !5
  %31 = call i32 @SMfrobenius_norm_squared3x3(ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef %4) #3
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %34, label %32

32:                                               ; preds = %6
  %33 = call i32 @SMerror(i32 noundef 670, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef %31, i32 noundef 0, ptr noundef null) #3
  br label %37

34:                                               ; preds = %6
  %35 = load double, ptr %4, align 8, !tbaa !5
  %36 = fneg double %35
  store double %36, ptr %4, align 8, !tbaa !5
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %34, %32
  %.0 = phi i32 [ %33, %32 ], [ 0, %34 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  ret i32 %.0
}

declare i32 @SMfrobenius_norm_squared3x3(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass