; LLVM IR from PyCee/NUS_library :: src/physics (NUS_mass)

; 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.NUS_mass = type { ptr, ptr, %struct.NUS_physics_state, %struct.NUS_physics_state, %struct.NUS_physics_state, %struct.NUS_matrix }
%struct.NUS_physics_state = type { %struct.NUS_vector, %struct.NUS_axes }
%struct.NUS_vector = type { double, double, double }
%struct.NUS_axes = type { %struct.NUS_vector, %struct.NUS_vector, %struct.NUS_vector }
%struct.NUS_matrix = type { [4 x [4 x float]] }
%struct.NUS_movement = type { %struct.NUS_kinematic_property, %struct.NUS_kinematic_property, %struct.NUS_vector, i32, i32 }
%struct.NUS_kinematic_property = type { ptr, %struct.NUS_vector, i32 }
%struct.NUS_orientation = type { %struct.NUS_vector, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @nus_mass_build(ptr dead_on_unwind noalias writable sret(%struct.NUS_mass) align 8 %0) #0 {
  %2 = alloca %struct.NUS_movement, align 8
  %3 = alloca %struct.NUS_orientation, align 8
  %4 = alloca %struct.NUS_physics_state, align 8
  %5 = alloca %struct.NUS_physics_state, align 8
  %6 = alloca %struct.NUS_physics_state, align 8
  %7 = alloca %struct.NUS_matrix, align 4
  %8 = call noalias ptr @malloc(i64 noundef 112) #5
  %9 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 0
  store ptr %8, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 112, ptr %2) #6
  call void @nus_movement_build(ptr dead_on_unwind writable sret(%struct.NUS_movement) align 8 %2)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %2, i64 112, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 112, ptr %2) #6
  %12 = call noalias ptr @malloc(i64 noundef 32) #5
  %13 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 1
  store ptr %12, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #6
  call void @nus_orientation_build(ptr dead_on_unwind writable sret(%struct.NUS_orientation) align 8 %3)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %3, i64 32, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #6
  %16 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 96, ptr %4) #6
  call void @nus_physics_state_build(ptr dead_on_unwind writable sret(%struct.NUS_physics_state) align 8 %4)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %4, i64 96, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 96, ptr %4) #6
  %17 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 96, ptr %5) #6
  call void @nus_physics_state_build(ptr dead_on_unwind writable sret(%struct.NUS_physics_state) align 8 %5)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 8 %5, i64 96, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 96, ptr %5) #6
  %18 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 4
  call void @llvm.lifetime.start.p0(i64 96, ptr %6) #6
  call void @nus_physics_state_build(ptr dead_on_unwind writable sret(%struct.NUS_physics_state) align 8 %6)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %6, i64 96, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 96, ptr %6) #6
  %19 = getelementptr inbounds %struct.NUS_mass, ptr %0, i32 0, i32 5
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #6
  call void @nus_matrix_identity(ptr dead_on_unwind writable sret(%struct.NUS_matrix) align 4 %7)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 4 %7, i64 64, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #6
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

declare void @nus_movement_build(ptr dead_on_unwind writable sret(%struct.NUS_movement) align 8) #3

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

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

declare void @nus_orientation_build(ptr dead_on_unwind writable sret(%struct.NUS_orientation) align 8) #3

declare void @nus_physics_state_build(ptr dead_on_unwind writable sret(%struct.NUS_physics_state) align 8) #3

declare void @nus_matrix_identity(ptr dead_on_unwind writable sret(%struct.NUS_matrix) align 4) #3

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 = { nounwind allocsize(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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"NUS_mass", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 112, !10, i64 208, !14, i64 304}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"NUS_physics_state", !11, i64 0, !13, i64 24}
!11 = !{!"NUS_vector", !12, i64 0, !12, i64 8, !12, i64 16}
!12 = !{!"double", !8, i64 0}
!13 = !{!"NUS_axes", !11, i64 0, !11, i64 24, !11, i64 48}
!14 = !{!"NUS_matrix", !8, i64 0}
!15 = !{i64 0, i64 8, !16, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 8, !17, i64 32, i64 4, !18, i64 40, i64 8, !16, i64 48, i64 8, !17, i64 56, i64 8, !17, i64 64, i64 8, !17, i64 72, i64 4, !18, i64 80, i64 8, !17, i64 88, i64 8, !17, i64 96, i64 8, !17, i64 104, i64 4, !18, i64 108, i64 4, !18}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !8, i64 0}
!20 = !{!6, !7, i64 8}
!21 = !{i64 0, i64 8, !17, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 4, !18}
!22 = !{i64 0, i64 8, !17, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 8, !17, i64 32, i64 8, !17, i64 40, i64 8, !17, i64 48, i64 8, !17, i64 56, i64 8, !17, i64 64, i64 8, !17, i64 72, i64 8, !17, i64 80, i64 8, !17, i64 88, i64 8, !17}
!23 = !{i64 0, i64 64, !24}
!24 = !{!8, !8, i64 0}


; 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.NUS_mass = type { ptr, ptr, %struct.NUS_physics_state, %struct.NUS_physics_state, %struct.NUS_physics_state, %struct.NUS_matrix }
%struct.NUS_physics_state = type { %struct.NUS_vector, %struct.NUS_axes }
%struct.NUS_vector = type { double, double, double }
%struct.NUS_axes = type { %struct.NUS_vector, %struct.NUS_vector, %struct.NUS_vector }
%struct.NUS_matrix = type { [4 x [4 x float]] }
%struct.NUS_movement = type { %struct.NUS_kinematic_property, %struct.NUS_kinematic_property, %struct.NUS_vector, i32, i32 }
%struct.NUS_kinematic_property = type { ptr, %struct.NUS_vector, i32 }
%struct.NUS_orientation = type { %struct.NUS_vector, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @nus_mass_build(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.NUS_mass) align 8 %0) local_unnamed_addr #0 {
  %2 = alloca %struct.NUS_movement, align 8
  %3 = alloca %struct.NUS_orientation, align 8
  %4 = alloca %struct.NUS_physics_state, align 8
  %5 = alloca %struct.NUS_physics_state, align 8
  %6 = alloca %struct.NUS_matrix, align 4
  %7 = tail call noalias dereferenceable_or_null(112) ptr @malloc(i64 noundef 112) #5
  store ptr %7, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %2) #6
  call void @nus_movement_build(ptr dead_on_unwind nonnull writable sret(%struct.NUS_movement) align 8 %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %7, ptr noundef nonnull align 8 dereferenceable(112) %2, i64 112, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %2) #6
  %8 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %8, ptr %9, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  call void @nus_orientation_build(ptr dead_on_unwind nonnull writable sret(%struct.NUS_orientation) align 8 %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(32) %3, i64 32, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  call void @nus_physics_state_build(ptr dead_on_unwind nonnull writable sret(%struct.NUS_physics_state) align 8 %10) #6
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %4) #6
  call void @nus_physics_state_build(ptr dead_on_unwind nonnull writable sret(%struct.NUS_physics_state) align 8 %4) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %11, ptr noundef nonnull align 8 dereferenceable(96) %4, i64 96, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %4) #6
  %12 = getelementptr inbounds i8, ptr %0, i64 208
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %5) #6
  call void @nus_physics_state_build(ptr dead_on_unwind nonnull writable sret(%struct.NUS_physics_state) align 8 %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %12, ptr noundef nonnull align 8 dereferenceable(96) %5, i64 96, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %5) #6
  %13 = getelementptr inbounds i8, ptr %0, i64 304
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #6
  call void @nus_matrix_identity(ptr dead_on_unwind nonnull writable sret(%struct.NUS_matrix) align 4 %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %13, ptr noundef nonnull align 4 dereferenceable(64) %6, i64 64, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #6
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

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

declare void @nus_movement_build(ptr dead_on_unwind writable sret(%struct.NUS_movement) align 8) local_unnamed_addr #3

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

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

declare void @nus_orientation_build(ptr dead_on_unwind writable sret(%struct.NUS_orientation) align 8) local_unnamed_addr #3

declare void @nus_physics_state_build(ptr dead_on_unwind writable sret(%struct.NUS_physics_state) align 8) local_unnamed_addr #3

declare void @nus_matrix_identity(ptr dead_on_unwind writable sret(%struct.NUS_matrix) align 4) local_unnamed_addr #3

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"NUS_mass", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 112, !10, i64 208, !14, i64 304}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"NUS_physics_state", !11, i64 0, !13, i64 24}
!11 = !{!"NUS_vector", !12, i64 0, !12, i64 8, !12, i64 16}
!12 = !{!"double", !8, i64 0}
!13 = !{!"NUS_axes", !11, i64 0, !11, i64 24, !11, i64 48}
!14 = !{!"NUS_matrix", !8, i64 0}
!15 = !{i64 0, i64 8, !16, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 8, !17, i64 32, i64 4, !18, i64 40, i64 8, !16, i64 48, i64 8, !17, i64 56, i64 8, !17, i64 64, i64 8, !17, i64 72, i64 4, !18, i64 80, i64 8, !17, i64 88, i64 8, !17, i64 96, i64 8, !17, i64 104, i64 4, !18, i64 108, i64 4, !18}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !8, i64 0}
!20 = !{!6, !7, i64 8}
!21 = !{i64 0, i64 8, !17, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 4, !18}
!22 = !{i64 0, i64 8, !17, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 8, !17, i64 32, i64 8, !17, i64 40, i64 8, !17, i64 48, i64 8, !17, i64 56, i64 8, !17, i64 64, i64 8, !17, i64 72, i64 8, !17, i64 80, i64 8, !17, i64 88, i64 8, !17}
!23 = !{i64 0, i64 64, !24}
!24 = !{!8, !8, i64 0}


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