; LLVM IR from caryll/otfcc :: lib/font (caryll-sfnt)

; 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_SplineFontContainer = type { i32, i32, ptr, ptr }
%struct.otfcc_Packet = type { i32, i16, i16, i16, i16, ptr }
%struct.otfcc_PacketPiece = type { i32, i32, i32, i32, ptr }

; 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
define dso_local void @otfcc_deleteSFNT(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  br label %97

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp ugt i32 %12, 0
  br i1 %13, label %14, label %90

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %15

15:                                               ; preds = %81, %14
  %16 = load i32, ptr %3, align 4, !tbaa !12
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = icmp ult i32 %16, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %15
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %84

22:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %23

23:                                               ; preds = %62, %22
  %24 = load i32, ptr %5, align 4, !tbaa !12
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %25, i32 0, i32 3
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = load i32, ptr %3, align 4, !tbaa !12
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds %struct.otfcc_Packet, ptr %27, i64 %29
  %31 = getelementptr inbounds %struct.otfcc_Packet, ptr %30, i32 0, i32 1
  %32 = load i16, ptr %31, align 4, !tbaa !14
  %33 = zext i16 %32 to i32
  %34 = icmp slt i32 %24, %33
  br i1 %34, label %36, label %35

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

36:                                               ; preds = %23
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %3, align 4, !tbaa !12
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds %struct.otfcc_Packet, ptr %39, i64 %41
  %43 = getelementptr inbounds %struct.otfcc_Packet, ptr %42, i32 0, i32 5
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  %45 = load i32, ptr %5, align 4, !tbaa !12
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %44, i64 %46
  %48 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  call void @free(ptr noundef %49) #3
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr %3, align 4, !tbaa !12
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds %struct.otfcc_Packet, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.otfcc_Packet, ptr %55, i32 0, i32 5
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = load i32, ptr %5, align 4, !tbaa !12
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %57, i64 %59
  %61 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %60, i32 0, i32 4
  store ptr null, ptr %61, align 8, !tbaa !18
  br label %62

62:                                               ; preds = %36
  %63 = load i32, ptr %5, align 4, !tbaa !12
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %5, align 4, !tbaa !12
  br label %23, !llvm.loop !20

65:                                               ; preds = %35
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %66, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  %69 = load i32, ptr %3, align 4, !tbaa !12
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds %struct.otfcc_Packet, ptr %68, i64 %70
  %72 = getelementptr inbounds %struct.otfcc_Packet, ptr %71, i32 0, i32 5
  %73 = load ptr, ptr %72, align 8, !tbaa !17
  call void @free(ptr noundef %73) #3
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %74, i32 0, i32 3
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  %77 = load i32, ptr %3, align 4, !tbaa !12
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds %struct.otfcc_Packet, ptr %76, i64 %78
  %80 = getelementptr inbounds %struct.otfcc_Packet, ptr %79, i32 0, i32 5
  store ptr null, ptr %80, align 8, !tbaa !17
  br label %81

81:                                               ; preds = %65
  %82 = load i32, ptr %3, align 4, !tbaa !12
  %83 = add i32 %82, 1
  store i32 %83, ptr %3, align 4, !tbaa !12
  br label %15, !llvm.loop !22

84:                                               ; preds = %21
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %85, i32 0, i32 3
  %87 = load ptr, ptr %86, align 8, !tbaa !13
  call void @free(ptr noundef %87) #3
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %88, i32 0, i32 3
  store ptr null, ptr %89, align 8, !tbaa !13
  br label %90

90:                                               ; preds = %84, %9
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %91, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !23
  call void @free(ptr noundef %93) #3
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.otfcc_SplineFontContainer, ptr %94, i32 0, i32 2
  store ptr null, ptr %95, align 8, !tbaa !23
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %96) #3
  store ptr null, ptr %2, align 8, !tbaa !5
  br label %97

97:                                               ; preds = %90, %8
  ret void
}

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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 = { 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 = { 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, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 16}
!14 = !{!15, !16, i64 4}
!15 = !{!"", !11, i64 0, !16, i64 4, !16, i64 6, !16, i64 8, !16, i64 10, !6, i64 16}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !6, i64 16}
!18 = !{!19, !6, i64 16}
!19 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = !{!10, !6, i64 8}


; 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.otfcc_Packet = type { i32, i16, i16, i16, i16, ptr }
%struct.otfcc_PacketPiece = type { i32, i32, i32, i32, ptr }

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

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %.not25 = icmp eq i32 %4, 0
  br i1 %.not25, label %27, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load ptr, ptr %5, align 8, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %6 = phi ptr [ %.pre, %.preheader.lr.ph ], [ %11, %._crit_edge ]
  %indvars.iv37 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next38, %._crit_edge ]
  %7 = getelementptr inbounds %struct.otfcc_Packet, ptr %6, i64 %indvars.iv37, i32 1
  %8 = load i16, ptr %7, align 4, !tbaa !12
  %.not35 = icmp eq i16 %8, 0
  %.phi.trans.insert41 = getelementptr inbounds %struct.otfcc_Packet, ptr %6, i64 %indvars.iv37, i32 5
  %.pre42 = load ptr, ptr %.phi.trans.insert41, align 8, !tbaa !15
  br i1 %.not35, label %._crit_edge, label %.lr.ph

._crit_edge33:                                    ; preds = %._crit_edge
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @free(ptr noundef nonnull %11) #2
  store ptr null, ptr %9, align 8, !tbaa !11
  br label %27

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %10 = phi ptr [ %.pre42, %.preheader ], [ %21, %.lr.ph ]
  tail call void @free(ptr noundef %10) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.otfcc_Packet, ptr %11, i64 %indvars.iv37, i32 5
  store ptr null, ptr %12, align 8, !tbaa !15
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = icmp ult i64 %indvars.iv.next38, %14
  br i1 %15, label %.preheader, label %._crit_edge33, !llvm.loop !16

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %16 = phi ptr [ %21, %.lr.ph ], [ %.pre42, %.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %17 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %16, i64 %indvars.iv, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !18
  tail call void @free(ptr noundef %18) #2
  %19 = load ptr, ptr %5, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.otfcc_Packet, ptr %19, i64 %indvars.iv37, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %21, i64 %indvars.iv, i32 4
  store ptr null, ptr %22, align 8, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = getelementptr inbounds %struct.otfcc_Packet, ptr %19, i64 %indvars.iv37, i32 1
  %24 = load i16, ptr %23, align 4, !tbaa !12
  %25 = zext i16 %24 to i64
  %26 = icmp ult i64 %indvars.iv.next, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !20

27:                                               ; preds = %._crit_edge33, %2
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  tail call void @free(ptr noundef %29) #2
  tail call void @free(ptr noundef nonnull %0) #2
  br label %30

30:                                               ; preds = %1, %27
  ret void
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !7, i64 4}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!13, !14, i64 4}
!13 = !{!"", !7, i64 0, !14, i64 4, !14, i64 6, !14, i64 8, !14, i64 10, !10, i64 16}
!14 = !{!"short", !8, i64 0}
!15 = !{!13, !10, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !10, i64 16}
!19 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!20 = distinct !{!20, !17}
!21 = !{!6, !10, i64 8}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass