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

; 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::TReflection" = type <{ ptr, i32, i32, i32, [4 x i8], %"class.glslang::TObjectReflection", %"class.std::map", %"class.std::map", %"class.std::map", %"class.std::vector.12", %"class.std::vector.12", %"class.std::vector.12", %"class.std::vector.12", %"class.std::vector.12", %"class.std::vector.12", %"class.std::vector.17", [3 x i32], [4 x i8] }>
%"class.glslang::TObjectReflection" = type { %"class.std::__cxx11::basic_string.2", i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%"class.std::__cxx11::basic_string.2" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.6 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.6 = type { i64, [8 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree.7" }
%"class.std::_Rb_tree.7" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector.12" = type { %"struct.std::_Vector_base.13" }
%"struct.std::_Vector_base.13" = type { %"struct.std::_Vector_base<glslang::TObjectReflection, std::allocator<glslang::TObjectReflection>>::_Vector_impl" }
%"struct.std::_Vector_base<glslang::TObjectReflection, std::allocator<glslang::TObjectReflection>>::_Vector_impl" = type { %"struct.std::_Vector_base<glslang::TObjectReflection, std::allocator<glslang::TObjectReflection>>::_Vector_impl_data" }
%"struct.std::_Vector_base<glslang::TObjectReflection, std::allocator<glslang::TObjectReflection>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.17" = type { %"struct.std::_Vector_base.18" }
%"struct.std::_Vector_base.18" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7glslang11TReflection24buildAttributeReflectionE11EShLanguageRKNS_13TIntermediateE(ptr noundef nonnull align 8 dereferenceable(428) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(1784) %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 5
  br i1 %10, label %11, label %28

11:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %24, %11
  %13 = load i32, ptr %7, align 4, !tbaa !11
  %14 = icmp slt i32 %13, 3
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %27

16:                                               ; preds = %12
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = call noundef i32 @_ZNK7glslang13TIntermediate12getLocalSizeEi(ptr noundef nonnull align 8 dereferenceable(1784) %17, i32 noundef %18)
  %20 = getelementptr inbounds %"class.glslang::TReflection", ptr %8, i32 0, i32 16
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [3 x i32], ptr %20, i64 0, i64 %22
  store i32 %19, ptr %23, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %16
  %25 = load i32, ptr %7, align 4, !tbaa !11
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %7, align 4, !tbaa !11
  br label %12, !llvm.loop !13

27:                                               ; preds = %15
  br label %28

28:                                               ; preds = %27, %3
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7glslang13TIntermediate12getLocalSizeEi(ptr noundef nonnull align 8 dereferenceable(1784), i32 noundef) #2 align 2

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

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 = { nocallback nofree nosync 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 = { 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 = !{!"_ZTS11EShLanguage", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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
define dso_local void @_ZN7glslang11TReflection24buildAttributeReflectionE11EShLanguageRKNS_13TIntermediateE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(428) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(1784) %2) local_unnamed_addr #0 align 2 {
  %4 = icmp eq i32 %1, 5
  br i1 %4, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 416
  %6 = tail call noundef i32 @_ZNK7glslang13TIntermediate12getLocalSizeEi(ptr noundef nonnull align 8 dereferenceable(1784) %2, i32 noundef 0)
  store i32 %6, ptr %5, align 8, !tbaa !5
  %7 = tail call noundef i32 @_ZNK7glslang13TIntermediate12getLocalSizeEi(ptr noundef nonnull align 8 dereferenceable(1784) %2, i32 noundef 1)
  %8 = getelementptr inbounds i8, ptr %0, i64 420
  store i32 %7, ptr %8, align 4, !tbaa !5
  %9 = tail call noundef i32 @_ZNK7glslang13TIntermediate12getLocalSizeEi(ptr noundef nonnull align 8 dereferenceable(1784) %2, i32 noundef 2)
  %10 = getelementptr inbounds i8, ptr %0, i64 424
  store i32 %9, ptr %10, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7glslang13TIntermediate12getLocalSizeEi(ptr noundef nonnull align 8 dereferenceable(1784), i32 noundef) 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" }

!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"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass