; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics/R3AreaLight.ll (ZNK11R3AreaLight16IntensityAtPointERK7R3Point)

; 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.R3Triad = type { [3 x %class.R3Vector] }
%class.R3Vector = type { [3 x double] }
%class.R3Point = type { [3 x double] }
%class.R3AreaLight = type { %class.R3Light.base, %class.R3Circle, double, double, double }
%class.R3Light.base = type <{ ptr, ptr, i32, [4 x i8], ptr, i32, [4 x i8], double, %class.RNRgb, i32 }>
%class.RNRgb = type { [3 x double] }
%class.R3Circle = type { %class.R3Surface, %class.R3Point, double, %class.R3Plane }
%class.R3Surface = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Plane = type { %class.R3Vector, double }

@R3xyz_triad = external global %class.R3Triad, align 8
@RN_EPSILON = external global double, align 8

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK11R3AreaLight6RadiusEv(ptr noundef nonnull align 8 dereferenceable(176)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(176)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight8PositionEv(ptr noundef nonnull align 8 dereferenceable(176)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK11R3AreaLight16IntensityAtPointERK7R3Point(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) unnamed_addr #1 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %class.R3Vector, align 8
  %9 = alloca i32, align 4
  %10 = alloca %class.R3Vector, align 8
  %11 = alloca %class.R3Vector, align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca %class.R3Point, align 8
  %17 = alloca %class.R3Vector, align 8
  %18 = alloca %class.R3Vector, align 8
  %19 = alloca %class.R3Vector, align 8
  %20 = alloca double, align 8
  %21 = alloca %class.R3Vector, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 4, ptr %6, align 4, !tbaa !9
  %27 = call noundef i32 @_ZNK7R3Light8IsActiveEv(ptr noundef nonnull align 8 dereferenceable(76) %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %2
  store double 0.000000e+00, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %130

30:                                               ; preds = %2
  %31 = getelementptr inbounds %class.R3AreaLight, ptr %26, i32 0, i32 1
  %32 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8R3Circle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(72) %31)
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %32, ptr noundef nonnull align 8 dereferenceable(24) %33)
  %35 = fcmp ole double %34, 0.000000e+00
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store double 0.000000e+00, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %130

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #6
  %38 = getelementptr inbounds %class.R3AreaLight, ptr %26, i32 0, i32 1
  %39 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Circle6NormalEv(ptr noundef nonnull align 8 dereferenceable(72) %38)
  call void @_ZN8R3VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(24) %39)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %40 = call noundef i32 @_ZNK8R3Vector12MinDimensionEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  store i32 %40, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #6
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3TriadixEi(ptr noundef nonnull align 8 dereferenceable(72) @R3xyz_triad, i32 noundef %41)
  call void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %10, ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(24) %42)
  call void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #6
  call void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %11, ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %113, %111, %37
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 4
  br i1 %45, label %46, label %114

46:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %47 = call noundef double @_Z14RNRandomScalarv()
  %48 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %47, double -1.000000e+00)
  store double %48, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %49 = call noundef double @_Z14RNRandomScalarv()
  %50 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %49, double -1.000000e+00)
  store double %50, ptr %15, align 8, !tbaa !11
  %51 = load double, ptr %14, align 8, !tbaa !11
  %52 = load double, ptr %14, align 8, !tbaa !11
  %53 = load double, ptr %15, align 8, !tbaa !11
  %54 = load double, ptr %15, align 8, !tbaa !11
  %55 = fmul double %53, %54
  %56 = call double @llvm.fmuladd.f64(double %51, double %52, double %55)
  %57 = fcmp ogt double %56, 1.000000e+00
  br i1 %57, label %58, label %59

58:                                               ; preds = %46
  store i32 2, ptr %7, align 4
  br label %111, !llvm.loop !13

59:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #6
  %60 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight8PositionEv(ptr noundef nonnull align 8 dereferenceable(176) %26)
  call void @_ZN7R3PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 8 dereferenceable(24) %60)
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #6
  %61 = load double, ptr %14, align 8, !tbaa !11
  %62 = call noundef double @_ZNK11R3AreaLight6RadiusEv(ptr noundef nonnull align 8 dereferenceable(176) %26)
  %63 = fmul double %61, %62
  call void @_ZmldRK8R3Vector(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %17, double noundef %63, ptr noundef nonnull align 8 dereferenceable(24) %10)
  %64 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointpLERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 8 dereferenceable(24) %17)
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #6
  %65 = load double, ptr %15, align 8, !tbaa !11
  %66 = call noundef double @_ZNK11R3AreaLight6RadiusEv(ptr noundef nonnull align 8 dereferenceable(176) %26)
  %67 = fmul double %65, %66
  call void @_ZmldRK8R3Vector(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %18, double noundef %67, ptr noundef nonnull align 8 dereferenceable(24) %11)
  %68 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointpLERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 8 dereferenceable(24) %18)
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #6
  %69 = load i32, ptr %12, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %19) #6
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZmiRK7R3PointS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %19, ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 8 dereferenceable(24) %71)
  call void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %72 = call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %26)
  %73 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(176) %26)
  call void @llvm.lifetime.start.p0(i64 24, ptr %21) #6
  call void @_ZngRK8R3Vector(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %21, ptr noundef nonnull align 8 dereferenceable(24) %19)
  %74 = call noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24) %73, ptr noundef nonnull align 8 dereferenceable(24) %21)
  %75 = fmul double %72, %74
  call void @llvm.lifetime.end.p0(i64 24, ptr %21) #6
  store double %75, ptr %20, align 8, !tbaa !11
  %76 = load double, ptr %20, align 8, !tbaa !11
  %77 = load double, ptr @RN_EPSILON, align 8, !tbaa !11
  %78 = call noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %76, double noundef %77)
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %81

80:                                               ; preds = %59
  store double 0.000000e+00, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %110

81:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %82, ptr noundef nonnull align 8 dereferenceable(24) %16)
  store double %83, ptr %22, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %84 = getelementptr inbounds %class.R3AreaLight, ptr %26, i32 0, i32 2
  %85 = load double, ptr %84, align 8, !tbaa !15
  store double %85, ptr %23, align 8, !tbaa !11
  %86 = load double, ptr %22, align 8, !tbaa !11
  %87 = getelementptr inbounds %class.R3AreaLight, ptr %26, i32 0, i32 3
  %88 = load double, ptr %87, align 8, !tbaa !25
  %89 = load double, ptr %23, align 8, !tbaa !11
  %90 = call double @llvm.fmuladd.f64(double %86, double %88, double %89)
  store double %90, ptr %23, align 8, !tbaa !11
  %91 = load double, ptr %22, align 8, !tbaa !11
  %92 = load double, ptr %22, align 8, !tbaa !11
  %93 = fmul double %91, %92
  %94 = getelementptr inbounds %class.R3AreaLight, ptr %26, i32 0, i32 4
  %95 = load double, ptr %94, align 8, !tbaa !26
  %96 = load double, ptr %23, align 8, !tbaa !11
  %97 = call double @llvm.fmuladd.f64(double %93, double %95, double %96)
  store double %97, ptr %23, align 8, !tbaa !11
  %98 = load double, ptr %23, align 8, !tbaa !11
  %99 = load double, ptr @RN_EPSILON, align 8, !tbaa !11
  %100 = call noundef i32 @_Z12RNIsPositivedd(double noundef %98, double noundef %99)
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %106

102:                                              ; preds = %81
  %103 = load double, ptr %23, align 8, !tbaa !11
  %104 = load double, ptr %20, align 8, !tbaa !11
  %105 = fdiv double %104, %103
  store double %105, ptr %20, align 8, !tbaa !11
  br label %106

106:                                              ; preds = %102, %81
  %107 = load double, ptr %20, align 8, !tbaa !11
  %108 = load double, ptr %13, align 8, !tbaa !11
  %109 = fadd double %108, %107
  store double %109, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  store i32 0, ptr %7, align 4
  br label %110

110:                                              ; preds = %106, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #6
  br label %111

111:                                              ; preds = %110, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  %112 = load i32, ptr %7, align 4
  switch i32 %112, label %129 [
    i32 0, label %113
    i32 2, label %43
  ]

113:                                              ; preds = %111
  br label %43, !llvm.loop !13

114:                                              ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %115 = getelementptr inbounds %class.R3AreaLight, ptr %26, i32 0, i32 1
  %116 = call noundef double @_ZNK8R3Circle4AreaEv(ptr noundef nonnull align 8 dereferenceable(72) %115)
  store double %116, ptr %24, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %117 = load double, ptr %13, align 8, !tbaa !11
  store double %117, ptr %25, align 8, !tbaa !11
  %118 = load i32, ptr %12, align 4, !tbaa !9
  %119 = icmp sgt i32 %118, 0
  br i1 %119, label %120, label %125

120:                                              ; preds = %114
  %121 = load i32, ptr %12, align 4, !tbaa !9
  %122 = sitofp i32 %121 to double
  %123 = load double, ptr %25, align 8, !tbaa !11
  %124 = fdiv double %123, %122
  store double %124, ptr %25, align 8, !tbaa !11
  br label %125

125:                                              ; preds = %120, %114
  %126 = load double, ptr %24, align 8, !tbaa !11
  %127 = load double, ptr %25, align 8, !tbaa !11
  %128 = fmul double %126, %127
  store double %128, ptr %3, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  br label %129

129:                                              ; preds = %125, %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #6
  br label %130

130:                                              ; preds = %129, %36, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %131 = load double, ptr %3, align 8
  ret double %131
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7R3Light8IsActiveEv(ptr noundef nonnull align 8 dereferenceable(76)) #3 align 2

declare noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8R3Circle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(72)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Circle6NormalEv(ptr noundef nonnull align 8 dereferenceable(72)) #0 align 2

declare void @_ZN8R3VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

declare noundef i32 @_ZNK8R3Vector12MinDimensionEv(ptr noundef nonnull align 8 dereferenceable(24)) #4

declare void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3TriadixEi(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) #0 align 2

declare void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #4

declare noundef double @_Z14RNRandomScalarv() #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

declare void @_ZN7R3PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZmldRK8R3Vector(ptr dead_on_unwind noalias writable sret(%class.R3Vector) align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(24)) #0

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointpLERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

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

declare void @_ZmiRK7R3PointS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76)) #3 align 2

declare noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

declare void @_ZngRK8R3Vector(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24)) #4

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

declare noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

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

declare noundef double @_ZNK8R3Circle4AreaEv(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #4

attributes #0 = { 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 #1 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !12, i64 152}
!16 = !{!"_ZTS11R3AreaLight", !17, i64 0, !19, i64 80, !12, i64 152, !12, i64 160, !12, i64 168}
!17 = !{!"_ZTS7R3Light", !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !12, i64 40, !18, i64 48, !10, i64 72}
!18 = !{!"_ZTS5RNRgb", !7, i64 0}
!19 = !{!"_ZTS8R3Circle", !20, i64 0, !22, i64 8, !12, i64 32, !23, i64 40}
!20 = !{!"_ZTS9R3Surface", !21, i64 0}
!21 = !{!"_ZTS7R3Shape"}
!22 = !{!"_ZTS7R3Point", !7, i64 0}
!23 = !{!"_ZTS7R3Plane", !24, i64 0, !12, i64 24}
!24 = !{!"_ZTS8R3Vector", !7, i64 0}
!25 = !{!16, !12, i64 160}
!26 = !{!16, !12, i64 168}


; 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.R3Triad = type { [3 x %class.R3Vector] }
%class.R3Vector = type { [3 x double] }
%class.R3Point = type { [3 x double] }

@R3xyz_triad = external global %class.R3Triad, align 8
@RN_EPSILON = external local_unnamed_addr global double, align 8

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK11R3AreaLight6RadiusEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight8PositionEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK11R3AreaLight16IntensityAtPointERK7R3Point(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) unnamed_addr #1 align 2 {
  %3 = alloca %class.R3Vector, align 8
  %4 = alloca %class.R3Vector, align 8
  %5 = alloca %class.R3Vector, align 8
  %6 = alloca %class.R3Point, align 8
  %7 = alloca %class.R3Vector, align 8
  %8 = alloca %class.R3Vector, align 8
  %9 = alloca %class.R3Vector, align 8
  %10 = alloca %class.R3Vector, align 8
  %11 = tail call noundef i32 @_ZNK7R3Light8IsActiveEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %65, label %12

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8R3Circle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(72) %13)
  %15 = tail call noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %16 = fcmp ugt double %15, 0.000000e+00
  br i1 %16, label %17, label %65

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  %18 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Circle6NormalEv(ptr noundef nonnull align 8 dereferenceable(72) %13)
  call void @_ZN8R3VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %18)
  %19 = call noundef i32 @_ZNK8R3Vector12MinDimensionEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  %20 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3TriadixEi(ptr noundef nonnull align 8 dereferenceable(72) @R3xyz_triad, i32 noundef %19)
  call void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %4, ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %20)
  call void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  call void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %5, ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %21 = getelementptr inbounds i8, ptr %0, i64 152
  %22 = getelementptr inbounds i8, ptr %0, i64 160
  %23 = getelementptr inbounds i8, ptr %0, i64 168
  br label %24

24:                                               ; preds = %17, %.backedge
  %.03545 = phi i32 [ 0, %17 ], [ %.13653, %.backedge ]
  %.03744 = phi double [ 0.000000e+00, %17 ], [ %.23951, %.backedge ]
  %25 = call noundef double @_Z14RNRandomScalarv()
  %26 = call double @llvm.fmuladd.f64(double %25, double 2.000000e+00, double -1.000000e+00)
  %27 = call noundef double @_Z14RNRandomScalarv()
  %28 = call double @llvm.fmuladd.f64(double %27, double 2.000000e+00, double -1.000000e+00)
  %29 = fmul double %28, %28
  %30 = call double @llvm.fmuladd.f64(double %26, double %26, double %29)
  %31 = fcmp ogt double %30, 1.000000e+00
  br i1 %31, label %.backedge, label %32, !llvm.loop !5

32:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #6
  %33 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight8PositionEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  call void @_ZN7R3PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %33)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #6
  %34 = call noundef double @_ZNK11R3AreaLight6RadiusEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  %35 = fmul double %26, %34
  call void @_ZmldRK8R3Vector(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %7, double noundef %35, ptr noundef nonnull align 8 dereferenceable(24) %4)
  %36 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointpLERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %7)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #6
  %37 = call noundef double @_ZNK11R3AreaLight6RadiusEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  %38 = fmul double %28, %37
  call void @_ZmldRK8R3Vector(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %8, double noundef %38, ptr noundef nonnull align 8 dereferenceable(24) %5)
  %39 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointpLERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %8)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #6
  call void @_ZmiRK7R3PointS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %1)
  call void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9)
  %40 = call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %41 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK11R3AreaLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #6
  call void @_ZngRK8R3Vector(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %10, ptr noundef nonnull align 8 dereferenceable(24) %9)
  %42 = call noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24) %41, ptr noundef nonnull align 8 dereferenceable(24) %10)
  %43 = fmul double %40, %42
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #6
  %44 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %45 = call noundef i32 @_Z18RNIsNegativeOrZerodd(double noundef %43, double noundef %44)
  %.not40 = icmp eq i32 %45, 0
  br i1 %.not40, label %46, label %.loopexit.loopexit

46:                                               ; preds = %32
  %47 = add nsw i32 %.03545, 1
  %48 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %6)
  %49 = load double, ptr %21, align 8, !tbaa !11
  %50 = load double, ptr %22, align 8, !tbaa !23
  %51 = call double @llvm.fmuladd.f64(double %48, double %50, double %49)
  %52 = fmul double %48, %48
  %53 = load double, ptr %23, align 8, !tbaa !24
  %54 = call double @llvm.fmuladd.f64(double %52, double %53, double %51)
  %55 = load double, ptr @RN_EPSILON, align 8, !tbaa !7
  %56 = call noundef i32 @_Z12RNIsPositivedd(double noundef %54, double noundef %55)
  %.not41 = icmp eq i32 %56, 0
  %57 = fdiv double %43, %54
  %.034 = select i1 %.not41, double %43, double %57
  %58 = fadd double %.03744, %.034
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #6
  br label %.backedge

.backedge:                                        ; preds = %24, %46
  %.13653 = phi i32 [ %47, %46 ], [ %.03545, %24 ]
  %.23951 = phi double [ %58, %46 ], [ %.03744, %24 ]
  %59 = icmp slt i32 %.13653, 4
  br i1 %59, label %24, label %60, !llvm.loop !5

60:                                               ; preds = %.backedge
  %61 = call noundef double @_ZNK8R3Circle4AreaEv(ptr noundef nonnull align 8 dereferenceable(72) %13)
  %62 = uitofp nneg i32 %.13653 to double
  %63 = fdiv double %.23951, %62
  %64 = fmul double %63, %61
  br label %.loopexit

.loopexit.loopexit:                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #6
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %60
  %.3 = phi double [ %64, %60 ], [ 0.000000e+00, %.loopexit.loopexit ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  br label %65

65:                                               ; preds = %12, %2, %.loopexit
  %.4 = phi double [ %.3, %.loopexit ], [ 0.000000e+00, %2 ], [ 0.000000e+00, %12 ]
  ret double %.4
}

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

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

declare noundef double @_Z16R3SignedDistanceRK7R3PlaneRK7R3Point(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK8R3Circle5PlaneEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Circle6NormalEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #0 align 2

declare void @_ZN8R3VectorC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

declare noundef i32 @_ZNK8R3Vector12MinDimensionEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

declare void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3TriadixEi(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) local_unnamed_addr #0 align 2

declare void @_ZN8R3Vector9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

declare noundef double @_Z14RNRandomScalarv() local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

declare void @_ZN7R3PointC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZmldRK8R3Vector(ptr dead_on_unwind noalias writable sret(%class.R3Vector) align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN7R3PointpLERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

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

declare void @_ZmiRK7R3PointS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

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

declare noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

declare void @_ZngRK8R3Vector(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

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

declare noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

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

declare noundef double @_ZNK8R3Circle4AreaEv(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #4

attributes #0 = { 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 #1 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !8, i64 152}
!12 = !{!"_ZTS11R3AreaLight", !13, i64 0, !17, i64 80, !8, i64 152, !8, i64 160, !8, i64 168}
!13 = !{!"_ZTS7R3Light", !14, i64 8, !15, i64 16, !14, i64 24, !15, i64 32, !8, i64 40, !16, i64 48, !15, i64 72}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"int", !9, i64 0}
!16 = !{!"_ZTS5RNRgb", !9, i64 0}
!17 = !{!"_ZTS8R3Circle", !18, i64 0, !20, i64 8, !8, i64 32, !21, i64 40}
!18 = !{!"_ZTS9R3Surface", !19, i64 0}
!19 = !{!"_ZTS7R3Shape"}
!20 = !{!"_ZTS7R3Point", !9, i64 0}
!21 = !{!"_ZTS7R3Plane", !22, i64 0, !8, i64 24}
!22 = !{!"_ZTS8R3Vector", !9, i64 0}
!23 = !{!12, !8, i64 160}
!24 = !{!12, !8, i64 168}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass