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

; 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.R3MeshProperty = type { ptr, [1024 x i8], i32, ptr, double, double, double, double, double, 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 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: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK14R3MeshProperty3DotERKS_(ptr noundef nonnull align 8 dereferenceable(1096) %0, ptr noundef nonnull align 8 dereferenceable(1096) %1) #2 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %struct.R3MeshProperty, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = icmp ne i32 %10, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store double 0.000000e+00, ptr %3, align 8
  br label %53

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !14
  br label %17

17:                                               ; preds = %48, %16
  %18 = load i32, ptr %7, align 4, !tbaa !14
  %19 = getelementptr inbounds %struct.R3MeshProperty, ptr %8, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %51

23:                                               ; preds = %17
  %24 = getelementptr inbounds %struct.R3MeshProperty, ptr %8, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load i32, ptr %7, align 4, !tbaa !14
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !13
  %30 = fcmp oeq double %29, -1.000000e+00
  br i1 %30, label %31, label %32

31:                                               ; preds = %23
  br label %48

32:                                               ; preds = %23
  %33 = getelementptr inbounds %struct.R3MeshProperty, ptr %8, i32 0, i32 3
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load i32, ptr %7, align 4, !tbaa !14
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %34, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.R3MeshProperty, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = load i32, ptr %7, align 4, !tbaa !14
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds double, ptr %41, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !13
  %46 = load double, ptr %6, align 8, !tbaa !13
  %47 = call double @llvm.fmuladd.f64(double %38, double %45, double %46)
  store double %47, ptr %6, align 8, !tbaa !13
  br label %48

48:                                               ; preds = %32, %31
  %49 = load i32, ptr %7, align 4, !tbaa !14
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %7, align 4, !tbaa !14
  br label %17, !llvm.loop !16

51:                                               ; preds = %22
  %52 = load double, ptr %6, align 8, !tbaa !13
  store double %52, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %53

53:                                               ; preds = %51, %15
  %54 = load double, ptr %3, align 8
  ret double %54
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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++ TBAA"}
!9 = !{!10, !11, i64 1032}
!10 = !{!"_ZTS14R3MeshProperty", !6, i64 0, !7, i64 8, !11, i64 1032, !6, i64 1040, !12, i64 1048, !12, i64 1056, !12, i64 1064, !12, i64 1072, !12, i64 1080, !12, i64 1088}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 1040}
!16 = distinct !{!16, !17}
!17 = !{!"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(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZNK14R3MeshProperty3DotERKS_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(1096) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(1096) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1032
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 1032
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %4, %6
  %7 = icmp sgt i32 %4, 0
  %or.cond = and i1 %.not, %7
  br i1 %or.cond, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 1040
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %1, i64 1040
  %11 = load ptr, ptr %10, align 8
  %wide.trip.count = zext nneg i32 %4 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %12 = icmp eq i32 %4, 1
  br i1 %12, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.new

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

13:                                               ; preds = %29, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %29 ]
  %.01013 = phi double [ 0.000000e+00, %.lr.ph.new ], [ %.1.1, %29 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %29 ]
  %14 = getelementptr inbounds double, ptr %9, i64 %indvars.iv
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = fcmp oeq double %15, -1.000000e+00
  br i1 %16, label %21, label %17

17:                                               ; preds = %13
  %18 = getelementptr inbounds double, ptr %11, i64 %indvars.iv
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = tail call double @llvm.fmuladd.f64(double %15, double %19, double %.01013)
  br label %21

21:                                               ; preds = %13, %17
  %.1 = phi double [ %.01013, %13 ], [ %20, %17 ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %22 = getelementptr inbounds double, ptr %9, i64 %indvars.iv.next
  %23 = load double, ptr %22, align 8, !tbaa !13
  %24 = fcmp oeq double %23, -1.000000e+00
  br i1 %24, label %29, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds double, ptr %11, i64 %indvars.iv.next
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = tail call double @llvm.fmuladd.f64(double %23, double %27, double %.1)
  br label %29

29:                                               ; preds = %25, %21
  %.1.1 = phi double [ %.1, %21 ], [ %28, %25 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %13, !llvm.loop !14

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

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa
  %30 = getelementptr inbounds double, ptr %9, i64 %indvars.iv.unr
  %31 = load double, ptr %30, align 8, !tbaa !13
  %32 = fcmp oeq double %31, -1.000000e+00
  br i1 %32, label %.loopexit, label %33

33:                                               ; preds = %.epil.preheader
  %34 = getelementptr inbounds double, ptr %11, i64 %indvars.iv.unr
  %35 = load double, ptr %34, align 8, !tbaa !13
  %36 = tail call double @llvm.fmuladd.f64(double %31, double %35, double %.01013.unr)
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %33, %.epil.preheader, %2
  %.011 = phi double [ 0.000000e+00, %2 ], [ %.1.lcssa.ph, %.loopexit.loopexit.unr-lcssa ], [ %.01013.unr, %.epil.preheader ], [ %36, %33 ]
  ret double %.011
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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, !10, i64 1032}
!6 = !{!"_ZTS14R3MeshProperty", !7, i64 0, !8, i64 8, !10, i64 1032, !7, i64 1040, !11, i64 1048, !11, i64 1056, !11, i64 1064, !11, i64 1072, !11, i64 1080, !11, i64 1088}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 1040}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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