; LLVM IR from SOHNE/Dura2D :: src/kinetics/d2Body.ll (ZN6d2Body19IntegrateVelocitiesEf)

; 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.d2Vec2 = type { float, float }
%class.d2Body = type <{ i16, [2 x i8], i32, %struct.d2Transform, %struct.d2Vec2, %struct.d2Vec2, float, float, float, %struct.d2Vec2, float, float, float, float, float, float, float, ptr, ptr, ptr, ptr, ptr, float, [4 x i8] }>
%struct.d2Transform = type { %struct.d2Vec2, %struct.d2Rot }
%struct.d2Rot = type { float, float }

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

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

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

declare <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6d2Body19IntegrateVelocitiesEf(ptr noundef nonnull align 8 dereferenceable(132) %0, float noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca %struct.d2Vec2, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 2
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %31

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %12 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 4
  %13 = load float, ptr %4, align 4, !tbaa !9
  %14 = call <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8) %12, float noundef %13)
  store <2 x float> %14, ptr %5, align 4
  %15 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 3
  %16 = getelementptr inbounds %struct.d2Transform, ptr %15, i32 0, i32 0
  %17 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %18 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 7
  %19 = load float, ptr %18, align 4, !tbaa !18
  %20 = load float, ptr %4, align 4, !tbaa !9
  %21 = fmul float %19, %20
  %22 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 3
  %23 = getelementptr inbounds %struct.d2Transform, ptr %22, i32 0, i32 1
  %24 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN5d2RotpLEf(ptr noundef nonnull align 4 dereferenceable(8) %23, float noundef %21)
  %25 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 18
  %26 = load ptr, ptr %25, align 8, !tbaa !19
  %27 = getelementptr inbounds %class.d2Body, ptr %6, i32 0, i32 3
  %28 = load ptr, ptr %26, align 8, !tbaa !20
  %29 = getelementptr inbounds ptr, ptr %28, i64 4
  %30 = load ptr, ptr %29, align 8
  call void %30(ptr noundef nonnull align 8 dereferenceable(8) %26, ptr noundef nonnull align 4 dereferenceable(16) %27)
  br label %31

31:                                               ; preds = %11, %10
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !14, i64 4}
!12 = !{!"_ZTS6d2Body", !13, i64 0, !14, i64 4, !15, i64 8, !16, i64 24, !16, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !16, i64 52, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !10, i64 128}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTS10d2BodyType", !7, i64 0}
!15 = !{!"_ZTS11d2Transform", !16, i64 0, !17, i64 8}
!16 = !{!"_ZTS6d2Vec2", !10, i64 0, !10, i64 4}
!17 = !{!"_ZTS5d2Rot", !10, i64 0, !10, i64 4}
!18 = !{!12, !10, i64 44}
!19 = !{!12, !6, i64 96}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !8, i64 0}


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

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

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

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

declare <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6d2Body19IntegrateVelocitiesEf(ptr noundef nonnull align 8 dereferenceable(132) %0, float noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %struct.d2Vec2, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %22, label %7

7:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = tail call <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8) %8, float noundef %1)
  store <2 x float> %9, ptr %3, align 8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %12 = getelementptr inbounds i8, ptr %0, i64 44
  %13 = load float, ptr %12, align 4, !tbaa !16
  %14 = fmul float %13, %1
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN5d2RotpLEf(ptr noundef nonnull align 4 dereferenceable(8) %15, float noundef %14)
  %17 = getelementptr inbounds i8, ptr %0, i64 96
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load ptr, ptr %18, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  %21 = load ptr, ptr %20, align 8
  call void %21(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull align 4 dereferenceable(16) %10)
  br label %22

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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, !10, i64 4}
!6 = !{!"_ZTS6d2Body", !7, i64 0, !10, i64 4, !11, i64 8, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 44, !13, i64 48, !12, i64 52, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !13, i64 128}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS10d2BodyType", !8, i64 0}
!11 = !{!"_ZTS11d2Transform", !12, i64 0, !14, i64 8}
!12 = !{!"_ZTS6d2Vec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTS5d2Rot", !13, i64 0, !13, i64 4}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!6, !13, i64 44}
!17 = !{!6, !15, i64 96}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !9, i64 0}


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