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

; 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.Color = type { i8, i8, i8, i8 }
%struct.Camera2D = type { %struct.Vector2, %struct.Vector2, float, float }
%struct.Vector2 = type { float, float }
%struct.RenderTexture = type { i32, %struct.Texture, %struct.Texture }
%struct.Texture = type { i32, i32, i32, i32, i32 }
%class.PixelCamera = type { %struct.Vector2, %struct.Vector2, float, float, i32, i32, float, %struct.Color, %struct.Camera2D, %struct.Camera2D, %struct.RenderTexture }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11PixelCameraC2Eiif(ptr noundef nonnull align 4 dereferenceable(132) %0, i32 noundef %1, i32 noundef %2, float noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca %struct.Color, align 1
  %10 = alloca %struct.Camera2D, align 4
  %11 = alloca %struct.Camera2D, align 4
  %12 = alloca %struct.RenderTexture, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !11
  %13 = load ptr, ptr %5, align 8
  %14 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.Vector2, ptr %14, i32 0, i32 0
  store float 0.000000e+00, ptr %15, align 4, !tbaa !13
  %16 = getelementptr inbounds %struct.Vector2, ptr %14, i32 0, i32 1
  store float 0.000000e+00, ptr %16, align 4, !tbaa !15
  %17 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 1
  %18 = getelementptr inbounds %struct.Vector2, ptr %17, i32 0, i32 0
  store float 0.000000e+00, ptr %18, align 4, !tbaa !13
  %19 = getelementptr inbounds %struct.Vector2, ptr %17, i32 0, i32 1
  store float 0.000000e+00, ptr %19, align 4, !tbaa !15
  %20 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 2
  store float 0.000000e+00, ptr %20, align 4, !tbaa !16
  %21 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 3
  store float 1.000000e+00, ptr %21, align 4, !tbaa !22
  %22 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 4
  %23 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %23, ptr %22, align 4, !tbaa !23
  %24 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 5
  %25 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %25, ptr %24, align 4, !tbaa !24
  %26 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 6
  %27 = load float, ptr %8, align 4, !tbaa !11
  store float %27, ptr %26, align 4, !tbaa !25
  %28 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 7
  %29 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 8
  %30 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 9
  %31 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 10
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %32 = getelementptr inbounds %struct.Color, ptr %9, i32 0, i32 0
  store i8 10, ptr %32, align 1, !tbaa !26
  %33 = getelementptr inbounds %struct.Color, ptr %9, i32 0, i32 1
  store i8 10, ptr %33, align 1, !tbaa !27
  %34 = getelementptr inbounds %struct.Color, ptr %9, i32 0, i32 2
  store i8 10, ptr %34, align 1, !tbaa !28
  %35 = getelementptr inbounds %struct.Color, ptr %9, i32 0, i32 3
  store i8 -1, ptr %35, align 1, !tbaa !29
  %36 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %36, ptr align 1 %9, i64 4, i1 false), !tbaa.struct !30
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  call void @llvm.memset.p0.i64(ptr align 4 %10, i8 0, i64 24, i1 false)
  %37 = getelementptr inbounds %struct.Camera2D, ptr %10, i32 0, i32 0
  %38 = getelementptr inbounds %struct.Vector2, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.Vector2, ptr %37, i32 0, i32 1
  %40 = getelementptr inbounds %struct.Camera2D, ptr %10, i32 0, i32 1
  %41 = getelementptr inbounds %struct.Vector2, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.Vector2, ptr %40, i32 0, i32 1
  %43 = getelementptr inbounds %struct.Camera2D, ptr %10, i32 0, i32 2
  %44 = getelementptr inbounds %struct.Camera2D, ptr %10, i32 0, i32 3
  %45 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %45, ptr align 4 %10, i64 24, i1 false), !tbaa.struct !32
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  %46 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 9
  %47 = getelementptr inbounds %struct.Camera2D, ptr %46, i32 0, i32 3
  store float 1.000000e+00, ptr %47, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 24, i1 false)
  %48 = getelementptr inbounds %struct.Camera2D, ptr %11, i32 0, i32 0
  %49 = getelementptr inbounds %struct.Vector2, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.Vector2, ptr %48, i32 0, i32 1
  %51 = getelementptr inbounds %struct.Camera2D, ptr %11, i32 0, i32 1
  %52 = getelementptr inbounds %struct.Vector2, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.Vector2, ptr %51, i32 0, i32 1
  %54 = getelementptr inbounds %struct.Camera2D, ptr %11, i32 0, i32 2
  %55 = getelementptr inbounds %struct.Camera2D, ptr %11, i32 0, i32 3
  %56 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %56, ptr align 4 %11, i64 24, i1 false), !tbaa.struct !32
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  %57 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 8
  %58 = getelementptr inbounds %struct.Camera2D, ptr %57, i32 0, i32 3
  store float 1.000000e+00, ptr %58, align 4, !tbaa !34
  call void @llvm.lifetime.start.p0(i64 44, ptr %12) #5
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = sitofp i32 %59 to float
  %61 = load float, ptr %8, align 4, !tbaa !11
  %62 = fdiv float %60, %61
  %63 = fadd float %62, 2.000000e+00
  %64 = fptosi float %63 to i32
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = sitofp i32 %65 to float
  %67 = load float, ptr %8, align 4, !tbaa !11
  %68 = fdiv float %66, %67
  %69 = fadd float %68, 2.000000e+00
  %70 = fptosi float %69 to i32
  call void @LoadRenderTexture(ptr dead_on_unwind writable sret(%struct.RenderTexture) align 4 %12, i32 noundef %64, i32 noundef %70)
  %71 = getelementptr inbounds %class.PixelCamera, ptr %13, i32 0, i32 10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %71, ptr align 4 %12, i64 44, i1 false), !tbaa.struct !35
  call void @llvm.lifetime.end.p0(i64 44, ptr %12) #5
  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 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @LoadRenderTexture(ptr dead_on_unwind writable sret(%struct.RenderTexture) align 4, i32 noundef, i32 noundef) #4

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTS7Vector2", !12, i64 0, !12, i64 4}
!15 = !{!14, !12, i64 4}
!16 = !{!17, !12, i64 16}
!17 = !{!"_ZTS11PixelCamera", !14, i64 0, !14, i64 8, !12, i64 16, !12, i64 20, !10, i64 24, !10, i64 28, !12, i64 32, !18, i64 36, !19, i64 40, !19, i64 64, !20, i64 88}
!18 = !{!"_ZTS5Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!19 = !{!"_ZTS8Camera2D", !14, i64 0, !14, i64 8, !12, i64 16, !12, i64 20}
!20 = !{!"_ZTS13RenderTexture", !10, i64 0, !21, i64 4, !21, i64 24}
!21 = !{!"_ZTS7Texture", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!22 = !{!17, !12, i64 20}
!23 = !{!17, !10, i64 24}
!24 = !{!17, !10, i64 28}
!25 = !{!17, !12, i64 32}
!26 = !{!18, !7, i64 0}
!27 = !{!18, !7, i64 1}
!28 = !{!18, !7, i64 2}
!29 = !{!18, !7, i64 3}
!30 = !{i64 0, i64 1, !31, i64 1, i64 1, !31, i64 2, i64 1, !31, i64 3, i64 1, !31}
!31 = !{!7, !7, i64 0}
!32 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 4, !11, i64 12, i64 4, !11, i64 16, i64 4, !11, i64 20, i64 4, !11}
!33 = !{!17, !12, i64 84}
!34 = !{!17, !12, i64 60}
!35 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 4, !9, i64 36, i64 4, !9, i64 40, 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"

%struct.RenderTexture = type { i32, %struct.Texture, %struct.Texture }
%struct.Texture = type { i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11PixelCameraC2Eiif(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(132) %0, i32 noundef %1, i32 noundef %2, float noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca %struct.RenderTexture, align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %0, i8 0, i64 20, i1 false)
  store float 1.000000e+00, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %1, ptr %7, align 4, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %2, ptr %8, align 4, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  store float %3, ptr %9, align 4, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 36
  store <4 x i8> <i8 10, i8 10, i8 10, i8 -1>, ptr %10, align 4, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %11, i8 0, i64 20, i1 false)
  %12 = getelementptr inbounds i8, ptr %0, i64 84
  store float 1.000000e+00, ptr %12, align 4, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %13, i8 0, i64 20, i1 false)
  %14 = getelementptr inbounds i8, ptr %0, i64 60
  store float 1.000000e+00, ptr %14, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 44, ptr nonnull %5) #5
  %15 = sitofp i32 %1 to float
  %16 = fdiv float %15, %3
  %17 = fadd float %16, 2.000000e+00
  %18 = fptosi float %17 to i32
  %19 = sitofp i32 %2 to float
  %20 = fdiv float %19, %3
  %21 = fadd float %20, 2.000000e+00
  %22 = fptosi float %21 to i32
  call void @LoadRenderTexture(ptr dead_on_unwind nonnull writable sret(%struct.RenderTexture) align 4 %5, i32 noundef %18, i32 noundef %22)
  %23 = getelementptr inbounds i8, ptr %0, i64 88
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(44) %23, ptr noundef nonnull align 4 dereferenceable(44) %5, i64 44, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 44, ptr nonnull %5) #5
  ret void
}

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

; Function Attrs: mustprogress 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @LoadRenderTexture(ptr dead_on_unwind writable sret(%struct.RenderTexture) align 4, i32 noundef, i32 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 #5 = { 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, !8, i64 20}
!6 = !{!"_ZTS11PixelCamera", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 20, !11, i64 24, !11, i64 28, !8, i64 32, !12, i64 36, !13, i64 40, !13, i64 64, !14, i64 88}
!7 = !{!"_ZTS7Vector2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTS5Color", !9, i64 0, !9, i64 1, !9, i64 2, !9, i64 3}
!13 = !{!"_ZTS8Camera2D", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 20}
!14 = !{!"_ZTS13RenderTexture", !11, i64 0, !15, i64 4, !15, i64 24}
!15 = !{!"_ZTS7Texture", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!16 = !{!6, !11, i64 24}
!17 = !{!6, !11, i64 28}
!18 = !{!6, !8, i64 32}
!19 = !{!9, !9, i64 0}
!20 = !{!6, !8, i64 84}
!21 = !{!6, !8, i64 60}
!22 = !{i64 0, i64 4, !23, i64 4, i64 4, !23, i64 8, i64 4, !23, i64 12, i64 4, !23, i64 16, i64 4, !23, i64 20, i64 4, !23, i64 24, i64 4, !23, i64 28, i64 4, !23, i64 32, i64 4, !23, i64 36, i64 4, !23, i64 40, i64 4, !23}
!23 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass