; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qspring.ll (ZN7QSpringC2EP9QParticleS1_b)

; 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.QVector = type { float, float }
%class.QSpring = type <{ ptr, float, [4 x i8], ptr, ptr, float, i8, i8, i8, i8 }>

@_ZTV7QSpring = external dso_local unnamed_addr constant { [3 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7QSpringC2EP9QParticleS1_b(ptr noundef nonnull align 8 dereferenceable(39) %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca %struct.QVector, align 4
  %10 = alloca %struct.QVector, align 4
  %11 = alloca %struct.QVector, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = zext i1 %3 to i8
  store i8 %12, ptr %8, align 1, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV7QSpring, i32 0, i32 0, i32 2), ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 1
  store float 1.000000e+00, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 6
  store i8 0, ptr %15, align 4, !tbaa !16
  %16 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 7
  store i8 1, ptr %16, align 1, !tbaa !17
  %17 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 8
  store i8 0, ptr %17, align 2, !tbaa !18
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 3
  store ptr %18, ptr %19, align 8, !tbaa !19
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 4
  store ptr %20, ptr %21, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %22 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !19
  %24 = call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %23)
  store <2 x float> %24, ptr %10, align 4
  %25 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  %27 = call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %26)
  store <2 x float> %27, ptr %11, align 4
  %28 = load <2 x float>, ptr %10, align 4
  %29 = load <2 x float>, ptr %11, align 4
  %30 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %28, <2 x float> %29)
  store <2 x float> %30, ptr %9, align 4
  %31 = call noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8) %9)
  %32 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 5
  store float %31, ptr %32, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %33 = load i8, ptr %8, align 1, !tbaa !9, !range !22, !noundef !23
  %34 = trunc i8 %33 to i1
  %35 = getelementptr inbounds %class.QSpring, ptr %13, i32 0, i32 6
  %36 = zext i1 %34 to i8
  store i8 %36, ptr %35, align 4, !tbaa !16
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmi7QVectorS_(<2 x float>, <2 x float>) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

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

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 = { mustprogress nounwind 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 #3 = { 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 #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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !15, i64 8}
!14 = !{!"_ZTS7QSpring", !15, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !10, i64 36, !10, i64 37, !10, i64 38}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !10, i64 36}
!17 = !{!14, !10, i64 37}
!18 = !{!14, !10, i64 38}
!19 = !{!14, !6, i64 16}
!20 = !{!14, !6, i64 24}
!21 = !{!14, !15, i64 32}
!22 = !{i8 0, i8 2}
!23 = !{}


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

@_ZTV7QSpring = external dso_local unnamed_addr constant { [3 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7QSpringC2EP9QParticleS1_b(ptr nocapture noundef nonnull align 8 dereferenceable(39) %0, ptr noundef nonnull %1, ptr noundef %2, i1 noundef zeroext %3) unnamed_addr #0 align 2 {
  %5 = alloca %struct.QVector, align 8
  %6 = zext i1 %3 to i8
  store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV7QSpring, i64 16), ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store float 1.000000e+00, ptr %7, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 36
  store i8 0, ptr %8, align 4, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 37
  store i8 1, ptr %9, align 1, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 38
  store i8 0, ptr %10, align 2, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %1, ptr %11, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %2, ptr %12, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %13 = tail call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %1)
  %14 = load ptr, ptr %12, align 8, !tbaa !18
  %15 = tail call <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290) %14)
  %16 = tail call <2 x float> @_Zmi7QVectorS_(<2 x float> %13, <2 x float> %15)
  store <2 x float> %16, ptr %5, align 8
  %17 = call noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  store float %17, ptr %18, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  store i8 %6, ptr %8, align 4, !tbaa !14
  ret void
}

; 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 uwtable
declare dso_local <2 x float> @_Zmi7QVectorS_(<2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_ZN9QParticle17GetGlobalPositionEv(ptr noundef nonnull align 8 dereferenceable(290)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK7QVector6LengthEv(ptr noundef nonnull align 4 dereferenceable(8)) 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) #1

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"="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 #3 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTS7QSpring", !10, i64 8, !12, i64 16, !12, i64 24, !10, i64 32, !13, i64 36, !13, i64 37, !13, i64 38}
!10 = !{!"float", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"any pointer", !11, i64 0}
!13 = !{!"bool", !11, i64 0}
!14 = !{!9, !13, i64 36}
!15 = !{!9, !13, i64 37}
!16 = !{!9, !13, i64 38}
!17 = !{!9, !12, i64 16}
!18 = !{!9, !12, i64 24}
!19 = !{!9, !10, i64 32}


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