; LLVM IR from drohmer/cgp :: library/cgp/12_shape/spatial_domain/spatial_domain_grid_3D/spatial_domain_grid_3_b8d942ba (stackIiLi3EEE)

; 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::numarray_stack.0" = type { i32, i32, i32 }
%"struct.cgp::spatial_domain_grid_3D" = type { %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack.0" }

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

; 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 #3 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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, !11, i64 0}
!10 = !{!"_ZTSN3cgp14numarray_stackIiLi3EEE", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 24}
!13 = !{!"_ZTSN3cgp22spatial_domain_grid_3DE", !14, i64 0, !14, i64 12, !10, i64 24}
!14 = !{!"_ZTSN3cgp14numarray_stackIfLi3EEE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!10, !11, i64 4}
!18 = !{!13, !11, i64 28}
!19 = !{!10, !11, i64 8}
!20 = !{!13, !11, 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
define dso_local { <2 x float>, float } @_ZNK3cgp22spatial_domain_grid_3D17position_relativeERKNS_14numarray_stackIiLi3EEE(ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"struct.cgp::numarray_stack", align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sitofp i32 %7 to float
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load i32, ptr %9, align 4, !tbaa !10
  %11 = sitofp i32 %10 to float
  %12 = fadd float %11, -1.000000e+00
  %13 = fdiv float %8, %12
  store float %13, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !15
  %16 = sitofp i32 %15 to float
  %17 = getelementptr inbounds i8, ptr %0, i64 28
  %18 = load i32, ptr %17, align 4, !tbaa !16
  %19 = sitofp i32 %18 to float
  %20 = fadd float %19, -1.000000e+00
  %21 = fdiv float %16, %20
  store float %21, ptr %5, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  %23 = load i32, ptr %22, align 4, !tbaa !17
  %24 = sitofp i32 %23 to float
  %25 = getelementptr inbounds i8, ptr %0, i64 32
  %26 = load i32, ptr %25, align 4, !tbaa !18
  %27 = sitofp i32 %26 to float
  %28 = fadd float %27, -1.000000e+00
  %29 = fdiv float %24, %28
  store float %29, ptr %6, align 4, !tbaa !14
  call void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12) %3, 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 nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  %.sroa.0.0.copyload = load <2 x float>, ptr %3, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %3, 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
}

; 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

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


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