; LLVM IR from timskillman/raspberrypi :: SharedCode/SMtriangle.ll (ZN10SMtriangle10faceNormalEv)

; 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.vec3f = type { float, float, float }
%class.SMtriangle = type { %class.vec3f, %class.vec3f, %class.vec3f }

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

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_Z12crossProductR5vec3fS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN5vec3fmiES_(ptr noundef nonnull align 4 dereferenceable(12), <2 x float>, float) #4 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZN10SMtriangle10faceNormalEv(ptr noundef nonnull align 4 dereferenceable(36) %0) #5 align 2 {
  %2 = alloca %class.vec3f, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %class.vec3f, align 4
  %5 = alloca %class.vec3f, align 4
  %6 = alloca { <2 x float>, float }, align 4
  %7 = alloca { <2 x float>, float }, align 8
  %8 = alloca %class.vec3f, align 4
  %9 = alloca %class.vec3f, align 4
  %10 = alloca { <2 x float>, float }, align 4
  %11 = alloca { <2 x float>, float }, align 8
  %12 = alloca %class.vec3f, align 4
  %13 = alloca { <2 x float>, float }, align 8
  %14 = alloca float, align 4
  %15 = alloca { <2 x float>, float }, align 8
  %16 = alloca i32, align 4
  %17 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %18 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #8
  %19 = getelementptr inbounds %class.SMtriangle, ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds %class.SMtriangle, ptr %18, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %20, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %5, i64 12, i1 false)
  %21 = getelementptr inbounds { <2 x float>, float }, ptr %6, i32 0, i32 0
  %22 = load <2 x float>, ptr %21, align 4
  %23 = getelementptr inbounds { <2 x float>, float }, ptr %6, i32 0, i32 1
  %24 = load float, ptr %23, align 4
  %25 = call { <2 x float>, float } @_ZN5vec3fmiES_(ptr noundef nonnull align 4 dereferenceable(12) %19, <2 x float> %22, float %24)
  store { <2 x float>, float } %25, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 8 %7, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #8
  %26 = getelementptr inbounds %class.SMtriangle, ptr %18, i32 0, i32 1
  %27 = getelementptr inbounds %class.SMtriangle, ptr %18, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %27, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %9, i64 12, i1 false)
  %28 = getelementptr inbounds { <2 x float>, float }, ptr %10, i32 0, i32 0
  %29 = load <2 x float>, ptr %28, align 4
  %30 = getelementptr inbounds { <2 x float>, float }, ptr %10, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  %32 = call { <2 x float>, float } @_ZN5vec3fmiES_(ptr noundef nonnull align 4 dereferenceable(12) %26, <2 x float> %29, float %31)
  store { <2 x float>, float } %32, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %11, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %12) #8
  %33 = call { <2 x float>, float } @_Z12crossProductR5vec3fS0_(ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %8)
  store { <2 x float>, float } %33, ptr %13, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 8 %13, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %34 = getelementptr inbounds %class.vec3f, ptr %12, i32 0, i32 0
  %35 = load float, ptr %34, align 4, !tbaa !12
  %36 = getelementptr inbounds %class.vec3f, ptr %12, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !12
  %38 = getelementptr inbounds %class.vec3f, ptr %12, i32 0, i32 1
  %39 = load float, ptr %38, align 4, !tbaa !14
  %40 = getelementptr inbounds %class.vec3f, ptr %12, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !14
  %42 = fmul float %39, %41
  %43 = call float @llvm.fmuladd.f32(float %35, float %37, float %42)
  %44 = getelementptr inbounds %class.vec3f, ptr %12, i32 0, i32 2
  %45 = load float, ptr %44, align 4, !tbaa !15
  %46 = getelementptr inbounds %class.vec3f, ptr %12, i32 0, i32 2
  %47 = load float, ptr %46, align 4, !tbaa !15
  %48 = call float @llvm.fmuladd.f32(float %45, float %47, float %43)
  %49 = call float @sqrtf(float noundef %48) #8
  store float %49, ptr %14, align 4, !tbaa !10
  %50 = load float, ptr %14, align 4, !tbaa !10
  %51 = fcmp ogt float %50, 0.000000e+00
  br i1 %51, label %52, label %55

52:                                               ; preds = %1
  %53 = load float, ptr %14, align 4, !tbaa !10
  %54 = call { <2 x float>, float } @_ZN5vec3fdvEf(ptr noundef nonnull align 4 dereferenceable(12) %12, float noundef %53)
  store { <2 x float>, float } %54, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 8 %15, i64 12, i1 false)
  store i32 1, ptr %16, align 4
  br label %56

