; LLVM IR from Phoenix15049/Absolute :: Buffer/ZN6Buffer7LinkVBOERK6ShaderRKNSt7/cxx1112basic_stringIcSt11char_traitsIcE_fb91cab0/ZN6Buffer7LinkVBOERK6ShaderRKNSt7 (9f76b5c2)

; 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.Buffer = type { i8, i32, i32, i32, i32, i32, i32, i32 }

@glad_glBindBuffer = external global ptr, align 8
@glad_glBindVertexArray = external global ptr, align 8
@glad_glGetAttribLocation = external global ptr, align 8
@glad_glVertexAttribPointer = external global ptr, align 8
@glad_glEnableVertexAttribArray = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Buffer7LinkVBOERK6ShaderRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7VBOTypeENS_13ComponentTypeENS_8DataTypeE(ptr noundef nonnull align 4 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #0 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  store i32 %5, ptr %12, align 4, !tbaa !13
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK6Shader18GetShaderProgramIDEv(ptr noundef nonnull align 4 dereferenceable(4) %16)
  store i32 %17, ptr %13, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %18 = load ptr, ptr @glad_glGetAttribLocation, align 8, !tbaa !5
  %19 = load i32, ptr %13, align 4, !tbaa !15
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %20) #4
  %22 = call i32 %18(i32 noundef %19, ptr noundef %21)
  store i32 %22, ptr %14, align 4, !tbaa !15
  %23 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.Buffer, ptr %15, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !17
  call void %23(i32 noundef %25)
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %6
  %29 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.Buffer, ptr %15, i32 0, i32 3
  %31 = load i32, ptr %30, align 4, !tbaa !20
  call void %29(i32 noundef 34962, i32 noundef %31)
  br label %52

32:                                               ; preds = %6
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %35, label %39

35:                                               ; preds = %32
  %36 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.Buffer, ptr %15, i32 0, i32 4
  %38 = load i32, ptr %37, align 4, !tbaa !21
  call void %36(i32 noundef 34962, i32 noundef %38)
  br label %51

39:                                               ; preds = %32
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 2
  br i1 %41, label %42, label %46

42:                                               ; preds = %39
  %43 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %44 = getelementptr inbounds %class.Buffer, ptr %15, i32 0, i32 5
  %45 = load i32, ptr %44, align 4, !tbaa !22
  call void %43(i32 noundef 34962, i32 noundef %45)
  br label %50

46:                                               ; preds = %39
  %47 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %48 = getelementptr inbounds %class.Buffer, ptr %15, i32 0, i32 6
  %49 = load i32, ptr %48, align 4, !tbaa !23
  call void %47(i32 noundef 34962, i32 noundef %49)
  br label %50

50:                                               ; preds = %46, %42
  br label %51

51:                                               ; preds = %50, %35
  br label %52

52:                                               ; preds = %51, %28
  %53 = load ptr, ptr @glad_glVertexAttribPointer, align 8, !tbaa !5
  %54 = load i32, ptr %14, align 4, !tbaa !15
  %55 = load i32, ptr %11, align 4, !tbaa !11
  call void %53(i32 noundef %54, i32 noundef %55, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef null)
  %56 = load ptr, ptr @glad_glEnableVertexAttribArray, align 8, !tbaa !5
  %57 = load i32, ptr %14, align 4, !tbaa !15
  call void %56(i32 noundef %57)
  %58 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  call void %58(i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret void
}

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

declare noundef i32 @_ZNK6Shader18GetShaderProgramIDEv(ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 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 = { "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 = { 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 #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 = !{!"_ZTSN6Buffer7VBOTypeE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN6Buffer13ComponentTypeE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTSN6Buffer8DataTypeE", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !16, i64 4}
!18 = !{!"_ZTS6Buffer", !19, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !16, i64 20, !16, i64 24, !16, i64 28}
!19 = !{!"bool", !7, i64 0}
!20 = !{!18, !16, i64 12}
!21 = !{!18, !16, i64 16}
!22 = !{!18, !16, i64 20}
!23 = !{!18, !16, 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"

@glad_glBindBuffer = external local_unnamed_addr global ptr, align 8
@glad_glBindVertexArray = external local_unnamed_addr global ptr, align 8
@glad_glGetAttribLocation = external local_unnamed_addr global ptr, align 8
@glad_glVertexAttribPointer = external local_unnamed_addr global ptr, align 8
@glad_glEnableVertexAttribArray = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Buffer7LinkVBOERK6ShaderRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7VBOTypeENS_13ComponentTypeENS_8DataTypeE(ptr nocapture noundef nonnull readonly align 4 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 align 2 {
  %7 = tail call noundef i32 @_ZNK6Shader18GetShaderProgramIDEv(ptr noundef nonnull align 4 dereferenceable(4) %1)
  %8 = load ptr, ptr @glad_glGetAttribLocation, align 8, !tbaa !5
  %9 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %2) #3
  %10 = tail call i32 %8(i32 noundef %7, ptr noundef %9)
  %11 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !9
  tail call void %11(i32 noundef %13)
  %14 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %15 = icmp ult i32 %3, 3
  %switch.idx.cast = zext i32 %3 to i64
  %switch.idx.mult = shl nuw nsw i64 %switch.idx.cast, 2
  %switch.offset = add nuw nsw i64 %switch.idx.mult, 12
  %.sink = select i1 %15, i64 %switch.offset, i64 24
  %16 = getelementptr inbounds i8, ptr %0, i64 %.sink
  %17 = load i32, ptr %16, align 4, !tbaa !13
  tail call void %14(i32 noundef 34962, i32 noundef %17)
  %18 = load ptr, ptr @glad_glVertexAttribPointer, align 8, !tbaa !5
  tail call void %18(i32 noundef %10, i32 noundef %4, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef null)
  %19 = load ptr, ptr @glad_glEnableVertexAttribArray, align 8, !tbaa !5
  tail call void %19(i32 noundef %10)
  %20 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  tail call void %20(i32 noundef 0)
  ret void
}

declare noundef i32 @_ZNK6Shader18GetShaderProgramIDEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_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 = { "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 = { 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, !12, i64 4}
!10 = !{!"_ZTS6Buffer", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}


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