; LLVM IR from hbatagelo/abcg :: abcg/external/glslang/glslang/MachineIndependent (PoolAlloc)

; 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.glslang::TPoolAllocator" = type { i64, i64, i64, i64, i64, ptr, ptr, %"class.std::vector", i32, i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<glslang::TPoolAllocator::tAllocState, std::allocator<glslang::TPoolAllocator::tAllocState>>::_Vector_impl" }
%"struct.std::_Vector_base<glslang::TPoolAllocator::tAllocState, std::allocator<glslang::TPoolAllocator::tAllocState>>::_Vector_impl" = type { %"struct.std::_Vector_base<glslang::TPoolAllocator::tAllocState, std::allocator<glslang::TPoolAllocator::tAllocState>>::_Vector_impl_data" }
%"struct.std::_Vector_base<glslang::TPoolAllocator::tAllocState, std::allocator<glslang::TPoolAllocator::tAllocState>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.glslang::TPoolAllocator::tAllocState" = type { i64, ptr }
%"struct.glslang::TPoolAllocator::tHeader" = type { ptr, i64 }

; 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 nounwind uwtable
declare dso_local void @_ZN7glslang14TPoolAllocator7tHeaderD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7glslang14TPoolAllocator3popEv(ptr noundef nonnull align 8 dereferenceable(96) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, 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.glslang::TPoolAllocator", ptr %6, i32 0, i32 7
  %8 = call noundef i64 @_ZNKSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  %9 = icmp ult i64 %8, 1
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  br label %59

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %12 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 7
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  %14 = getelementptr inbounds %"struct.glslang::TPoolAllocator::tAllocState", ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 7
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #3
  %18 = getelementptr inbounds %"struct.glslang::TPoolAllocator::tAllocState", ptr %17, i32 0, i32 0
  %19 = load i64, ptr %18, align 8, !tbaa !12
  %20 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 4
  store i64 %19, ptr %20, align 8, !tbaa !13
  br label %21

21:                                               ; preds = %54, %11
  %22 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = icmp ne ptr %23, %24
  br i1 %25, label %26, label %57

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %27 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %29 = getelementptr inbounds %"struct.glslang::TPoolAllocator::tHeader", ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  store ptr %30, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %31 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = getelementptr inbounds %"struct.glslang::TPoolAllocator::tHeader", ptr %32, i32 0, i32 1
  %34 = load i64, ptr %33, align 8, !tbaa !23
  store i64 %34, ptr %5, align 8, !tbaa !24
  %35 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  call void @_ZN7glslang14TPoolAllocator7tHeaderD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %36) #3
  %37 = load i64, ptr %5, align 8, !tbaa !24
  %38 = icmp ugt i64 %37, 1
  br i1 %38, label %39, label %45

39:                                               ; preds = %26
  %40 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = icmp eq ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @_ZdaPv(ptr noundef %41) #4
  br label %44

44:                                               ; preds = %43, %39
  br label %54

45:                                               ; preds = %26
  %46 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !25
  %48 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  %50 = getelementptr inbounds %"struct.glslang::TPoolAllocator::tHeader", ptr %49, i32 0, i32 0
  store ptr %47, ptr %50, align 8, !tbaa !21
  %51 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %53 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 5
  store ptr %52, ptr %53, align 8, !tbaa !25
  br label %54

54:                                               ; preds = %45, %44
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 6
  store ptr %55, ptr %56, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %21, !llvm.loop !26

57:                                               ; preds = %21
  %58 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %6, i32 0, i32 7
  call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %58) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %59

59:                                               ; preds = %57, %10
  ret void
}

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

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

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

attributes #0 = { 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 = { 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 #3 = { nounwind }
attributes #4 = { 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"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN7glslang14TPoolAllocator11tAllocStateE", !11, i64 0, !6, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!14, !11, i64 32}
!14 = !{!"_ZTSN7glslang14TPoolAllocatorE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !19, i64 80, !11, i64 88}
!15 = !{!"_ZTSSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"int", !7, i64 0}
!20 = !{!14, !6, i64 48}
!21 = !{!22, !6, i64 0}
!22 = !{!"_ZTSN7glslang14TPoolAllocator7tHeaderE", !6, i64 0, !11, i64 8}
!23 = !{!22, !11, i64 8}
!24 = !{!11, !11, i64 0}
!25 = !{!14, !6, i64 40}
!26 = distinct !{!26, !27}
!27 = !{!"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 nounwind uwtable
declare dso_local void @_ZN7glslang14TPoolAllocator7tHeaderD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7glslang14TPoolAllocator3popEv(ptr noundef nonnull align 8 dereferenceable(96) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  %3 = tail call noundef i64 @_ZNKSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %4 = icmp eq i64 %3, 0
  br i1 %4, label %29, label %5

5:                                                ; preds = %1
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %10, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = load ptr, ptr %12, align 8, !tbaa !19
  %.not4 = icmp eq ptr %13, %8
  br i1 %.not4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  br label %15

15:                                               ; preds = %.lr.ph, %28
  %16 = phi ptr [ %13, %.lr.ph ], [ %17, %28 ]
  %17 = load ptr, ptr %16, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %16, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !22
  tail call void @_ZN7glslang14TPoolAllocator7tHeaderD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %16) #2
  %20 = icmp ugt i64 %19, 1
  br i1 %20, label %21, label %25

21:                                               ; preds = %15
  %22 = load ptr, ptr %12, align 8, !tbaa !19
  %23 = icmp eq ptr %22, null
  br i1 %23, label %28, label %24

24:                                               ; preds = %21
  tail call void @_ZdaPv(ptr noundef nonnull %22) #3
  br label %28

25:                                               ; preds = %15
  %26 = load ptr, ptr %14, align 8, !tbaa !23
  %27 = load ptr, ptr %12, align 8, !tbaa !19
  store ptr %26, ptr %27, align 8, !tbaa !20
  store ptr %27, ptr %14, align 8, !tbaa !23
  br label %28

28:                                               ; preds = %21, %24, %25
  store ptr %17, ptr %12, align 8, !tbaa !19
  %.not = icmp eq ptr %17, %8
  br i1 %.not, label %._crit_edge, label %15, !llvm.loop !24

._crit_edge:                                      ; preds = %28, %5
  tail call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  br label %29

29:                                               ; preds = %1, %._crit_edge
  ret void
}

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

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

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

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" }
attributes #1 = { 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 #2 = { nounwind }
attributes #3 = { 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, !10, i64 8}
!6 = !{!"_ZTSN7glslang14TPoolAllocator11tAllocStateE", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 32}
!13 = !{!"_ZTSN7glslang14TPoolAllocatorE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !18, i64 80, !7, i64 88}
!14 = !{!"_ZTSSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"int", !8, i64 0}
!19 = !{!13, !10, i64 48}
!20 = !{!21, !10, i64 0}
!21 = !{!"_ZTSN7glslang14TPoolAllocator7tHeaderE", !10, i64 0, !7, i64 8}
!22 = !{!21, !7, i64 8}
!23 = !{!13, !10, i64 40}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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