55:                                               ; preds = %1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %12, i64 12, i1 false), !tbaa.struct !9
  store i32 1, ptr %16, align 4
  br label %56

56:                                               ; preds = %55, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 4 %2, i64 12, i1 false)
  %57 = load { <2 x float>, float }, ptr %17, align 8
  ret { <2 x float>, float } %57
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN5vec3fdvEf(ptr noundef nonnull align 4 dereferenceable(12), float noundef) #7 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 uwtable "min-legal-vector-width"="64" "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 "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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTS5vec3f", !11, i64 0, !11, i64 4, !11, i64 8}
!14 = !{!13, !11, i64 4}
!15 = !{!13, !11, i64 8}


; 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.vec3f = type { float, float, float }

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_Z12crossProductR5vec3fS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0

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

; 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 uwtable
declare dso_local { <2 x float>, float } @_ZN5vec3fmiES_(ptr noundef nonnull align 4 dereferenceable(12), <2 x float>, float) 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) #2

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZN10SMtriangle10faceNormalEv(ptr noundef nonnull align 4 dereferenceable(36) %0) local_unnamed_addr #4 align 2 {
  %2 = alloca %class.vec3f, align 8
  %3 = alloca %class.vec3f, align 8
  %4 = alloca %class.vec3f, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #7
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %.sroa.022.0.copyload = load <2 x float>, ptr %6, align 4
  %.sroa.223.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 20
  %.sroa.223.0.copyload = load float, ptr %.sroa.223.0..sroa_idx, align 4, !tbaa !5
  %7 = tail call { <2 x float>, float } @_ZN5vec3fmiES_(ptr noundef nonnull align 4 dereferenceable(12) %5, <2 x float> %.sroa.022.0.copyload, float %.sroa.223.0.copyload)
  %.fca.0.extract16 = extractvalue { <2 x float>, float } %7, 0
  %.fca.1.extract17 = extractvalue { <2 x float>, float } %7, 1
  store <2 x float> %.fca.0.extract16, ptr %2, align 8
  %.sroa.219.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  store float %.fca.1.extract17, ptr %.sroa.219.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #7
  %.sroa.014.0.copyload = load <2 x float>, ptr %0, align 4
  %.sroa.215.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.215.0.copyload = load float, ptr %.sroa.215.0..sroa_idx, align 4, !tbaa !5
  %8 = tail call { <2 x float>, float } @_ZN5vec3fmiES_(ptr noundef nonnull align 4 dereferenceable(12) %6, <2 x float> %.sroa.014.0.copyload, float %.sroa.215.0.copyload)
  %.fca.0.extract8 = extractvalue { <2 x float>, float } %8, 0
  %.fca.1.extract9 = extractvalue { <2 x float>, float } %8, 1
  store <2 x float> %.fca.0.extract8, ptr %3, align 8
  %.sroa.211.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  store float %.fca.1.extract9, ptr %.sroa.211.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  %9 = call { <2 x float>, float } @_Z12crossProductR5vec3fS0_(ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %3)
  %.fca.0.extract4 = extractvalue { <2 x float>, float } %9, 0
  %.fca.1.extract5 = extractvalue { <2 x float>, float } %9, 1
  store <2 x float> %.fca.0.extract4, ptr %4, align 8
  %.sroa.27.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract5, ptr %.sroa.27.0..sroa_idx, align 8
  %10 = extractelement <2 x float> %.fca.0.extract4, i64 0
  %11 = fmul <2 x float> %.fca.0.extract4, %.fca.0.extract4
  %12 = extractelement <2 x float> %11, i64 1
  %13 = call float @llvm.fmuladd.f32(float %10, float %10, float %12)
  %14 = call float @llvm.fmuladd.f32(float %.fca.1.extract5, float %.fca.1.extract5, float %13)
  %sqrt = call float @llvm.sqrt.f32(float %14)
  %15 = fcmp ogt float %sqrt, 0.000000e+00
  br i1 %15, label %16, label %18

16:                                               ; preds = %1
  %17 = call { <2 x float>, float } @_ZN5vec3fdvEf(ptr noundef nonnull align 4 dereferenceable(12) %4, float noundef %sqrt)
  br label %18

18:                                               ; preds = %1, %16
  %.fca.1.insert.merged = phi { <2 x float>, float } [ %17, %16 ], [ %9, %1 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #7
  ret { <2 x float>, float } %.fca.1.insert.merged
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN5vec3fdvEf(ptr noundef nonnull align 4 dereferenceable(12), float noundef) local_unnamed_addr #5 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 uwtable "min-legal-vector-width"="64" "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 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 nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SCCPPass,SROAPass,TailCallElimPass,VectorCombinePass