; LLVM IR from aparis69/Rock-fracturing :: Code/Source (blocks-sdf)

; 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.Box = type { %struct.Vector3, %struct.Vector3 }
%struct.Vector3 = type { double, double, double }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.BVHPartitionPredicate = type { i32, double }
%struct.SDFNode = type { ptr, %class.Box }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3BoxC2ERKS_S1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiid(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, double noundef %3) #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %class.Box, align 8
  %13 = alloca i32, align 4
  %14 = alloca %class.Box, align 8
  %15 = alloca i32, align 4
  %16 = alloca %struct.Vector3, align 8
  %17 = alloca double, align 8
  %18 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %19 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %20 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %21 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %22 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %23 = alloca %struct.BVHPartitionPredicate, align 8
  %24 = alloca i32, align 4
  %25 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %26 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca ptr, align 8
  %30 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = sub nsw i32 %31, %32
  store i32 %33, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp sle i32 %34, 1
  br i1 %35, label %36, label %42

36:                                               ; preds = %4
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %39) #8
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  store ptr %41, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %145

42:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 48, ptr %12) #8
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %43, i64 noundef %45) #8
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.SDFNode, ptr %47, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %48, i64 48, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %13, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %63, %42
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %66

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 48, ptr %14) #8
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %57, i64 noundef %59) #8
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.SDFNode, ptr %61, i32 0, i32 1
  call void @_ZN3BoxC2ERKS_S1_(ptr noundef nonnull align 8 dereferenceable(48) %14, ptr noundef nonnull align 8 dereferenceable(48) %12, ptr noundef nonnull align 8 dereferenceable(48) %62)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %14, i64 48, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 48, ptr %14) #8
  br label %63

63:                                               ; preds = %56
  %64 = load i32, ptr %13, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %13, align 4, !tbaa !9
  br label %51, !llvm.loop !14

66:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #8
  call void @_ZNK3Box8DiagonalEv(ptr dead_on_unwind writable sret(%struct.Vector3) align 8 %16, ptr noundef nonnull align 8 dereferenceable(48) %12)
  %67 = call noundef i32 @_ZNK7Vector38MaxIndexEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #8
  store i32 %67, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %68 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3BoxixEi(ptr noundef nonnull align 8 dereferenceable(48) %12, i32 noundef 0)
  %69 = load i32, ptr %15, align 4, !tbaa !9
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7Vector3ixEi(ptr noundef nonnull align 8 dereferenceable(24) %68, i32 noundef %69)
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3BoxixEi(ptr noundef nonnull align 8 dereferenceable(48) %12, i32 noundef 1)
  %73 = load i32, ptr %15, align 4, !tbaa !9
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7Vector3ixEi(ptr noundef nonnull align 8 dereferenceable(24) %72, i32 noundef %73)
  %75 = load double, ptr %74, align 8, !tbaa !11
  %76 = fadd double %71, %75
  %77 = fdiv double %76, 2.000000e+00
  store double %77, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = call ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %78) #8
  %80 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %20, i32 0, i32 0
  store ptr %79, ptr %80, align 8
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS2_SaIS2_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %20, i64 noundef %82) #8
  %84 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  store ptr %83, ptr %84, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #8
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = call ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %85) #8
  %87 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %22, i32 0, i32 0
  store ptr %86, ptr %87, align 8
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS2_SaIS2_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %22, i64 noundef %89) #8
  %91 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  store ptr %90, ptr %91, align 8
  %92 = load i32, ptr %15, align 4, !tbaa !9
  %93 = load double, ptr %17, align 8, !tbaa !11
  call void @_ZZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiidEN21BVHPartitionPredicateC2Eid(ptr noundef nonnull align 8 dereferenceable(16) %23, i32 noundef %92, double noundef %93)
  %94 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8
  %96 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8
  %98 = getelementptr inbounds { i32, double }, ptr %23, i32 0, i32 0
  %99 = load i32, ptr %98, align 8
  %100 = getelementptr inbounds { i32, double }, ptr %23, i32 0, i32 1
  %101 = load double, ptr %100, align 8
  %102 = call ptr @_ZSt9partitionIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERS7_iidE21BVHPartitionPredicateET_SC_SC_T0_(ptr %95, ptr %97, i32 %99, double %101)
  %103 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %18, i32 0, i32 0
  store ptr %102, ptr %103, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = call ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %104) #8
  %106 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %25, i32 0, i32 0
  store ptr %105, ptr %106, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 8 %18, i64 8, i1 false), !tbaa.struct !16
  %107 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %25, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8
  %109 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %26, i32 0, i32 0
  %110 = load ptr, ptr %109, align 8
  %111 = call noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr %108, ptr %110)
  %112 = trunc i64 %111 to i32
  store i32 %112, ptr %24, align 4, !tbaa !9
  %113 = load i32, ptr %24, align 4, !tbaa !9
  %114 = load i32, ptr %7, align 4, !tbaa !9
  %115 = icmp eq i32 %113, %114
  br i1 %115, label %120, label %116

116:                                              ; preds = %66
  %117 = load i32, ptr %24, align 4, !tbaa !9
  %118 = load i32, ptr %8, align 4, !tbaa !9
  %119 = icmp eq i32 %117, %118
  br i1 %119, label %120, label %125

120:                                              ; preds = %116, %66
  %121 = load i32, ptr %7, align 4, !tbaa !9
  %122 = load i32, ptr %8, align 4, !tbaa !9
  %123 = add nsw i32 %121, %122
  %124 = sdiv i32 %123, 2
  store i32 %124, ptr %24, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %120, %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #8
  %126 = load ptr, ptr %6, align 8, !tbaa !5
  %127 = load i32, ptr %7, align 4, !tbaa !9
  %128 = load i32, ptr %24, align 4, !tbaa !9
  %129 = load double, ptr %9, align 8, !tbaa !11
  %130 = call noundef ptr @_ZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiid(ptr noundef nonnull align 8 dereferenceable(24) %126, i32 noundef %127, i32 noundef %128, double noundef %129)
  store ptr %130, ptr %27, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  %131 = load ptr, ptr %6, align 8, !tbaa !5
  %132 = load i32, ptr %24, align 4, !tbaa !9
  %133 = load i32, ptr %8, align 4, !tbaa !9
  %134 = load double, ptr %9, align 8, !tbaa !11
  %135 = call noundef ptr @_ZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiid(ptr noundef nonnull align 8 dereferenceable(24) %131, i32 noundef %132, i32 noundef %133, double noundef %134)
  store ptr %135, ptr %28, align 8, !tbaa !5
  %136 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 112) #9
  %137 = load ptr, ptr %27, align 8, !tbaa !5
  %138 = load ptr, ptr %28, align 8, !tbaa !5
  %139 = load double, ptr %9, align 8, !tbaa !11
  invoke void @_ZN17SDFUnionSphereLODC1EP7SDFNodeS1_d(ptr noundef nonnull align 8 dereferenceable(112) %136, ptr noundef %137, ptr noundef %138, double noundef %139)
          to label %140 unwind label %141

140:                                              ; preds = %125
  store ptr %136, ptr %5, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr %12) #8
  br label %145

141:                                              ; preds = %125
  %142 = landingpad { ptr, i32 }
          cleanup
  %143 = extractvalue { ptr, i32 } %142, 0
  store ptr %143, ptr %29, align 8
  %144 = extractvalue { ptr, i32 } %142, 1
  store i32 %144, ptr %30, align 4
  call void @_ZdlPvm(ptr noundef %136, i64 noundef 112) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %147

145:                                              ; preds = %140, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  %146 = load ptr, ptr %5, align 8
  ret ptr %146

147:                                              ; preds = %141
  %148 = load ptr, ptr %29, align 8
  %149 = load i32, ptr %30, align 4
  %150 = insertvalue { ptr, i32 } poison, ptr %148, 0
  %151 = insertvalue { ptr, i32 } %150, i32 %149, 1
  resume { ptr, i32 } %151
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK3Box8DiagonalEv(ptr dead_on_unwind noalias writable sret(%struct.Vector3) align 8, ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3BoxixEi(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN7Vector3ixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden ptr @_ZSt9partitionIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERS7_iidE21BVHPartitionPredicateET_SC_SC_T0_(ptr, ptr, i32, double) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS2_SaIS2_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiidEN21BVHPartitionPredicateC2Eid(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, double noundef) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr, ptr) #2

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

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN17SDFUnionSphereLODC1EP7SDFNodeS1_d(ptr, ptr, ptr, double)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #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 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{i64 0, i64 8, !11, i64 8, i64 8, !11, i64 16, i64 8, !11, i64 24, i64 8, !11, i64 32, i64 8, !11, i64 40, i64 8, !11}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 8, !5}


; 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.Box = type { %struct.Vector3, %struct.Vector3 }
%struct.Vector3 = type { double, double, double }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.BVHPartitionPredicate = type { i32, double }

; 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3BoxC2ERKS_S1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiid(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, double noundef %3) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.Box, align 8
  %6 = alloca %class.Box, align 8
  %7 = alloca %struct.Vector3, align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %10 = alloca %struct.BVHPartitionPredicate, align 8
  %11 = sub nsw i32 %2, %1
  %12 = icmp slt i32 %11, 2
  br i1 %12, label %13, label %17

13:                                               ; preds = %4
  %14 = sext i32 %1 to i64
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %14) #8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  br label %60

17:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #8
  %18 = sext i32 %1 to i64
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %18) #8
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(48) %21, i64 48, i1 false), !tbaa.struct !9
  %.04549 = add nsw i32 %1, 1
  %22 = icmp slt i32 %.04549, %2
  br i1 %22, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %17
  %23 = sext i32 %.04549 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %17
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #8
  call void @_ZNK3Box8DiagonalEv(ptr dead_on_unwind nonnull writable sret(%struct.Vector3) align 8 %7, ptr noundef nonnull align 8 dereferenceable(48) %5)
  %24 = call noundef i32 @_ZNK7Vector38MaxIndexEv(ptr noundef nonnull align 8 dereferenceable(24) %7)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #8
  %25 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3BoxixEi(ptr noundef nonnull align 8 dereferenceable(48) %5, i32 noundef 0)
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7Vector3ixEi(ptr noundef nonnull align 8 dereferenceable(24) %25, i32 noundef %24)
  %27 = load double, ptr %26, align 8, !tbaa !10
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN3BoxixEi(ptr noundef nonnull align 8 dereferenceable(48) %5, i32 noundef 1)
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7Vector3ixEi(ptr noundef nonnull align 8 dereferenceable(24) %28, i32 noundef %24)
  %30 = load double, ptr %29, align 8, !tbaa !10
  %31 = fadd double %27, %30
  %32 = fmul double %31, 5.000000e-01
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  %33 = call ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #8
  store ptr %33, ptr %8, align 8
  %34 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS2_SaIS2_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %8, i64 noundef %18) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #8
  %35 = call ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #8
  store ptr %35, ptr %9, align 8
  %36 = sext i32 %2 to i64
  %37 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS2_SaIS2_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %9, i64 noundef %36) #8
  call void @_ZZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiidEN21BVHPartitionPredicateC2Eid(ptr noundef nonnull align 8 dereferenceable(16) %10, i32 noundef %24, double noundef %32)
  %38 = load i32, ptr %10, align 8
  %39 = getelementptr inbounds i8, ptr %10, i64 8
  %40 = load double, ptr %39, align 8
  %41 = call ptr @_ZSt9partitionIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERS7_iidE21BVHPartitionPredicateET_SC_SC_T0_(ptr %34, ptr %37, i32 %38, double %40)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  %42 = call ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #8
  %43 = call noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr %42, ptr %41)
  %44 = trunc i64 %43 to i32
  %45 = icmp eq i32 %44, %1
  %46 = icmp eq i32 %44, %2
  %or.cond = or i1 %45, %46
  br i1 %or.cond, label %50, label %53

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %23, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #8
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #8
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 8
  call void @_ZN3BoxC2ERKS_S1_(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(48) %49)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(48) %6, i64 48, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #8
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %lftr.wideiv, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

50:                                               ; preds = %._crit_edge
  %51 = add nsw i32 %2, %1
  %52 = sdiv i32 %51, 2
  br label %53

53:                                               ; preds = %._crit_edge, %50
  %.046 = phi i32 [ %52, %50 ], [ %44, %._crit_edge ]
  %54 = call noundef ptr @_ZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiid(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %.046, double noundef %3)
  %55 = call noundef ptr @_ZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiid(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.046, i32 noundef %2, double noundef %3)
  %56 = call noalias noundef nonnull dereferenceable(112) ptr @_Znwm(i64 noundef 112) #9
  invoke void @_ZN17SDFUnionSphereLODC1EP7SDFNodeS1_d(ptr noundef nonnull align 8 dereferenceable(112) %56, ptr noundef %54, ptr noundef %55, double noundef %3)
          to label %57 unwind label %58

57:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #8
  br label %60

58:                                               ; preds = %53
  %59 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %56, i64 noundef 112) #10
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #8
  resume { ptr, i32 } %59

60:                                               ; preds = %57, %13
  %.0 = phi ptr [ %16, %13 ], [ %56, %57 ]
  ret ptr %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK3Box8DiagonalEv(ptr dead_on_unwind noalias writable sret(%struct.Vector3) align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN7Vector3ixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden ptr @_ZSt9partitionIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERS7_iidE21BVHPartitionPredicateET_SC_SC_T0_(ptr, ptr, i32, double) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIP7SDFNodeSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS2_SaIS2_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZZN17SDFUnionSphereLOD21OptimizedBVHRecursiveERSt6vectorIP7SDFNodeSaIS2_EEiidEN21BVHPartitionPredicateC2Eid(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, double noundef) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPP7SDFNodeSt6vectorIS3_SaIS3_EEEEENSt15iterator_traitsIT_E15difference_typeESA_SA_(ptr, ptr) local_unnamed_addr #2

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

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN17SDFUnionSphereLODC1EP7SDFNodeS1_d(ptr, ptr, ptr, double) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #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 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { 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 = !{i64 0, i64 8, !10, i64 8, i64 8, !10, i64 16, i64 8, !10, i64 24, i64 8, !10, i64 32, i64 8, !10, i64 40, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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