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

; 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 }

@_ZTV11RGBDSurface = external dso_local unnamed_addr constant { [33 x ptr] }, align 8
@R2null_point = external global %class.R2Point, align 8
@RN_EPSILON = external global double, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [67 x i8], align 1
@R2ones_point = external global %class.R2Point, align 8

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

declare void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40), double noundef, double noundef, double noundef, double noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

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

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

declare void @_ZN5R2Box5ResetERK7R2PointS2_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11RGBDSurfaceC2EPKcP6R3Meshd(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1, ptr noundef %2, double noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, 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 double %3, ptr %8, align 8, !tbaa !9
  %16 = load ptr, ptr %5, align 8
  store ptr getelementptr inbounds inrange(-16, 248) ({ [33 x ptr] }, ptr @_ZTV11RGBDSurface, i32 0, i32 0, i32 2), ptr %16, align 8, !tbaa !11
  %17 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 1
  store ptr null, ptr %17, align 8, !tbaa !13
  %18 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 2
  store i32 -1, ptr %18, align 8, !tbaa !22
  %19 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 3
  call void @_ZN7RNArrayIP6R2GridEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19)
  %20 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 4
  store i32 0, ptr %20, align 8, !tbaa !23
  %21 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 5
  store i32 0, ptr %21, align 4, !tbaa !24
  %22 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 6
  store i32 -1, ptr %22, align 8, !tbaa !25
  %23 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 7
  store ptr null, ptr %23, align 8, !tbaa !26
  %24 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 8
  store ptr null, ptr %24, align 8, !tbaa !27
  %25 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 9
  invoke void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40) %25, double noundef 0x47EFFFFFE0000000, double noundef 0x47EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000)
          to label %26 unwind label %37

26:                                               ; preds = %4
  %27 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 10
  store i32 0, ptr %27, align 8, !tbaa !28
  %28 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 11
  store ptr null, ptr %28, align 8, !tbaa !29
  %29 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 12
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %30, ptr %29, align 8, !tbaa !30
  %31 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 13
  store ptr null, ptr %31, align 8, !tbaa !31
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = invoke noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %32)
          to label %34 unwind label %41

34:                                               ; preds = %26
  %35 = icmp eq i32 %33, 0
  br i1 %35, label %36, label %45

36:                                               ; preds = %34
  br label %151

37:                                               ; preds = %4
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %9, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %10, align 4
  br label %154

41:                                               ; preds = %26
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %9, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %10, align 4
  br label %153

45:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = invoke noundef double @_ZNK6R3Mesh4AreaEv(ptr noundef nonnull align 8 dereferenceable(272) %46)
          to label %48 unwind label %57

48:                                               ; preds = %45
  store double %47, ptr %11, align 8, !tbaa !9
  %49 = load double, ptr %11, align 8, !tbaa !9
  %50 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %51 = invoke noundef i32 @_Z8RNIsZerodd(double noundef %49, double noundef %50)
          to label %52 unwind label %57

52:                                               ; preds = %48
  %53 = icmp ne i32 %51, 0
  br i1 %53, label %54, label %61

54:                                               ; preds = %52
  %55 = load ptr, ptr @stderr, align 8, !tbaa !5
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str) #6
  store i32 1, ptr %12, align 4
  br label %149

57:                                               ; preds = %143, %118, %115, %106, %101, %98, %48, %45
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %9, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %10, align 4
  br label %152

61:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !32
  br label %62

62:                                               ; preds = %85, %61
  %63 = load i32, ptr %13, align 4, !tbaa !32
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = invoke noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %64)
          to label %66 unwind label %69

66:                                               ; preds = %62
  %67 = icmp slt i32 %63, %65
  br i1 %67, label %73, label %68

68:                                               ; preds = %66
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %98

69:                                               ; preds = %62
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %9, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %10, align 4
  br label %97

73:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load i32, ptr %13, align 4, !tbaa !32
  %76 = invoke noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272) %74, i32 noundef %75)
          to label %77 unwind label %88

77:                                               ; preds = %73
  store ptr %76, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = load ptr, ptr %14, align 8, !tbaa !5
  %80 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %78, ptr noundef %79)
          to label %81 unwind label %92

81:                                               ; preds = %77
  store ptr %80, ptr %15, align 8, !tbaa !5
  %82 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 9
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  invoke void @_ZN5R2Box5UnionERK7R2Point(ptr noundef nonnull align 8 dereferenceable(40) %82, ptr noundef nonnull align 8 dereferenceable(16) %83)
          to label %84 unwind label %92

84:                                               ; preds = %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %13, align 4, !tbaa !32
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %13, align 4, !tbaa !32
  br label %62, !llvm.loop !33

88:                                               ; preds = %73
  %89 = landingpad { ptr, i32 }
          cleanup
  %90 = extractvalue { ptr, i32 } %89, 0
  store ptr %90, ptr %9, align 8
  %91 = extractvalue { ptr, i32 } %89, 1
  store i32 %91, ptr %10, align 4
  br label %96

92:                                               ; preds = %81, %77
  %93 = landingpad { ptr, i32 }
          cleanup
  %94 = extractvalue { ptr, i32 } %93, 0
  store ptr %94, ptr %9, align 8
  %95 = extractvalue { ptr, i32 } %93, 1
  store i32 %95, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %96

96:                                               ; preds = %92, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %97

97:                                               ; preds = %96, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %152

98:                                               ; preds = %68
  %99 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 9
  %100 = invoke noundef double @_ZNK5R2Box4AreaEv(ptr noundef nonnull align 8 dereferenceable(40) %99)
          to label %101 unwind label %57

101:                                              ; preds = %98
  %102 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %103 = invoke noundef i32 @_Z8RNIsZerodd(double noundef %100, double noundef %102)
          to label %104 unwind label %57

104:                                              ; preds = %101
  %105 = icmp ne i32 %103, 0
  br i1 %105, label %106, label %111

106:                                              ; preds = %104
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str.1) #6
  %109 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 9
  invoke void @_ZN5R2Box5ResetERK7R2PointS2_(ptr noundef nonnull align 8 dereferenceable(40) %109, ptr noundef nonnull align 8 dereferenceable(16) @R2null_point, ptr noundef nonnull align 8 dereferenceable(16) @R2ones_point)
          to label %110 unwind label %57

110:                                              ; preds = %106
  br label %111

111:                                              ; preds = %110, %104
  %112 = load double, ptr %8, align 8, !tbaa !9
  %113 = fcmp ole double %112, 0.000000e+00
  br i1 %113, label %114, label %115

114:                                              ; preds = %111
  store double 1.000000e-02, ptr %8, align 8, !tbaa !9
  br label %115

115:                                              ; preds = %114, %111
  %116 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 9
  %117 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %116)
          to label %118 unwind label %57

118:                                              ; preds = %115
  %119 = load double, ptr %8, align 8, !tbaa !9
  %120 = fdiv double %117, %119
  %121 = fadd double %120, 5.000000e-01
  %122 = fptosi double %121 to i32
  %123 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 4
  store i32 %122, ptr %123, align 8, !tbaa !23
  %124 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 9
  %125 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %124)
          to label %126 unwind label %57

126:                                              ; preds = %118
  %127 = load double, ptr %8, align 8, !tbaa !9
  %128 = fdiv double %125, %127
  %129 = fadd double %128, 5.000000e-01
  %130 = fptosi double %129 to i32
  %131 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 5
  store i32 %130, ptr %131, align 4, !tbaa !24
  %132 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 4
  %133 = load i32, ptr %132, align 8, !tbaa !23
  %134 = icmp sle i32 %133, 0
  br i1 %134, label %135, label %137

135:                                              ; preds = %126
  %136 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 4
  store i32 1, ptr %136, align 8, !tbaa !23
  br label %137

137:                                              ; preds = %135, %126
  %138 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 5
  %139 = load i32, ptr %138, align 4, !tbaa !24
  %140 = icmp sle i32 %139, 0
  br i1 %140, label %141, label %143

141:                                              ; preds = %137
  %142 = getelementptr inbounds %class.RGBDSurface, ptr %16, i32 0, i32 5
  store i32 1, ptr %142, align 4, !tbaa !24
  br label %143

143:                                              ; preds = %141, %137
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = load ptr, ptr %16, align 8, !tbaa !11
  %146 = getelementptr inbounds ptr, ptr %145, i64 23
  %147 = load ptr, ptr %146, align 8
  invoke void %147(ptr noundef nonnull align 8 dereferenceable(144) %16, ptr noundef %144)
          to label %148 unwind label %57

148:                                              ; preds = %143
  store i32 0, ptr %12, align 4
  br label %149

149:                                              ; preds = %148, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %150 = load i32, ptr %12, align 4
  switch i32 %150, label %160 [
    i32 0, label %151
    i32 1, label %151
  ]

151:                                              ; preds = %149, %149, %36
  ret void

152:                                              ; preds = %97, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %153

153:                                              ; preds = %152, %41
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %25) #6
  br label %154

154:                                              ; preds = %153, %37
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #6
  br label %155

155:                                              ; preds = %154
  %156 = load ptr, ptr %9, align 8
  %157 = load i32, ptr %10, align 4
  %158 = insertvalue { ptr, i32 } poison, ptr %156, 0
  %159 = insertvalue { ptr, i32 } %158, i32 %157, 1
  resume { ptr, i32 } %159

160:                                              ; preds = %149
  unreachable
}

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

declare noundef double @_ZNK6R3Mesh4AreaEv(ptr noundef nonnull align 8 dereferenceable(272)) #1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

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

; 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) #5 align 2

declare void @_ZN5R2Box5UnionERK7R2Point(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) #4 align 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS11RGBDSurface", !6, i64 8, !15, i64 16, !16, i64 24, !15, i64 40, !15, i64 44, !15, i64 48, !6, i64 56, !6, i64 64, !18, i64 72, !15, i64 112, !6, i64 120, !6, i64 128, !6, i64 136}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS7RNArrayIP6R2GridE", !17, i64 0}
!17 = !{!"_ZTS8RNVArray", !6, i64 0, !15, i64 8, !15, i64 12}
!18 = !{!"_ZTS5R2Box", !19, i64 0, !21, i64 8, !21, i64 24}
!19 = !{!"_ZTS7R2Solid", !20, i64 0}
!20 = !{!"_ZTS7R2Shape"}
!21 = !{!"_ZTS7R2Point", !7, i64 0}
!22 = !{!14, !15, i64 16}
!23 = !{!14, !15, i64 40}
!24 = !{!14, !15, i64 44}
!25 = !{!14, !15, i64 48}
!26 = !{!14, !6, i64 56}
!27 = !{!14, !6, i64 64}
!28 = !{!14, !15, i64 112}
!29 = !{!14, !6, i64 120}
!30 = !{!14, !6, i64 128}
!31 = !{!14, !6, i64 136}
!32 = !{!15, !15, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"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] }

@_ZTV11RGBDSurface = external dso_local unnamed_addr constant { [33 x ptr] }, align 8
@R2null_point = external global %class.R2Point, align 8
@RN_EPSILON = external local_unnamed_addr global double, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [67 x i8], align 1
@R2ones_point = external global %class.R2Point, align 8

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

declare void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40), double noundef, double noundef, double noundef, double noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN5R2Box5ResetERK7R2PointS2_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11RGBDSurfaceC2EPKcP6R3Meshd(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1, ptr noundef %2, double noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 248) (i8, ptr @_ZTV11RGBDSurface, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %5, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 -1, ptr %6, align 8, !tbaa !19
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN7RNArrayIP6R2GridEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 0, ptr %8, align 8, !tbaa !20
  %9 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 0, ptr %9, align 4, !tbaa !21
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 -1, ptr %10, align 8, !tbaa !22
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  invoke void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40) %12, double noundef 0x47EFFFFFE0000000, double noundef 0x47EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000)
          to label %13 unwind label %21

13:                                               ; preds = %4
  %14 = getelementptr inbounds i8, ptr %0, i64 112
  store i32 0, ptr %14, align 8, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr null, ptr %15, align 8, !tbaa !24
  %16 = getelementptr inbounds i8, ptr %0, i64 128
  store ptr %2, ptr %16, align 8, !tbaa !25
  %17 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr null, ptr %17, align 8, !tbaa !26
  %18 = invoke noundef i32 @_ZNK6R3Mesh6NFacesEv(ptr noundef nonnull align 8 dereferenceable(272) %2)
          to label %19 unwind label %23

19:                                               ; preds = %13
  %20 = icmp eq i32 %18, 0
  br i1 %20, label %82, label %25

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

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

25:                                               ; preds = %19
  %26 = invoke noundef double @_ZNK6R3Mesh4AreaEv(ptr noundef nonnull align 8 dereferenceable(272) %2)
          to label %27 unwind label %34

27:                                               ; preds = %25
  %28 = load double, ptr @RN_EPSILON, align 8, !tbaa !27
  %29 = invoke noundef i32 @_Z8RNIsZerodd(double noundef %26, double noundef %28)
          to label %30 unwind label %34

30:                                               ; preds = %27
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %.preheader, label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr @stderr, align 8, !tbaa !29
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str) #7
  br label %82

34:                                               ; preds = %78, %63, %60, %57, %53, %39, %27, %25
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %83

.preheader:                                       ; preds = %30, %47
  %.019 = phi i32 [ %48, %47 ], [ 0, %30 ]
  %36 = invoke noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %2)
          to label %37 unwind label %41

37:                                               ; preds = %.preheader
  %38 = icmp slt i32 %.019, %36
  br i1 %38, label %43, label %39

39:                                               ; preds = %37
  %40 = invoke noundef double @_ZNK5R2Box4AreaEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
          to label %53 unwind label %34

41:                                               ; preds = %.preheader
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %83

43:                                               ; preds = %37
  %44 = invoke noundef ptr @_ZNK6R3Mesh6VertexEi(ptr noundef nonnull align 8 dereferenceable(272) %2, i32 noundef %.019)
          to label %45 unwind label %49

45:                                               ; preds = %43
  %46 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6R3Mesh19VertexTextureCoordsEPK12R3MeshVertex(ptr noundef nonnull align 8 dereferenceable(272) %2, ptr noundef %44)
  invoke void @_ZN5R2Box5UnionERK7R2Point(ptr noundef nonnull align 8 dereferenceable(40) %12, ptr noundef nonnull align 8 dereferenceable(16) %46)
          to label %47 unwind label %51

47:                                               ; preds = %45
  %48 = add nuw nsw i32 %.019, 1
  br label %.preheader, !llvm.loop !30

49:                                               ; preds = %43
  %50 = landingpad { ptr, i32 }
          cleanup
  br label %83

51:                                               ; preds = %45
  %52 = landingpad { ptr, i32 }
          cleanup
  br label %83

53:                                               ; preds = %39
  %54 = load double, ptr @RN_EPSILON, align 8, !tbaa !27
  %55 = invoke noundef i32 @_Z8RNIsZerodd(double noundef %40, double noundef %54)
          to label %56 unwind label %34

56:                                               ; preds = %53
  %.not26 = icmp eq i32 %55, 0
  br i1 %.not26, label %60, label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr @stderr, align 8, !tbaa !29
  %59 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef nonnull @.str.1) #7
  invoke void @_ZN5R2Box5ResetERK7R2PointS2_(ptr noundef nonnull align 8 dereferenceable(40) %12, ptr noundef nonnull align 8 dereferenceable(16) @R2null_point, ptr noundef nonnull align 8 dereferenceable(16) @R2ones_point)
          to label %60 unwind label %34

60:                                               ; preds = %57, %56
  %61 = fcmp ugt double %3, 0.000000e+00
  %.0 = select i1 %61, double %3, double 1.000000e-02
  %62 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
          to label %63 unwind label %34

63:                                               ; preds = %60
  %64 = fdiv double %62, %.0
  %65 = fadd double %64, 5.000000e-01
  %66 = fptosi double %65 to i32
  store i32 %66, ptr %8, align 8, !tbaa !20
  %67 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
          to label %68 unwind label %34

68:                                               ; preds = %63
  %69 = fdiv double %67, %.0
  %70 = fadd double %69, 5.000000e-01
  %71 = fptosi double %70 to i32
  store i32 %71, ptr %9, align 4, !tbaa !21
  %72 = load i32, ptr %8, align 8, !tbaa !20
  %73 = icmp slt i32 %72, 1
  br i1 %73, label %74, label %75

74:                                               ; preds = %68
  store i32 1, ptr %8, align 8, !tbaa !20
  br label %75

75:                                               ; preds = %74, %68
  %76 = icmp slt i32 %71, 1
  br i1 %76, label %77, label %78

77:                                               ; preds = %75
  store i32 1, ptr %9, align 4, !tbaa !21
  br label %78

78:                                               ; preds = %77, %75
  %79 = load ptr, ptr %0, align 8, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %79, i64 184
  %81 = load ptr, ptr %80, align 8
  invoke void %81(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1)
          to label %82 unwind label %34

82:                                               ; preds = %31, %78, %19
  ret void

83:                                               ; preds = %34, %49, %51, %41, %23
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %24, %23 ], [ %35, %34 ], [ %42, %41 ], [ %52, %51 ], [ %50, %49 ]
  tail call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %12) #8
  br label %84

84:                                               ; preds = %83, %21
  %.pn.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn.pn, %83 ], [ %22, %21 ]
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #8
  resume { ptr, i32 } %.pn.pn.pn.pn.pn
}

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

declare noundef double @_ZNK6R3Mesh4AreaEv(ptr noundef nonnull align 8 dereferenceable(272)) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

; 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 #5 align 2

declare void @_ZN5R2Box5UnionERK7R2Point(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #3 align 2

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

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 = { 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 #4 = { nofree 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 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { cold nounwind }
attributes #8 = { 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, !10, i64 8}
!9 = !{!"_ZTS11RGBDSurface", !10, i64 8, !12, i64 16, !13, i64 24, !12, i64 40, !12, i64 44, !12, i64 48, !10, i64 56, !10, i64 64, !15, i64 72, !12, i64 112, !10, i64 120, !10, i64 128, !10, i64 136}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"_ZTS7RNArrayIP6R2GridE", !14, i64 0}
!14 = !{!"_ZTS8RNVArray", !10, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!"_ZTS5R2Box", !16, i64 0, !18, i64 8, !18, i64 24}
!16 = !{!"_ZTS7R2Solid", !17, i64 0}
!17 = !{!"_ZTS7R2Shape"}
!18 = !{!"_ZTS7R2Point", !11, i64 0}
!19 = !{!9, !12, i64 16}
!20 = !{!9, !12, i64 40}
!21 = !{!9, !12, i64 44}
!22 = !{!9, !12, i64 48}
!23 = !{!9, !12, i64 112}
!24 = !{!9, !10, i64 120}
!25 = !{!9, !10, i64 128}
!26 = !{!9, !10, i64 136}
!27 = !{!28, !28, i64 0}
!28 = !{!"double", !11, i64 0}
!29 = !{!10, !10, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


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