; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/freetype-src/src/autofit (afcjk)

; 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.AF_CJKMetricsRec_ = type { %struct.AF_StyleMetricsRec_, i32, [2 x %struct.AF_CJKAxisRec_] }
%struct.AF_StyleMetricsRec_ = type { ptr, %struct.AF_ScalerRec_, i8, ptr }
%struct.AF_ScalerRec_ = type { ptr, i64, i64, i64, i64, i32, i32 }
%struct.AF_CJKAxisRec_ = type { i64, i64, i32, [16 x %struct.AF_WidthRec_], i64, i64, i8, i8, i32, [266 x %struct.AF_CJKBlueRec_], i64, i64 }
%struct.AF_WidthRec_ = type { i64, i64, i64 }
%struct.AF_CJKBlueRec_ = type { %struct.AF_WidthRec_, %struct.AF_WidthRec_, i32 }

@__const.af_cjk_metrics_check_digits.digits = external hidden unnamed_addr constant [20 x i8], align 16

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

declare ptr @af_shaper_get_cluster(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare i64 @af_shaper_get_elem(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

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

declare void @af_shaper_buf_destroy(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define hidden void @af_cjk_metrics_check_digits(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [20 x i8], align 16
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  store i8 0, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  store i8 1, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store ptr %9, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %11) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 16 @__const.af_cjk_metrics_check_digits.digits, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %16 = getelementptr inbounds [20 x i8], ptr %11, i64 0, i64 0
  store ptr %16, ptr %12, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %52, %50, %2
  %18 = load ptr, ptr %12, align 8, !tbaa !5
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = icmp ne i8 %19, 0
  br i1 %20, label %21, label %53

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.AF_CJKMetricsRec_, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = call ptr @af_shaper_get_cluster(ptr noundef %22, ptr noundef %24, ptr noundef %25, ptr noundef %14)
  store ptr %26, ptr %12, align 8, !tbaa !5
  %27 = load i32, ptr %14, align 4, !tbaa !12
  %28 = icmp ugt i32 %27, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %21
  store i32 2, ptr %15, align 4
  br label %50, !llvm.loop !14

30:                                               ; preds = %21
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.AF_CJKMetricsRec_, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = call i64 @af_shaper_get_elem(ptr noundef %32, ptr noundef %33, i32 noundef 0, ptr noundef %7, ptr noundef null)
  store i64 %34, ptr %13, align 8, !tbaa !10
  %35 = load i64, ptr %13, align 8, !tbaa !10
  %36 = icmp ne i64 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %30
  store i32 2, ptr %15, align 4
  br label %50, !llvm.loop !14

38:                                               ; preds = %30
  %39 = load i8, ptr %5, align 1, !tbaa !9
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %41, label %47

41:                                               ; preds = %38
  %42 = load i64, ptr %7, align 8, !tbaa !10
  %43 = load i64, ptr %8, align 8, !tbaa !10
  %44 = icmp ne i64 %42, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  store i8 0, ptr %6, align 1, !tbaa !9
  store i32 3, ptr %15, align 4
  br label %50

46:                                               ; preds = %41
  br label %49

47:                                               ; preds = %38
  %48 = load i64, ptr %7, align 8, !tbaa !10
  store i64 %48, ptr %8, align 8, !tbaa !10
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %49

49:                                               ; preds = %47, %46
  store i32 0, ptr %15, align 4
  br label %50

50:                                               ; preds = %49, %45, %37, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %51 = load i32, ptr %15, align 4
  switch i32 %51, label %60 [
    i32 0, label %52
    i32 2, label %17
    i32 3, label %53
  ]

52:                                               ; preds = %50
  br label %17, !llvm.loop !14

53:                                               ; preds = %50, %17
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  call void @af_shaper_buf_destroy(ptr noundef %54, ptr noundef %55)
  %56 = load i8, ptr %6, align 1, !tbaa !9
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.AF_CJKMetricsRec_, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.AF_StyleMetricsRec_, ptr %58, i32 0, i32 2
  store i8 %56, ptr %59, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  ret void

60:                                               ; preds = %50
  unreachable
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !7, i64 56}
!17 = !{!"AF_CJKMetricsRec_", !18, i64 0, !13, i64 72, !7, i64 80}
!18 = !{!"AF_StyleMetricsRec_", !6, i64 0, !19, i64 8, !7, i64 56, !6, i64 64}
!19 = !{!"AF_ScalerRec_", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !13, i64 40, !13, i64 44}


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

@__const.af_cjk_metrics_check_digits.digits = external hidden unnamed_addr constant [20 x i8], align 16

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

declare ptr @af_shaper_get_cluster(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i64 @af_shaper_get_elem(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare void @af_shaper_buf_destroy(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define hidden void @af_cjk_metrics_check_digits(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca [20 x i8], align 16
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %5, ptr noundef nonnull align 16 dereferenceable(20) @__const.af_cjk_metrics_check_digits.digits, i64 20, i1 false)
  %7 = load i8, ptr %5, align 16, !tbaa !9
  %.not30 = icmp eq i8 %7, 0
  br i1 %.not30, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %2, %select.unfold
  %.01333 = phi i8 [ %.2, %select.unfold ], [ 0, %2 ]
  %.01432 = phi ptr [ %8, %select.unfold ], [ %5, %2 ]
  %.01831 = phi i64 [ %.220, %select.unfold ], [ 0, %2 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %8 = call ptr @af_shaper_get_cluster(ptr noundef nonnull %.01432, ptr noundef %0, ptr noundef nonnull %4, ptr noundef nonnull %6) #4
  %9 = load i32, ptr %6, align 4, !tbaa !10
  %10 = icmp ugt i32 %9, 1
  br i1 %10, label %select.unfold, label %11, !llvm.loop !12

11:                                               ; preds = %.lr.ph
  %12 = call i64 @af_shaper_get_elem(ptr noundef %0, ptr noundef nonnull %4, i32 noundef 0, ptr noundef nonnull %3, ptr noundef null) #4
  %.not21 = icmp eq i64 %12, 0
  br i1 %.not21, label %select.unfold, label %13, !llvm.loop !12

13:                                               ; preds = %11
  %.not22 = icmp eq i8 %.01333, 0
  %14 = load i64, ptr %3, align 8, !tbaa !5
  br i1 %.not22, label %select.unfold, label %15

15:                                               ; preds = %13
  %.not23 = icmp eq i64 %14, %.01831
  br i1 %.not23, label %select.unfold, label %.thread

.thread:                                          ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  br label %.loopexit

select.unfold:                                    ; preds = %13, %15, %11, %.lr.ph
  %.220 = phi i64 [ %.01831, %.lr.ph ], [ %.01831, %11 ], [ %.01831, %15 ], [ %14, %13 ]
  %.2 = phi i8 [ %.01333, %.lr.ph ], [ %.01333, %11 ], [ 1, %15 ], [ 1, %13 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  %16 = load i8, ptr %8, align 1, !tbaa !9
  %.not = icmp eq i8 %16, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.loopexit:                                        ; preds = %select.unfold, %2, %.thread
  %.217 = phi i8 [ 0, %.thread ], [ 1, %2 ], [ 1, %select.unfold ]
  call void @af_shaper_buf_destroy(ptr noundef %1, ptr noundef nonnull %4) #4
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  store i8 %.217, ptr %17, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !7, i64 56}
!15 = !{!"AF_CJKMetricsRec_", !16, i64 0, !11, i64 72, !7, i64 80}
!16 = !{!"AF_StyleMetricsRec_", !17, i64 0, !18, i64 8, !7, i64 56, !17, i64 64}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!"AF_ScalerRec_", !17, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass