; LLVM IR from caryll/otfcc :: lib/table/otl/subtables (gpos-common)

; 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.__caryll_vectorinterface_otl_MarkArray = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otfcc_HandlePackage = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otl_MarkRecord = type { %struct.otfcc_Handle, i16, %struct.otl_Anchor }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.otl_Anchor = type { i8, double, double }
%struct.otl_Coverage = type { i16, i32, ptr }

@otl_iMarkArray = external dso_local constant %struct.__caryll_vectorinterface_otl_MarkArray, align 8
@otfcc_iHandle = external constant %struct.otfcc_HandlePackage, align 8

; Function Attrs: nounwind uwtable
define dso_local void @otl_readMarkArray(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca i16, align 2
  %14 = alloca i16, align 2
  %15 = alloca %struct.otl_MarkRecord, align 8
  %16 = alloca %struct.otl_MarkRecord, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = add i32 %18, 2
  %20 = icmp ult i32 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  br label %118

22:                                               ; preds = %5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  %27 = call zeroext i16 @read_16u(ptr noundef %26)
  store i16 %27, ptr %11, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #3
  store i16 0, ptr %12, align 2, !tbaa !11
  br label %28

28:                                               ; preds = %114, %22
  %29 = load i16, ptr %12, align 2, !tbaa !11
  %30 = zext i16 %29 to i32
  %31 = load i16, ptr %11, align 2, !tbaa !11
  %32 = zext i16 %31 to i32
  %33 = icmp slt i32 %30, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #3
  br label %117

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #3
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %36, i64 %38
  %40 = getelementptr inbounds i8, ptr %39, i64 2
  %41 = load i16, ptr %12, align 2, !tbaa !11
  %42 = zext i16 %41 to i32
  %43 = mul nsw i32 %42, 4
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %40, i64 %44
  %46 = call zeroext i16 @read_16u(ptr noundef %45)
  store i16 %46, ptr %13, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #3
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  %51 = getelementptr inbounds i8, ptr %50, i64 2
  %52 = load i16, ptr %12, align 2, !tbaa !11
  %53 = zext i16 %52 to i32
  %54 = mul nsw i32 %53, 4
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %51, i64 %55
  %57 = getelementptr inbounds i8, ptr %56, i64 2
  %58 = call zeroext i16 @read_16u(ptr noundef %57)
  store i16 %58, ptr %14, align 2, !tbaa !11
  %59 = load i16, ptr %14, align 2, !tbaa !11
  %60 = icmp ne i16 %59, 0
  br i1 %60, label %61, label %90

61:                                               ; preds = %35
  %62 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_otl_MarkArray, ptr @otl_iMarkArray, i32 0, i32 13), align 8, !tbaa !13
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.otl_MarkRecord, ptr %15, i32 0, i32 0
  %65 = load ptr, ptr getelementptr inbounds (%struct.otfcc_HandlePackage, ptr @otfcc_iHandle, i32 0, i32 7), align 8, !tbaa !15
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.otl_Coverage, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  %69 = load i16, ptr %12, align 2, !tbaa !11
  %70 = zext i16 %69 to i64
  %71 = getelementptr inbounds %struct.otfcc_Handle, ptr %68, i64 %70
  %72 = getelementptr inbounds { i64, ptr }, ptr %71, i32 0, i32 0
  %73 = load i64, ptr %72, align 8
  %74 = getelementptr inbounds { i64, ptr }, ptr %71, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8
  %76 = call { i64, ptr } %65(i64 %73, ptr %75)
  %77 = getelementptr inbounds { i64, ptr }, ptr %64, i32 0, i32 0
  %78 = extractvalue { i64, ptr } %76, 0
  store i64 %78, ptr %77, align 8
  %79 = getelementptr inbounds { i64, ptr }, ptr %64, i32 0, i32 1
  %80 = extractvalue { i64, ptr } %76, 1
  store ptr %80, ptr %79, align 8
  %81 = getelementptr inbounds %struct.otl_MarkRecord, ptr %15, i32 0, i32 1
  %82 = load i16, ptr %13, align 2, !tbaa !11
  store i16 %82, ptr %81, align 8, !tbaa !19
  %83 = getelementptr inbounds %struct.otl_MarkRecord, ptr %15, i32 0, i32 2
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = load i16, ptr %14, align 2, !tbaa !11
  %88 = zext i16 %87 to i32
  %89 = add i32 %86, %88
  call void @otl_read_anchor(ptr dead_on_unwind writable sret(%struct.otl_Anchor) align 8 %83, ptr noundef %84, i32 noundef %85, i32 noundef %89)
  call void %62(ptr noundef %63, ptr noundef byval(%struct.otl_MarkRecord) align 8 %15)
  br label %113

