; LLVM IR from faishasj/cpparticles :: src/particle.ll (ZN8Particle7combineEPS_)

; 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.Vector = type { float, float }
%class.Particle = type { float, float, float, float, float, float, float, float, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZplRK6VectorS1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5hypotff(float noundef, float noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8Particle7combineEPS_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %struct.Vector, align 4
  %10 = alloca %struct.Vector, align 4
  %11 = alloca %struct.Vector, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %13 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 6
  %14 = load float, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.Particle, ptr %15, i32 0, i32 6
  %17 = load float, ptr %16, align 8, !tbaa !9
  %18 = fsub float %14, %17
  store float %18, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %19 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 7
  %20 = load float, ptr %19, align 4, !tbaa !13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.Particle, ptr %21, i32 0, i32 7
  %23 = load float, ptr %22, align 4, !tbaa !13
  %24 = fsub float %20, %23
  store float %24, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %25 = load float, ptr %5, align 4, !tbaa !12
  %26 = load float, ptr %6, align 4, !tbaa !12
  %27 = call noundef float @_ZSt5hypotff(float noundef %25, float noundef %26)
  store float %27, ptr %7, align 4, !tbaa !12
  %28 = load float, ptr %7, align 4, !tbaa !12
  %29 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 4
  %30 = load float, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %class.Particle, ptr %31, i32 0, i32 4
  %33 = load float, ptr %32, align 8, !tbaa !14
  %34 = fadd float %30, %33
  %35 = fcmp olt float %28, %34
  br i1 %35, label %36, label %120

36:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %37 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %38 = load float, ptr %37, align 4, !tbaa !15
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %class.Particle, ptr %39, i32 0, i32 3
  %41 = load float, ptr %40, align 4, !tbaa !15
  %42 = fadd float %38, %41
  store float %42, ptr %8, align 4, !tbaa !12
  %43 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 6
  %44 = load float, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %46 = load float, ptr %45, align 4, !tbaa !15
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %class.Particle, ptr %47, i32 0, i32 6
  %49 = load float, ptr %48, align 8, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %class.Particle, ptr %50, i32 0, i32 3
  %52 = load float, ptr %51, align 4, !tbaa !15
  %53 = fmul float %49, %52
  %54 = call float @llvm.fmuladd.f32(float %44, float %46, float %53)
  %55 = load float, ptr %8, align 4, !tbaa !12
  %56 = fdiv float %54, %55
  %57 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 6
  store float %56, ptr %57, align 8, !tbaa !9
  %58 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 7
  %59 = load float, ptr %58, align 4, !tbaa !13
  %60 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %61 = load float, ptr %60, align 4, !tbaa !15
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %class.Particle, ptr %62, i32 0, i32 7
  %64 = load float, ptr %63, align 4, !tbaa !13
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %class.Particle, ptr %65, i32 0, i32 3
  %67 = load float, ptr %66, align 4, !tbaa !15
  %68 = fmul float %64, %67
  %69 = call float @llvm.fmuladd.f32(float %59, float %61, float %68)
  %70 = load float, ptr %8, align 4, !tbaa !12
  %71 = fdiv float %69, %70
  %72 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 7
  store float %71, ptr %72, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %73 = getelementptr inbounds %struct.Vector, ptr %10, i32 0, i32 0
  %74 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 0
  %75 = load float, ptr %74, align 8, !tbaa !16
  store float %75, ptr %73, align 4, !tbaa !17
  %76 = getelementptr inbounds %struct.Vector, ptr %10, i32 0, i32 1
  %77 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 5
  %78 = load float, ptr %77, align 4, !tbaa !19
  %79 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %80 = load float, ptr %79, align 4, !tbaa !15
  %81 = fmul float %78, %80
  %82 = load float, ptr %8, align 4, !tbaa !12
  %83 = fdiv float %81, %82
  store float %83, ptr %76, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %84 = getelementptr inbounds %struct.Vector, ptr %11, i32 0, i32 0
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %class.Particle, ptr %85, i32 0, i32 0
  %87 = load float, ptr %86, align 8, !tbaa !16
  store float %87, ptr %84, align 4, !tbaa !17
  %88 = getelementptr inbounds %struct.Vector, ptr %11, i32 0, i32 1
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %class.Particle, ptr %89, i32 0, i32 5
  %91 = load float, ptr %90, align 4, !tbaa !19
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %class.Particle, ptr %92, i32 0, i32 3
  %94 = load float, ptr %93, align 4, !tbaa !15
  %95 = fmul float %91, %94
  %96 = load float, ptr %8, align 4, !tbaa !12
  %97 = fdiv float %95, %96
  store float %97, ptr %88, align 4, !tbaa !20
  %98 = call <2 x float> @_ZplRK6VectorS1_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(8) %11)
  store <2 x float> %98, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %99 = getelementptr inbounds %struct.Vector, ptr %9, i32 0, i32 0
  %100 = load float, ptr %99, align 4, !tbaa !17
  %101 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 0
  store float %100, ptr %101, align 8, !tbaa !16
  %102 = getelementptr inbounds %struct.Vector, ptr %9, i32 0, i32 1
  %103 = load float, ptr %102, align 4, !tbaa !20
  %104 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 2
  %105 = load float, ptr %104, align 8, !tbaa !21
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %class.Particle, ptr %106, i32 0, i32 2
  %108 = load float, ptr %107, align 8, !tbaa !21
  %109 = fmul float %105, %108
  %110 = fmul float %103, %109
  %111 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 5
  store float %110, ptr %111, align 4, !tbaa !19
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %class.Particle, ptr %112, i32 0, i32 3
  %114 = load float, ptr %113, align 4, !tbaa !15
  %115 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %116 = load float, ptr %115, align 4, !tbaa !15
  %117 = fadd float %116, %114
  store float %117, ptr %115, align 4, !tbaa !15
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 8
  store ptr %118, ptr %119, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %120

120:                                              ; preds = %36, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { 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, !11, i64 24}
!10 = !{!"_ZTS8Particle", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !6, i64 32}
!11 = !{!"float", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 28}
!14 = !{!10, !11, i64 16}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"_ZTS6Vector", !11, i64 0, !11, i64 4}
!19 = !{!10, !11, i64 20}
!20 = !{!18, !11, i64 4}
!21 = !{!10, !11, i64 8}
!22 = !{!10, !6, i64 32}


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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5hypotff(float noundef, float noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8Particle7combineEPS_(ptr nocapture noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %struct.Vector, align 4
  %4 = alloca %struct.Vector, align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load float, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load float, ptr %7, align 8, !tbaa !5
  %9 = fsub float %6, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  %11 = load float, ptr %10, align 4, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %1, i64 28
  %13 = load float, ptr %12, align 4, !tbaa !11
  %14 = fsub float %11, %13
  %15 = tail call noundef float @_ZSt5hypotff(float noundef %9, float noundef %14)
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load float, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  %19 = load float, ptr %18, align 8, !tbaa !12
  %20 = fadd float %17, %19
  %21 = fcmp olt float %15, %20
  br i1 %21, label %22, label %65

22:                                               ; preds = %2
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load float, ptr %23, align 4, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %1, i64 12
  %26 = load float, ptr %25, align 4, !tbaa !13
  %27 = fadd float %24, %26
  %28 = load float, ptr %7, align 8, !tbaa !5
  %29 = load float, ptr %12, align 4, !tbaa !11
  %30 = load <2 x float>, ptr %5, align 8, !tbaa !14
  %31 = insertelement <2 x float> poison, float %28, i64 0
  %32 = insertelement <2 x float> %31, float %26, i64 1
  %33 = insertelement <2 x float> poison, float %26, i64 0
  %34 = insertelement <2 x float> %33, float %29, i64 1
  %35 = fmul <2 x float> %32, %34
  %36 = insertelement <2 x float> poison, float %24, i64 0
  %37 = shufflevector <2 x float> %36, <2 x float> poison, <2 x i32> zeroinitializer
  %38 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %30, <2 x float> %37, <2 x float> %35)
  %39 = insertelement <2 x float> poison, float %27, i64 0
  %40 = shufflevector <2 x float> %39, <2 x float> poison, <2 x i32> zeroinitializer
  %41 = fdiv <2 x float> %38, %40
  store <2 x float> %41, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %42 = load float, ptr %0, align 8, !tbaa !15
  store float %42, ptr %3, align 4, !tbaa !16
  %43 = getelementptr inbounds i8, ptr %3, i64 4
  %44 = getelementptr inbounds i8, ptr %0, i64 20
  %45 = load float, ptr %44, align 4, !tbaa !18
  %46 = fmul float %24, %45
  %47 = fdiv float %46, %27
  store float %47, ptr %43, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %48 = load float, ptr %1, align 8, !tbaa !15
  store float %48, ptr %4, align 4, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %4, i64 4
  %50 = getelementptr inbounds i8, ptr %1, i64 20
  %51 = load float, ptr %50, align 4, !tbaa !18
  %52 = fmul float %26, %51
  %53 = fdiv float %52, %27
  store float %53, ptr %49, align 4, !tbaa !19
  %54 = call <2 x float> @_ZplRK6VectorS1_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %.sroa.0.0.vec.extract = extractelement <2 x float> %54, i64 0
  store float %.sroa.0.0.vec.extract, ptr %0, align 8, !tbaa !15
  %.sroa.0.4.vec.extract = extractelement <2 x float> %54, i64 1
  %55 = getelementptr inbounds i8, ptr %0, i64 8
  %56 = load float, ptr %55, align 8, !tbaa !20
  %57 = getelementptr inbounds i8, ptr %1, i64 8
  %58 = load float, ptr %57, align 8, !tbaa !20
  %59 = fmul float %56, %58
  %60 = fmul float %.sroa.0.4.vec.extract, %59
  store float %60, ptr %44, align 4, !tbaa !18
  %61 = load float, ptr %25, align 4, !tbaa !13
  %62 = load float, ptr %23, align 4, !tbaa !13
  %63 = fadd float %61, %62
  store float %63, ptr %23, align 4, !tbaa !13
  %64 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %1, ptr %64, align 8, !tbaa !21
  br label %65

65:                                               ; preds = %22, %2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 24}
!6 = !{!"_ZTS8Particle", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !10, i64 32}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 28}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 12}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"_ZTS6Vector", !7, i64 0, !7, i64 4}
!18 = !{!6, !7, i64 20}
!19 = !{!17, !7, i64 4}
!20 = !{!6, !7, i64 8}
!21 = !{!6, !10, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass