; LLVM IR from paroj/gltut :: Tut 07 World in Motion (WorldWithUBO)

; 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.ProgramData = type { i32, i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_funcptr_glGetUniformLocation = external global ptr, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@_funcptr_glGetUniformBlockIndex = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@_funcptr_glUniformBlockBinding = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11LoadProgramRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_(ptr dead_on_unwind noalias writable sret(%struct.ProgramData) align 4 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.std::vector", align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = invoke noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef 35633, ptr noundef nonnull align 8 dereferenceable(32) %11)
          to label %13 unwind label %46

13:                                               ; preds = %3
  store i32 %12, ptr %7, align 4, !tbaa !9
  invoke void @_ZNSt6vectorIjSaIjEE9push_backEOj(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %14 unwind label %46

14:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = invoke noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef 35632, ptr noundef nonnull align 8 dereferenceable(32) %15)
          to label %17 unwind label %50

17:                                               ; preds = %14
  store i32 %16, ptr %10, align 4, !tbaa !9
  invoke void @_ZNSt6vectorIjSaIjEE9push_backEOj(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 4 dereferenceable(4) %10)
          to label %18 unwind label %50

18:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %19 = invoke noundef i32 @_ZN9Framework13CreateProgramERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(24) %6)
          to label %20 unwind label %54

20:                                               ; preds = %18
  %21 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 0
  store i32 %19, ptr %21, align 4, !tbaa !11
  %22 = load ptr, ptr @_funcptr_glGetUniformLocation, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = invoke i32 %22(i32 noundef %24, ptr noundef @.str)
          to label %26 unwind label %54

26:                                               ; preds = %20
  %27 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 2
  store i32 %25, ptr %27, align 4, !tbaa !13
  %28 = load ptr, ptr @_funcptr_glGetUniformBlockIndex, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 0
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = invoke i32 %28(i32 noundef %30, ptr noundef @.str.1)
          to label %32 unwind label %54

32:                                               ; preds = %26
  %33 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 1
  store i32 %31, ptr %33, align 4, !tbaa !14
  %34 = load ptr, ptr @_funcptr_glGetUniformLocation, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = invoke i32 %34(i32 noundef %36, ptr noundef @.str.2)
          to label %38 unwind label %54

38:                                               ; preds = %32
  %39 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 3
  store i32 %37, ptr %39, align 4, !tbaa !15
  %40 = load ptr, ptr @_funcptr_glUniformBlockBinding, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = getelementptr inbounds %struct.ProgramData, ptr %0, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !14
  invoke void %40(i32 noundef %42, i32 noundef %44, i32 noundef 0)
          to label %45 unwind label %54

45:                                               ; preds = %38
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  ret void

46:                                               ; preds = %13, %3
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %8, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %58

50:                                               ; preds = %17, %14
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %8, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %58

54:                                               ; preds = %38, %32, %26, %20, %18
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %8, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %9, align 4
  br label %58

58:                                               ; preds = %54, %50, %46
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %8, align 8
  %61 = load i32, ptr %9, align 4
  %62 = insertvalue { ptr, i32 } poison, ptr %60, 0
  %63 = insertvalue { ptr, i32 } %62, i32 %61, 1
  resume { ptr, i32 } %63
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIjSaIjEE9push_backEOj(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

declare noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef, ptr noundef nonnull align 8 dereferenceable(32)) #3

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) #1

declare noundef i32 @_ZN9Framework13CreateProgramERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(24)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 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 = { 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 = { "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 #4 = { 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, !10, i64 0}
!12 = !{!"_ZTS11ProgramData", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !10, i64 12}


; 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.ProgramData = type { i32, i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_funcptr_glGetUniformLocation = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@_funcptr_glGetUniformBlockIndex = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@_funcptr_glUniformBlockBinding = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11LoadProgramRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.ProgramData) align 4 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::vector", align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %7 = invoke noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef 35633, ptr noundef nonnull align 8 dereferenceable(32) %1)
          to label %8 unwind label %29

8:                                                ; preds = %3
  store i32 %7, ptr %5, align 4, !tbaa !5
  invoke void @_ZNSt6vectorIjSaIjEE9push_backEOj(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %9 unwind label %29

9:                                                ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %10 = invoke noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef 35632, ptr noundef nonnull align 8 dereferenceable(32) %2)
          to label %11 unwind label %31

11:                                               ; preds = %9
  store i32 %10, ptr %6, align 4, !tbaa !5
  invoke void @_ZNSt6vectorIjSaIjEE9push_backEOj(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 4 dereferenceable(4) %6)
          to label %12 unwind label %31

12:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  %13 = invoke noundef i32 @_ZN9Framework13CreateProgramERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(24) %4)
          to label %14 unwind label %33

14:                                               ; preds = %12
  store i32 %13, ptr %0, align 4, !tbaa !9
  %15 = load ptr, ptr @_funcptr_glGetUniformLocation, align 8, !tbaa !11
  %16 = invoke i32 %15(i32 noundef %13, ptr noundef nonnull @.str)
          to label %17 unwind label %33

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %16, ptr %18, align 4, !tbaa !13
  %19 = load ptr, ptr @_funcptr_glGetUniformBlockIndex, align 8, !tbaa !11
  %20 = invoke i32 %19(i32 noundef %13, ptr noundef nonnull @.str.1)
          to label %21 unwind label %33

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %20, ptr %22, align 4, !tbaa !14
  %23 = load ptr, ptr @_funcptr_glGetUniformLocation, align 8, !tbaa !11
  %24 = invoke i32 %23(i32 noundef %13, ptr noundef nonnull @.str.2)
          to label %25 unwind label %33

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %24, ptr %26, align 4, !tbaa !15
  %27 = load ptr, ptr @_funcptr_glUniformBlockBinding, align 8, !tbaa !11
  invoke void %27(i32 noundef %13, i32 noundef %20, i32 noundef 0)
          to label %28 unwind label %33

28:                                               ; preds = %25
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  ret void

29:                                               ; preds = %8, %3
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %35

31:                                               ; preds = %11, %9
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  br label %35

33:                                               ; preds = %25, %21, %17, %14, %12
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %35

35:                                               ; preds = %33, %31, %29
  %.pn = phi { ptr, i32 } [ %34, %33 ], [ %32, %31 ], [ %30, %29 ]
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress 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 void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

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

declare noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

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

declare noundef i32 @_ZN9Framework13CreateProgramERKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 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 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 = { "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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS11ProgramData", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 4}
!15 = !{!10, !6, i64 12}


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