90:                                               ; preds = %35
  %91 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_otl_MarkArray, ptr @otl_iMarkArray, i32 0, i32 13), align 8, !tbaa !13
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.otl_MarkRecord, ptr %16, i32 0, i32 0
  %94 = load ptr, ptr getelementptr inbounds (%struct.otfcc_HandlePackage, ptr @otfcc_iHandle, i32 0, i32 7), align 8, !tbaa !15
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.otl_Coverage, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !17
  %98 = load i16, ptr %12, align 2, !tbaa !11
  %99 = zext i16 %98 to i64
  %100 = getelementptr inbounds %struct.otfcc_Handle, ptr %97, i64 %99
  %101 = getelementptr inbounds { i64, ptr }, ptr %100, i32 0, i32 0
  %102 = load i64, ptr %101, align 8
  %103 = getelementptr inbounds { i64, ptr }, ptr %100, i32 0, i32 1
  %104 = load ptr, ptr %103, align 8
  %105 = call { i64, ptr } %94(i64 %102, ptr %104)
  %106 = getelementptr inbounds { i64, ptr }, ptr %93, i32 0, i32 0
  %107 = extractvalue { i64, ptr } %105, 0
  store i64 %107, ptr %106, align 8
  %108 = getelementptr inbounds { i64, ptr }, ptr %93, i32 0, i32 1
  %109 = extractvalue { i64, ptr } %105, 1
  store ptr %109, ptr %108, align 8
  %110 = getelementptr inbounds %struct.otl_MarkRecord, ptr %16, i32 0, i32 1
  %111 = load i16, ptr %13, align 2, !tbaa !11
  store i16 %111, ptr %110, align 8, !tbaa !19
  %112 = getelementptr inbounds %struct.otl_MarkRecord, ptr %16, i32 0, i32 2
  call void @otl_anchor_absent(ptr dead_on_unwind writable sret(%struct.otl_Anchor) align 8 %112)
  call void %91(ptr noundef %92, ptr noundef byval(%struct.otl_MarkRecord) align 8 %16)
  br label %113

113:                                              ; preds = %90, %61
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #3
  br label %114

114:                                              ; preds = %113
  %115 = load i16, ptr %12, align 2, !tbaa !11
  %116 = add i16 %115, 1
  store i16 %116, ptr %12, align 2, !tbaa !11
  br label %28, !llvm.loop !25

117:                                              ; preds = %34
  br label %118

118:                                              ; preds = %117, %21
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @read_16u(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @otl_read_anchor(ptr dead_on_unwind noalias writable sret(%struct.otl_Anchor) align 8, ptr noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @otl_anchor_absent(ptr dead_on_unwind noalias writable sret(%struct.otl_Anchor) align 8) #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 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !6, i64 104}
!14 = !{!"__caryll_vectorinterface_otl_MarkArray", !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, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!15 = !{!16, !6, i64 56}
!16 = !{!"otfcc_HandlePackage", !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}
!17 = !{!18, !6, i64 8}
!18 = !{!"", !12, i64 0, !10, i64 4, !6, i64 8}
!19 = !{!20, !12, i64 16}
!20 = !{!"", !21, i64 0, !12, i64 16, !22, i64 24}
!21 = !{!"otfcc_Handle", !10, i64 0, !12, i64 4, !6, i64 8}
!22 = !{!"", !23, i64 0, !24, i64 8, !24, i64 16}
!23 = !{!"_Bool", !7, i64 0}
!24 = !{!"double", !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; 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.__caryll_vectorinterface_otl_MarkArray = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otfcc_HandlePackage = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otl_MarkRecord = type { %struct.otfcc_Handle, i16, %struct.otl_Anchor }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.otl_Anchor = type { i8, double, double }

@otl_iMarkArray = external dso_local local_unnamed_addr constant %struct.__caryll_vectorinterface_otl_MarkArray, align 8
@otfcc_iHandle = external local_unnamed_addr constant %struct.otfcc_HandlePackage, align 8

; Function Attrs: nounwind uwtable
define dso_local void @otl_readMarkArray(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.otl_MarkRecord, align 8
  %7 = alloca %struct.otl_MarkRecord, align 8
  %8 = add i32 %4, 2
  %9 = icmp ugt i32 %8, %3
  br i1 %9, label %.loopexit, label %10

10:                                               ; preds = %5
  %11 = zext i32 %4 to i64
  %12 = getelementptr inbounds i8, ptr %2, i64 %11
  %13 = tail call zeroext i16 @read_16u(ptr noundef %12)
  %.not29 = icmp eq i16 %13, 0
  br i1 %.not29, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %14 = getelementptr inbounds i8, ptr %12, i64 2
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @otl_iMarkArray, i64 104), align 8
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @otfcc_iHandle, i64 56), align 8
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = getelementptr inbounds i8, ptr %6, i64 8
  %19 = getelementptr inbounds i8, ptr %6, i64 16
  %20 = getelementptr inbounds i8, ptr %6, i64 24
  %21 = getelementptr inbounds i8, ptr %7, i64 8
  %22 = getelementptr inbounds i8, ptr %7, i64 16
  %23 = getelementptr inbounds i8, ptr %7, i64 24
  %wide.trip.count = zext i16 %13 to i64
  br label %24

24:                                               ; preds = %.lr.ph, %42
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %42 ]
  %25 = shl nuw nsw i64 %indvars.iv, 2
  %26 = getelementptr inbounds i8, ptr %14, i64 %25
  %27 = call zeroext i16 @read_16u(ptr noundef nonnull %26)
  %28 = getelementptr inbounds i8, ptr %26, i64 2
  %29 = call zeroext i16 @read_16u(ptr noundef nonnull %28)
  %.not = icmp eq i16 %29, 0
  %30 = load ptr, ptr %17, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.otfcc_Handle, ptr %30, i64 %indvars.iv
  %32 = load i64, ptr %31, align 8
  %33 = getelementptr inbounds i8, ptr %31, i64 8
  %34 = load ptr, ptr %33, align 8
  %35 = call { i64, ptr } %16(i64 %32, ptr %34) #2
  %36 = extractvalue { i64, ptr } %35, 0
  %37 = extractvalue { i64, ptr } %35, 1
  br i1 %.not, label %41, label %38

38:                                               ; preds = %24
  store i64 %36, ptr %6, align 8
  store ptr %37, ptr %18, align 8
  store i16 %27, ptr %19, align 8, !tbaa !12
  %39 = zext i16 %29 to i32
  %40 = add i32 %39, %4
  call void @otl_read_anchor(ptr dead_on_unwind nonnull writable sret(%struct.otl_Anchor) align 8 %20, ptr noundef %2, i32 noundef %3, i32 noundef %40)
  br label %42

41:                                               ; preds = %24
  store i64 %36, ptr %7, align 8
  store ptr %37, ptr %21, align 8
  store i16 %27, ptr %22, align 8, !tbaa !12
  call void @otl_anchor_absent(ptr dead_on_unwind nonnull writable sret(%struct.otl_Anchor) align 8 %23)
  br label %42

42:                                               ; preds = %41, %38
  %.sink = phi ptr [ %7, %41 ], [ %6, %38 ]
  call void %15(ptr noundef %0, ptr noundef nonnull byval(%struct.otl_MarkRecord) align 8 %.sink) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %24, !llvm.loop !18

.loopexit:                                        ; preds = %42, %10, %5
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @read_16u(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @otl_read_anchor(ptr dead_on_unwind noalias writable sret(%struct.otl_Anchor) align 8, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @otl_anchor_absent(ptr dead_on_unwind noalias writable sret(%struct.otl_Anchor) align 8) 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 = { inlinehint 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 }

!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, !11, i64 8}
!6 = !{!"", !7, i64 0, !10, i64 4, !11, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !7, i64 16}
!13 = !{!"", !14, i64 0, !7, i64 16, !15, i64 24}
!14 = !{!"otfcc_Handle", !10, i64 0, !7, i64 4, !11, i64 8}
!15 = !{!"", !16, i64 0, !17, i64 8, !17, i64 16}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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