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

; 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.RNFlags = type { i64 }
%class.R3MeshEdge = type { ptr, [2 x ptr], [2 x ptr], double, i32, %class.RNFlags, double, i32, ptr }
%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 }
%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.R3MeshVertex = type { ptr, %class.RNArray.0, %class.R3Point, %class.R3Vector, %class.R2Point, %class.RNRgb, double, i32, %class.RNFlags, double, i32, ptr }
%class.R3Vector = type { [3 x double] }
%class.R2Point = type { [2 x double] }
%class.RNRgb = type { [3 x double] }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN7RNFlags3AddES_(ptr noundef nonnull align 8 dereferenceable(8), i64) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN6R3Mesh10CreateEdgeEP12R3MeshVertexS1_P10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %class.RNFlags, align 8
  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
  store ptr %3, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %26, label %15

15:                                               ; preds = %4
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 88) #4
  invoke void @_ZN10R3MeshEdgeC1Ev(ptr noundef nonnull align 8 dereferenceable(88) %16)
          to label %17 unwind label %22

17:                                               ; preds = %15
  store ptr %16, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.R3MeshEdge, ptr %18, i32 0, i32 5
  call void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8) %11, i64 noundef 1)
  %20 = getelementptr inbounds %class.RNFlags, ptr %11, i32 0, i32 0
  %21 = load i64, ptr %20, align 8
  call void @_ZN7RNFlags3AddES_(ptr noundef nonnull align 8 dereferenceable(8) %19, i64 %21)
  br label %26

22:                                               ; preds = %15
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %9, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %10, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 88) #5
  br label %51

26:                                               ; preds = %17, %4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.R3MeshEdge, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds [2 x ptr], ptr %29, i64 0, i64 0
  store ptr %27, ptr %30, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.R3MeshEdge, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds [2 x ptr], ptr %33, i64 0, i64 1
  store ptr %31, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.R3Mesh, ptr %12, i32 0, i32 2
  %36 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %35)
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.R3MeshEdge, ptr %37, i32 0, i32 4
  store i32 %36, ptr %38, align 8, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %class.R3MeshVertex, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef ptr @_ZN7RNArrayIP10R3MeshEdgeE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef %41)
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %class.R3MeshVertex, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call noundef ptr @_ZN7RNArrayIP10R3MeshEdgeE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef %45)
  %47 = getelementptr inbounds %class.R3Mesh, ptr %12, i32 0, i32 2
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = call noundef ptr @_ZN7RNArrayIP10R3MeshEdgeE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %47, ptr noundef %48)
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  ret ptr %50

51:                                               ; preds = %22
  %52 = load ptr, ptr %9, align 8
  %53 = load i32, ptr %10, align 4
  %54 = insertvalue { ptr, i32 } poison, ptr %52, 0
  %55 = insertvalue { ptr, i32 } %54, i32 %53, 1
  resume { ptr, i32 } %55
}

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

declare void @_ZN10R3MeshEdgeC1Ev(ptr)

attributes #0 = { nobuiltin 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 #1 = { inlinehint 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 #2 = { nobuiltin 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 = { 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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !12, i64 48}
!10 = !{!"_ZTS10R3MeshEdge", !7, i64 8, !7, i64 24, !11, i64 40, !12, i64 48, !13, i64 56, !11, i64 64, !12, i64 72, !6, i64 80}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS7RNFlags", !14, i64 0}
!14 = !{!"long", !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.RNFlags = type { i64 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN7RNFlags3AddES_(ptr noundef nonnull align 8 dereferenceable(8), i64) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN6R3Mesh10CreateEdgeEP12R3MeshVertexS1_P10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.RNFlags, align 8
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %6, label %13

6:                                                ; preds = %4
  %7 = tail call noalias noundef nonnull dereferenceable(88) ptr @_Znwm(i64 noundef 88) #4
  invoke void @_ZN10R3MeshEdgeC1Ev(ptr noundef nonnull align 8 dereferenceable(88) %7)
          to label %8 unwind label %11

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %7, i64 56
  call void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef 1)
  %10 = load i64, ptr %5, align 8
  call void @_ZN7RNFlags3AddES_(ptr noundef nonnull align 8 dereferenceable(8) %9, i64 %10)
  br label %13

11:                                               ; preds = %6
  %12 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 88) #5
  resume { ptr, i32 } %12

13:                                               ; preds = %8, %4
  %.0 = phi ptr [ %3, %4 ], [ %7, %8 ]
  %14 = getelementptr inbounds i8, ptr %.0, i64 8
  store ptr %1, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.0, i64 16
  store ptr %2, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  %18 = getelementptr inbounds i8, ptr %.0, i64 48
  store i32 %17, ptr %18, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = call noundef ptr @_ZN7RNArrayIP10R3MeshEdgeE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull %.0)
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  %22 = call noundef ptr @_ZN7RNArrayIP10R3MeshEdgeE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull %.0)
  %23 = call noundef ptr @_ZN7RNArrayIP10R3MeshEdgeE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull %.0)
  ret ptr %.0
}

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

declare void @_ZN10R3MeshEdgeC1Ev(ptr) local_unnamed_addr

attributes #0 = { nobuiltin 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 #1 = { inlinehint 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 #2 = { nobuiltin 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 = { 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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !12, i64 48}
!10 = !{!"_ZTS10R3MeshEdge", !7, i64 8, !7, i64 24, !11, i64 40, !12, i64 48, !13, i64 56, !11, i64 64, !12, i64 72, !6, i64 80}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS7RNFlags", !14, i64 0}
!14 = !{!"long", !7, i64 0}


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