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

; 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272)) #0 align 2

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK14R3MeshProperty9LaplacianEP12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14R3MeshProperty14SetVertexValueEP12R3MeshVertexd(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef, double noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshProperty7LaplaceEv(ptr noundef nonnull align 8 dereferenceable(1096) %0) #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.R3MeshProperty, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1096, ptr %3) #4
  call void @_ZN14R3MeshPropertyC1ERKS_(ptr noundef nonnull align 8 dereferenceable(1096) %3, ptr noundef nonnull align 8 dereferenceable(1096) %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %49, %1
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = getelementptr inbounds %struct.R3MeshProperty, ptr %9, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = invoke noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %13)
          to label %15 unwind label %18

15:                                               ; preds = %10
  %16 = icmp slt i32 %11, %14
  br i1 %16, label %22, label %17

17:                                               ; preds = %15
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %53

18:                                               ; preds = %10
  %19 = landingpad { ptr, i32 }
          cleanup
  %20 = extractvalue { ptr, i32 } %19, 0
  store ptr %20, ptr %5, align 8
  %21 = extractvalue { ptr, i32 } %19, 1
  store i32 %21, ptr %6, align 4
  br label %52

22:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %23 = getelementptr inbounds %struct.R3MeshProperty, ptr %9, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = invoke noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272) %24, i32 noundef %25)
          to label %27 unwind label %36

27:                                               ; preds = %22
  store ptr %26, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.R3MeshProperty, ptr %9, i32 0, i32 3
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %29, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !15
  %34 = fcmp oeq double %33, -1.000000e+00
  br i1 %34, label %35, label %40

35:                                               ; preds = %27
  store i32 4, ptr %7, align 4
  br label %46

36:                                               ; preds = %44, %40, %22
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %5, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %52

40:                                               ; preds = %27
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = invoke noundef double @_ZNK14R3MeshProperty9LaplacianEP12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(1096) %3, ptr noundef %42)
          to label %44 unwind label %36

44:                                               ; preds = %40
  invoke void @_ZN14R3MeshProperty14SetVertexValueEP12R3MeshVertexd(ptr noundef nonnull align 8 dereferenceable(1096) %9, ptr noundef %41, double noundef %43)
          to label %45 unwind label %36

45:                                               ; preds = %44
  store i32 0, ptr %7, align 4
  br label %46

46:                                               ; preds = %45, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %47 = load i32, ptr %7, align 4
  switch i32 %47, label %65 [
    i32 0, label %48
    i32 4, label %49
  ]

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48, %46
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %4, align 4, !tbaa !9
  br label %10, !llvm.loop !16

52:                                               ; preds = %36, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %59

53:                                               ; preds = %17
  invoke void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %9)
          to label %54 unwind label %55

54:                                               ; preds = %53
  call void @_ZN14R3MeshPropertyD1Ev(ptr noundef nonnull align 8 dereferenceable(1096) %3) #4
  call void @llvm.lifetime.end.p0(i64 1096, ptr %3) #4
  ret void

55:                                               ; preds = %53
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %5, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %6, align 4
  br label %59

59:                                               ; preds = %55, %52
  call void @_ZN14R3MeshPropertyD1Ev(ptr noundef nonnull align 8 dereferenceable(1096) %3) #4
  call void @llvm.lifetime.end.p0(i64 1096, ptr %3) #4
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %5, align 8
  %62 = load i32, ptr %6, align 4
  %63 = insertvalue { ptr, i32 } poison, ptr %61, 0
  %64 = insertvalue { ptr, i32 } %63, i32 %62, 1
  resume { ptr, i32 } %64

65:                                               ; preds = %46
  unreachable
}

declare void @_ZN14R3MeshPropertyC1ERKS_(ptr, ptr)

declare void @_ZN14R3MeshPropertyD1Ev(ptr)

attributes #0 = { inlinehint 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 0}
!12 = !{!"_ZTS14R3MeshProperty", !6, i64 0, !7, i64 8, !10, i64 1032, !6, i64 1040, !13, i64 1048, !13, i64 1056, !13, i64 1064, !13, i64 1072, !13, i64 1080, !13, i64 1088}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 1040}
!15 = !{!13, !13, i64 0}
!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"

%struct.R3MeshProperty = type { ptr, [1024 x i8], i32, ptr, double, double, double, double, double, double }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK14R3MeshProperty9LaplacianEP12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14R3MeshProperty14SetVertexValueEP12R3MeshVertexd(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef, double noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshProperty7LaplaceEv(ptr noundef nonnull align 8 dereferenceable(1096) %0) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %struct.R3MeshProperty, align 8
  call void @llvm.lifetime.start.p0(i64 1096, ptr nonnull %2) #4
  call void @_ZN14R3MeshPropertyC1ERKS_(ptr noundef nonnull align 8 dereferenceable(1096) %2, ptr noundef nonnull align 8 dereferenceable(1096) %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 1040
  br label %4

4:                                                ; preds = %27, %1
  %indvars.iv = phi i64 [ %indvars.iv.next, %27 ], [ 0, %1 ]
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = invoke noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %5)
          to label %7 unwind label %11

7:                                                ; preds = %4
  %8 = sext i32 %6 to i64
  %9 = icmp slt i64 %indvars.iv, %8
  br i1 %9, label %13, label %10

10:                                               ; preds = %7
  call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %0)
  call void @_ZN14R3MeshPropertyD1Ev(ptr noundef nonnull align 8 dereferenceable(1096) %2) #4
  call void @llvm.lifetime.end.p0(i64 1096, ptr nonnull %2) #4
  ret void

11:                                               ; preds = %4
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %28

13:                                               ; preds = %7
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  %16 = invoke noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272) %14, i32 noundef %15)
          to label %17 unwind label %22

17:                                               ; preds = %13
  %18 = load ptr, ptr %3, align 8, !tbaa !12
  %19 = getelementptr inbounds double, ptr %18, i64 %indvars.iv
  %20 = load double, ptr %19, align 8, !tbaa !13
  %21 = fcmp oeq double %20, -1.000000e+00
  br i1 %21, label %27, label %24

22:                                               ; preds = %26, %24, %13
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %28

24:                                               ; preds = %17
  %25 = invoke noundef double @_ZNK14R3MeshProperty9LaplacianEP12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(1096) %2, ptr noundef %16)
          to label %26 unwind label %22

26:                                               ; preds = %24
  invoke void @_ZN14R3MeshProperty14SetVertexValueEP12R3MeshVertexd(ptr noundef nonnull align 8 dereferenceable(1096) %0, ptr noundef %16, double noundef %25)
          to label %27 unwind label %22

27:                                               ; preds = %26, %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br label %4, !llvm.loop !14

28:                                               ; preds = %22, %11
  %.pn = phi { ptr, i32 } [ %23, %22 ], [ %12, %11 ]
  call void @_ZN14R3MeshPropertyD1Ev(ptr noundef nonnull align 8 dereferenceable(1096) %2) #4
  call void @llvm.lifetime.end.p0(i64 1096, ptr nonnull %2) #4
  resume { ptr, i32 } %.pn
}

declare void @_ZN14R3MeshPropertyC1ERKS_(ptr, ptr) local_unnamed_addr

declare void @_ZN14R3MeshPropertyD1Ev(ptr) local_unnamed_addr

attributes #0 = { inlinehint 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !7, i64 0}
!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,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,SROAPass,SimplifyCFGPass