; LLVM IR from caryll/otfcc :: lib/table/glyf (glyf)

; 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.otfcc_Options = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, ptr }
%struct.otfcc_ILogger = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.table_glyf = type { i64, i64, ptr }
%struct.glyf_Glyph = type { ptr, %struct.VQ, %struct.VQ, %struct.VQ, %struct.VQ, %struct.glyf_ContourList, %struct.glyf_ReferenceList, %struct.glyf_StemDefList, %struct.glyf_StemDefList, %struct.glyf_MaskList, %struct.glyf_MaskList, i16, ptr, i8, %struct.otfcc_Handle, i16, %struct.glyf_GlyphStat }
%struct.VQ = type { double, %struct.vq_SegList }
%struct.vq_SegList = type { i64, i64, ptr }
%struct.glyf_ContourList = type { i64, i64, ptr }
%struct.glyf_ReferenceList = type { i64, i64, ptr }
%struct.glyf_StemDefList = type { i64, i64, ptr }
%struct.glyf_MaskList = type { i64, i64, ptr }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.glyf_GlyphStat = type { double, double, double, double, i16, i16, i16, i16, i16 }

@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; 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: nounwind uwtable
declare dso_local void @otfcc_dump_glyphorder(ptr noundef, ptr noundef) #1

declare ptr @json_object_push(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @otfcc_dumpGlyf(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i16, align 2
  %13 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %4
  br label %86

17:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.otfcc_Options, ptr %18, i32 0, i32 24
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.otfcc_ILogger, ptr %20, i32 0, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.otfcc_Options, ptr %23, i32 0, i32 24
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = call ptr @sdsempty()
  %27 = call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %26, ptr noundef @.str.1)
  call void %22(ptr noundef %25, ptr noundef %27)
  store i8 1, ptr %9, align 1, !tbaa !14
  br label %28

28:                                               ; preds = %77, %17
  %29 = load i8, ptr %9, align 1, !tbaa !14, !range !15, !noundef !16
  %30 = trunc i8 %29 to i1
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  br label %86

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.table_glyf, ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !17
  %36 = call ptr @json_object_new(i64 noundef %35)
  store ptr %36, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #3
  store i16 0, ptr %12, align 2, !tbaa !20
  br label %37

37:                                               ; preds = %62, %32
  %38 = load i16, ptr %12, align 2, !tbaa !20
  %39 = zext i16 %38 to i64
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.table_glyf, ptr %40, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !17
  %43 = icmp ult i64 %39, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %37
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #3
  br label %65

45:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.table_glyf, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !22
  %49 = load i16, ptr %12, align 2, !tbaa !20
  %50 = zext i16 %49 to i64
  %51 = getelementptr inbounds ptr, ptr %48, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  store ptr %52, ptr %13, align 8, !tbaa !5
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.glyf_Glyph, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = call ptr @glyf_dump_glyph(ptr noundef %57, ptr noundef %58, ptr noundef %59)
  %61 = call ptr @json_object_push(ptr noundef %53, ptr noundef %56, ptr noundef %60)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %62

62:                                               ; preds = %45
  %63 = load i16, ptr %12, align 2, !tbaa !20
  %64 = add i16 %63, 1
  store i16 %64, ptr %12, align 2, !tbaa !20
  br label %37, !llvm.loop !30

65:                                               ; preds = %44
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = call ptr @json_object_push(ptr noundef %66, ptr noundef @.str.1, ptr noundef %67)
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.otfcc_Options, ptr %69, i32 0, i32 1
  %71 = load i8, ptr %70, align 1, !tbaa !32, !range !15, !noundef !16
  %72 = trunc i8 %71 to i1
  br i1 %72, label %76, label %73

73:                                               ; preds = %65
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  call void @otfcc_dump_glyphorder(ptr noundef %74, ptr noundef %75)
  br label %76

76:                                               ; preds = %73, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %77

77:                                               ; preds = %76
  store i8 0, ptr %9, align 1, !tbaa !14
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.otfcc_Options, ptr %78, i32 0, i32 24
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.otfcc_ILogger, ptr %80, i32 0, i32 8
  %82 = load ptr, ptr %81, align 8, !tbaa !33
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.otfcc_Options, ptr %83, i32 0, i32 24
  %85 = load ptr, ptr %84, align 8, !tbaa !9
  call void %82(ptr noundef %85)
  br label %28, !llvm.loop !34

86:                                               ; preds = %31, %16
  ret void
}

declare ptr @sdscatprintf(ptr noundef, ptr noundef, ...) #2

declare ptr @sdsempty() #2

declare ptr @json_object_new(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @glyf_dump_glyph(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8, !11, i64 9, !11, i64 10, !11, i64 11, !11, i64 12, !11, i64 13, !11, i64 14, !11, i64 15, !11, i64 16, !11, i64 17, !11, i64 18, !11, i64 19, !11, i64 20, !11, i64 21, !11, i64 22, !6, i64 24, !6, i64 32}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!13, !6, i64 32}
!13 = !{!"otfcc_ILogger", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!14 = !{!11, !11, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !19, i64 0}
!18 = !{!"", !19, i64 0, !19, i64 8, !6, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = !{!18, !6, i64 16}
!23 = !{!24, !6, i64 0}
!24 = !{!"", !6, i64 0, !25, i64 8, !25, i64 40, !25, i64 72, !25, i64 104, !18, i64 136, !18, i64 160, !18, i64 184, !18, i64 208, !18, i64 232, !18, i64 256, !21, i64 280, !6, i64 288, !7, i64 296, !27, i64 304, !21, i64 320, !29, i64 328}
!25 = !{!"", !26, i64 0, !18, i64 8}
!26 = !{!"double", !7, i64 0}
!27 = !{!"otfcc_Handle", !28, i64 0, !21, i64 4, !6, i64 8}
!28 = !{!"int", !7, i64 0}
!29 = !{!"", !26, i64 0, !26, i64 8, !26, i64 16, !26, i64 24, !21, i64 32, !21, i64 34, !21, i64 36, !21, i64 38, !21, i64 40}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!10, !11, i64 1}
!33 = !{!13, !6, i64 64}
!34 = distinct !{!34, !31}


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

@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @otfcc_dump_glyphorder(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @otfcc_dumpGlyf(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %.critedge

.critedge:                                        ; preds = %4
  %5 = getelementptr inbounds i8, ptr %2, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = tail call ptr @sdsempty() #2
  %10 = tail call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %9, ptr noundef nonnull @.str.1) #2
  tail call void %8(ptr noundef %6, ptr noundef %10) #2
  %11 = load i64, ptr %0, align 8, !tbaa !13
  %12 = tail call ptr @json_object_new(i64 noundef %11) #2
  %13 = load i64, ptr %0, align 8, !tbaa !13
  %.not25 = icmp eq i64 %13, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.critedge
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  br label %19

._crit_edge:                                      ; preds = %19, %.critedge
  %15 = tail call ptr @json_object_push(ptr noundef %1, ptr noundef nonnull @.str.1, ptr noundef %12) #2
  %16 = getelementptr inbounds i8, ptr %2, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !16, !range !17, !noundef !18
  %18 = trunc nuw i8 %17 to i1
  br i1 %18, label %32, label %31

19:                                               ; preds = %.lr.ph, %19
  %20 = phi i64 [ 0, %.lr.ph ], [ %28, %19 ]
  %.02124 = phi i16 [ 0, %.lr.ph ], [ %27, %19 ]
  %21 = load ptr, ptr %14, align 8, !tbaa !19
  %22 = getelementptr inbounds ptr, ptr %21, i64 %20
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  %25 = tail call ptr @glyf_dump_glyph(ptr noundef nonnull %23, ptr noundef %2, ptr noundef %3)
  %26 = tail call ptr @json_object_push(ptr noundef %12, ptr noundef %24, ptr noundef %25) #2
  %27 = add i16 %.02124, 1
  %28 = zext i16 %27 to i64
  %29 = load i64, ptr %0, align 8, !tbaa !13
  %30 = icmp ugt i64 %29, %28
  br i1 %30, label %19, label %._crit_edge, !llvm.loop !29

31:                                               ; preds = %._crit_edge
  tail call void @otfcc_dump_glyphorder(ptr noundef nonnull %0, ptr noundef %1)
  br label %32

32:                                               ; preds = %31, %._crit_edge
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 64
  %35 = load ptr, ptr %34, align 8, !tbaa !31
  tail call void %35(ptr noundef %33) #2
  br label %36

36:                                               ; preds = %4, %32
  ret void
}

declare ptr @sdscatprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare ptr @sdsempty() local_unnamed_addr #1

declare ptr @json_object_new(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @glyf_dump_glyph(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 }

!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, !10, i64 32}
!6 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22, !10, i64 24, !10, i64 32}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"otfcc_ILogger", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88}
!13 = !{!14, !15, i64 0}
!14 = !{!"", !15, i64 0, !15, i64 8, !10, i64 16}
!15 = !{!"long", !8, i64 0}
!16 = !{!6, !7, i64 1}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!14, !10, i64 16}
!20 = !{!10, !10, i64 0}
!21 = !{!22, !10, i64 0}
!22 = !{!"", !10, i64 0, !23, i64 8, !23, i64 40, !23, i64 72, !23, i64 104, !14, i64 136, !14, i64 160, !14, i64 184, !14, i64 208, !14, i64 232, !14, i64 256, !25, i64 280, !10, i64 288, !8, i64 296, !26, i64 304, !25, i64 320, !28, i64 328}
!23 = !{!"", !24, i64 0, !14, i64 8}
!24 = !{!"double", !8, i64 0}
!25 = !{!"short", !8, i64 0}
!26 = !{!"otfcc_Handle", !27, i64 0, !25, i64 4, !10, i64 8}
!27 = !{!"int", !8, i64 0}
!28 = !{!"", !24, i64 0, !24, i64 8, !24, i64 16, !24, i64 24, !25, i64 32, !25, i64 34, !25, i64 36, !25, i64 38, !25, i64 40}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!12, !10, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass