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

; 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_elementinterface_table_OTL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otfcc_Packet = type { i32, i16, i16, i16, i16, ptr }
%struct.otfcc_PacketPiece = type { i32, i32, i32, i32, ptr }
%struct.table_OTL = type { %struct.otl_LookupList, %struct.otl_FeatureList, %struct.otl_LangSystemList }
%struct.otl_LookupList = type { i64, i64, ptr }
%struct.otl_FeatureList = type { i64, i64, ptr }
%struct.otl_LangSystemList = type { i64, i64, ptr }

@table_iOTL = external constant %struct.__caryll_elementinterface_table_OTL, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @otfcc_readOtl(ptr noundef byval(%struct.otfcc_Packet) align 8 %0, ptr noundef %1, i32 noundef %2, i16 noundef zeroext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i16, align 2
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.otfcc_PacketPiece, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i16, align 2
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i16 %3, ptr %8, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %127, %4
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %31

22:                                               ; preds = %19
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %22
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = getelementptr inbounds %struct.otfcc_Packet, ptr %0, i32 0, i32 1
  %28 = load i16, ptr %27, align 4, !tbaa !13
  %29 = zext i16 %28 to i32
  %30 = icmp slt i32 %26, %29
  br label %31

31:                                               ; preds = %25, %22, %19
  %32 = phi i1 [ false, %22 ], [ false, %19 ], [ %30, %25 ]
  br i1 %32, label %34, label %33

33:                                               ; preds = %31
  store i32 2, ptr %13, align 4
  br label %134

34:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #3
  %35 = getelementptr inbounds %struct.otfcc_Packet, ptr %0, i32 0, i32 5
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %36, i64 %38
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %39, i64 24, i1 false), !tbaa.struct !16
  br label %40

40:                                               ; preds = %119, %34
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store i32 5, ptr %13, align 4
  br label %124

44:                                               ; preds = %40
  %45 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %14, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !17
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %118

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

50:                                               ; preds = %114, %49
  %51 = load i32, ptr %15, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  store i32 8, ptr %13, align 4
  br label %115

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %55 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %14, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  store ptr %56, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %57 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %14, i32 0, i32 3
  %58 = load i32, ptr %57, align 4, !tbaa !20
  store i32 %58, ptr %17, align 4, !tbaa !9
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = load i32, ptr %17, align 4, !tbaa !9
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 1196643650
  br i1 %62, label %63, label %64

63:                                               ; preds = %54
  br label %69

64:                                               ; preds = %54
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = icmp eq i32 %65, 1196445523
  %67 = zext i1 %66 to i64
  %68 = select i1 %66, i32 32, i32 0
  br label %69

69:                                               ; preds = %64, %63
  %70 = phi i32 [ 16, %63 ], [ %68, %64 ]
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = call ptr @otfcc_readOtl_common(ptr noundef %59, i32 noundef %60, i32 noundef %70, ptr noundef %71)
  store ptr %72, ptr %9, align 8, !tbaa !5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %76, label %75

75:                                               ; preds = %69
  br label %104

76:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 2, ptr %18) #3
  store i16 0, ptr %18, align 2, !tbaa !11
  br label %77

77:                                               ; preds = %99, %76
  %78 = load i16, ptr %18, align 2, !tbaa !11
  %79 = zext i16 %78 to i64
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.table_OTL, ptr %80, i32 0, i32 0
  %82 = getelementptr inbounds %struct.otl_LookupList, ptr %81, i32 0, i32 0
  %83 = load i64, ptr %82, align 8, !tbaa !21
  %84 = icmp ult i64 %79, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %77
  store i32 12, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #3
  br label %102

86:                                               ; preds = %77
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  %88 = load i32, ptr %17, align 4, !tbaa !9
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.table_OTL, ptr %89, i32 0, i32 0
  %91 = getelementptr inbounds %struct.otl_LookupList, ptr %90, i32 0, i32 2
  %92 = load ptr, ptr %91, align 8, !tbaa !25
  %93 = load i16, ptr %18, align 2, !tbaa !11
  %94 = zext i16 %93 to i64
  %95 = getelementptr inbounds ptr, ptr %92, i64 %94
  %96 = load ptr, ptr %95, align 8, !tbaa !5
  %97 = load i16, ptr %8, align 2, !tbaa !11
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  call void @otfcc_readOtl_lookup(ptr noundef %87, i32 noundef %88, ptr noundef %96, i16 noundef zeroext %97, ptr noundef %98)
  br label %99

99:                                               ; preds = %86
  %100 = load i16, ptr %18, align 2, !tbaa !11
  %101 = add i16 %100, 1
  store i16 %101, ptr %18, align 2, !tbaa !11
  br label %77, !llvm.loop !26

102:                                              ; preds = %85
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %103, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %111

104:                                              ; preds = %75
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %110

107:                                              ; preds = %104
  %108 = load ptr, ptr getelementptr inbounds (%struct.__caryll_elementinterface_table_OTL, ptr @table_iOTL, i32 0, i32 7), align 8, !tbaa !28
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  call void %108(ptr noundef %109)
  br label %110

110:                                              ; preds = %107, %104
  store ptr null, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %13, align 4
  br label %111

111:                                              ; preds = %110, %102
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %112 = load i32, ptr %13, align 4
  switch i32 %112, label %115 [
    i32 0, label %113
  ]

113:                                              ; preds = %111
  br label %114

114:                                              ; preds = %113
  store i32 0, ptr %15, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %50, !llvm.loop !30

115:                                              ; preds = %111, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  %116 = load i32, ptr %13, align 4
  switch i32 %116, label %124 [
    i32 8, label %117
  ]

117:                                              ; preds = %115
  br label %118

118:                                              ; preds = %117, %44
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %10, align 4, !tbaa !9
  %121 = icmp ne i32 %120, 0
  %122 = xor i1 %121, true
  %123 = zext i1 %122 to i32
  store i32 %123, ptr %10, align 4, !tbaa !9
  br label %40, !llvm.loop !31

124:                                              ; preds = %115, %43
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  %125 = load i32, ptr %13, align 4
  switch i32 %125, label %134 [
    i32 5, label %126
  ]

126:                                              ; preds = %124
  br label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %10, align 4, !tbaa !9
  %129 = icmp ne i32 %128, 0
  %130 = xor i1 %129, true
  %131 = zext i1 %130 to i32
  store i32 %131, ptr %10, align 4, !tbaa !9
  %132 = load i32, ptr %11, align 4, !tbaa !9
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %11, align 4, !tbaa !9
  br label %19, !llvm.loop !32

134:                                              ; preds = %124, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %135 = load i32, ptr %13, align 4
  switch i32 %135, label %137 [
    i32 2, label %136
  ]

136:                                              ; preds = %134
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %137

137:                                              ; preds = %136, %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %138 = load ptr, ptr %5, align 8
  ret ptr %138
}

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

; 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) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @otfcc_readOtl_lookup(ptr noundef, i32 noundef, ptr noundef, i16 noundef zeroext, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree 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, !12, i64 4}
!14 = !{!"", !10, i64 0, !12, i64 4, !12, i64 6, !12, i64 8, !12, i64 10, !6, i64 16}
!15 = !{!14, !6, i64 16}
!16 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 8, !5}
!17 = !{!18, !10, i64 0}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!19 = !{!18, !6, i64 16}
!20 = !{!18, !10, i64 12}
!21 = !{!22, !24, i64 0}
!22 = !{!"", !23, i64 0, !23, i64 24, !23, i64 48}
!23 = !{!"", !24, i64 0, !24, i64 8, !6, i64 16}
!24 = !{!"long", !7, i64 0}
!25 = !{!22, !6, i64 16}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!29, !6, i64 56}
!29 = !{!"__caryll_elementinterface_table_OTL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!30 = distinct !{!30, !27}
!31 = distinct !{!31, !27}
!32 = distinct !{!32, !27}


; 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 ptr @otfcc_readOtl(ptr nocapture noundef readonly byval(%struct.otfcc_Packet) align 8 %0, ptr noundef %1, i32 noundef %2, i16 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i16, ptr %5, align 4
  %.not = icmp eq i16 %6, 0
  br i1 %.not, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq i32 %2, 1196643650
  %10 = icmp eq i32 %2, 1196445523
  %11 = select i1 %10, i32 32, i32 0
  %12 = select i1 %9, i32 16, i32 %11
  %13 = zext i16 %6 to i64
  br label %14

14:                                               ; preds = %.lr.ph, %.thread64
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %.thread64 ]
  %15 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %8, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %15, align 8, !tbaa !12
  %.not100 = icmp eq i32 %.sroa.0.0.copyload, %2
  br i1 %.not100, label %.preheader71.us.preheader, label %.thread64

.preheader71.us.preheader:                        ; preds = %14
  %.sroa.411.0..sroa_idx.le = getelementptr inbounds i8, ptr %15, i64 12
  %.sroa.411.0.copyload.le = load i32, ptr %.sroa.411.0..sroa_idx.le, align 4, !tbaa !12
  %.sroa.5.0..sroa_idx.le = getelementptr inbounds i8, ptr %15, i64 16
  %.sroa.5.0.copyload.le = load ptr, ptr %.sroa.5.0..sroa_idx.le, align 8, !tbaa !13
  %16 = tail call ptr @otfcc_readOtl_common(ptr noundef %.sroa.5.0.copyload.le, i32 noundef %.sroa.411.0.copyload.le, i32 noundef %12, ptr noundef %1)
  %.not56.us = icmp eq ptr %16, null
  br i1 %.not56.us, label %.critedge, label %.preheader.us, !llvm.loop !14

17:                                               ; preds = %.lr.ph.us, %17
  %18 = phi i64 [ 0, %.lr.ph.us ], [ %23, %17 ]
  %.077.us = phi i16 [ 0, %.lr.ph.us ], [ %22, %17 ]
  %19 = load ptr, ptr %26, align 8, !tbaa !16
  %20 = getelementptr inbounds ptr, ptr %19, i64 %18
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  tail call void @otfcc_readOtl_lookup(ptr noundef %.sroa.5.0.copyload.le, i32 noundef %.sroa.411.0.copyload.le, ptr noundef %21, i16 noundef zeroext %3, ptr noundef %1)
  %22 = add i16 %.077.us, 1
  %23 = zext i16 %22 to i64
  %24 = load i64, ptr %16, align 8, !tbaa !20
  %25 = icmp ugt i64 %24, %23
  br i1 %25, label %17, label %.critedge, !llvm.loop !21

.preheader.us:                                    ; preds = %.preheader71.us.preheader
  %.pre = load i64, ptr %16, align 8, !tbaa !20
  %.not90 = icmp eq i64 %.pre, 0
  br i1 %.not90, label %.critedge, label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.preheader.us
  %26 = getelementptr inbounds i8, ptr %16, i64 16
  br label %17

.thread64:                                        ; preds = %14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = icmp ult i64 %indvars.iv.next, %13
  br i1 %27, label %14, label %.critedge, !llvm.loop !22

.critedge:                                        ; preds = %.thread64, %17, %.preheader71.us.preheader, %.preheader.us, %4
  %28 = phi ptr [ null, %4 ], [ %16, %.preheader.us ], [ null, %.preheader71.us.preheader ], [ %16, %17 ], [ null, %.thread64 ]
  ret ptr %28
}

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

; Function Attrs: nounwind uwtable
declare hidden void @otfcc_readOtl_lookup(ptr noundef, i32 noundef, ptr noundef, i16 noundef zeroext, 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" }

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


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