; LLVM IR from Calvin-L/MarchingTetrahedrons :: Isosurface.ll (ZNK10Isosurface10gradientAtEfff)

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

%struct.Vector3D = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK10Isosurface10gradientAtEfff(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1, float noundef %2, float noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca %struct.Vector3D, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 0x3F1A36E2E0000000, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %16 = load float, ptr %7, align 4, !tbaa !9
  %17 = fadd float %16, 0x3F1A36E2E0000000
  %18 = load float, ptr %8, align 4, !tbaa !9
  %19 = load float, ptr %9, align 4, !tbaa !9
  %20 = load ptr, ptr %15, align 8, !tbaa !11
  %21 = getelementptr inbounds ptr, ptr %20, i64 0
  %22 = load ptr, ptr %21, align 8
  %23 = call noundef float %22(ptr noundef nonnull align 8 dereferenceable(8) %15, float noundef %17, float noundef %18, float noundef %19)
  %24 = load float, ptr %7, align 4, !tbaa !9
  %25 = fsub float %24, 0x3F1A36E2E0000000
  %26 = load float, ptr %8, align 4, !tbaa !9
  %27 = load float, ptr %9, align 4, !tbaa !9
  %28 = load ptr, ptr %15, align 8, !tbaa !11
  %29 = getelementptr inbounds ptr, ptr %28, i64 0
  %30 = load ptr, ptr %29, align 8
  %31 = call noundef float %30(ptr noundef nonnull align 8 dereferenceable(8) %15, float noundef %25, float noundef %26, float noundef %27)
  %32 = fsub float %23, %31
  store float %32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %33 = load float, ptr %7, align 4, !tbaa !9
  %34 = load float, ptr %8, align 4, !tbaa !9
  %35 = fadd float %34, 0x3F1A36E2E0000000
  %36 = load float, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %15, align 8, !tbaa !11
  %38 = getelementptr inbounds ptr, ptr %37, i64 0
  %39 = load ptr, ptr %38, align 8
  %40 = call noundef float %39(ptr noundef nonnull align 8 dereferenceable(8) %15, float noundef %33, float noundef %35, float noundef %36)
  %41 = load float, ptr %7, align 4, !tbaa !9
  %42 = load float, ptr %8, align 4, !tbaa !9
  %43 = fsub float %42, 0x3F1A36E2E0000000
  %44 = load float, ptr %9, align 4, !tbaa !9
  %45 = load ptr, ptr %15, align 8, !tbaa !11
  %46 = getelementptr inbounds ptr, ptr %45, i64 0
  %47 = load ptr, ptr %46, align 8
  %48 = call noundef float %47(ptr noundef nonnull align 8 dereferenceable(8) %15, float noundef %41, float noundef %43, float noundef %44)
  %49 = fsub float %40, %48
  store float %49, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %50 = load float, ptr %7, align 4, !tbaa !9
  %51 = load float, ptr %8, align 4, !tbaa !9
  %52 = load float, ptr %9, align 4, !tbaa !9
  %53 = fadd float %52, 0x3F1A36E2E0000000
  %54 = load ptr, ptr %15, align 8, !tbaa !11
  %55 = getelementptr inbounds ptr, ptr %54, i64 0
  %56 = load ptr, ptr %55, align 8
  %57 = call noundef float %56(ptr noundef nonnull align 8 dereferenceable(8) %15, float noundef %50, float noundef %51, float noundef %53)
  %58 = load float, ptr %7, align 4, !tbaa !9
  %59 = load float, ptr %8, align 4, !tbaa !9
  %60 = load float, ptr %9, align 4, !tbaa !9
  %61 = fsub float %60, 0x3F1A36E2E0000000
  %62 = load ptr, ptr %15, align 8, !tbaa !11
  %63 = getelementptr inbounds ptr, ptr %62, i64 0
  %64 = load ptr, ptr %63, align 8
  %65 = call noundef float %64(ptr noundef nonnull align 8 dereferenceable(8) %15, float noundef %58, float noundef %59, float noundef %61)
  %66 = fsub float %57, %65
  store float %66, ptr %13, align 4, !tbaa !9
  %67 = getelementptr inbounds %struct.Vector3D, ptr %5, i32 0, i32 0
  %68 = load float, ptr %11, align 4, !tbaa !9
  store float %68, ptr %67, align 4, !tbaa !13
  %69 = getelementptr inbounds %struct.Vector3D, ptr %5, i32 0, i32 1
  %70 = load float, ptr %12, align 4, !tbaa !9
  store float %70, ptr %69, align 4, !tbaa !15
  %71 = getelementptr inbounds %struct.Vector3D, ptr %5, i32 0, i32 2
  %72 = load float, ptr %13, align 4, !tbaa !9
  store float %72, ptr %71, align 4, !tbaa !16
  call void @_Z9normalizeR8Vector3D(ptr noundef nonnull align 4 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 4 %5, i64 12, i1 false)
  %73 = load { <2 x float>, float }, ptr %14, align 8
  ret { <2 x float>, float } %73
}

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

declare void @_Z9normalizeR8Vector3D(ptr noundef nonnull align 4 dereferenceable(12)) #2

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS8Vector3D", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!14, !10, i64 4}
!16 = !{!14, !10, 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"

%struct.Vector3D = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK10Isosurface10gradientAtEfff(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1, float noundef %2, float noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca %struct.Vector3D, align 8
  %6 = fadd float %1, 0x3F1A36E2E0000000
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8
  %9 = tail call noundef float %8(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %6, float noundef %2, float noundef %3)
  %10 = fadd float %1, 0xBF1A36E2E0000000
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %12 = load ptr, ptr %11, align 8
  %13 = tail call noundef float %12(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %10, float noundef %2, float noundef %3)
  %14 = fadd float %2, 0x3F1A36E2E0000000
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = load ptr, ptr %15, align 8
  %17 = tail call noundef float %16(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1, float noundef %14, float noundef %3)
  %18 = fadd float %2, 0xBF1A36E2E0000000
  %19 = load ptr, ptr %0, align 8, !tbaa !5
  %20 = load ptr, ptr %19, align 8
  %21 = tail call noundef float %20(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1, float noundef %18, float noundef %3)
  %22 = fadd float %3, 0x3F1A36E2E0000000
  %23 = load ptr, ptr %0, align 8, !tbaa !5
  %24 = load ptr, ptr %23, align 8
  %25 = tail call noundef float %24(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1, float noundef %2, float noundef %22)
  %26 = fadd float %3, 0xBF1A36E2E0000000
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8
  %29 = tail call noundef float %28(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1, float noundef %2, float noundef %26)
  %30 = fsub float %25, %29
  %31 = insertelement <2 x float> poison, float %9, i64 0
  %32 = insertelement <2 x float> %31, float %17, i64 1
  %33 = insertelement <2 x float> poison, float %13, i64 0
  %34 = insertelement <2 x float> %33, float %21, i64 1
  %35 = fsub <2 x float> %32, %34
  store <2 x float> %35, ptr %5, align 8, !tbaa !8
  %36 = getelementptr inbounds i8, ptr %5, i64 8
  store float %30, ptr %36, align 8, !tbaa !11
  call void @_Z9normalizeR8Vector3D(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %.sroa.0.0.copyload = load <2 x float>, ptr %5, align 8
  %.sroa.2.0.copyload = load float, ptr %36, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

declare void @_Z9normalizeR8Vector3D(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 8}
!12 = !{!"_ZTS8Vector3D", !9, i64 0, !9, i64 4, !9, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass