; LLVM IR from NotManyIdeasDev/double-pendulum-sim :: double-pendulum-sim/Double-pendulum-sim/src/pixel_camera.ll (ZN11PixelCamera6UpdateEv)

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

%class.PixelCamera = type { %struct.Vector2, %struct.Vector2, float, float, i32, i32, float, %struct.Color, %struct.Camera2D, %struct.Camera2D, %struct.RenderTexture }
%struct.Vector2 = type { float, float }
%struct.Color = type { i8, i8, i8, i8 }
%struct.Camera2D = type { %struct.Vector2, %struct.Vector2, float, float }
%struct.RenderTexture = type { i32, %struct.Texture, %struct.Texture }
%struct.Texture = type { i32, i32, i32, i32, i32 }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11PixelCamera6UpdateEv(ptr noundef nonnull align 4 dereferenceable(132) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 0
  %5 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %6 = getelementptr inbounds %struct.Camera2D, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !9
  %7 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 1
  %8 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %9 = getelementptr inbounds %struct.Camera2D, ptr %8, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !9
  %10 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 2
  %11 = load float, ptr %10, align 4, !tbaa !12
  %12 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %13 = getelementptr inbounds %struct.Camera2D, ptr %12, i32 0, i32 2
  store float %11, ptr %13, align 4, !tbaa !20
  %14 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 3
  %15 = load float, ptr %14, align 4, !tbaa !21
  %16 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %17 = getelementptr inbounds %struct.Camera2D, ptr %16, i32 0, i32 3
  store float %15, ptr %17, align 4, !tbaa !22
  %18 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %19 = getelementptr inbounds %struct.Camera2D, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds %struct.Vector2, ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !23
  %22 = fptosi float %21 to i32
  %23 = sitofp i32 %22 to float
  %24 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 9
  %25 = getelementptr inbounds %struct.Camera2D, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds %struct.Vector2, ptr %25, i32 0, i32 0
  store float %23, ptr %26, align 4, !tbaa !24
  %27 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 9
  %28 = getelementptr inbounds %struct.Camera2D, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.Vector2, ptr %28, i32 0, i32 0
  %30 = load float, ptr %29, align 4, !tbaa !24
  %31 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %32 = getelementptr inbounds %struct.Camera2D, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct.Vector2, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !23
  %35 = fsub float %34, %30
  store float %35, ptr %33, align 4, !tbaa !23
  %36 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 6
  %37 = load float, ptr %36, align 4, !tbaa !25
  %38 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %39 = getelementptr inbounds %struct.Camera2D, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds %struct.Vector2, ptr %39, i32 0, i32 0
  %41 = load float, ptr %40, align 4, !tbaa !23
  %42 = fmul float %41, %37
  store float %42, ptr %40, align 4, !tbaa !23
  %43 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %44 = getelementptr inbounds %struct.Camera2D, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.Vector2, ptr %44, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !26
  %47 = fptosi float %46 to i32
  %48 = sitofp i32 %47 to float
  %49 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 9
  %50 = getelementptr inbounds %struct.Camera2D, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.Vector2, ptr %50, i32 0, i32 1
  store float %48, ptr %51, align 4, !tbaa !27
  %52 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 9
  %53 = getelementptr inbounds %struct.Camera2D, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.Vector2, ptr %53, i32 0, i32 1
  %55 = load float, ptr %54, align 4, !tbaa !27
  %56 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %57 = getelementptr inbounds %struct.Camera2D, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %struct.Vector2, ptr %57, i32 0, i32 1
  %59 = load float, ptr %58, align 4, !tbaa !26
  %60 = fsub float %59, %55
  store float %60, ptr %58, align 4, !tbaa !26
  %61 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 6
  %62 = load float, ptr %61, align 4, !tbaa !25
  %63 = getelementptr inbounds %class.PixelCamera, ptr %3, i32 0, i32 8
  %64 = getelementptr inbounds %struct.Camera2D, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds %struct.Vector2, ptr %64, i32 0, i32 1
  %66 = load float, ptr %65, align 4, !tbaa !26
  %67 = fmul float %66, %62
  store float %67, ptr %65, align 4, !tbaa !26
  ret void
}

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

!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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"_ZTS11PixelCamera", !14, i64 0, !14, i64 8, !11, i64 16, !11, i64 20, !15, i64 24, !15, i64 28, !11, i64 32, !16, i64 36, !17, i64 40, !17, i64 64, !18, i64 88}
!14 = !{!"_ZTS7Vector2", !11, i64 0, !11, i64 4}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS5Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!17 = !{!"_ZTS8Camera2D", !14, i64 0, !14, i64 8, !11, i64 16, !11, i64 20}
!18 = !{!"_ZTS13RenderTexture", !15, i64 0, !19, i64 4, !19, i64 24}
!19 = !{!"_ZTS7Texture", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16}
!20 = !{!13, !11, i64 56}
!21 = !{!13, !11, i64 20}
!22 = !{!13, !11, i64 60}
!23 = !{!13, !11, i64 48}
!24 = !{!13, !11, i64 72}
!25 = !{!13, !11, i64 32}
!26 = !{!13, !11, i64 52}
!27 = !{!13, !11, i64 76}


; 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(argmem: readwrite) uwtable
define dso_local void @_ZN11PixelCamera6UpdateEv(ptr nocapture noundef nonnull align 4 dereferenceable(132) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i64, ptr %0, align 4
  store i64 %3, ptr %2, align 4
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load i64, ptr %4, align 4
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = load <2 x float>, ptr %7, align 4, !tbaa !5
  store <2 x float> %9, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load <4 x float>, ptr %11, align 4
  %13 = lshr i64 %6, 32
  %14 = insertelement <2 x i64> poison, i64 %6, i64 0
  %15 = insertelement <2 x i64> %14, i64 %13, i64 1
  %16 = trunc <2 x i64> %15 to <2 x i32>
  %17 = bitcast <2 x i32> %16 to <2 x float>
  %18 = fptosi <2 x float> %17 to <2 x i32>
  %19 = sitofp <2 x i32> %18 to <2 x float>
  store <2 x float> %19, ptr %10, align 4, !tbaa !5
  %20 = fsub <2 x float> %17, %19
  %21 = shufflevector <4 x float> %12, <4 x float> poison, <2 x i32> zeroinitializer
  %22 = fmul <2 x float> %20, %21
  store <2 x float> %22, ptr %5, align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,VectorCombinePass