; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

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

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @r8mat_solve_2d(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds double, ptr %10, i64 0
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %13, i64 3
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 2
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i64 1
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = fmul double %18, %21
  %23 = fneg double %22
  %24 = call double @llvm.fmuladd.f64(double %12, double %15, double %23)
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  store double %24, ptr %25, align 8, !tbaa !9
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fcmp oeq double %27, 0.000000e+00
  br i1 %28, label %29, label %30

29:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %73

30:                                               ; preds = %3
  %31 = call noalias ptr @malloc(i64 noundef 16) #5
  store ptr %31, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 3
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 0
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 2
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %41, i64 1
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fmul double %40, %43
  %45 = fneg double %44
  %46 = call double @llvm.fmuladd.f64(double %34, double %37, double %45)
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = fdiv double %46, %48
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds double, ptr %50, i64 0
  store double %49, ptr %51, align 8, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds double, ptr %52, i64 1
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = fneg double %54
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds double, ptr %56, i64 0
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 0
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %62, i64 1
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = fmul double %61, %64
  %66 = call double @llvm.fmuladd.f64(double %55, double %58, double %65)
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load double, ptr %67, align 8, !tbaa !9
  %69 = fdiv double %66, %68
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds double, ptr %70, i64 1
  store double %69, ptr %71, align 8, !tbaa !9
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %72, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %73

73:                                               ; preds = %30, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %74 = load ptr, ptr %4, align 8
  ret ptr %74
}

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

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


; 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 nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @r8mat_solve_2d(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fneg double %8
  %12 = fmul double %10, %11
  %13 = tail call double @llvm.fmuladd.f64(double %4, double %6, double %12)
  store double %13, ptr %2, align 8, !tbaa !5
  %14 = fcmp oeq double %13, 0.000000e+00
  br i1 %14, label %39, label %15

15:                                               ; preds = %3
  %16 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #4
  %17 = load double, ptr %5, align 8, !tbaa !5
  %18 = load double, ptr %1, align 8, !tbaa !5
  %19 = load double, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = fneg double %19
  %23 = load double, ptr %9, align 8, !tbaa !5
  %24 = fneg double %23
  %25 = load double, ptr %0, align 8, !tbaa !5
  %26 = insertelement <2 x double> poison, double %21, i64 0
  %27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
  %28 = insertelement <2 x double> poison, double %22, i64 0
  %29 = insertelement <2 x double> %28, double %25, i64 1
  %30 = fmul <2 x double> %27, %29
  %31 = insertelement <2 x double> poison, double %17, i64 0
  %32 = insertelement <2 x double> %31, double %24, i64 1
  %33 = insertelement <2 x double> poison, double %18, i64 0
  %34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
  %35 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %34, <2 x double> %30)
  %36 = insertelement <2 x double> poison, double %13, i64 0
  %37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
  %38 = fdiv <2 x double> %35, %37
  store <2 x double> %38, ptr %16, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %3, %15
  %.0 = phi ptr [ %16, %15 ], [ null, %3 ]
  ret ptr %.0
}

; 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>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind allocsize(0) }

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


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