; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/c_bindings/cbindings.ll (ZN9CBindings9to_structE4AABB)

; 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.AABB_t = type { %struct.Vector3_t, float, float, float }
%struct.Vector3_t = type { float, float, float }
%"class.vmath::vec3" = type { float, float, float }
%class.AABB = type { %"class.vmath::vec3", double, double, double }

; 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: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZN9CBindings9to_structEN5vmath4vec3E(ptr noundef) #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: mustprogress nounwind uwtable
define dso_local void @_ZN9CBindings9to_structE4AABB(ptr dead_on_unwind noalias writable sret(%struct.AABB_t) align 4 %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.Vector3_t, align 4
  %5 = alloca %"class.vmath::vec3", align 4
  %6 = alloca { <2 x float>, float }, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #5
  %7 = getelementptr inbounds %class.AABB, ptr %1, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 8 %7, i64 12, i1 false), !tbaa.struct !9
  %8 = call { <2 x float>, float } @_ZN9CBindings9to_structEN5vmath4vec3E(ptr noundef %5)
  store { <2 x float>, float } %8, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 8 %6, i64 12, i1 false)
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #5
  %9 = getelementptr inbounds %struct.AABB_t, ptr %0, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %4, i64 12, i1 false), !tbaa.struct !9
  %10 = getelementptr inbounds %struct.AABB_t, ptr %0, i32 0, i32 1
  %11 = getelementptr inbounds %class.AABB, ptr %1, i32 0, i32 1
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = fptrunc double %12 to float
  store float %13, ptr %10, align 4, !tbaa !16
  %14 = getelementptr inbounds %struct.AABB_t, ptr %0, i32 0, i32 2
  %15 = getelementptr inbounds %class.AABB, ptr %1, i32 0, i32 2
  %16 = load double, ptr %15, align 8, !tbaa !19
  %17 = fptrunc double %16 to float
  store float %17, ptr %14, align 4, !tbaa !20
  %18 = getelementptr inbounds %struct.AABB_t, ptr %0, i32 0, i32 3
  %19 = getelementptr inbounds %class.AABB, ptr %1, i32 0, i32 3
  %20 = load double, ptr %19, align 8, !tbaa !21
  %21 = fptrunc double %20 to float
  store float %21, ptr %18, align 4, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #5
  ret void
}

; Function Attrs: nounwind
declare void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #4

attributes #0 = { nocallback nofree nosync 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" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 "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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !15, i64 16}
!13 = !{!"_ZTS4AABB", !14, i64 0, !15, i64 16, !15, i64 24, !15, i64 32}
!14 = !{!"_ZTSN5vmath4vec3E", !11, i64 0, !11, i64 4, !11, i64 8}
!15 = !{!"double", !7, i64 0}
!16 = !{!17, !11, i64 12}
!17 = !{!"_ZTS6AABB_t", !18, i64 0, !11, i64 12, !11, i64 16, !11, i64 20}
!18 = !{!"_ZTS9Vector3_t", !11, i64 0, !11, i64 4, !11, i64 8}
!19 = !{!13, !15, i64 24}
!20 = !{!17, !11, i64 16}
!21 = !{!13, !15, i64 32}
!22 = !{!17, !11, i64 20}


; 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.AABB_t = type { %struct.Vector3_t, float, float, float }
%struct.Vector3_t = type { float, float, float }
%"class.vmath::vec3" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_ZN9CBindings9to_structEN5vmath4vec3E(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9CBindings9to_structE4AABB(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.AABB_t) align 4 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca %"class.vmath::vec3", align 4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 8 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !5
  %4 = call { <2 x float>, float } @_ZN9CBindings9to_structEN5vmath4vec3E(ptr noundef nonnull %3)
  %.fca.0.extract = extractvalue { <2 x float>, float } %4, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %4, 1
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %3) #4
  store <2 x float> %.fca.0.extract, ptr %0, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store float %.fca.1.extract, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !6
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load <2 x double>, ptr %6, align 8, !tbaa !10
  %8 = fptrunc <2 x double> %7 to <2 x float>
  store <2 x float> %8, ptr %5, align 4, !tbaa !6
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = load double, ptr %10, align 8, !tbaa !12
  %12 = fptrunc double %11 to float
  store float %12, ptr %9, align 4, !tbaa !15
  ret void
}

; Function Attrs: nounwind
declare void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3

attributes #0 = { 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 "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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!13, !11, i64 32}
!13 = !{!"_ZTS4AABB", !14, i64 0, !11, i64 16, !11, i64 24, !11, i64 32}
!14 = !{!"_ZTSN5vmath4vec3E", !7, i64 0, !7, i64 4, !7, i64 8}
!15 = !{!16, !7, i64 20}
!16 = !{!"_ZTS6AABB_t", !17, i64 0, !7, i64 12, !7, i64 16, !7, i64 20}
!17 = !{!"_ZTS9Vector3_t", !7, i64 0, !7, i64 4, !7, i64 8}


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