; LLVM IR from FlorentCLMichel/palisade :: src/core/lib/utils/blockAllocator (xallocator)

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

%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::unique_lock" = type <{ ptr, i8, [7 x i8] }>

@_ZL11_allocators = external hidden global [15 x ptr], align 16
@_ZL12xalloc_mutex = external hidden global { %union.pthread_mutex_t }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @xalloc_destroy() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::unique_lock", align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  call void @_ZL8lock_getv()
  call void @llvm.lifetime.start.p0(i64 16, ptr %1) #6
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9) %1, ptr noundef nonnull align 8 dereferenceable(40) @_ZL12xalloc_mutex)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %28, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp ult i32 %7, 15
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %3, align 4
  br label %31

10:                                               ; preds = %6
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds [15 x ptr], ptr @_ZL11_allocators, i64 0, i64 %12
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %10
  store i32 2, ptr %3, align 4
  br label %31

17:                                               ; preds = %10
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [15 x ptr], ptr @_ZL11_allocators, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = icmp eq ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %21) #6
  call void @_ZdlPvm(ptr noundef %21, i64 noundef 72) #7
  br label %24

24:                                               ; preds = %23, %17
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds [15 x ptr], ptr @_ZL11_allocators, i64 0, i64 %26
  store ptr null, ptr %27, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %24
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !11

31:                                               ; preds = %16, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %32

32:                                               ; preds = %31
  invoke void @_ZL12lock_releasev()
          to label %33 unwind label %35

33:                                               ; preds = %32
  invoke void @_ZL12lock_destroyv()
          to label %34 unwind label %35

34:                                               ; preds = %33
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %1) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %1) #6
  ret void

35:                                               ; preds = %33, %32
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %4, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %5, align 4
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %1) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %1) #6
  br label %39

39:                                               ; preds = %35
  %40 = load ptr, ptr %4, align 8
  %41 = load i32, ptr %5, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL8lock_getv() #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #0 align 2

; Function Attrs: nounwind
declare void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL12lock_releasev() #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL12lock_destroyv() #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #5 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 = { nobuiltin nounwind "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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::unique_lock" = type <{ ptr, i8, [7 x i8] }>

@_ZL11_allocators = external hidden local_unnamed_addr global [15 x ptr], align 16
@_ZL12xalloc_mutex = external hidden global { %union.pthread_mutex_t }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @xalloc_destroy() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::unique_lock", align 8
  tail call void @_ZL8lock_getv()
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #6
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9) %1, ptr noundef nonnull align 8 dereferenceable(40) @_ZL12xalloc_mutex)
  %2 = load ptr, ptr @_ZL11_allocators, align 16, !tbaa !5
  %3 = icmp eq ptr %2, null
  br i1 %3, label %47, label %4

4:                                                ; preds = %0
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %2) #6
  call void @_ZdlPvm(ptr noundef nonnull %2, i64 noundef 72) #7
  store ptr null, ptr @_ZL11_allocators, align 16, !tbaa !5
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 8), align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %47, label %7

7:                                                ; preds = %4
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %5) #6
  call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 8), align 8, !tbaa !5
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 16), align 16, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %47, label %10

10:                                               ; preds = %7
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %8) #6
  call void @_ZdlPvm(ptr noundef nonnull %8, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 16), align 16, !tbaa !5
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 24), align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %47, label %13

13:                                               ; preds = %10
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %11) #6
  call void @_ZdlPvm(ptr noundef nonnull %11, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 24), align 8, !tbaa !5
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 32), align 16, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %47, label %16

16:                                               ; preds = %13
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %14) #6
  call void @_ZdlPvm(ptr noundef nonnull %14, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 32), align 16, !tbaa !5
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 40), align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %47, label %19

19:                                               ; preds = %16
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %17) #6
  call void @_ZdlPvm(ptr noundef nonnull %17, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 40), align 8, !tbaa !5
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 48), align 16, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %47, label %22

22:                                               ; preds = %19
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %20) #6
  call void @_ZdlPvm(ptr noundef nonnull %20, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 48), align 16, !tbaa !5
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 56), align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %47, label %25

25:                                               ; preds = %22
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %23) #6
  call void @_ZdlPvm(ptr noundef nonnull %23, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 56), align 8, !tbaa !5
  %26 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 64), align 16, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %47, label %28

28:                                               ; preds = %25
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %26) #6
  call void @_ZdlPvm(ptr noundef nonnull %26, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 64), align 16, !tbaa !5
  %29 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 72), align 8, !tbaa !5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %47, label %31

31:                                               ; preds = %28
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %29) #6
  call void @_ZdlPvm(ptr noundef nonnull %29, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 72), align 8, !tbaa !5
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 80), align 16, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %47, label %34

34:                                               ; preds = %31
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %32) #6
  call void @_ZdlPvm(ptr noundef nonnull %32, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 80), align 16, !tbaa !5
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 88), align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %47, label %37

37:                                               ; preds = %34
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %35) #6
  call void @_ZdlPvm(ptr noundef nonnull %35, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 88), align 8, !tbaa !5
  %38 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 96), align 16, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %47, label %40

40:                                               ; preds = %37
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %38) #6
  call void @_ZdlPvm(ptr noundef nonnull %38, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 96), align 16, !tbaa !5
  %41 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 104), align 8, !tbaa !5
  %42 = icmp eq ptr %41, null
  br i1 %42, label %47, label %43

43:                                               ; preds = %40
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %41) #6
  call void @_ZdlPvm(ptr noundef nonnull %41, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 104), align 8, !tbaa !5
  %44 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 112), align 16, !tbaa !5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  call void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72) %44) #6
  call void @_ZdlPvm(ptr noundef nonnull %44, i64 noundef 72) #7
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL11_allocators, i64 112), align 16, !tbaa !5
  br label %47

47:                                               ; preds = %46, %43, %40, %37, %34, %31, %28, %25, %22, %19, %16, %13, %10, %7, %4, %0
  call void @_ZL12lock_releasev()
  call void @_ZL12lock_destroyv()
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %1) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #6
  ret void
}

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL8lock_getv() local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #0 align 2

; Function Attrs: nounwind
declare void @_ZN9AllocatorD1Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL12lock_releasev() local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL12lock_destroyv() local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #5 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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 = { nobuiltin nounwind "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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass