; LLVM IR from paroj/gltut :: Tut 10 Plane Lights (FragmentAttenuation)

; 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.UnlitProgData = type { 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 [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@_funcptr_glGetUniformBlockIndex = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@_funcptr_glUniformBlockBinding = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local { i64, i32 } @_Z16LoadUnlitProgramRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %struct.UnlitProgData, align 4
  %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
  %11 = alloca i32, align 4
  %12 = alloca { i64, i32 }, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  call void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = invoke noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef 35633, ptr noundef nonnull align 8 dereferenceable(32) %13)
          to label %15 unwind label %47

15:                                               ; preds = %2
  store i32 %14, 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 %16 unwind label %47

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

19:                                               ; preds = %16
  store i32 %18, 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 %20 unwind label %51

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

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

28:                                               ; preds = %22
  %29 = getelementptr inbounds %struct.UnlitProgData, ptr %3, i32 0, i32 2
  store i32 %27, ptr %29, align 4, !tbaa !13
  %30 = load ptr, ptr @_funcptr_glGetUniformLocation, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.UnlitProgData, ptr %3, i32 0, i32 0
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = invoke i32 %30(i32 noundef %32, ptr noundef @.str.1)
          to label %34 unwind label %55

34:                                               ; preds = %28
  %35 = getelementptr inbounds %struct.UnlitProgData, ptr %3, i32 0, i32 1
  store i32 %33, ptr %35, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %36 = load ptr, ptr @_funcptr_glGetUniformBlockIndex, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.UnlitProgData, ptr %3, i32 0, i32 0
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = invoke i32 %36(i32 noundef %38, ptr noundef @.str.2)
          to label %40 unwind label %59

40:                                               ; preds = %34
  store i32 %39, ptr %11, align 4, !tbaa !9
  %41 = load ptr, ptr @_funcptr_glUniformBlockBinding, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.UnlitProgData, ptr %3, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = load i32, ptr %11, align 4, !tbaa !9
  invoke void %41(i32 noundef %43, i32 noundef %44, i32 noundef 2)
          to label %45 unwind label %59

45:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 4 %3, i64 12, i1 false)
  %46 = load { i64, i32 }, ptr %12, align 8
  ret { i64, i32 } %46

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

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

55:                                               ; preds = %28, %22, %20
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %8, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %9, align 4
  br label %63

59:                                               ; preds = %40, %34
  %60 = landingpad { ptr, i32 }
          cleanup
  %61 = extractvalue { ptr, i32 } %60, 0
  store ptr %61, ptr %8, align 8
  %62 = extractvalue { ptr, i32 } %60, 1
  store i32 %62, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %63

63:                                               ; preds = %59, %55, %51, %47
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  br label %64

64:                                               ; preds = %63
  %65 = load ptr, ptr %8, align 8
  %66 = load i32, ptr %9, align 4
  %67 = insertvalue { ptr, i32 } poison, ptr %65, 0
  %68 = insertvalue { ptr, i32 } %67, i32 %66, 1
  resume { ptr, i32 } %68
}

; 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

; 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) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!"_ZTS13UnlitProgData", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 4}


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

%"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 [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@_funcptr_glGetUniformBlockIndex = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@_funcptr_glUniformBlockBinding = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local { i64, i32 } @_Z16LoadUnlitProgramRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::vector", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  call void @_ZNSt6vectorIjSaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %6 = invoke noundef i32 @_ZN9Framework10LoadShaderEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(i32 noundef 35633, ptr noundef nonnull align 8 dereferenceable(32) %0)
          to label %7 unwind label %25

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

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

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

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

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

16:                                               ; preds = %13
  %17 = load ptr, ptr @_funcptr_glGetUniformLocation, align 8, !tbaa !9
  %18 = invoke i32 %17(i32 noundef %12, ptr noundef nonnull @.str.1)
          to label %19 unwind label %29

19:                                               ; preds = %16
  %20 = load ptr, ptr @_funcptr_glGetUniformBlockIndex, align 8, !tbaa !9
  %21 = invoke i32 %20(i32 noundef %12, ptr noundef nonnull @.str.2)
          to label %22 unwind label %31

22:                                               ; preds = %19
  %23 = load ptr, ptr @_funcptr_glUniformBlockBinding, align 8, !tbaa !9
  invoke void %23(i32 noundef %12, i32 noundef %21, i32 noundef 2)
          to label %24 unwind label %31

24:                                               ; preds = %22
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  %.sroa.6.0.insert.ext = zext i32 %18 to i64
  %.sroa.6.0.insert.shift = shl nuw i64 %.sroa.6.0.insert.ext, 32
  %.sroa.04.0.insert.ext = zext i32 %12 to i64
  %.sroa.04.0.insert.insert = or disjoint i64 %.sroa.6.0.insert.shift, %.sroa.04.0.insert.ext
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.04.0.insert.insert, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %15, 1
  ret { i64, i32 } %.fca.1.insert

25:                                               ; preds = %7, %2
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %33

27:                                               ; preds = %10, %8
  %28 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %33

29:                                               ; preds = %16, %13, %11
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %33

31:                                               ; preds = %22, %19
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %33

33:                                               ; preds = %31, %29, %27, %25
  %.pn = phi { ptr, i32 } [ %32, %31 ], [ %30, %29 ], [ %28, %27 ], [ %26, %25 ]
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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