; LLVM IR from Phoenix15049/Absolute :: Buffer.ll (ZN6Buffer7FillVBOENS_7VBOTypeEPflNS_8FillTypeE)

; 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_glBufferData = external global ptr, align 8
@glad_glBindVertexArray = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Buffer7FillVBOENS_7VBOTypeEPflNS_8FillTypeE(ptr noundef nonnull align 4 dereferenceable(32) %0, i32 noundef %1, ptr noundef %2, i64 noundef %3, i32 noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !13
  %11 = load ptr, ptr %6, align 8
  %12 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.Buffer, ptr %11, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !15
  call void %12(i32 noundef %14)
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %21

17:                                               ; preds = %5
  %18 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.Buffer, ptr %11, i32 0, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !19
  call void %18(i32 noundef 34962, i32 noundef %20)
  br label %41

21:                                               ; preds = %5
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  %25 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.Buffer, ptr %11, i32 0, i32 4
  %27 = load i32, ptr %26, align 4, !tbaa !20
  call void %25(i32 noundef 34962, i32 noundef %27)
  br label %40

28:                                               ; preds = %21
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = icmp eq i32 %29, 2
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.Buffer, ptr %11, i32 0, i32 5
  %34 = load i32, ptr %33, align 4, !tbaa !21
  call void %32(i32 noundef 34962, i32 noundef %34)
  br label %39

35:                                               ; preds = %28
  %36 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.Buffer, ptr %11, i32 0, i32 6
  %38 = load i32, ptr %37, align 4, !tbaa !22
  call void %36(i32 noundef 34962, i32 noundef %38)
  br label %39

39:                                               ; preds = %35, %31
  br label %40

40:                                               ; preds = %39, %24
  br label %41

41:                                               ; preds = %40, %17
  %42 = load ptr, ptr @glad_glBufferData, align 8, !tbaa !5
  %43 = load i64, ptr %9, align 8, !tbaa !11
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load i32, ptr %10, align 4, !tbaa !13
  call void %42(i32 noundef 34962, i64 noundef %43, ptr noundef %44, i32 noundef %45)
  %46 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  call void %46(i32 noundef 0)
  ret void
}

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

!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 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTSN6Buffer8FillTypeE", !7, i64 0}
!15 = !{!16, !18, i64 4}
!16 = !{!"_ZTS6Buffer", !17, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !18, i64 20, !18, i64 24, !18, i64 28}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!16, !18, i64 12}
!20 = !{!16, !18, i64 16}
!21 = !{!16, !18, i64 20}
!22 = !{!16, !18, 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_glBufferData = external local_unnamed_addr global ptr, align 8
@glad_glBindVertexArray = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Buffer7FillVBOENS_7VBOTypeEPflNS_8FillTypeE(ptr nocapture noundef nonnull readonly align 4 dereferenceable(32) %0, i32 noundef %1, ptr noundef %2, i64 noundef %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !9
  tail call void %6(i32 noundef %8)
  %9 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %10 = icmp ult i32 %1, 3
  %switch.idx.cast = zext i32 %1 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 %10, i64 %switch.offset, i64 24
  %11 = getelementptr inbounds i8, ptr %0, i64 %.sink
  %12 = load i32, ptr %11, align 4, !tbaa !13
  tail call void %9(i32 noundef 34962, i32 noundef %12)
  %13 = load ptr, ptr @glad_glBufferData, align 8, !tbaa !5
  tail call void %13(i32 noundef 34962, i64 noundef %3, ptr noundef %2, i32 noundef %4)
  %14 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  tail call void %14(i32 noundef 0)
  ret void
}

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

!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,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass