; LLVM IR from ardiloot/NonlinearTMM :: NonlinearTMM/src/eigen-3.4.0/test/mapstaticmethods.ll (Z21test_mapstaticmethodsv)

; 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"

@_ZN12_GLOBAL__N_13ptrE = external hidden global ptr, align 8
@_ZN12_GLOBAL__N_19const_ptrE = external hidden global ptr, align 8

; 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 uwtable
define dso_local void @_Z21test_mapstaticmethodsv() #1 {
  %1 = alloca i32, align 4
  %2 = call noundef ptr @_ZN5Eigen8internal11aligned_newIfEEPT_m(i64 noundef 1000)
  store ptr %2, ptr @_ZN12_GLOBAL__N_13ptrE, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %3

3:                                                ; preds = %14, %0
  %4 = load i32, ptr %1, align 4, !tbaa !9
  %5 = icmp slt i32 %4, 1000
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %17

7:                                                ; preds = %3
  %8 = load i32, ptr %1, align 4, !tbaa !9
  %9 = sitofp i32 %8 to float
  %10 = load ptr, ptr @_ZN12_GLOBAL__N_13ptrE, align 8, !tbaa !5
  %11 = load i32, ptr %1, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds float, ptr %10, i64 %12
  store float %9, ptr %13, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %7
  %15 = load i32, ptr %1, align 4, !tbaa !9
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %1, align 4, !tbaa !9
  br label %3, !llvm.loop !13

17:                                               ; preds = %6
  %18 = load ptr, ptr @_ZN12_GLOBAL__N_13ptrE, align 8, !tbaa !5
  store ptr %18, ptr @_ZN12_GLOBAL__N_19const_ptrE, align 8, !tbaa !5
  %19 = load ptr, ptr @_ZN12_GLOBAL__N_13ptrE, align 8, !tbaa !5
  call void @_ZN5Eigen8internal14aligned_deleteIfEEvPT_m(ptr noundef %19, i64 noundef 1000)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN5Eigen8internal11aligned_newIfEEPT_m(i64 noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5Eigen8internal14aligned_deleteIfEEvPT_m(ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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"

@_ZN12_GLOBAL__N_13ptrE = external hidden local_unnamed_addr global ptr, align 8
@_ZN12_GLOBAL__N_19const_ptrE = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z21test_mapstaticmethodsv() local_unnamed_addr #0 {
vector.ph:
  %0 = tail call noundef ptr @_ZN5Eigen8internal11aligned_newIfEEPT_m(i64 noundef 1000)
  store ptr %0, ptr @_ZN12_GLOBAL__N_13ptrE, align 8, !tbaa !5
  br label %vector.body

vector.body:                                      ; preds = %vector.body.1, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.1, %vector.body.1 ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next.1, %vector.body.1 ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %1 = uitofp <4 x i32> %vec.ind to <4 x float>
  %2 = uitofp <4 x i32> %step.add to <4 x float>
  %3 = getelementptr inbounds float, ptr %0, i64 %index
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  store <4 x float> %1, ptr %3, align 4, !tbaa !9
  store <4 x float> %2, ptr %4, align 4, !tbaa !9
  %5 = icmp eq i64 %index, 992
  br i1 %5, label %middle.block, label %vector.body.1, !llvm.loop !11

vector.body.1:                                    ; preds = %vector.body
  %index.next = or disjoint i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %step.add.1 = add <4 x i32> %vec.ind, <i32 12, i32 12, i32 12, i32 12>
  %6 = uitofp <4 x i32> %vec.ind.next to <4 x float>
  %7 = uitofp <4 x i32> %step.add.1 to <4 x float>
  %8 = getelementptr inbounds float, ptr %0, i64 %index.next
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <4 x float> %6, ptr %8, align 4, !tbaa !9
  store <4 x float> %7, ptr %9, align 4, !tbaa !9
  %index.next.1 = add nuw nsw i64 %index, 16
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  br label %vector.body

middle.block:                                     ; preds = %vector.body
  store ptr %0, ptr @_ZN12_GLOBAL__N_19const_ptrE, align 8, !tbaa !5
  tail call void @_ZN5Eigen8internal14aligned_deleteIfEEvPT_m(ptr noundef nonnull %0, i64 noundef 1000)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN5Eigen8internal11aligned_newIfEEPT_m(i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5Eigen8internal14aligned_deleteIfEEvPT_m(ptr noundef, i64 noundef) local_unnamed_addr #1

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 = { inlinehint 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" }

!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 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass