; LLVM IR from BlueBrain/CoreNeuron :: coreneuron/permute/cellorder1.ll (ZN10coreneuron5TNode6mkhashEv)

; 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.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.coreneuron::TNode" = type <{ ptr, ptr, %"class.std::vector", i64, i64, i64, i64, i64, i64, i64, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<coreneuron::TNode *, std::allocator<coreneuron::TNode *>>::_Vector_impl" }
%"struct.std::_Vector_base<coreneuron::TNode *, std::allocator<coreneuron::TNode *>>::_Vector_impl" = type { %"struct.std::_Vector_base<coreneuron::TNode *, std::allocator<coreneuron::TNode *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<coreneuron::TNode *, std::allocator<coreneuron::TNode *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN10coreneuron5TNode6mkhashEv(ptr noundef nonnull align 8 dereferenceable(100) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 2
  %8 = call ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %9 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  store ptr %8, ptr %9, align 8
  %10 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 2
  %11 = call ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  %12 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  store ptr %11, ptr %12, align 8
  %13 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8
  %15 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPPN10coreneuron5TNodeESt6vectorIS4_SaIS4_EEEEPFbS4_S4_EEvT_SC_T0_(ptr %14, ptr %16, ptr noundef @_ZN10coreneuronL17ptr_tnode_earlierEPNS_5TNodeES1_)
  %17 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 2
  %18 = call noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #4
  %19 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 3
  store i64 %18, ptr %19, align 8, !tbaa !9
  %20 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 4
  store i64 1, ptr %20, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !18
  br label %21

21:                                               ; preds = %55, %1
  %22 = load i64, ptr %5, align 8, !tbaa !18
  %23 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 2
  %24 = call noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #4
  %25 = icmp ult i64 %22, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %58

27:                                               ; preds = %21
  %28 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 2
  %29 = load i64, ptr %5, align 8, !tbaa !18
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %29) #4
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.coreneuron::TNode", ptr %31, i32 0, i32 3
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = add i64 %33, 2654435769
  %35 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 3
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = shl i64 %36, 6
  %38 = add i64 %34, %37
  %39 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 3
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = lshr i64 %40, 2
  %42 = add i64 %38, %41
  %43 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 3
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = xor i64 %44, %42
  store i64 %45, ptr %43, align 8, !tbaa !9
  %46 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 2
  %47 = load i64, ptr %5, align 8, !tbaa !18
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %46, i64 noundef %47) #4
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.coreneuron::TNode", ptr %49, i32 0, i32 4
  %51 = load i64, ptr %50, align 8, !tbaa !17
  %52 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 4
  %53 = load i64, ptr %52, align 8, !tbaa !17
  %54 = add i64 %53, %51
  store i64 %54, ptr %52, align 8, !tbaa !17
  br label %55

55:                                               ; preds = %27
  %56 = load i64, ptr %5, align 8, !tbaa !18
  %57 = add i64 %56, 1
  store i64 %57, ptr %5, align 8, !tbaa !18
  br label %21, !llvm.loop !19

58:                                               ; preds = %26
  %59 = getelementptr inbounds %"class.coreneuron::TNode", ptr %6, i32 0, i32 3
  %60 = load i64, ptr %59, align 8, !tbaa !9
  ret i64 %60
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN10coreneuronL17ptr_tnode_earlierEPNS_5TNodeES1_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

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" }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !15, i64 40}
!10 = !{!"_ZTSN10coreneuron5TNodeE", !6, i64 8, !11, i64 16, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !16, i64 96}
!11 = !{!"_ZTSSt6vectorIPN10coreneuron5TNodeESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIPN10coreneuron5TNodeESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIPN10coreneuron5TNodeESaIS2_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIPN10coreneuron5TNodeESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!10, !15, i64 48}
!18 = !{!15, !15, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN10coreneuron5TNode6mkhashEv(ptr noundef nonnull align 8 dereferenceable(100) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = tail call ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %4 = tail call ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  tail call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPPN10coreneuron5TNodeESt6vectorIS4_SaIS4_EEEEPFbS4_S4_EEvT_SC_T0_(ptr %3, ptr %4, ptr noundef nonnull @_ZN10coreneuronL17ptr_tnode_earlierEPNS_5TNodeES1_)
  %5 = tail call noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %5, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 1, ptr %7, align 8, !tbaa !16
  %8 = tail call noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %9 = load i64, ptr %6, align 8, !tbaa !5
  ret i64 %9

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.05 = phi i64 [ %27, %.lr.ph ], [ 0, %1 ]
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.05) #3
  %11 = load ptr, ptr %10, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %11, i64 40
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = add i64 %13, 2654435769
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = shl i64 %15, 6
  %17 = add i64 %14, %16
  %18 = lshr i64 %15, 2
  %19 = add i64 %17, %18
  %20 = xor i64 %19, %15
  store i64 %20, ptr %6, align 8, !tbaa !5
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.05) #3
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = getelementptr inbounds i8, ptr %22, i64 48
  %24 = load i64, ptr %23, align 8, !tbaa !16
  %25 = load i64, ptr %7, align 8, !tbaa !16
  %26 = add i64 %25, %24
  store i64 %26, ptr %7, align 8, !tbaa !16
  %27 = add nuw i64 %.05, 1
  %28 = tail call noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !18
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN10coreneuronL17ptr_tnode_earlierEPNS_5TNodeES1_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN10coreneuron5TNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN10coreneuron5TNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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" }
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 = { 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, !14, i64 40}
!6 = !{!"_ZTSN10coreneuron5TNodeE", !7, i64 8, !10, i64 16, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !15, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIPN10coreneuron5TNodeESaIS2_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIPN10coreneuron5TNodeESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIPN10coreneuron5TNodeESaIS2_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIPN10coreneuron5TNodeESaIS2_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!6, !14, i64 48}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass