; LLVM IR from hbatagelo/abcg :: abcg/external/glslang/glslang/HLSL (hlslTokenStream)

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

%"struct.glslang::HlslToken" = type { %"struct.glslang::TSourceLoc", i32, %union.anon }
%"struct.glslang::TSourceLoc" = type { ptr, i32, i32, i32 }
%union.anon = type { ptr }
%"class.glslang::HlslTokenStream" = type <{ ptr, %"struct.glslang::HlslToken", ptr, %"class.glslang::TVector", %"class.glslang::TVector.0", %"class.glslang::TVector.4", [2 x %"struct.glslang::HlslToken"], i32, [4 x i8], [2 x %"struct.glslang::HlslToken"], i32, [4 x i8] }>
%"class.glslang::TVector" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<const glslang::TVector<glslang::HlslToken> *, glslang::pool_allocator<const glslang::TVector<glslang::HlslToken> *>>::_Vector_impl" }
%"struct.std::_Vector_base<const glslang::TVector<glslang::HlslToken> *, glslang::pool_allocator<const glslang::TVector<glslang::HlslToken> *>>::_Vector_impl" = type { %"class.glslang::pool_allocator", %"struct.std::_Vector_base<const glslang::TVector<glslang::HlslToken> *, glslang::pool_allocator<const glslang::TVector<glslang::HlslToken> *>>::_Vector_impl_data" }
%"class.glslang::pool_allocator" = type { ptr }
%"struct.std::_Vector_base<const glslang::TVector<glslang::HlslToken> *, glslang::pool_allocator<const glslang::TVector<glslang::HlslToken> *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.glslang::TVector.0" = type { %"class.std::vector.1" }
%"class.std::vector.1" = type { %"struct.std::_Vector_base.2" }
%"struct.std::_Vector_base.2" = type { %"struct.std::_Vector_base<int, glslang::pool_allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, glslang::pool_allocator<int>>::_Vector_impl" = type { %"class.glslang::pool_allocator.3", %"struct.std::_Vector_base<int, glslang::pool_allocator<int>>::_Vector_impl_data" }
%"class.glslang::pool_allocator.3" = type { ptr }
%"struct.std::_Vector_base<int, glslang::pool_allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.glslang::TVector.4" = type { %"class.std::vector.5" }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<glslang::HlslToken, glslang::pool_allocator<glslang::HlslToken>>::_Vector_impl" }
%"struct.std::_Vector_base<glslang::HlslToken, glslang::pool_allocator<glslang::HlslToken>>::_Vector_impl" = type { %"class.glslang::pool_allocator.7", %"struct.std::_Vector_base<glslang::HlslToken, glslang::pool_allocator<glslang::HlslToken>>::_Vector_impl_data" }
%"class.glslang::pool_allocator.7" = type { ptr }
%"struct.std::_Vector_base<glslang::HlslToken, glslang::pool_allocator<glslang::HlslToken>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__._ZN7glslang15HlslTokenStream11popPreTokenEv = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7glslang15HlslTokenStream11popPreTokenEv(ptr dead_on_unwind noalias writable sret(%"struct.glslang::HlslToken") align 8 %0, ptr noundef nonnull align 8 dereferenceable(324) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %"class.glslang::HlslTokenStream", ptr %4, i32 0, i32 7
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %11

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 48, ptr noundef @__PRETTY_FUNCTION__._ZN7glslang15HlslTokenStream11popPreTokenEv) #3
  unreachable

10:                                               ; No predecessors!
  br label %11

11:                                               ; preds = %10, %8
  %12 = getelementptr inbounds %"class.glslang::HlslTokenStream", ptr %4, i32 0, i32 6
  %13 = getelementptr inbounds %"class.glslang::HlslTokenStream", ptr %4, i32 0, i32 7
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %13, align 8, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2 x %"struct.glslang::HlslToken"], ptr %12, i64 0, i64 %16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %17, i64 40, i1 false), !tbaa.struct !33
  ret void
}

attributes #0 = { noreturn 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn 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, !13, i64 232}
!10 = !{!"_ZTSN7glslang15HlslTokenStreamE", !11, i64 8, !6, i64 48, !15, i64 56, !21, i64 88, !27, i64 120, !7, i64 152, !13, i64 232, !7, i64 240, !13, i64 320}
!11 = !{!"_ZTSN7glslang9HlslTokenE", !12, i64 0, !14, i64 24, !7, i64 32}
!12 = !{!"_ZTSN7glslang10TSourceLocE", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN7glslang15EHlslTokenClassE", !7, i64 0}
!15 = !{!"_ZTSN7glslang7TVectorIPKNS0_INS_9HlslTokenEEEEE", !16, i64 0}
!16 = !{!"_ZTSSt6vectorIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE12_Vector_implE", !19, i64 0, !20, i64 8}
!19 = !{!"_ZTSN7glslang14pool_allocatorIPKNS_7TVectorINS_9HlslTokenEEEEE", !6, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSN7glslang7TVectorIiEE", !22, i64 0}
!22 = !{!"_ZTSSt6vectorIiN7glslang14pool_allocatorIiEEE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIiN7glslang14pool_allocatorIiEEE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIiN7glslang14pool_allocatorIiEEE12_Vector_implE", !25, i64 0, !26, i64 8}
!25 = !{!"_ZTSN7glslang14pool_allocatorIiEE", !6, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIiN7glslang14pool_allocatorIiEEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!27 = !{!"_ZTSN7glslang7TVectorINS_9HlslTokenEEE", !28, i64 0}
!28 = !{!"_ZTSSt6vectorIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE", !29, i64 0}
!29 = !{!"_ZTSSt12_Vector_baseIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE12_Vector_implE", !31, i64 0, !32, i64 8}
!31 = !{!"_ZTSN7glslang14pool_allocatorINS_9HlslTokenEEE", !6, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{i64 0, i64 8, !5, i64 8, i64 4, !34, i64 12, i64 4, !34, i64 16, i64 4, !34, i64 24, i64 4, !35, i64 32, i64 8, !36}
!34 = !{!13, !13, i64 0}
!35 = !{!14, !14, i64 0}
!36 = !{!7, !7, i64 0}


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

%"struct.glslang::HlslToken" = type { %"struct.glslang::TSourceLoc", i32, %union.anon }
%"struct.glslang::TSourceLoc" = type { ptr, i32, i32, i32 }
%union.anon = type { ptr }

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__._ZN7glslang15HlslTokenStream11popPreTokenEv = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7glslang15HlslTokenStream11popPreTokenEv(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.glslang::HlslToken") align 8 %0, ptr nocapture noundef nonnull align 8 dereferenceable(324) %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 232
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 48, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7glslang15HlslTokenStream11popPreTokenEv) #3
  unreachable

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %1, i64 152
  %9 = add nsw i32 %4, -1
  store i32 %9, ptr %3, align 8, !tbaa !5
  %10 = zext nneg i32 %9 to i64
  %11 = getelementptr inbounds [2 x %"struct.glslang::HlslToken"], ptr %8, i64 0, i64 %10
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %11, i64 40, i1 false), !tbaa.struct !32
  ret void
}

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn 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, !12, i64 232}
!6 = !{!"_ZTSN7glslang15HlslTokenStreamE", !7, i64 8, !9, i64 48, !14, i64 56, !20, i64 88, !26, i64 120, !10, i64 152, !12, i64 232, !10, i64 240, !12, i64 320}
!7 = !{!"_ZTSN7glslang9HlslTokenE", !8, i64 0, !13, i64 24, !10, i64 32}
!8 = !{!"_ZTSN7glslang10TSourceLocE", !9, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"_ZTSN7glslang15EHlslTokenClassE", !10, i64 0}
!14 = !{!"_ZTSN7glslang7TVectorIPKNS0_INS_9HlslTokenEEEEE", !15, i64 0}
!15 = !{!"_ZTSSt6vectorIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE12_Vector_implE", !18, i64 0, !19, i64 8}
!18 = !{!"_ZTSN7glslang14pool_allocatorIPKNS_7TVectorINS_9HlslTokenEEEEE", !9, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIPKN7glslang7TVectorINS0_9HlslTokenEEENS0_14pool_allocatorIS5_EEE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!20 = !{!"_ZTSN7glslang7TVectorIiEE", !21, i64 0}
!21 = !{!"_ZTSSt6vectorIiN7glslang14pool_allocatorIiEEE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseIiN7glslang14pool_allocatorIiEEE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIiN7glslang14pool_allocatorIiEEE12_Vector_implE", !24, i64 0, !25, i64 8}
!24 = !{!"_ZTSN7glslang14pool_allocatorIiEE", !9, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIiN7glslang14pool_allocatorIiEEE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!26 = !{!"_ZTSN7glslang7TVectorINS_9HlslTokenEEE", !27, i64 0}
!27 = !{!"_ZTSSt6vectorIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE", !28, i64 0}
!28 = !{!"_ZTSSt12_Vector_baseIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE12_Vector_implE", !30, i64 0, !31, i64 8}
!30 = !{!"_ZTSN7glslang14pool_allocatorINS_9HlslTokenEEE", !9, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIN7glslang9HlslTokenENS0_14pool_allocatorIS1_EEE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!32 = !{i64 0, i64 8, !33, i64 8, i64 4, !34, i64 12, i64 4, !34, i64 16, i64 4, !34, i64 24, i64 4, !35, i64 32, i64 8, !36}
!33 = !{!9, !9, i64 0}
!34 = !{!12, !12, i64 0}
!35 = !{!13, !13, i64 0}
!36 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass