; LLVM IR from paroj/gltut :: glsdk/glutil/source/Font.ll (ZN6glutil12GenerateFontENS_9FontSizesE)

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

%"struct.glutil::detail::TypefaceMetrics" = type { i32, i32, i32, i32, i32, i32, i32 }
%"struct.glutil::detail::Glyph" = type { i32, i32, i32, i32, i32, float, float, float, float }

@_ZN6glutil6detail14small_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail12small_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail11small_ImageE = external constant [0 x i8], align 1
@_ZN6glutil6detail15medium_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail13medium_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail12medium_ImageE = external constant [0 x i8], align 1
@_ZN6glutil6detail14large_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail12large_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail11large_ImageE = external constant [0 x i8], align 1
@_ZN6glutil6detail14giant_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail12giant_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail11giant_ImageE = external constant [0 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN6glutil12GenerateFontENS_9FontSizesE(i32 noundef %0) #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr null, ptr %3, align 8, !tbaa !9
  %6 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %6, label %35 [
    i32 0, label %7
    i32 1, label %14
    i32 2, label %21
    i32 3, label %28
  ]

7:                                                ; preds = %1
  %8 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %8, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail14small_TypefaceE, ptr noundef @_ZN6glutil6detail12small_GlyphsE, ptr noundef @_ZN6glutil6detail11small_ImageE)
          to label %9 unwind label %10

9:                                                ; preds = %7
  store ptr %8, ptr %3, align 8, !tbaa !9
  br label %35

10:                                               ; preds = %7
  %11 = landingpad { ptr, i32 }
          cleanup
  %12 = extractvalue { ptr, i32 } %11, 0
  store ptr %12, ptr %4, align 8
  %13 = extractvalue { ptr, i32 } %11, 1
  store i32 %13, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %8, i64 noundef 48) #6
  br label %43

14:                                               ; preds = %1
  %15 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %15, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail15medium_TypefaceE, ptr noundef @_ZN6glutil6detail13medium_GlyphsE, ptr noundef @_ZN6glutil6detail12medium_ImageE)
          to label %16 unwind label %17

16:                                               ; preds = %14
  store ptr %15, ptr %3, align 8, !tbaa !9
  br label %35

17:                                               ; preds = %14
  %18 = landingpad { ptr, i32 }
          cleanup
  %19 = extractvalue { ptr, i32 } %18, 0
  store ptr %19, ptr %4, align 8
  %20 = extractvalue { ptr, i32 } %18, 1
  store i32 %20, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %15, i64 noundef 48) #6
  br label %43

21:                                               ; preds = %1
  %22 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %22, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail14large_TypefaceE, ptr noundef @_ZN6glutil6detail12large_GlyphsE, ptr noundef @_ZN6glutil6detail11large_ImageE)
          to label %23 unwind label %24

23:                                               ; preds = %21
  store ptr %22, ptr %3, align 8, !tbaa !9
  br label %35

24:                                               ; preds = %21
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %4, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %22, i64 noundef 48) #6
  br label %43

28:                                               ; preds = %1
  %29 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %29, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail14giant_TypefaceE, ptr noundef @_ZN6glutil6detail12giant_GlyphsE, ptr noundef @_ZN6glutil6detail11giant_ImageE)
          to label %30 unwind label %31

30:                                               ; preds = %28
  store ptr %29, ptr %3, align 8, !tbaa !9
  br label %35

31:                                               ; preds = %28
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %4, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %29, i64 noundef 48) #6
  br label %43

35:                                               ; preds = %30, %23, %16, %9, %1
  %36 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8) #5
  %37 = load ptr, ptr %3, align 8, !tbaa !9
  invoke void @_ZN6glutil4FontC1EPNS_6detail8FontImplE(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef %37)
          to label %38 unwind label %39

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %36

39:                                               ; preds = %35
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %4, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %36, i64 noundef 8) #6
  br label %43

43:                                               ; preds = %39, %31, %24, %17, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %4, align 8
  %46 = load i32, ptr %5, align 4
  %47 = insertvalue { ptr, i32 } poison, ptr %45, 0
  %48 = insertvalue { ptr, i32 } %47, i32 %46, 1
  resume { ptr, i32 } %48
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef, ptr noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

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

declare void @_ZN6glutil4FontC1EPNS_6detail8FontImplE(ptr, ptr)

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 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { builtin 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 = !{!"_ZTSN6glutil9FontSizesE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

%"struct.glutil::detail::TypefaceMetrics" = type { i32, i32, i32, i32, i32, i32, i32 }
%"struct.glutil::detail::Glyph" = type { i32, i32, i32, i32, i32, float, float, float, float }

@_ZN6glutil6detail14small_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail12small_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail11small_ImageE = external constant [0 x i8], align 1
@_ZN6glutil6detail15medium_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail13medium_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail12medium_ImageE = external constant [0 x i8], align 1
@_ZN6glutil6detail14large_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail12large_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail11large_ImageE = external constant [0 x i8], align 1
@_ZN6glutil6detail14giant_TypefaceE = external global %"struct.glutil::detail::TypefaceMetrics", align 4
@_ZN6glutil6detail12giant_GlyphsE = external global [0 x %"struct.glutil::detail::Glyph"], align 4
@_ZN6glutil6detail11giant_ImageE = external constant [0 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN6glutil12GenerateFontENS_9FontSizesE(i32 noundef %0) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  switch i32 %0, label %18 [
    i32 0, label %2
    i32 1, label %6
    i32 2, label %10
    i32 3, label %14
  ]

2:                                                ; preds = %1
  %3 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #3
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %3, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail14small_TypefaceE, ptr noundef nonnull @_ZN6glutil6detail12small_GlyphsE, ptr noundef nonnull @_ZN6glutil6detail11small_ImageE)
          to label %18 unwind label %4

4:                                                ; preds = %2
  %5 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %3, i64 noundef 48) #4
  br label %23

6:                                                ; preds = %1
  %7 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #3
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %7, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail15medium_TypefaceE, ptr noundef nonnull @_ZN6glutil6detail13medium_GlyphsE, ptr noundef nonnull @_ZN6glutil6detail12medium_ImageE)
          to label %18 unwind label %8

8:                                                ; preds = %6
  %9 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 48) #4
  br label %23

10:                                               ; preds = %1
  %11 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #3
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %11, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail14large_TypefaceE, ptr noundef nonnull @_ZN6glutil6detail12large_GlyphsE, ptr noundef nonnull @_ZN6glutil6detail11large_ImageE)
          to label %18 unwind label %12

12:                                               ; preds = %10
  %13 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %11, i64 noundef 48) #4
  br label %23

14:                                               ; preds = %1
  %15 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #3
  invoke void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44) %15, ptr noundef nonnull align 4 dereferenceable(28) @_ZN6glutil6detail14giant_TypefaceE, ptr noundef nonnull @_ZN6glutil6detail12giant_GlyphsE, ptr noundef nonnull @_ZN6glutil6detail11giant_ImageE)
          to label %18 unwind label %16

16:                                               ; preds = %14
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %15, i64 noundef 48) #4
  br label %23

18:                                               ; preds = %14, %10, %6, %2, %1
  %.04 = phi ptr [ null, %1 ], [ %3, %2 ], [ %7, %6 ], [ %11, %10 ], [ %15, %14 ]
  %19 = tail call noalias noundef nonnull dereferenceable(8) ptr @_Znwm(i64 noundef 8) #3
  invoke void @_ZN6glutil4FontC1EPNS_6detail8FontImplE(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef %.04)
          to label %20 unwind label %21

20:                                               ; preds = %18
  ret ptr %19

21:                                               ; preds = %18
  %22 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %19, i64 noundef 8) #4
  br label %23

23:                                               ; preds = %21, %16, %12, %8, %4
  %.pn = phi { ptr, i32 } [ %22, %21 ], [ %17, %16 ], [ %13, %12 ], [ %9, %8 ], [ %5, %4 ]
  resume { ptr, i32 } %.pn
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6glutil6detail8FontImplC2ERKNS0_15TypefaceMetricsEPKNS0_5GlyphEPKh(ptr noundef nonnull align 8 dereferenceable(44), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef, ptr noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @_ZN6glutil4FontC1EPNS_6detail8FontImplE(ptr, ptr) local_unnamed_addr

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 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #4 = { builtin 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)"}


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