; LLVM IR from erincatto/box2d-lite :: src/Body.ll (ZN4Body3SetERK4Vec2f)

; 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.Body = type { %struct.Vec2, float, %struct.Vec2, float, %struct.Vec2, float, %struct.Vec2, float, float, float, float, float }
%struct.Vec2 = type { float, float }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Body3SetERK4Vec2f(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, float noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 0
  call void @_ZN4Vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) %8, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %9 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 1
  store float 0.000000e+00, ptr %9, align 4, !tbaa !11
  %10 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 2
  call void @_ZN4Vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) %10, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %11 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 3
  store float 0.000000e+00, ptr %11, align 4, !tbaa !14
  %12 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 4
  call void @_ZN4Vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) %12, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %13 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 5
  store float 0.000000e+00, ptr %13, align 4, !tbaa !15
  %14 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 7
  store float 0x3FC99999A0000000, ptr %14, align 4, !tbaa !16
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !17
  %17 = load float, ptr %6, align 4, !tbaa !9
  %18 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 8
  store float %17, ptr %18, align 4, !tbaa !18
  %19 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 8
  %20 = load float, ptr %19, align 4, !tbaa !18
  %21 = fcmp olt float %20, 0x47EFFFFFE0000000
  br i1 %21, label %22, label %50

22:                                               ; preds = %3
  %23 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 8
  %24 = load float, ptr %23, align 4, !tbaa !18
  %25 = fdiv float 1.000000e+00, %24
  %26 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 9
  store float %25, ptr %26, align 4, !tbaa !19
  %27 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 8
  %28 = load float, ptr %27, align 4, !tbaa !18
  %29 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 6
  %30 = getelementptr inbounds %struct.Vec2, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !20
  %32 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 6
  %33 = getelementptr inbounds %struct.Vec2, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !20
  %35 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 6
  %36 = getelementptr inbounds %struct.Vec2, ptr %35, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !21
  %38 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 6
  %39 = getelementptr inbounds %struct.Vec2, ptr %38, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !21
  %41 = fmul float %37, %40
  %42 = call float @llvm.fmuladd.f32(float %31, float %34, float %41)
  %43 = fmul float %28, %42
  %44 = fdiv float %43, 1.200000e+01
  %45 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 10
  store float %44, ptr %45, align 4, !tbaa !22
  %46 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 10
  %47 = load float, ptr %46, align 4, !tbaa !22
  %48 = fdiv float 1.000000e+00, %47
  %49 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 11
  store float %48, ptr %49, align 4, !tbaa !23
  br label %54

50:                                               ; preds = %3
  %51 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 9
  store float 0.000000e+00, ptr %51, align 4, !tbaa !19
  %52 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 10
  store float 0x47EFFFFFE0000000, ptr %52, align 4, !tbaa !22
  %53 = getelementptr inbounds %struct.Body, ptr %7, i32 0, i32 11
  store float 0.000000e+00, ptr %53, align 4, !tbaa !23
  br label %54

54:                                               ; preds = %50, %22
  ret void
}

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

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

attributes #0 = { 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 #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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, i64 8}
!12 = !{!"_ZTS4Body", !13, i64 0, !10, i64 8, !13, i64 12, !10, i64 20, !13, i64 24, !10, i64 32, !13, i64 36, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60}
!13 = !{!"_ZTS4Vec2", !10, i64 0, !10, i64 4}
!14 = !{!12, !10, i64 20}
!15 = !{!12, !10, i64 32}
!16 = !{!12, !10, i64 44}
!17 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}
!18 = !{!12, !10, i64 48}
!19 = !{!12, !10, i64 52}
!20 = !{!12, !10, i64 36}
!21 = !{!12, !10, i64 40}
!22 = !{!12, !10, i64 56}
!23 = !{!12, !10, i64 60}


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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Body3SetERK4Vec2f(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %1, float noundef %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN4Vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store float 0.000000e+00, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  tail call void @_ZN4Vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) %5, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  store float 0.000000e+00, ptr %6, align 4, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN4Vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) %7, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  store float 0.000000e+00, ptr %8, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 44
  store float 0x3FC99999A0000000, ptr %9, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 36
  %11 = load i64, ptr %1, align 4
  store i64 %11, ptr %10, align 4
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  store float %2, ptr %12, align 4, !tbaa !14
  %13 = fcmp olt float %2, 0x47EFFFFFE0000000
  br i1 %13, label %14, label %28

14:                                               ; preds = %3
  %15 = lshr i64 %11, 32
  %16 = trunc nuw i64 %15 to i32
  %17 = bitcast i32 %16 to float
  %18 = trunc i64 %11 to i32
  %19 = bitcast i32 %18 to float
  %20 = fmul float %17, %17
  %21 = tail call float @llvm.fmuladd.f32(float %19, float %19, float %20)
  %22 = fmul float %21, %2
  %23 = insertelement <2 x float> <float 1.000000e+00, float poison>, float %22, i64 1
  %24 = insertelement <2 x float> <float poison, float 1.200000e+01>, float %2, i64 0
  %25 = fdiv <2 x float> %23, %24
  %26 = extractelement <2 x float> %25, i64 1
  %27 = fdiv float 1.000000e+00, %26
  br label %28

28:                                               ; preds = %3, %14
  %.sink = phi float [ %27, %14 ], [ 0.000000e+00, %3 ]
  %29 = phi <2 x float> [ %25, %14 ], [ <float 0.000000e+00, float 0x47EFFFFFE0000000>, %3 ]
  %30 = getelementptr inbounds i8, ptr %0, i64 52
  store <2 x float> %29, ptr %30, align 4
  %31 = getelementptr inbounds i8, ptr %0, i64 60
  store float %.sink, ptr %31, align 4
  ret void
}

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !8, i64 8}
!6 = !{!"_ZTS4Body", !7, i64 0, !8, i64 8, !7, i64 12, !8, i64 20, !7, i64 24, !8, i64 32, !7, i64 36, !8, i64 44, !8, i64 48, !8, i64 52, !8, i64 56, !8, i64 60}
!7 = !{!"_ZTS4Vec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 20}
!12 = !{!6, !8, i64 32}
!13 = !{!6, !8, i64 44}
!14 = !{!6, !8, i64 48}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,TailCallElimPass