; LLVM IR from mvr/jiggle :: src (Collision)

; 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.jgCollision = type { ptr, ptr, ptr, ptr, %struct.jgVector2, float, %struct.jgVector2, float, float, float, float }
%struct.jgVector2 = type { float, float }
%struct.jgParticle = type { float, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, float, float, i8, i8, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @jgCollisionFindMoveProportions(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.jgCollision, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.jgCollision, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  store ptr %14, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.jgCollision, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.jgParticle, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 8, !tbaa !15
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.jgParticle, ptr %21, i32 0, i32 0
  %23 = load float, ptr %22, align 8, !tbaa !15
  %24 = fadd float %20, %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.jgParticle, ptr %25, i32 0, i32 0
  %27 = load float, ptr %26, align 8, !tbaa !15
  %28 = fadd float %24, %27
  store float %28, ptr %6, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.jgParticle, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 8, !tbaa !15
  %32 = fcmp oeq float %31, 0x7FF0000000000000
  br i1 %32, label %33, label %40

33:                                               ; preds = %1
  store float 0.000000e+00, ptr %7, align 4, !tbaa !18
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.jgCollision, ptr %34, i32 0, i32 7
  %36 = load float, ptr %35, align 4, !tbaa !19
  %37 = fpext float %36 to double
  %38 = fadd double %37, 1.000000e-03
  %39 = fptrunc double %38 to float
  store float %39, ptr %8, align 4, !tbaa !18
  br label %80

40:                                               ; preds = %1
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.jgParticle, ptr %41, i32 0, i32 0
  %43 = load float, ptr %42, align 8, !tbaa !15
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.jgParticle, ptr %44, i32 0, i32 0
  %46 = load float, ptr %45, align 8, !tbaa !15
  %47 = fadd float %43, %46
  %48 = fcmp oeq float %47, 0x7FF0000000000000
  br i1 %48, label %49, label %56

49:                                               ; preds = %40
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.jgCollision, ptr %50, i32 0, i32 7
  %52 = load float, ptr %51, align 4, !tbaa !19
  %53 = fpext float %52 to double
  %54 = fadd double %53, 1.000000e-03
  %55 = fptrunc double %54 to float
  store float %55, ptr %7, align 4, !tbaa !18
  store float 0.000000e+00, ptr %8, align 4, !tbaa !18
  br label %79

56:                                               ; preds = %40
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.jgCollision, ptr %57, i32 0, i32 7
  %59 = load float, ptr %58, align 4, !tbaa !19
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.jgParticle, ptr %60, i32 0, i32 0
  %62 = load float, ptr %61, align 8, !tbaa !15
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.jgParticle, ptr %63, i32 0, i32 0
  %65 = load float, ptr %64, align 8, !tbaa !15
  %66 = fadd float %62, %65
  %67 = load float, ptr %6, align 4, !tbaa !18
  %68 = fdiv float %66, %67
  %69 = fmul float %59, %68
  store float %69, ptr %7, align 4, !tbaa !18
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.jgCollision, ptr %70, i32 0, i32 7
  %72 = load float, ptr %71, align 4, !tbaa !19
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.jgParticle, ptr %73, i32 0, i32 0
  %75 = load float, ptr %74, align 8, !tbaa !15
  %76 = load float, ptr %6, align 4, !tbaa !18
  %77 = fdiv float %75, %76
  %78 = fmul float %72, %77
  store float %78, ptr %8, align 4, !tbaa !18
  br label %79

79:                                               ; preds = %56, %49
  br label %80

80:                                               ; preds = %79, %33
  %81 = load float, ptr %7, align 4, !tbaa !18
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.jgCollision, ptr %82, i32 0, i32 8
  store float %81, ptr %83, align 8, !tbaa !20
  %84 = load float, ptr %8, align 4, !tbaa !18
  %85 = fpext float %84 to double
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.jgCollision, ptr %86, i32 0, i32 5
  %88 = load float, ptr %87, align 8, !tbaa !21
  %89 = fpext float %88 to double
  %90 = fsub double 1.000000e+00, %89
  %91 = fmul double %85, %90
  %92 = fptrunc double %91 to float
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.jgCollision, ptr %93, i32 0, i32 9
  store float %92, ptr %94, align 4, !tbaa !22
  %95 = load float, ptr %8, align 4, !tbaa !18
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.jgCollision, ptr %96, i32 0, i32 5
  %98 = load float, ptr %97, align 8, !tbaa !21
  %99 = fmul float %95, %98
  %100 = load ptr, ptr %2, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.jgCollision, ptr %100, i32 0, i32 10
  store float %99, ptr %101, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"jgCollision", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !12, i64 40, !11, i64 44, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64}
!11 = !{!"jgVector2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !6, i64 24}
!15 = !{!16, !12, i64 0}
!16 = !{!"jgParticle", !12, i64 0, !11, i64 4, !11, i64 12, !11, i64 20, !11, i64 28, !11, i64 36, !12, i64 44, !12, i64 48, !17, i64 52, !17, i64 53, !6, i64 56}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{!10, !12, i64 52}
!20 = !{!10, !12, i64 56}
!21 = !{!10, !12, i64 40}
!22 = !{!10, !12, i64 60}
!23 = !{!10, !12, i64 64}


; 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 nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @jgCollisionFindMoveProportions(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %7 = load float, ptr %2, align 8, !tbaa !14
  %8 = load float, ptr %4, align 8, !tbaa !14
  %9 = fadd float %7, %8
  %10 = load float, ptr %6, align 8, !tbaa !14
  %11 = fadd float %9, %10
  %12 = fcmp oeq float %7, 0x7FF0000000000000
  br i1 %12, label %13, label %20

13:                                               ; preds = %1
  %14 = getelementptr inbounds i8, ptr %0, i64 52
  %15 = load float, ptr %14, align 4, !tbaa !17
  %16 = fpext float %15 to double
  %17 = fadd double %16, 1.000000e-03
  %18 = fptrunc double %17 to float
  %19 = insertelement <2 x float> <float 0.000000e+00, float poison>, float %18, i64 1
  br label %39

20:                                               ; preds = %1
  %21 = fadd float %8, %10
  %22 = fcmp oeq float %21, 0x7FF0000000000000
  %23 = getelementptr inbounds i8, ptr %0, i64 52
  %24 = load float, ptr %23, align 4, !tbaa !17
  br i1 %22, label %25, label %30

25:                                               ; preds = %20
  %26 = fpext float %24 to double
  %27 = fadd double %26, 1.000000e-03
  %28 = fptrunc double %27 to float
  %29 = insertelement <2 x float> <float poison, float 0.000000e+00>, float %28, i64 0
  br label %39

30:                                               ; preds = %20
  %31 = insertelement <2 x float> poison, float %21, i64 0
  %32 = insertelement <2 x float> %31, float %7, i64 1
  %33 = insertelement <2 x float> poison, float %11, i64 0
  %34 = shufflevector <2 x float> %33, <2 x float> poison, <2 x i32> zeroinitializer
  %35 = fdiv <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 = fmul <2 x float> %35, %37
  br label %39

39:                                               ; preds = %25, %30, %13
  %40 = phi <2 x float> [ %19, %13 ], [ %29, %25 ], [ %38, %30 ]
  %41 = getelementptr inbounds i8, ptr %0, i64 56
  %42 = extractelement <2 x float> %40, i64 0
  store float %42, ptr %41, align 8, !tbaa !18
  %43 = extractelement <2 x float> %40, i64 1
  %44 = fpext float %43 to double
  %45 = getelementptr inbounds i8, ptr %0, i64 40
  %46 = load float, ptr %45, align 8, !tbaa !19
  %47 = fpext float %46 to double
  %48 = fsub double 1.000000e+00, %47
  %49 = fmul double %48, %44
  %50 = fptrunc double %49 to float
  %51 = getelementptr inbounds i8, ptr %0, i64 60
  store float %50, ptr %51, align 4, !tbaa !20
  %52 = fmul float %43, %46
  %53 = getelementptr inbounds i8, ptr %0, i64 64
  store float %52, ptr %53, align 8, !tbaa !21
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 0}
!6 = !{!"jgCollision", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !10, i64 44, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"jgVector2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 24}
!14 = !{!15, !11, i64 0}
!15 = !{!"jgParticle", !11, i64 0, !10, i64 4, !10, i64 12, !10, i64 20, !10, i64 28, !10, i64 36, !11, i64 44, !11, i64 48, !16, i64 52, !16, i64 53, !7, i64 56}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!6, !11, i64 52}
!18 = !{!6, !11, i64 56}
!19 = !{!6, !11, i64 40}
!20 = !{!6, !11, i64 60}
!21 = !{!6, !11, i64 64}


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