; LLVM IR from drohmer/cgp :: library/cgp/12_shape/spatial_domain/spatial_domain_grid_3D/spatial_domain_grid_3_54f896c8 (lengthEv)

; 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.cgp::numarray_stack" = type { float, float, float }
%"struct.cgp::spatial_domain_grid_3D" = type { %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack.0" }
%"struct.cgp::numarray_stack.0" = type { 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK3cgp22spatial_domain_grid_3D12voxel_lengthEv(ptr noundef nonnull align 4 dereferenceable(36) %0) #3 align 2 {
  %2 = alloca %"struct.cgp::numarray_stack", align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %9 = getelementptr inbounds %"struct.cgp::spatial_domain_grid_3D", ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %9, i32 0, i32 0
  %11 = load float, ptr %10, align 4, !tbaa !9
  %12 = getelementptr inbounds %"struct.cgp::spatial_domain_grid_3D", ptr %8, i32 0, i32 2
  %13 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %15 = sub nsw i32 %14, 1
  %16 = sitofp i32 %15 to float
  %17 = fdiv float %11, %16
  store float %17, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %18 = getelementptr inbounds %"struct.cgp::spatial_domain_grid_3D", ptr %8, i32 0, i32 1
  %19 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %18, i32 0, i32 1
  %20 = load float, ptr %19, align 4, !tbaa !17
  %21 = getelementptr inbounds %"struct.cgp::spatial_domain_grid_3D", ptr %8, i32 0, i32 2
  %22 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = sub nsw i32 %23, 1
  %25 = sitofp i32 %24 to float
  %26 = fdiv float %20, %25
  store float %26, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %27 = getelementptr inbounds %"struct.cgp::spatial_domain_grid_3D", ptr %8, i32 0, i32 1
  %28 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %27, i32 0, i32 2
  %29 = load float, ptr %28, align 4, !tbaa !19
  %30 = getelementptr inbounds %"struct.cgp::spatial_domain_grid_3D", ptr %8, i32 0, i32 2
  %31 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !20
  %33 = sub nsw i32 %32, 1
  %34 = sitofp i32 %33 to float
  %35 = fdiv float %29, %34
  store float %35, ptr %6, align 4, !tbaa !16
  call void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 4 %2, i64 12, i1 false)
  %36 = load { <2 x float>, float }, ptr %7, align 8
  ret { <2 x float>, float } %36
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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++ TBAA"}
!9 = !{!10, !12, i64 12}
!10 = !{!"_ZTSN3cgp22spatial_domain_grid_3DE", !11, i64 0, !11, i64 12, !13, i64 24}
!11 = !{!"_ZTSN3cgp14numarray_stackIfLi3EEE", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_ZTSN3cgp14numarray_stackIiLi3EEE", !14, i64 0, !14, i64 4, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !14, i64 24}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !12, i64 16}
!18 = !{!10, !14, i64 28}
!19 = !{!10, !12, i64 20}
!20 = !{!10, !14, i64 32}


; 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.cgp::numarray_stack" = type { float, float, float }

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

; Function Attrs: mustprogress 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 void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, float } @_ZNK3cgp22spatial_domain_grid_3D12voxel_lengthEv(ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"struct.cgp::numarray_stack", align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %10 = add nsw i32 %9, -1
  %11 = sitofp i32 %10 to float
  %12 = fdiv float %7, %11
  store float %12, ptr %3, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load float, ptr %13, align 4, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 28
  %16 = load i32, ptr %15, align 4, !tbaa !16
  %17 = add nsw i32 %16, -1
  %18 = sitofp i32 %17 to float
  %19 = fdiv float %14, %18
  store float %19, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  %20 = getelementptr inbounds i8, ptr %0, i64 20
  %21 = load float, ptr %20, align 4, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = add nsw i32 %23, -1
  %25 = sitofp i32 %24 to float
  %26 = fdiv float %21, %25
  store float %26, ptr %5, align 4, !tbaa !14
  call void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  %.sroa.0.0.copyload = load <2 x float>, ptr %2, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.2.0.copyload = load float, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

attributes #0 = { mustprogress 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 = { 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 12}
!6 = !{!"_ZTSN3cgp22spatial_domain_grid_3DE", !7, i64 0, !7, i64 12, !11, i64 24}
!7 = !{!"_ZTSN3cgp14numarray_stackIfLi3EEE", !8, i64 0, !8, i64 4, !8, i64 8}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN3cgp14numarray_stackIiLi3EEE", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !9, i64 0}
!13 = !{!6, !12, i64 24}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !8, i64 16}
!16 = !{!6, !12, i64 28}
!17 = !{!6, !8, i64 20}
!18 = !{!6, !12, i64 32}


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