; LLVM IR from santa01/graphene :: src/Mesh.ll (ZN8Graphene4MeshC2EPKvii)

; 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.Graphene::Mesh" = type { i32, [2 x i32], i32, i32 }

@_ZN8Graphene17glGenVertexArraysE = external global ptr, align 8
@_ZN8Graphene17glBindVertexArrayE = external global ptr, align 8
@_ZN8Graphene12glGenBuffersE = external global ptr, align 8
@_ZN8Graphene12glBindBufferE = external global ptr, align 8
@_ZN8Graphene12glBufferDataE = external global ptr, align 8
@_ZN8Graphene25glEnableVertexAttribArrayE = external global ptr, align 8
@_ZN8Graphene21glVertexAttribPointerE = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8Graphene4MeshC2EPKvii(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %16 = load ptr, ptr %5, align 8
  %17 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 0
  store i32 0, ptr %17, align 4, !tbaa !11
  %18 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 1
  %19 = getelementptr inbounds i32, ptr %18, i64 2
  br label %20

20:                                               ; preds = %20, %4
  %21 = phi ptr [ %18, %4 ], [ %22, %20 ]
  store i32 0, ptr %21, align 4, !tbaa !9
  %22 = getelementptr inbounds i32, ptr %21, i64 1
  %23 = icmp eq ptr %22, %19
  br i1 %23, label %24, label %20

24:                                               ; preds = %20
  %25 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 2
  %26 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %26, ptr %25, align 4, !tbaa !13
  %27 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 3
  %28 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %28, ptr %27, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %29, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %30, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %31 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = sext i32 %32 to i64
  %34 = mul i64 4, %33
  %35 = mul i64 %34, 8
  store i64 %35, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load i64, ptr %11, align 8, !tbaa !15
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  store ptr %38, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %39 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 3
  %40 = load i32, ptr %39, align 4, !tbaa !14
  %41 = sext i32 %40 to i64
  %42 = mul i64 4, %41
  %43 = mul i64 %42, 3
  store i64 %43, ptr %13, align 8, !tbaa !15
  %44 = load ptr, ptr @_ZN8Graphene17glGenVertexArraysE, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 0
  call void %44(i32 noundef 1, ptr noundef %45)
  %46 = load ptr, ptr @_ZN8Graphene17glBindVertexArrayE, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !11
  call void %46(i32 noundef %48)
  %49 = load ptr, ptr @_ZN8Graphene12glGenBuffersE, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 1
  %51 = getelementptr inbounds [2 x i32], ptr %50, i64 0, i64 0
  call void %49(i32 noundef 2, ptr noundef %51)
  %52 = load ptr, ptr @_ZN8Graphene12glBindBufferE, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 1
  %54 = getelementptr inbounds [2 x i32], ptr %53, i64 0, i64 0
  %55 = load i32, ptr %54, align 4, !tbaa !9
  call void %52(i32 noundef 34962, i32 noundef %55)
  %56 = load ptr, ptr @_ZN8Graphene12glBufferDataE, align 8, !tbaa !5
  %57 = load i64, ptr %11, align 8, !tbaa !15
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  call void %56(i32 noundef 34962, i64 noundef %57, ptr noundef %58, i32 noundef 35044)
  %59 = load ptr, ptr @_ZN8Graphene25glEnableVertexAttribArrayE, align 8, !tbaa !5
  call void %59(i32 noundef 0)
  %60 = load ptr, ptr @_ZN8Graphene25glEnableVertexAttribArrayE, align 8, !tbaa !5
  call void %60(i32 noundef 1)
  %61 = load ptr, ptr @_ZN8Graphene25glEnableVertexAttribArrayE, align 8, !tbaa !5
  call void %61(i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %62 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = sext i32 %63 to i64
  %65 = mul i64 4, %64
  %66 = mul i64 %65, 3
  store i64 %66, ptr %14, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %67 = load i64, ptr %14, align 8, !tbaa !15
  %68 = mul nsw i64 %67, 2
  store i64 %68, ptr %15, align 8, !tbaa !15
  %69 = load ptr, ptr @_ZN8Graphene21glVertexAttribPointerE, align 8, !tbaa !5
  call void %69(i32 noundef 0, i32 noundef 3, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef null)
  %70 = load ptr, ptr @_ZN8Graphene21glVertexAttribPointerE, align 8, !tbaa !5
  %71 = load i64, ptr %14, align 8, !tbaa !15
  %72 = inttoptr i64 %71 to ptr
  call void %70(i32 noundef 1, i32 noundef 3, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef %72)
  %73 = load ptr, ptr @_ZN8Graphene21glVertexAttribPointerE, align 8, !tbaa !5
  %74 = load i64, ptr %15, align 8, !tbaa !15
  %75 = inttoptr i64 %74 to ptr
  call void %73(i32 noundef 2, i32 noundef 2, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef %75)
  %76 = load ptr, ptr @_ZN8Graphene12glBindBufferE, align 8, !tbaa !5
  %77 = getelementptr inbounds %"class.Graphene::Mesh", ptr %16, i32 0, i32 1
  %78 = getelementptr inbounds [2 x i32], ptr %77, i64 0, i64 1
  %79 = load i32, ptr %78, align 4, !tbaa !9
  call void %76(i32 noundef 34963, i32 noundef %79)
  %80 = load ptr, ptr @_ZN8Graphene12glBufferDataE, align 8, !tbaa !5
  %81 = load i64, ptr %13, align 8, !tbaa !15
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  call void %80(i32 noundef 34963, i64 noundef %81, ptr noundef %82, i32 noundef 35044)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret void
}

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

; 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 = { 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 = !{!"_ZTSN8Graphene4MeshE", !10, i64 0, !7, i64 4, !10, i64 12, !10, i64 16}
!13 = !{!12, !10, i64 12}
!14 = !{!12, !10, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}


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

@_ZN8Graphene17glGenVertexArraysE = external local_unnamed_addr global ptr, align 8
@_ZN8Graphene17glBindVertexArrayE = external local_unnamed_addr global ptr, align 8
@_ZN8Graphene12glGenBuffersE = external local_unnamed_addr global ptr, align 8
@_ZN8Graphene12glBindBufferE = external local_unnamed_addr global ptr, align 8
@_ZN8Graphene12glBufferDataE = external local_unnamed_addr global ptr, align 8
@_ZN8Graphene25glEnableVertexAttribArrayE = external local_unnamed_addr global ptr, align 8
@_ZN8Graphene21glVertexAttribPointerE = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8Graphene4MeshC2EPKvii(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  store i32 0, ptr %0, align 4, !tbaa !5
  %scevgep = getelementptr inbounds i8, ptr %0, i64 4
  store i64 0, ptr %scevgep, align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %2, ptr %5, align 4, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %3, ptr %6, align 4, !tbaa !11
  %7 = sext i32 %2 to i64
  %8 = shl nsw i64 %7, 5
  %9 = getelementptr inbounds i8, ptr %1, i64 %8
  %10 = sext i32 %3 to i64
  %11 = mul nsw i64 %10, 12
  %12 = load ptr, ptr @_ZN8Graphene17glGenVertexArraysE, align 8, !tbaa !12
  tail call void %12(i32 noundef 1, ptr noundef nonnull %0)
  %13 = load ptr, ptr @_ZN8Graphene17glBindVertexArrayE, align 8, !tbaa !12
  %14 = load i32, ptr %0, align 4, !tbaa !5
  tail call void %13(i32 noundef %14)
  %15 = load ptr, ptr @_ZN8Graphene12glGenBuffersE, align 8, !tbaa !12
  tail call void %15(i32 noundef 2, ptr noundef nonnull %scevgep)
  %16 = load ptr, ptr @_ZN8Graphene12glBindBufferE, align 8, !tbaa !12
  %17 = load i32, ptr %scevgep, align 4, !tbaa !14
  tail call void %16(i32 noundef 34962, i32 noundef %17)
  %18 = load ptr, ptr @_ZN8Graphene12glBufferDataE, align 8, !tbaa !12
  tail call void %18(i32 noundef 34962, i64 noundef %8, ptr noundef %1, i32 noundef 35044)
  %19 = load ptr, ptr @_ZN8Graphene25glEnableVertexAttribArrayE, align 8, !tbaa !12
  tail call void %19(i32 noundef 0)
  %20 = load ptr, ptr @_ZN8Graphene25glEnableVertexAttribArrayE, align 8, !tbaa !12
  tail call void %20(i32 noundef 1)
  %21 = load ptr, ptr @_ZN8Graphene25glEnableVertexAttribArrayE, align 8, !tbaa !12
  tail call void %21(i32 noundef 2)
  %22 = load i32, ptr %5, align 4, !tbaa !10
  %23 = sext i32 %22 to i64
  %24 = mul nsw i64 %23, 12
  %25 = mul nsw i64 %23, 24
  %26 = load ptr, ptr @_ZN8Graphene21glVertexAttribPointerE, align 8, !tbaa !12
  tail call void %26(i32 noundef 0, i32 noundef 3, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef null)
  %27 = load ptr, ptr @_ZN8Graphene21glVertexAttribPointerE, align 8, !tbaa !12
  %28 = inttoptr i64 %24 to ptr
  tail call void %27(i32 noundef 1, i32 noundef 3, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef %28)
  %29 = load ptr, ptr @_ZN8Graphene21glVertexAttribPointerE, align 8, !tbaa !12
  %30 = inttoptr i64 %25 to ptr
  tail call void %29(i32 noundef 2, i32 noundef 2, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 0, ptr noundef %30)
  %31 = load ptr, ptr @_ZN8Graphene12glBindBufferE, align 8, !tbaa !12
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i32, ptr %32, align 4, !tbaa !14
  tail call void %31(i32 noundef 34963, i32 noundef %33)
  %34 = load ptr, ptr @_ZN8Graphene12glBufferDataE, align 8, !tbaa !12
  tail call void %34(i32 noundef 34963, i64 noundef %11, ptr noundef %9, i32 noundef 35044)
  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, !7, i64 0}
!6 = !{!"_ZTSN8Graphene4MeshE", !7, i64 0, !8, i64 4, !7, i64 12, !7, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 12}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,SROAPass,TailCallElimPass