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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Buffer12CreateBufferEjb(ptr noundef nonnull align 4 dereferenceable(32) %0, i32 noundef %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  %9 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %10 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 3
  call void %9(i32 noundef 1, ptr noundef %10)
  %11 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 4
  call void %11(i32 noundef 1, ptr noundef %12)
  %13 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %14 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 5
  call void %13(i32 noundef 1, ptr noundef %14)
  %15 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 6
  call void %15(i32 noundef 1, ptr noundef %16)
  %17 = load ptr, ptr @glad_glGenVertexArrays, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 1
  call void %17(i32 noundef 1, ptr noundef %18)
  %19 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %28

21:                                               ; preds = %3
  %22 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 2
  call void %22(i32 noundef 1, ptr noundef %23)
  %24 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %25 = trunc i8 %24 to i1
  %26 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 0
  %27 = zext i1 %25 to i8
  store i8 %27, ptr %26, align 4, !tbaa !15
  br label %28

28:                                               ; preds = %21, %3
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = getelementptr inbounds %class.Buffer, ptr %8, i32 0, i32 7
  store i32 %29, ptr %30, align 4, !tbaa !17
  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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !12, i64 0}
!16 = !{!"_ZTS6Buffer", !12, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!17 = !{!16, !10, i64 28}


; 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_glGenBuffers = external local_unnamed_addr global ptr, align 8
@glad_glGenVertexArrays = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Buffer12CreateBufferEjb(ptr noundef nonnull align 4 dereferenceable(32) %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  tail call void %4(i32 noundef 1, ptr noundef nonnull %5)
  %6 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void %6(i32 noundef 1, ptr noundef nonnull %7)
  %8 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  tail call void %8(i32 noundef 1, ptr noundef nonnull %9)
  %10 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void %10(i32 noundef 1, ptr noundef nonnull %11)
  %12 = load ptr, ptr @glad_glGenVertexArrays, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  tail call void %12(i32 noundef 1, ptr noundef nonnull %13)
  br i1 %2, label %14, label %17

14:                                               ; preds = %3
  %15 = load ptr, ptr @glad_glGenBuffers, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void %15(i32 noundef 1, ptr noundef nonnull %16)
  store i8 1, ptr %0, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %14, %3
  %18 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %1, ptr %18, align 4, !tbaa !13
  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, !11, i64 0}
!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 = !{!10, !12, i64 28}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass