; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RGBD/RGBDSurface.ll (ZN11RGBDSurface19UpdateMeshFaceIndexEv)

; 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.R2Point = type { [2 x double] }
%class.RGBDSurface = type { ptr, ptr, i32, %class.RNArray, i32, i32, i32, ptr, ptr, %class.R2Box, i32, ptr, ptr, ptr }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }

@RN_EPSILON = external global double, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8RNIsZerodd(double noundef, double noundef) #1

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

declare noundef double @_ZNK5R2Box4AreaEv(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3

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

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

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

declare void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11RGBDSurface19UpdateMeshFaceIndexEv(ptr noundef nonnull align 8 dereferenceable(144) %0) unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %class.R2Point, align 8
  %11 = alloca %class.R2Point, align 8
  %12 = alloca %class.R2Point, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8
  %14 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %1
  br label %93

18:                                               ; preds = %1
  %19 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 4
  %20 = load i32, ptr %19, align 8, !tbaa !18
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  br label %93

23:                                               ; preds = %18
  %24 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 5
  %25 = load i32, ptr %24, align 4, !tbaa !19
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  br label %93

28:                                               ; preds = %23
  %29 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 9
  %30 = call noundef double @_ZNK5R2Box4AreaEv(ptr noundef nonnull align 8 dereferenceable(40) %29)
  %31 = load double, ptr @RN_EPSILON, align 8, !tbaa !20
  %32 = call noundef i32 @_Z8RNIsZerodd(double noundef %30, double noundef %31)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %28
  br label %93

35:                                               ; preds = %28
  %36 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 208) #7
  %37 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 4
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 5
  %40 = load i32, ptr %39, align 4, !tbaa !19
  %41 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 9
  invoke void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %36, i32 noundef %38, i32 noundef %40, ptr noundef nonnull align 8 dereferenceable(40) %41)
          to label %42 unwind label %53

42:                                               ; preds = %35
  %43 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 13
  store ptr %36, ptr %43, align 8, !tbaa !22
  %44 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 13
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  call void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208) %45, double noundef -3.210000e+02)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 0, ptr %5, align 4, !tbaa !23
  br label %46

46:                                               ; preds = %90, %42
  %47 = load i32, ptr %5, align 4, !tbaa !23
  %48 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = call noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %49)
  %51 = icmp slt i32 %47, %50
  br i1 %51, label %57, label %52

52:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %93

53:                                               ; preds = %35
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %3, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %36, i64 noundef 208) #9
  br label %94

57:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %58 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  %60 = load i32, ptr %5, align 4, !tbaa !23
  %61 = call noundef ptr @_ZNK6R3Mesh4FaceEi(ptr noundef nonnull align 8 dereferenceable(272) %59, i32 noundef %60)
  store ptr %61, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %62 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call noundef ptr @_ZNK6R3Mesh12VertexOnFaceEPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %63, ptr noundef %64, i32 noundef 0)
  store ptr %65, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %66 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %67 = load ptr, ptr %66, align 8, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call noundef ptr @_ZNK6R3Mesh12VertexOnFaceEPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %67, ptr noundef %68, i32 noundef 1)
  store ptr %69, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %70 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %71 = load ptr, ptr %70, align 8, !tbaa !9
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call noundef ptr @_ZNK6R3Mesh12VertexOnFaceEPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %71, ptr noundef %72, i32 noundef 2)
  store ptr %73, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #8
  %74 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %75, ptr noundef %76)
  call void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %77)
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #8
  %78 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %79, ptr noundef %80)
  call void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(16) %81)
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #8
  %82 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 12
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %83, ptr noundef %84)
  call void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(16) %85)
  %86 = getelementptr inbounds %class.RGBDSurface, ptr %13, i32 0, i32 13
  %87 = load ptr, ptr %86, align 8, !tbaa !22
  %88 = load i32, ptr %5, align 4, !tbaa !23
  %89 = sitofp i32 %88 to double
  call void @_ZN6R2Grid22RasterizeWorldTriangleERK7R2PointS2_S2_di(ptr noundef nonnull align 8 dereferenceable(208) %87, ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(16) %12, double noundef %89, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  br label %90

90:                                               ; preds = %57
  %91 = load i32, ptr %5, align 4, !tbaa !23
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %5, align 4, !tbaa !23
  br label %46, !llvm.loop !24

93:                                               ; preds = %52, %34, %27, %22, %17
  ret void

94:                                               ; preds = %53
  %95 = load ptr, ptr %3, align 8
  %96 = load i32, ptr %4, align 4
  %97 = insertvalue { ptr, i32 } poison, ptr %95, 0
  %98 = insertvalue { ptr, i32 } %97, i32 %96, 1
  resume { ptr, i32 } %98
}

declare void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3

declare void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208), double noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R2Grid22RasterizeWorldTriangleERK7R2PointS2_S2_di(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), double noundef, i32 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = { 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 #5 = { 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 #6 = { 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 #7 = { builtin allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { 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, !6, i64 128}
!10 = !{!"_ZTS11RGBDSurface", !6, i64 8, !11, i64 16, !12, i64 24, !11, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !6, i64 64, !14, i64 72, !11, i64 112, !6, i64 120, !6, i64 128, !6, i64 136}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS7RNArrayIP6R2GridE", !13, i64 0}
!13 = !{!"_ZTS8RNVArray", !6, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!"_ZTS5R2Box", !15, i64 0, !17, i64 8, !17, i64 24}
!15 = !{!"_ZTS7R2Solid", !16, i64 0}
!16 = !{!"_ZTS7R2Shape"}
!17 = !{!"_ZTS7R2Point", !7, i64 0}
!18 = !{!10, !11, i64 40}
!19 = !{!10, !11, i64 44}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !7, i64 0}
!22 = !{!10, !6, i64 136}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

%class.R2Point = type { [2 x double] }

@RN_EPSILON = external local_unnamed_addr global double, align 8

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8RNIsZerodd(double noundef, double noundef) local_unnamed_addr #1

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

declare noundef double @_ZNK5R2Box4AreaEv(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3

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

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

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

declare void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11RGBDSurface19UpdateMeshFaceIndexEv(ptr noundef nonnull align 8 dereferenceable(144) %0) unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.R2Point, align 8
  %3 = alloca %class.R2Point, align 8
  %4 = alloca %class.R2Point, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %.loopexit, label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load i32, ptr %8, align 8, !tbaa !17
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 44
  %13 = load i32, ptr %12, align 4, !tbaa !18
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %.loopexit, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  %17 = tail call noundef double @_ZNK5R2Box4AreaEv(ptr noundef nonnull align 8 dereferenceable(40) %16)
  %18 = load double, ptr @RN_EPSILON, align 8, !tbaa !19
  %19 = tail call noundef i32 @_Z8RNIsZerodd(double noundef %17, double noundef %18)
  %.not12 = icmp eq i32 %19, 0
  br i1 %.not12, label %20, label %.loopexit

20:                                               ; preds = %15
  %21 = tail call noalias noundef nonnull dereferenceable(208) ptr @_Znwm(i64 noundef 208) #7
  %22 = load i32, ptr %8, align 8, !tbaa !17
  %23 = load i32, ptr %12, align 4, !tbaa !18
  invoke void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %21, i32 noundef %22, i32 noundef %23, ptr noundef nonnull align 8 dereferenceable(40) %16)
          to label %24 unwind label %29

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr %21, ptr %25, align 8, !tbaa !21
  tail call void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208) %21, double noundef -3.210000e+02)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = tail call noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %26)
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph, label %.loopexit

29:                                               ; preds = %20
  %30 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %21, i64 noundef 208) #8
  resume { ptr, i32 } %30

.lr.ph:                                           ; preds = %24, %.lr.ph
  %.013 = phi i32 [ %47, %.lr.ph ], [ 0, %24 ]
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call noundef ptr @_ZNK6R3Mesh4FaceEi(ptr noundef nonnull align 8 dereferenceable(272) %31, i32 noundef %.013)
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call noundef ptr @_ZNK6R3Mesh12VertexOnFaceEPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %33, ptr noundef %32, i32 noundef 0)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call noundef ptr @_ZNK6R3Mesh12VertexOnFaceEPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %35, ptr noundef %32, i32 noundef 1)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = call noundef ptr @_ZNK6R3Mesh12VertexOnFaceEPK10R3MeshFacei(ptr noundef nonnull align 8 dereferenceable(272) %37, ptr noundef %32, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #9
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %39, ptr noundef %34)
  call void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %40)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %41, ptr noundef %36)
  call void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %42)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %43, ptr noundef %38)
  call void @_ZN7R2PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %44)
  %45 = load ptr, ptr %25, align 8, !tbaa !21
  %46 = uitofp nneg i32 %.013 to double
  call void @_ZN6R2Grid22RasterizeWorldTriangleERK7R2PointS2_S2_di(ptr noundef nonnull align 8 dereferenceable(208) %45, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4, double noundef %46, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #9
  %47 = add nuw nsw i32 %.013, 1
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = call noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %48)
  %50 = icmp slt i32 %47, %49
  br i1 %50, label %.lr.ph, label %.loopexit, !llvm.loop !22

.loopexit:                                        ; preds = %.lr.ph, %24, %15, %11, %7, %1
  ret void
}

declare void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3

declare void @_ZN6R2Grid5ClearEd(ptr noundef nonnull align 8 dereferenceable(208), double noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R2Grid22RasterizeWorldTriangleERK7R2PointS2_S2_di(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), double noundef, i32 noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = { 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 #5 = { 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 #6 = { 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 #7 = { builtin allocsize(0) }
attributes #8 = { builtin nounwind }
attributes #9 = { 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 128}
!6 = !{!"_ZTS11RGBDSurface", !7, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !7, i64 64, !13, i64 72, !10, i64 112, !7, i64 120, !7, i64 128, !7, i64 136}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS7RNArrayIP6R2GridE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !7, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!"_ZTS5R2Box", !14, i64 0, !16, i64 8, !16, i64 24}
!14 = !{!"_ZTS7R2Solid", !15, i64 0}
!15 = !{!"_ZTS7R2Shape"}
!16 = !{!"_ZTS7R2Point", !8, i64 0}
!17 = !{!6, !10, i64 40}
!18 = !{!6, !10, i64 44}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !8, i64 0}
!21 = !{!6, !7, i64 136}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass