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

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

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: mustprogress uwtable
declare dso_local void @_ZN6R3Mesh17SetVertexPositionEP12R3MeshVertexRK7R3Point(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) #2 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: mustprogress uwtable
declare dso_local noundef ptr @_ZN7RNArrayIP12R3MeshVertexE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN6R3Mesh12CreateVertexERK12R3MeshVertexPS0_(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull align 8 dereferenceable(160) %1, ptr noundef %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %class.RNFlags, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %24, label %13

13:                                               ; preds = %3
  %14 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 160) #5
  invoke void @_ZN12R3MeshVertexC1Ev(ptr noundef nonnull align 8 dereferenceable(160) %14)
          to label %15 unwind label %20

15:                                               ; preds = %13
  store ptr %14, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.R3MeshVertex, ptr %16, i32 0, i32 8
  call void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8) %9, i64 noundef 1)
  %18 = getelementptr inbounds %class.RNFlags, ptr %9, i32 0, i32 0
  %19 = load i64, ptr %18, align 8
  call void @_ZN7RNFlags3AddES_(ptr noundef nonnull align 8 dereferenceable(8) %17, i64 %19)
  br label %24

20:                                               ; preds = %13
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %7, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %8, align 4
  call void @_ZdlPvm(ptr noundef %14, i64 noundef 160) #6
  br label %51

24:                                               ; preds = %15, %3
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.R3MeshVertex, ptr %26, i32 0, i32 2
  call void @_ZN6R3Mesh17SetVertexPositionEP12R3MeshVertexRK7R3Point(ptr noundef nonnull align 8 dereferenceable(272) %10, ptr noundef %25, ptr noundef nonnull align 8 dereferenceable(24) %27)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.R3MeshVertex, ptr %28, i32 0, i32 3
  %30 = call noundef i32 @_ZNK8R3Vector6IsZeroEv(ptr noundef nonnull align 8 dereferenceable(24) %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %36, label %32

32:                                               ; preds = %24
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.R3MeshVertex, ptr %34, i32 0, i32 3
  call void @_ZN6R3Mesh15SetVertexNormalEP12R3MeshVertexRK8R3Vector(ptr noundef nonnull align 8 dereferenceable(272) %10, ptr noundef %33, ptr noundef nonnull align 8 dereferenceable(24) %35)
  br label %36

36:                                               ; preds = %32, %24
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %class.R3MeshVertex, ptr %38, i32 0, i32 5
  call void @_ZN6R3Mesh14SetVertexColorEP12R3MeshVertexRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(272) %10, ptr noundef %37, ptr noundef nonnull align 8 dereferenceable(24) %39)
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.R3MeshVertex, ptr %41, i32 0, i32 4
  call void @_ZN6R3Mesh22SetVertexTextureCoordsEP12R3MeshVertexRK7R2Point(ptr noundef nonnull align 8 dereferenceable(272) %10, ptr noundef %40, ptr noundef nonnull align 8 dereferenceable(16) %42)
  %43 = getelementptr inbounds %class.R3Mesh, ptr %10, i32 0, i32 1
  %44 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %43)
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.R3MeshVertex, ptr %45, i32 0, i32 7
  store i32 %44, ptr %46, align 8, !tbaa !9
  %47 = getelementptr inbounds %class.R3Mesh, ptr %10, i32 0, i32 1
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call noundef ptr @_ZN7RNArrayIP12R3MeshVertexE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %47, ptr noundef %48)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  ret ptr %50

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Mesh15SetVertexNormalEP12R3MeshVertexRK8R3Vector(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Mesh14SetVertexColorEP12R3MeshVertexRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Mesh22SetVertexTextureCoordsEP12R3MeshVertexRK7R2Point(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

declare void @_ZN12R3MeshVertexC1Ev(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 = { 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 #3 = { 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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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, !13, i64 120}
!10 = !{!"_ZTS12R3MeshVertex", !11, i64 8, !14, i64 24, !15, i64 48, !16, i64 72, !17, i64 88, !18, i64 112, !13, i64 120, !19, i64 128, !18, i64 136, !13, i64 144, !6, i64 152}
!11 = !{!"_ZTS7RNArrayIP10R3MeshEdgeE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !6, i64 0, !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7R3Point", !7, i64 0}
!15 = !{!"_ZTS8R3Vector", !7, i64 0}
!16 = !{!"_ZTS7R2Point", !7, i64 0}
!17 = !{!"_ZTS5RNRgb", !7, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!"_ZTS7RNFlags", !20, i64 0}
!20 = !{!"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: mustprogress uwtable
declare dso_local void @_ZN6R3Mesh17SetVertexPositionEP12R3MeshVertexRK7R3Point(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 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: mustprogress uwtable
declare dso_local noundef ptr @_ZN7RNArrayIP12R3MeshVertexE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #2 align 2

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

5:                                                ; preds = %3
  %6 = tail call noalias noundef nonnull dereferenceable(160) ptr @_Znwm(i64 noundef 160) #5
  invoke void @_ZN12R3MeshVertexC1Ev(ptr noundef nonnull align 8 dereferenceable(160) %6)
          to label %7 unwind label %10

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

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

12:                                               ; preds = %7, %3
  %.0 = phi ptr [ %2, %3 ], [ %6, %7 ]
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  call void @_ZN6R3Mesh17SetVertexPositionEP12R3MeshVertexRK7R3Point(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %.0, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %14 = getelementptr inbounds i8, ptr %1, i64 48
  %15 = call noundef i32 @_ZNK8R3Vector6IsZeroEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  %.not17 = icmp eq i32 %15, 0
  br i1 %.not17, label %16, label %17

16:                                               ; preds = %12
  call void @_ZN6R3Mesh15SetVertexNormalEP12R3MeshVertexRK8R3Vector(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %.0, ptr noundef nonnull align 8 dereferenceable(24) %14)
  br label %17

17:                                               ; preds = %16, %12
  %18 = getelementptr inbounds i8, ptr %1, i64 88
  call void @_ZN6R3Mesh14SetVertexColorEP12R3MeshVertexRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %.0, ptr noundef nonnull align 8 dereferenceable(24) %18)
  %19 = getelementptr inbounds i8, ptr %1, i64 72
  call void @_ZN6R3Mesh22SetVertexTextureCoordsEP12R3MeshVertexRK7R2Point(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %.0, ptr noundef nonnull align 8 dereferenceable(16) %19)
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %20)
  %22 = getelementptr inbounds i8, ptr %.0, i64 120
  store i32 %21, ptr %22, align 8, !tbaa !5
  %23 = call noundef ptr @_ZN7RNArrayIP12R3MeshVertexE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull %.0)
  ret ptr %.0
}

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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8R3Vector6IsZeroEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Mesh15SetVertexNormalEP12R3MeshVertexRK8R3Vector(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Mesh14SetVertexColorEP12R3MeshVertexRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Mesh22SetVertexTextureCoordsEP12R3MeshVertexRK7R2Point(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

declare void @_ZN12R3MeshVertexC1Ev(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 = { 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 #3 = { 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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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, !12, i64 120}
!6 = !{!"_ZTS12R3MeshVertex", !7, i64 8, !13, i64 24, !14, i64 48, !15, i64 72, !16, i64 88, !17, i64 112, !12, i64 120, !18, i64 128, !17, i64 136, !12, i64 144, !9, i64 152}
!7 = !{!"_ZTS7RNArrayIP10R3MeshEdgeE", !8, i64 0}
!8 = !{!"_ZTS8RNVArray", !9, i64 0, !12, i64 8, !12, i64 12}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"_ZTS7R3Point", !10, i64 0}
!14 = !{!"_ZTS8R3Vector", !10, i64 0}
!15 = !{!"_ZTS7R2Point", !10, i64 0}
!16 = !{!"_ZTS5RNRgb", !10, i64 0}
!17 = !{!"double", !10, i64 0}
!18 = !{!"_ZTS7RNFlags", !19, i64 0}
!19 = !{!"long", !10, i64 0}


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