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

; 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.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }
%class.R3Mesh = type { ptr, %class.RNArray, %class.RNArray.0, %class.RNArray.1, ptr, ptr, ptr, [128 x i8], %class.R3Box, ptr }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.RNArray.0 = type { %class.RNVArray }
%class.RNArray.1 = type { %class.RNVArray }

@_ZTV6R3Mesh = external dso_local unnamed_addr constant { [82 x ptr] }, align 8
@R3null_box = external global %class.R3Box, align 8
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3MeshC2Ev(ptr noundef nonnull align 8 dereferenceable(272) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 640) ({ [82 x ptr] }, ptr @_ZTV6R3Mesh, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 1
  call void @_ZN7RNArrayIP12R3MeshVertexEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %7 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 2
  invoke void @_ZN7RNArrayIP10R3MeshEdgeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7)
          to label %8 unwind label %27

8:                                                ; preds = %1
  %9 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 3
  invoke void @_ZN7RNArrayIP10R3MeshFaceEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %10 unwind label %31

10:                                               ; preds = %8
  %11 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 4
  store ptr null, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 5
  store ptr null, ptr %12, align 8, !tbaa !22
  %13 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 6
  store ptr null, ptr %13, align 8, !tbaa !23
  %14 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 8
  invoke void @_ZN5R3BoxC1ERKS_(ptr noundef nonnull align 8 dereferenceable(56) %14, ptr noundef nonnull align 8 dereferenceable(56) @R3null_box)
          to label %15 unwind label %35

15:                                               ; preds = %10
  %16 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 9
  store ptr null, ptr %16, align 8, !tbaa !24
  %17 = getelementptr inbounds %class.R3Mesh, ptr %5, i32 0, i32 7
  %18 = getelementptr inbounds [128 x i8], ptr %17, i64 0, i64 0
  store i8 0, ptr %18, align 8, !tbaa !25
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %19, i64 66
  %21 = load ptr, ptr %20, align 8
  %22 = invoke noundef i32 %21(ptr noundef nonnull align 8 dereferenceable(272) %5)
          to label %23 unwind label %39

23:                                               ; preds = %15
  %24 = icmp ne i32 %22, 0
  br i1 %24, label %43, label %25

25:                                               ; preds = %23
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 35, ptr noundef @.str.2)
          to label %26 unwind label %39

26:                                               ; preds = %25
  br label %43

27:                                               ; preds = %1
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %3, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %4, align 4
  br label %46

31:                                               ; preds = %8
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %3, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %4, align 4
  br label %45

35:                                               ; preds = %10
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %3, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %4, align 4
  br label %44

39:                                               ; preds = %25, %15
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %3, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %4, align 4
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %14) #3
  br label %44

43:                                               ; preds = %26, %23
  ret void

44:                                               ; preds = %39, %35
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  br label %45

45:                                               ; preds = %44, %31
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  br label %46

46:                                               ; preds = %45, %27
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #3
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %3, align 8
  %49 = load i32, ptr %4, align 4
  %50 = insertvalue { ptr, i32 } poison, ptr %48, 0
  %51 = insertvalue { ptr, i32 } %50, i32 %49, 1
  resume { ptr, i32 } %51
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP12R3MeshVertexEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP10R3MeshEdgeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP10R3MeshFaceEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

declare void @_ZN5R3BoxC1ERKS_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #1

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

; Function Attrs: nounwind
declare void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

attributes #0 = { 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 = { "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 "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, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 56}
!12 = !{!"_ZTS6R3Mesh", !13, i64 8, !16, i64 24, !17, i64 40, !6, i64 56, !6, i64 64, !6, i64 72, !7, i64 80, !18, i64 208, !6, i64 264}
!13 = !{!"_ZTS7RNArrayIP12R3MeshVertexE", !14, i64 0}
!14 = !{!"_ZTS8RNVArray", !6, i64 0, !15, i64 8, !15, i64 12}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS7RNArrayIP10R3MeshEdgeE", !14, i64 0}
!17 = !{!"_ZTS7RNArrayIP10R3MeshFaceE", !14, i64 0}
!18 = !{!"_ZTS5R3Box", !19, i64 0, !21, i64 8, !21, i64 32}
!19 = !{!"_ZTS7R3Solid", !20, i64 0}
!20 = !{!"_ZTS7R3Shape"}
!21 = !{!"_ZTS7R3Point", !7, i64 0}
!22 = !{!12, !6, i64 64}
!23 = !{!12, !6, i64 72}
!24 = !{!12, !6, i64 264}
!25 = !{!7, !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"

%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }

@_ZTV6R3Mesh = external dso_local unnamed_addr constant { [82 x ptr] }, align 8
@R3null_box = external global %class.R3Box, align 8
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3MeshC2Ev(ptr noundef nonnull align 8 dereferenceable(272) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 640) (i8, ptr @_ZTV6R3Mesh, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN7RNArrayIP12R3MeshVertexEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  invoke void @_ZN7RNArrayIP10R3MeshEdgeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %4 unwind label %18

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  invoke void @_ZN7RNArrayIP10R3MeshFaceEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %6 unwind label %20

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = getelementptr inbounds i8, ptr %0, i64 208
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %7, i8 0, i64 24, i1 false)
  invoke void @_ZN5R3BoxC1ERKS_(ptr noundef nonnull align 8 dereferenceable(56) %8, ptr noundef nonnull align 8 dereferenceable(56) @R3null_box)
          to label %9 unwind label %22

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 264
  store ptr null, ptr %10, align 8, !tbaa !8
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  store i8 0, ptr %11, align 8, !tbaa !21
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 528
  %14 = load ptr, ptr %13, align 8
  %15 = invoke noundef i32 %14(ptr noundef nonnull align 8 dereferenceable(272) %0)
          to label %16 unwind label %24

16:                                               ; preds = %9
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %17, label %26

17:                                               ; preds = %16
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 35, ptr noundef nonnull @.str.2)
          to label %26 unwind label %24

18:                                               ; preds = %1
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %29

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

22:                                               ; preds = %6
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %27

24:                                               ; preds = %17, %9
  %25 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %8) #4
  br label %27

26:                                               ; preds = %17, %16
  ret void

27:                                               ; preds = %24, %22
  %.pn = phi { ptr, i32 } [ %25, %24 ], [ %23, %22 ]
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  br label %28

28:                                               ; preds = %27, %20
  %.pn.pn = phi { ptr, i32 } [ %.pn, %27 ], [ %21, %20 ]
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  br label %29

29:                                               ; preds = %28, %18
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %28 ], [ %19, %18 ]
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  resume { ptr, i32 } %.pn.pn.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP12R3MeshVertexEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP10R3MeshEdgeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7RNArrayIP10R3MeshFaceEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

declare void @_ZN5R3BoxC1ERKS_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #1

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

; Function Attrs: nounwind
declare void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { 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 = { "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 "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 nounwind willreturn memory(argmem: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 264}
!9 = !{!"_ZTS6R3Mesh", !10, i64 8, !15, i64 24, !16, i64 40, !12, i64 56, !12, i64 64, !12, i64 72, !13, i64 80, !17, i64 208, !12, i64 264}
!10 = !{!"_ZTS7RNArrayIP12R3MeshVertexE", !11, i64 0}
!11 = !{!"_ZTS8RNVArray", !12, i64 0, !14, i64 8, !14, i64 12}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !7, i64 0}
!14 = !{!"int", !13, i64 0}
!15 = !{!"_ZTS7RNArrayIP10R3MeshEdgeE", !11, i64 0}
!16 = !{!"_ZTS7RNArrayIP10R3MeshFaceE", !11, i64 0}
!17 = !{!"_ZTS5R3Box", !18, i64 0, !20, i64 8, !20, i64 32}
!18 = !{!"_ZTS7R3Solid", !19, i64 0}
!19 = !{!"_ZTS7R3Shape"}
!20 = !{!"_ZTS7R3Point", !13, i64 0}
!21 = !{!13, !13, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass