; 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::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 @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7glslang14TPoolAllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(96) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  br label %6

6:                                                ; preds = %21, %1
  %7 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 6
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %24

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

20:                                               ; preds = %10
  call void @_ZdaPv(ptr noundef %18) #4
  br label %21

21:                                               ; preds = %20, %10
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 6
  store ptr %22, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %6, !llvm.loop !19

24:                                               ; preds = %6
  br label %25

25:                                               ; preds = %38, %24
  %26 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %41

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %30 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 5
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %"struct.glslang::TPoolAllocator::tHeader", ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  store ptr %33, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = icmp eq ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %29
  call void @_ZdaPv(ptr noundef %35) #4
  br label %38

38:                                               ; preds = %37, %29
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 5
  store ptr %39, ptr %40, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %25, !llvm.loop !22

41:                                               ; preds = %25
  %42 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %5, i32 0, i32 7
  call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %42) #3
  ret void
}

; 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

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 48}
!10 = !{!"_ZTSN7glslang14TPoolAllocatorE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !16, i64 80, !11, i64 88}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN7glslang14TPoolAllocator11tAllocStateESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"_ZTSN7glslang14TPoolAllocator7tHeaderE", !6, i64 0, !11, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !6, i64 40}
!22 = distinct !{!22, !20}


; 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 @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7glslang14TPoolAllocatorD2Ev(ptr noundef nonnull align 8 dereferenceable(96) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not6 = icmp eq ptr %3, null
  br i1 %.not6, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %11, %1
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !16
  %.not57 = icmp eq ptr %5, null
  br i1 %.not57, label %._crit_edge, label %.lr.ph8

.lr.ph:                                           ; preds = %1, %11
  %6 = phi ptr [ %7, %11 ], [ %3, %1 ]
  %7 = load ptr, ptr %6, align 8, !tbaa !17
  tail call void @_ZN7glslang14TPoolAllocator7tHeaderD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #2
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %11, label %10

10:                                               ; preds = %.lr.ph
  tail call void @_ZdaPv(ptr noundef nonnull %8) #3
  br label %11

11:                                               ; preds = %10, %.lr.ph
  store ptr %7, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !19

.lr.ph8:                                          ; preds = %.preheader, %.lr.ph8
  %12 = phi ptr [ %13, %.lr.ph8 ], [ %5, %.preheader ]
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  tail call void @_ZdaPv(ptr noundef nonnull %12) #3
  store ptr %13, ptr %4, align 8, !tbaa !16
  %.not5 = icmp eq ptr %13, null
  br i1 %.not5, label %._crit_edge, label %.lr.ph8, !llvm.loop !21

._crit_edge:                                      ; preds = %.lr.ph8, %.preheader
  %14 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %14) #2
  ret void
}

; 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

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


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