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

; 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.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: 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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Add(<2 x float>, <2 x float>) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Multiply(<2 x float>, float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @jgParticleIntegrate(ptr noundef %0, float noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca %struct.jgVector2, align 4
  %6 = alloca %struct.jgVector2, align 4
  %7 = alloca %struct.jgVector2, align 4
  %8 = alloca %struct.jgVector2, align 4
  %9 = alloca %struct.jgVector2, align 4
  %10 = alloca %struct.jgVector2, align 4
  %11 = alloca %struct.jgVector2, align 4
  %12 = alloca %struct.jgVector2, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.jgParticle, ptr %13, i32 0, i32 0
  %15 = load float, ptr %14, align 8, !tbaa !11
  %16 = fcmp une float %15, 0x7FF0000000000000
  br i1 %16, label %17, label %60

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.jgParticle, ptr %18, i32 0, i32 4
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.jgParticle, ptr %20, i32 0, i32 0
  %22 = load float, ptr %21, align 8, !tbaa !11
  %23 = load <2 x float>, ptr %19, align 4
  %24 = call <2 x float> @jgVector2Divide(<2 x float> %23, float noundef %22)
  store <2 x float> %24, ptr %5, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.jgParticle, ptr %25, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %26, i64 8, i1 false), !tbaa.struct !15
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.jgParticle, ptr %27, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.jgParticle, ptr %29, i32 0, i32 1
  %31 = load <2 x float>, ptr %30, align 4
  %32 = call <2 x float> @jgVector2Multiply(<2 x float> %31, float noundef 2.000000e+00)
  store <2 x float> %32, ptr %9, align 4
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.jgParticle, ptr %33, i32 0, i32 2
  %35 = load <2 x float>, ptr %9, align 4
  %36 = load <2 x float>, ptr %34, align 4
  %37 = call <2 x float> @jgVector2Subtract(<2 x float> %35, <2 x float> %36)
  store <2 x float> %37, ptr %8, align 4
  %38 = load float, ptr %4, align 4, !tbaa !9
  %39 = load float, ptr %4, align 4, !tbaa !9
  %40 = fmul float %38, %39
  %41 = load <2 x float>, ptr %5, align 4
  %42 = call <2 x float> @jgVector2Multiply(<2 x float> %41, float noundef %40)
  store <2 x float> %42, ptr %10, align 4
  %43 = load <2 x float>, ptr %8, align 4
  %44 = load <2 x float>, ptr %10, align 4
  %45 = call <2 x float> @jgVector2Add(<2 x float> %43, <2 x float> %44)
  store <2 x float> %45, ptr %7, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.jgParticle, ptr %46, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !15
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.jgParticle, ptr %48, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.jgParticle, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.jgParticle, ptr %52, i32 0, i32 2
  %54 = load <2 x float>, ptr %51, align 4
  %55 = load <2 x float>, ptr %53, align 4
  %56 = call <2 x float> @jgVector2Subtract(<2 x float> %54, <2 x float> %55)
  store <2 x float> %56, ptr %12, align 4
  %57 = load float, ptr %4, align 4, !tbaa !9
  %58 = load <2 x float>, ptr %12, align 4
  %59 = call <2 x float> @jgVector2Divide(<2 x float> %58, float noundef %57)
  store <2 x float> %59, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %60

60:                                               ; preds = %17, %2
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.jgParticle, ptr %61, i32 0, i32 4
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.jgParticle, ptr %63, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %62, ptr align 4 %64, i64 8, i1 false), !tbaa.struct !15
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Divide(<2 x float>, float noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Subtract(<2 x float>, <2 x float>) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"jgParticle", !10, i64 0, !13, i64 4, !13, i64 12, !13, i64 20, !13, i64 28, !13, i64 36, !10, i64 44, !10, i64 48, !14, i64 52, !14, i64 53, !6, i64 56}
!13 = !{!"jgVector2", !10, i64 0, !10, i64 4}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}


; 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: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Add(<2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Multiply(<2 x float>, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @jgParticleIntegrate(ptr nocapture noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = load float, ptr %0, align 8, !tbaa !5
  %4 = fcmp une float %3, 0x7FF0000000000000
  br i1 %4, label %5, label %21

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = load <2 x float>, ptr %6, align 4
  %8 = tail call <2 x float> @jgVector2Divide(<2 x float> %7, float noundef %3)
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i64, ptr %9, align 4
  %.cast = bitcast i64 %10 to <2 x float>
  %11 = tail call <2 x float> @jgVector2Multiply(<2 x float> %.cast, float noundef 2.000000e+00)
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  %13 = load <2 x float>, ptr %12, align 4
  %14 = tail call <2 x float> @jgVector2Subtract(<2 x float> %11, <2 x float> %13)
  %15 = fmul float %1, %1
  %16 = tail call <2 x float> @jgVector2Multiply(<2 x float> %8, float noundef %15)
  %17 = tail call <2 x float> @jgVector2Add(<2 x float> %14, <2 x float> %16)
  store <2 x float> %17, ptr %9, align 4
  store i64 %10, ptr %12, align 4
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  %19 = tail call <2 x float> @jgVector2Subtract(<2 x float> %17, <2 x float> %.cast)
  %20 = tail call <2 x float> @jgVector2Divide(<2 x float> %19, float noundef %1)
  store <2 x float> %20, ptr %18, align 4
  br label %21

21:                                               ; preds = %5, %2
  %22 = getelementptr inbounds i8, ptr %0, i64 28
  %23 = getelementptr inbounds i8, ptr %0, i64 36
  %24 = load i64, ptr %23, align 4
  store i64 %24, ptr %22, align 4
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Divide(<2 x float>, float noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Subtract(<2 x float>, <2 x float>) local_unnamed_addr #0

attributes #0 = { inlinehint 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 #1 = { 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" }

!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 = !{!"jgParticle", !7, i64 0, !10, i64 4, !10, i64 12, !10, i64 20, !10, i64 28, !10, i64 36, !7, i64 44, !7, i64 48, !11, i64 52, !11, i64 53, !12, i64 56}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"jgVector2", !7, i64 0, !7, i64 4}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}


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