; LLVM IR from paroj/gltut :: glsdk/glmesh/source/VertexFormat.ll (ZNK6glmesh12VertexFormat16BindAttribFormatEmj)

; 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.glmesh::AttribDesc" = type { i32, i32, i32, i32 }

@_ZN2gl23EnableVertexAttribArrayE = external global ptr, align 8
@_ZN6glmesh12_GLOBAL__N_118t_vertexUploadTypeE = external hidden global [9 x i32], align 16
@_ZN2gl19VertexAttribBindingE = external global ptr, align 8
@_ZN2gl18VertexAttribFormatE = external global ptr, align 8
@_ZN2gl19VertexAttribIFormatE = external global ptr, align 8
@_ZN2gl19VertexAttribLFormatE = external global ptr, align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc17GetVertexDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc14GetAttribIndexEv(ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZNK6glmesh12VertexFormat13GetAttribDescEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK6glmesh12VertexFormat19GetAttribByteOffsetEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc16GetNumComponentsEv(ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc17GetAttribDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6glmesh12VertexFormat16BindAttribFormatEmj(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %"class.glmesh::AttribDesc", align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = call { i64, i64 } @_ZNK6glmesh12VertexFormat13GetAttribDescEm(ptr noundef nonnull align 8 dereferenceable(56) %13, i64 noundef %14)
  %16 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %17 = extractvalue { i64, i64 } %15, 0
  store i64 %17, ptr %16, align 4
  %18 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %19 = extractvalue { i64, i64 } %15, 1
  store i64 %19, ptr %18, align 4
  store ptr %8, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = call noundef i64 @_ZNK6glmesh12VertexFormat19GetAttribByteOffsetEm(ptr noundef nonnull align 8 dereferenceable(56) %13, i64 noundef %20)
  store i64 %21, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call noundef i32 @_ZNK6glmesh10AttribDesc14GetAttribIndexEv(ptr noundef nonnull align 4 dereferenceable(16) %22)
  store i32 %23, ptr %10, align 4, !tbaa !11
  %24 = load ptr, ptr @_ZN2gl23EnableVertexAttribArrayE, align 8, !tbaa !5
  %25 = load i32, ptr %10, align 4, !tbaa !11
  call void %24(i32 noundef %25)
  %26 = load ptr, ptr @_ZN2gl19VertexAttribBindingE, align 8, !tbaa !5
  %27 = load i32, ptr %10, align 4, !tbaa !11
  %28 = load i32, ptr %6, align 4, !tbaa !11
  call void %26(i32 noundef %27, i32 noundef %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call noundef i32 @_ZNK6glmesh10AttribDesc17GetVertexDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16) %29)
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds [9 x i32], ptr @_ZN6glmesh12_GLOBAL__N_118t_vertexUploadTypeE, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !11
  store i32 %33, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = call noundef i32 @_ZNK6glmesh10AttribDesc16GetNumComponentsEv(ptr noundef nonnull align 4 dereferenceable(16) %34)
  store i32 %35, ptr %12, align 4, !tbaa !11
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call noundef i32 @_ZNK6glmesh10AttribDesc17GetAttribDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16) %36)
  switch i32 %37, label %66 [
    i32 0, label %38
    i32 1, label %45
    i32 2, label %52
    i32 3, label %59
  ]

38:                                               ; preds = %3
  %39 = load ptr, ptr @_ZN2gl18VertexAttribFormatE, align 8, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !11
  %41 = load i32, ptr %12, align 4, !tbaa !11
  %42 = load i32, ptr %11, align 4, !tbaa !11
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = trunc i64 %43 to i32
  call void %39(i32 noundef %40, i32 noundef %41, i32 noundef %42, i8 noundef zeroext 0, i32 noundef %44)
  br label %66

45:                                               ; preds = %3
  %46 = load ptr, ptr @_ZN2gl18VertexAttribFormatE, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !11
  %48 = load i32, ptr %12, align 4, !tbaa !11
  %49 = load i32, ptr %11, align 4, !tbaa !11
  %50 = load i64, ptr %9, align 8, !tbaa !9
  %51 = trunc i64 %50 to i32
  call void %46(i32 noundef %47, i32 noundef %48, i32 noundef %49, i8 noundef zeroext 1, i32 noundef %51)
  br label %66

52:                                               ; preds = %3
  %53 = load ptr, ptr @_ZN2gl19VertexAttribIFormatE, align 8, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !11
  %55 = load i32, ptr %12, align 4, !tbaa !11
  %56 = load i32, ptr %11, align 4, !tbaa !11
  %57 = load i64, ptr %9, align 8, !tbaa !9
  %58 = trunc i64 %57 to i32
  call void %53(i32 noundef %54, i32 noundef %55, i32 noundef %56, i32 noundef %58)
  br label %66

59:                                               ; preds = %3
  %60 = load ptr, ptr @_ZN2gl19VertexAttribLFormatE, align 8, !tbaa !5
  %61 = load i32, ptr %10, align 4, !tbaa !11
  %62 = load i32, ptr %12, align 4, !tbaa !11
  %63 = load i32, ptr %11, align 4, !tbaa !11
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = trunc i64 %64 to i32
  call void %60(i32 noundef %61, i32 noundef %62, i32 noundef %63, i32 noundef %65)
  br label %66

66:                                               ; preds = %59, %52, %45, %38, %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

%"class.glmesh::AttribDesc" = type { i32, i32, i32, i32 }

@_ZN2gl23EnableVertexAttribArrayE = external local_unnamed_addr global ptr, align 8
@_ZN6glmesh12_GLOBAL__N_118t_vertexUploadTypeE = external hidden local_unnamed_addr global [9 x i32], align 16
@_ZN2gl19VertexAttribBindingE = external local_unnamed_addr global ptr, align 8
@_ZN2gl18VertexAttribFormatE = external local_unnamed_addr global ptr, align 8
@_ZN2gl19VertexAttribIFormatE = external local_unnamed_addr global ptr, align 8
@_ZN2gl19VertexAttribLFormatE = external local_unnamed_addr global ptr, align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc17GetVertexDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc14GetAttribIndexEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZNK6glmesh12VertexFormat13GetAttribDescEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK6glmesh12VertexFormat19GetAttribByteOffsetEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc16GetNumComponentsEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6glmesh10AttribDesc17GetAttribDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6glmesh12VertexFormat16BindAttribFormatEmj(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %"class.glmesh::AttribDesc", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  %5 = tail call { i64, i64 } @_ZNK6glmesh12VertexFormat13GetAttribDescEm(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %1)
  %6 = extractvalue { i64, i64 } %5, 0
  store i64 %6, ptr %4, align 8
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  %8 = extractvalue { i64, i64 } %5, 1
  store i64 %8, ptr %7, align 8
  %9 = tail call noundef i64 @_ZNK6glmesh12VertexFormat19GetAttribByteOffsetEm(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %1)
  %10 = call noundef i32 @_ZNK6glmesh10AttribDesc14GetAttribIndexEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  %11 = load ptr, ptr @_ZN2gl23EnableVertexAttribArrayE, align 8, !tbaa !5
  call void %11(i32 noundef %10)
  %12 = load ptr, ptr @_ZN2gl19VertexAttribBindingE, align 8, !tbaa !5
  call void %12(i32 noundef %10, i32 noundef %2)
  %13 = call noundef i32 @_ZNK6glmesh10AttribDesc17GetVertexDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds [9 x i32], ptr @_ZN6glmesh12_GLOBAL__N_118t_vertexUploadTypeE, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = call noundef i32 @_ZNK6glmesh10AttribDesc16GetNumComponentsEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  %18 = call noundef i32 @_ZNK6glmesh10AttribDesc17GetAttribDataTypeEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  switch i32 %18, label %31 [
    i32 0, label %19
    i32 1, label %22
    i32 2, label %25
    i32 3, label %28
  ]

19:                                               ; preds = %3
  %20 = load ptr, ptr @_ZN2gl18VertexAttribFormatE, align 8, !tbaa !5
  %21 = trunc i64 %9 to i32
  call void %20(i32 noundef %10, i32 noundef %17, i32 noundef %16, i8 noundef zeroext 0, i32 noundef %21)
  br label %31

22:                                               ; preds = %3
  %23 = load ptr, ptr @_ZN2gl18VertexAttribFormatE, align 8, !tbaa !5
  %24 = trunc i64 %9 to i32
  call void %23(i32 noundef %10, i32 noundef %17, i32 noundef %16, i8 noundef zeroext 1, i32 noundef %24)
  br label %31

25:                                               ; preds = %3
  %26 = load ptr, ptr @_ZN2gl19VertexAttribIFormatE, align 8, !tbaa !5
  %27 = trunc i64 %9 to i32
  call void %26(i32 noundef %10, i32 noundef %17, i32 noundef %16, i32 noundef %27)
  br label %31

28:                                               ; preds = %3
  %29 = load ptr, ptr @_ZN2gl19VertexAttribLFormatE, align 8, !tbaa !5
  %30 = trunc i64 %9 to i32
  call void %29(i32 noundef %10, i32 noundef %17, i32 noundef %16, i32 noundef %30)
  br label %31

31:                                               ; preds = %28, %25, %22, %19, %3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass