; LLVM IR from yuikns/panther :: ann/src/kd_tree.ll (ZN10ANNkdStats5mergeERKS_)

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

%class.ANNkdStats = type { i32, i32, i32, i32, i32, i32, i32, i32, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40) %0, ptr noundef nonnull align 4 dereferenceable(40) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %class.ANNkdStats, ptr %6, i32 0, i32 3
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 3
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = add nsw i32 %10, %8
  store i32 %11, ptr %9, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.ANNkdStats, ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 4
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = add nsw i32 %16, %14
  store i32 %17, ptr %15, align 4, !tbaa !13
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.ANNkdStats, ptr %18, i32 0, i32 5
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 5
  %22 = load i32, ptr %21, align 4, !tbaa !14
  %23 = add nsw i32 %22, %20
  store i32 %23, ptr %21, align 4, !tbaa !14
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.ANNkdStats, ptr %24, i32 0, i32 6
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 6
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = add nsw i32 %28, %26
  store i32 %29, ptr %27, align 4, !tbaa !15
  %30 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 7
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.ANNkdStats, ptr %32, i32 0, i32 7
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = icmp sgt i32 %31, %34
  br i1 %35, label %36, label %39

36:                                               ; preds = %2
  %37 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 7
  %38 = load i32, ptr %37, align 4, !tbaa !16
  br label %43

39:                                               ; preds = %2
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.ANNkdStats, ptr %40, i32 0, i32 7
  %42 = load i32, ptr %41, align 4, !tbaa !16
  br label %43

43:                                               ; preds = %39, %36
  %44 = phi i32 [ %38, %36 ], [ %42, %39 ]
  %45 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 7
  store i32 %44, ptr %45, align 4, !tbaa !16
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %class.ANNkdStats, ptr %46, i32 0, i32 8
  %48 = load float, ptr %47, align 4, !tbaa !17
  %49 = getelementptr inbounds %class.ANNkdStats, ptr %5, i32 0, i32 8
  %50 = load float, ptr %49, align 4, !tbaa !17
  %51 = fadd float %50, %48
  store float %51, ptr %49, align 4, !tbaa !17
  ret void
}

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

!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 12}
!10 = !{!"_ZTS10ANNkdStats", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !12, i64 32, !12, i64 36}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 20}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 28}
!17 = !{!10, !12, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN10ANNkdStats5mergeERKS_(ptr nocapture noundef nonnull align 4 dereferenceable(40) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(40) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 12
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load <4 x i32>, ptr %3, align 4, !tbaa !5
  %6 = load <4 x i32>, ptr %4, align 4, !tbaa !5
  %7 = add nsw <4 x i32> %6, %5
  store <4 x i32> %7, ptr %4, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %1, i64 28
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %. = tail call i32 @llvm.smax.i32(i32 %9, i32 %11)
  store i32 %., ptr %8, align 4, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %1, i64 32
  %13 = load float, ptr %12, align 4, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load float, ptr %14, align 4, !tbaa !12
  %16 = fadd float %13, %15
  store float %16, ptr %14, align 4, !tbaa !12
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 28}
!10 = !{!"_ZTS10ANNkdStats", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !11, i64 32, !11, i64 36}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass