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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7glslang14TPoolAllocatorC2Eii(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  %12 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 0
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  store i64 %14, ptr %12, align 8, !tbaa !11
  %15 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 1
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  store i64 %17, ptr %15, align 8, !tbaa !18
  %18 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 5
  store ptr null, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 6
  store ptr null, ptr %19, align 8, !tbaa !20
  %20 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 7
  call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %20) #3
  %21 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 8
  store i32 0, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 0
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = icmp ult i64 %23, 4096
  br i1 %24, label %25, label %27

25:                                               ; preds = %3
  %26 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 0
  store i64 4096, ptr %26, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %25, %3
  %28 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 4
  store i64 %29, ptr %30, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 8, ptr %7, align 8, !tbaa !23
  %31 = load i64, ptr %7, align 8, !tbaa !23
  %32 = sub i64 %31, 1
  %33 = xor i64 %32, -1
  %34 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !18
  %36 = and i64 %35, %33
  store i64 %36, ptr %34, align 8, !tbaa !18
  %37 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !18
  %39 = load i64, ptr %7, align 8, !tbaa !23
  %40 = icmp ult i64 %38, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %27
  %42 = load i64, ptr %7, align 8, !tbaa !23
  %43 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 1
  store i64 %42, ptr %43, align 8, !tbaa !18
  br label %44

44:                                               ; preds = %41, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 1, ptr %8, align 8, !tbaa !23
  br label %45

45:                                               ; preds = %50, %44
  %46 = load i64, ptr %8, align 8, !tbaa !23
  %47 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !18
  %49 = icmp ult i64 %46, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  %51 = load i64, ptr %8, align 8, !tbaa !23
  %52 = shl i64 %51, 1
  store i64 %52, ptr %8, align 8, !tbaa !23
  br label %45, !llvm.loop !24

53:                                               ; preds = %45
  %54 = load i64, ptr %8, align 8, !tbaa !23
  %55 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 1
  store i64 %54, ptr %55, align 8, !tbaa !18
  %56 = load i64, ptr %8, align 8, !tbaa !23
  %57 = sub i64 %56, 1
  %58 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 2
  store i64 %57, ptr %58, align 8, !tbaa !26
  %59 = load i64, ptr %7, align 8, !tbaa !23
  %60 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 3
  store i64 %59, ptr %60, align 8, !tbaa !27
  %61 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 3
  %62 = load i64, ptr %61, align 8, !tbaa !27
  %63 = icmp ult i64 %62, 16
  br i1 %63, label %64, label %73

64:                                               ; preds = %53
  %65 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 2
  %66 = load i64, ptr %65, align 8, !tbaa !26
  %67 = add i64 16, %66
  %68 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 2
  %69 = load i64, ptr %68, align 8, !tbaa !26
  %70 = xor i64 %69, -1
  %71 = and i64 %67, %70
  %72 = getelementptr inbounds %"class.glslang::TPoolAllocator", ptr %11, i32 0, i32 3
  store i64 %71, ptr %72, align 8, !tbaa !27
  br label %73

73:                                               ; preds = %64, %53
  invoke void @_ZN7glslang14TPoolAllocator4pushEv(ptr noundef nonnull align 8 dereferenceable(96) %11)
          to label %74 unwind label %75

74:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void

75:                                               ; preds = %73
  %76 = landingpad { ptr, i32 }
          cleanup
  %77 = extractvalue { ptr, i32 } %76, 0
  store ptr %77, ptr %9, align 8
  %78 = extractvalue { ptr, i32 } %76, 1
  store i32 %78, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %20) #3
  br label %79

79:                                               ; preds = %75
  %80 = load ptr, ptr %9, align 8
  %81 = load i32, ptr %10, align 4
  %82 = insertvalue { ptr, i32 } poison, ptr %80, 0
  %83 = insertvalue { ptr, i32 } %82, i32 %81, 1
  resume { ptr, i32 } %83
}

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 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 = { 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 }

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


; 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 void @_ZN7glslang14TPoolAllocatorC2Eii(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = sext i32 %1 to i64
  store i64 %4, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = sext i32 %2 to i64
  store i64 %6, ptr %5, align 8, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  tail call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 0, ptr %9, align 8, !tbaa !17
  %10 = load i64, ptr %0, align 8, !tbaa !5
  %11 = icmp ult i64 %10, 4096
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  store i64 4096, ptr %0, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %12, %3
  %14 = phi i64 [ 4096, %12 ], [ %10, %3 ]
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %14, ptr %15, align 8, !tbaa !18
  %16 = load i64, ptr %5, align 8, !tbaa !16
  %17 = and i64 %16, -8
  %18 = icmp ult i64 %16, 8
  %spec.select = select i1 %18, i64 8, i64 %17
  store i64 %spec.select, ptr %5, align 8, !tbaa !16
  br label %19

19:                                               ; preds = %19, %13
  %.0 = phi i64 [ 1, %13 ], [ %21, %19 ]
  %20 = icmp ult i64 %.0, %spec.select
  %21 = shl i64 %.0, 1
  br i1 %20, label %19, label %22, !llvm.loop !19

22:                                               ; preds = %19
  store i64 %.0, ptr %5, align 8, !tbaa !16
  %23 = add i64 %.0, -1
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %23, ptr %24, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = add i64 %.0, 15
  %27 = sub i64 0, %.0
  %28 = and i64 %26, %27
  store i64 %28, ptr %25, align 8, !tbaa !22
  invoke void @_ZN7glslang14TPoolAllocator4pushEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
          to label %29 unwind label %30

29:                                               ; preds = %22
  ret void

30:                                               ; preds = %22
  %31 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt6vectorIN7glslang14TPoolAllocator11tAllocStateESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #3
  resume { ptr, i32 } %31
}

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

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

declare i32 @__gxx_personality_v0(...)

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!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, !7, i64 8}
!17 = !{!6, !15, i64 80}
!18 = !{!6, !7, i64 32}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !7, i64 16}
!22 = !{!6, !7, i64 24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass