; LLVM IR from The-Order-of-the-Simulation/Path-Tracing-Renderer :: cpu/main.ll (Z6sphere4vec3S_S_f)

; 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.vec3 = type { float, float, float }
%class.intersection = type { float, float, i8, %class.vec3, %class.material }
%class.material = type { i8, %class.vec3, float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z3dotRK4vec3S1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9normalizeRK4vec3(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12)) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4vec3miERKS_(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4vec3mlEf(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12), float noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6sphere4vec3S_S_f(ptr dead_on_unwind noalias writable sret(%class.intersection) align 4 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, float noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca %class.vec3, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca %class.vec3, align 4
  %17 = alloca %class.vec3, align 4
  %18 = alloca %class.vec3, align 4
  %19 = alloca %class.vec3, align 4
  store ptr %0, ptr %6, align 8
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store float %4, ptr %10, align 4, !tbaa !9
  call void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48) %0)
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #7
  call void @_ZNK4vec3miERKS_(ptr dead_on_unwind writable sret(%class.vec3) align 4 %11, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %20 = call noundef float @_Z3dotRK4vec3S1_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %2)
  store float %20, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %21 = call noundef float @_Z3dotRK4vec3S1_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %11)
  %22 = load float, ptr %10, align 4, !tbaa !9
  %23 = load float, ptr %10, align 4, !tbaa !9
  %24 = fneg float %22
  %25 = call float @llvm.fmuladd.f32(float %24, float %23, float %21)
  store float %25, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %26 = load float, ptr %12, align 4, !tbaa !9
  %27 = load float, ptr %12, align 4, !tbaa !9
  %28 = load float, ptr %13, align 4, !tbaa !9
  %29 = fneg float %28
  %30 = call float @llvm.fmuladd.f32(float %26, float %27, float %29)
  store float %30, ptr %14, align 4, !tbaa !9
  %31 = load float, ptr %14, align 4, !tbaa !9
  %32 = fcmp olt float %31, 0.000000e+00
  br i1 %32, label %33, label %34

33:                                               ; preds = %5
  store i32 1, ptr %15, align 4
  br label %56

34:                                               ; preds = %5
  %35 = load float, ptr %14, align 4, !tbaa !9
  %36 = call float @sqrtf(float noundef %35) #7
  store float %36, ptr %14, align 4, !tbaa !9
  %37 = load float, ptr %12, align 4, !tbaa !9
  %38 = fneg float %37
  %39 = load float, ptr %14, align 4, !tbaa !9
  %40 = fsub float %38, %39
  %41 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 0
  store float %40, ptr %41, align 4, !tbaa !11
  %42 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 0
  %43 = load float, ptr %42, align 4, !tbaa !11
  %44 = fcmp olt float %43, 0.000000e+00
  br i1 %44, label %45, label %46

45:                                               ; preds = %34
  store i32 1, ptr %15, align 4
  br label %56

46:                                               ; preds = %34
  %47 = load float, ptr %12, align 4, !tbaa !9
  %48 = fneg float %47
  %49 = load float, ptr %14, align 4, !tbaa !9
  %50 = fadd float %48, %49
  %51 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 1
  store float %50, ptr %51, align 4, !tbaa !16
  %52 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 2
  store i8 1, ptr %52, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %17) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %19) #7
  %53 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 0
  %54 = load float, ptr %53, align 4, !tbaa !11
  call void @_ZNK4vec3mlEf(ptr dead_on_unwind writable sret(%class.vec3) align 4 %19, ptr noundef nonnull align 4 dereferenceable(12) %2, float noundef %54)
  call void @_ZNK4vec3plERKS_(ptr dead_on_unwind writable sret(%class.vec3) align 4 %18, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %19)
  call void @_ZNK4vec3miERKS_(ptr dead_on_unwind writable sret(%class.vec3) align 4 %17, ptr noundef nonnull align 4 dereferenceable(12) %18, ptr noundef nonnull align 4 dereferenceable(12) %3)
  call void @_Z9normalizeRK4vec3(ptr dead_on_unwind writable sret(%class.vec3) align 4 %16, ptr noundef nonnull align 4 dereferenceable(12) %17)
  %55 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %55, ptr align 4 %16, i64 12, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 12, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #7
  store i32 1, ptr %15, align 4
  br label %56

56:                                               ; preds = %46, %45, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #7
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4vec3plERKS_(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; 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) #6

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS12intersection", !10, i64 0, !10, i64 4, !13, i64 8, !14, i64 12, !15, i64 24}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS4vec3", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!"_ZTS8material", !13, i64 0, !14, i64 4, !10, i64 16, !10, i64 20}
!16 = !{!12, !10, i64 4}
!17 = !{!12, !13, i64 8}
!18 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9}


; 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.vec3 = type { float, float, float }
%class.intersection = type { float, float, i8, %class.vec3, %class.material }
%class.material = type { i8, %class.vec3, float, float }

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z3dotRK4vec3S1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9normalizeRK4vec3(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4vec3miERKS_(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4vec3mlEf(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12), float noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6sphere4vec3S_S_f(ptr dead_on_unwind noalias nonnull writable sret(%class.intersection) align 4 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, float noundef %4) local_unnamed_addr #3 {
  %6 = alloca %class.vec3, align 4
  %7 = alloca %class.vec3, align 4
  %8 = alloca %class.vec3, align 4
  %9 = alloca %class.vec3, align 4
  %10 = alloca %class.vec3, align 4
  tail call void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48) %0)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #7
  call void @_ZNK4vec3miERKS_(ptr dead_on_unwind nonnull writable sret(%class.vec3) align 4 %6, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %3)
  %11 = call noundef float @_Z3dotRK4vec3S1_(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %12 = call noundef float @_Z3dotRK4vec3S1_(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %6)
  %13 = fneg float %4
  %14 = call float @llvm.fmuladd.f32(float %13, float %4, float %12)
  %15 = fneg float %14
  %16 = call float @llvm.fmuladd.f32(float %11, float %11, float %15)
  %17 = fcmp olt float %16, 0.000000e+00
  br i1 %17, label %28, label %18

18:                                               ; preds = %5
  %19 = call float @sqrtf(float noundef %16) #7
  %20 = fneg float %11
  %21 = fsub float %20, %19
  store float %21, ptr %0, align 4, !tbaa !5
  %22 = fcmp olt float %21, 0.000000e+00
  br i1 %22, label %28, label %23

23:                                               ; preds = %18
  %24 = fsub float %19, %11
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  store float %24, ptr %25, align 4, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 1, ptr %26, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  call void @_ZNK4vec3mlEf(ptr dead_on_unwind nonnull writable sret(%class.vec3) align 4 %10, ptr noundef nonnull align 4 dereferenceable(12) %2, float noundef %21)
  call void @_ZNK4vec3plERKS_(ptr dead_on_unwind nonnull writable sret(%class.vec3) align 4 %9, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @_ZNK4vec3miERKS_(ptr dead_on_unwind nonnull writable sret(%class.vec3) align 4 %8, ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %3)
  call void @_Z9normalizeRK4vec3(ptr dead_on_unwind nonnull writable sret(%class.vec3) align 4 %7, ptr noundef nonnull align 4 dereferenceable(12) %8)
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %27, ptr noundef nonnull align 4 dereferenceable(12) %7, i64 12, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  br label %28

28:                                               ; preds = %18, %5, %23
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #7
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4vec3plERKS_(ptr dead_on_unwind noalias writable sret(%class.vec3) align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3 align 2

; 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) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTS12intersection", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 12, !12, i64 24}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS4vec3", !7, i64 0, !7, i64 4, !7, i64 8}
!12 = !{!"_ZTS8material", !10, i64 0, !11, i64 4, !7, i64 16, !7, i64 20}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !10, i64 8}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 4, !16}
!16 = !{!7, !7, i64 0}


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