; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Grid.ll (ZNK6R3Grid3DotERKS_)

; 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.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [48 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK6R3Grid3DotERKS_(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 8 dereferenceable(592) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %class.R3Grid, ptr %7, i32 0, i32 5
  %9 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 0
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.R3Grid, ptr %11, i32 0, i32 5
  %13 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp eq i32 %10, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %2
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.16, i32 noundef 2774, ptr noundef @.str.2)
  br label %17

17:                                               ; preds = %16, %2
  %18 = getelementptr inbounds %class.R3Grid, ptr %7, i32 0, i32 5
  %19 = getelementptr inbounds [3 x i32], ptr %18, i64 0, i64 1
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.R3Grid, ptr %21, i32 0, i32 5
  %23 = getelementptr inbounds [3 x i32], ptr %22, i64 0, i64 1
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = icmp eq i32 %20, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %17
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.17, i32 noundef 2775, ptr noundef @.str.2)
  br label %27

27:                                               ; preds = %26, %17
  %28 = getelementptr inbounds %class.R3Grid, ptr %7, i32 0, i32 5
  %29 = getelementptr inbounds [3 x i32], ptr %28, i64 0, i64 2
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %class.R3Grid, ptr %31, i32 0, i32 5
  %33 = getelementptr inbounds [3 x i32], ptr %32, i64 0, i64 2
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = icmp eq i32 %30, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %27
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.18, i32 noundef 2776, ptr noundef @.str.2)
  br label %37

37:                                               ; preds = %36, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %60, %37
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = getelementptr inbounds %class.R3Grid, ptr %7, i32 0, i32 8
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = icmp slt i32 %39, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %63

44:                                               ; preds = %38
  %45 = getelementptr inbounds %class.R3Grid, ptr %7, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !20
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %46, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %class.R3Grid, ptr %51, i32 0, i32 4
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds double, ptr %53, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !11
  %58 = load double, ptr %5, align 8, !tbaa !11
  %59 = call double @llvm.fmuladd.f64(double %50, double %57, double %58)
  store double %59, ptr %5, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %44
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %6, align 4, !tbaa !9
  br label %38, !llvm.loop !21

63:                                               ; preds = %43
  %64 = load double, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret double %64
}

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

!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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 588}
!14 = !{!"_ZTS6R3Grid", !15, i64 0, !15, i64 272, !12, i64 544, !12, i64 552, !6, i64 560, !7, i64 568, !10, i64 580, !10, i64 584, !10, i64 588}
!15 = !{!"_ZTS8R3Affine", !16, i64 0, !17, i64 8, !17, i64 136, !18, i64 264}
!16 = !{!"_ZTS16R3Transformation"}
!17 = !{!"_ZTS8R4Matrix", !7, i64 0}
!18 = !{!"_ZTS7RNFlags", !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!14, !6, i64 560}
!21 = distinct !{!21, !22}
!22 = !{!"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"

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [48 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK6R3Grid3DotERKS_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(592) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(592) %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 568
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 568
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i32 %4, %6
  br i1 %7, label %9, label %8

8:                                                ; preds = %2
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.16, i32 noundef 2774, ptr noundef nonnull @.str.2)
  br label %9

9:                                                ; preds = %8, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 572
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 572
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp eq i32 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.17, i32 noundef 2775, ptr noundef nonnull @.str.2)
  br label %16

16:                                               ; preds = %15, %9
  %17 = getelementptr inbounds i8, ptr %0, i64 576
  %18 = load i32, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 576
  %20 = load i32, ptr %19, align 8, !tbaa !5
  %21 = icmp eq i32 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.18, i32 noundef 2776, ptr noundef nonnull @.str.2)
  br label %23

23:                                               ; preds = %22, %16
  %24 = getelementptr inbounds i8, ptr %0, i64 588
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %23
  %27 = getelementptr inbounds i8, ptr %0, i64 560
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = getelementptr inbounds i8, ptr %1, i64 560
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %wide.trip.count = zext nneg i32 %25 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %31 = icmp ult i32 %25, 4
  br i1 %31, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %37

._crit_edge.loopexit.unr-lcssa:                   ; preds = %37, %.lr.ph
  %.lcssa.ph = phi double [ poison, %.lr.ph ], [ %57, %37 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %37 ]
  %.01011.unr = phi double [ 0.000000e+00, %.lr.ph ], [ %57, %37 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01011.epil = phi double [ %36, %.epil.preheader ], [ %.01011.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %32 = getelementptr inbounds double, ptr %28, i64 %indvars.iv.epil
  %33 = load double, ptr %32, align 8, !tbaa !19
  %34 = getelementptr inbounds double, ptr %30, i64 %indvars.iv.epil
  %35 = load double, ptr %34, align 8, !tbaa !19
  %36 = tail call double @llvm.fmuladd.f64(double %33, double %35, double %.01011.epil)
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !20

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %23
  %.010.lcssa = phi double [ 0.000000e+00, %23 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %36, %.epil.preheader ]
  ret double %.010.lcssa

37:                                               ; preds = %37, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %37 ]
  %.01011 = phi double [ 0.000000e+00, %.lr.ph.new ], [ %57, %37 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %37 ]
  %38 = getelementptr inbounds double, ptr %28, i64 %indvars.iv
  %39 = load double, ptr %38, align 8, !tbaa !19
  %40 = getelementptr inbounds double, ptr %30, i64 %indvars.iv
  %41 = load double, ptr %40, align 8, !tbaa !19
  %42 = tail call double @llvm.fmuladd.f64(double %39, double %41, double %.01011)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %43 = getelementptr inbounds double, ptr %28, i64 %indvars.iv.next
  %44 = load double, ptr %43, align 8, !tbaa !19
  %45 = getelementptr inbounds double, ptr %30, i64 %indvars.iv.next
  %46 = load double, ptr %45, align 8, !tbaa !19
  %47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %42)
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %48 = getelementptr inbounds double, ptr %28, i64 %indvars.iv.next.1
  %49 = load double, ptr %48, align 8, !tbaa !19
  %50 = getelementptr inbounds double, ptr %30, i64 %indvars.iv.next.1
  %51 = load double, ptr %50, align 8, !tbaa !19
  %52 = tail call double @llvm.fmuladd.f64(double %49, double %51, double %47)
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %53 = getelementptr inbounds double, ptr %28, i64 %indvars.iv.next.2
  %54 = load double, ptr %53, align 8, !tbaa !19
  %55 = getelementptr inbounds double, ptr %30, i64 %indvars.iv.next.2
  %56 = load double, ptr %55, align 8, !tbaa !19
  %57 = tail call double @llvm.fmuladd.f64(double %54, double %56, double %52)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %37, !llvm.loop !22
}

attributes #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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 588}
!10 = !{!"_ZTS6R3Grid", !11, i64 0, !11, i64 272, !16, i64 544, !16, i64 552, !17, i64 560, !7, i64 568, !6, i64 580, !6, i64 584, !6, i64 588}
!11 = !{!"_ZTS8R3Affine", !12, i64 0, !13, i64 8, !13, i64 136, !14, i64 264}
!12 = !{!"_ZTS16R3Transformation"}
!13 = !{!"_ZTS8R4Matrix", !7, i64 0}
!14 = !{!"_ZTS7RNFlags", !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!10, !17, i64 560}
!19 = !{!16, !16, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.unroll.disable"}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass