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

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

@otl_iClassDef = external constant %struct.__otfcc_IClassDef, align 8
@otfcc_iHandle = external constant %struct.otfcc_HandlePackage, align 8

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

14:                                               ; preds = %99, %2
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %26

17:                                               ; preds = %14
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %26

20:                                               ; preds = %17
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = getelementptr inbounds %struct.otfcc_Packet, ptr %0, i32 0, i32 1
  %23 = load i16, ptr %22, align 4, !tbaa !11
  %24 = zext i16 %23 to i32
  %25 = icmp slt i32 %21, %24
  br label %26

26:                                               ; preds = %20, %17, %14
  %27 = phi i1 [ false, %17 ], [ false, %14 ], [ %25, %20 ]
  br i1 %27, label %29, label %28

28:                                               ; preds = %26
  store i32 2, ptr %8, align 4
  br label %106

29:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #4
  %30 = getelementptr inbounds %struct.otfcc_Packet, ptr %0, i32 0, i32 5
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %31, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %34, i64 24, i1 false), !tbaa.struct !15
  br label %35

35:                                               ; preds = %91, %29
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  store i32 5, ptr %8, align 4
  br label %96

39:                                               ; preds = %35
  %40 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %9, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !16
  %42 = icmp eq i32 %41, 1414744373
  br i1 %42, label %43, label %90

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

44:                                               ; preds = %86, %43
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 8, ptr %8, align 4
  br label %87

48:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %49 = load ptr, ptr getelementptr inbounds (%struct.__otfcc_IClassDef, ptr @otl_iClassDef, i32 0, i32 6), align 8, !tbaa !18
  %50 = call ptr (...) %49()
  store ptr %50, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #4
  store i16 0, ptr %12, align 2, !tbaa !20
  br label %51

51:                                               ; preds = %81, %48
  %52 = load i16, ptr %12, align 2, !tbaa !20
  %53 = zext i16 %52 to i32
  %54 = mul nsw i32 %53, 2
  %55 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %9, i32 0, i32 3
  %56 = load i32, ptr %55, align 4, !tbaa !21
  %57 = icmp ult i32 %54, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %51
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #4
  br label %84

59:                                               ; preds = %51
  %60 = load ptr, ptr getelementptr inbounds (%struct.__otfcc_IClassDef, ptr @otl_iClassDef, i32 0, i32 8), align 8, !tbaa !22
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = load ptr, ptr getelementptr inbounds (%struct.otfcc_HandlePackage, ptr @otfcc_iHandle, i32 0, i32 8), align 8, !tbaa !23
  %63 = load i16, ptr %12, align 2, !tbaa !20
  %64 = call { i64, ptr } %62(i16 noundef zeroext %63)
  %65 = getelementptr inbounds { i64, ptr }, ptr %13, i32 0, i32 0
  %66 = extractvalue { i64, ptr } %64, 0
  store i64 %66, ptr %65, align 8
  %67 = getelementptr inbounds { i64, ptr }, ptr %13, i32 0, i32 1
  %68 = extractvalue { i64, ptr } %64, 1
  store ptr %68, ptr %67, align 8
  %69 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %9, i32 0, i32 4
  %70 = load ptr, ptr %69, align 8, !tbaa !25
  %71 = load i16, ptr %12, align 2, !tbaa !20
  %72 = zext i16 %71 to i32
  %73 = mul nsw i32 %72, 2
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %70, i64 %74
  %76 = call zeroext i16 @read_16u(ptr noundef %75)
  %77 = getelementptr inbounds { i64, ptr }, ptr %13, i32 0, i32 0
  %78 = load i64, ptr %77, align 8
  %79 = getelementptr inbounds { i64, ptr }, ptr %13, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8
  call void %60(ptr noundef %61, i64 %78, ptr %80, i16 noundef zeroext %76)
  br label %81

81:                                               ; preds = %59
  %82 = load i16, ptr %12, align 2, !tbaa !20
  %83 = add i16 %82, 1
  store i16 %83, ptr %12, align 2, !tbaa !20
  br label %51, !llvm.loop !26

84:                                               ; preds = %58
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %85, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %87

86:                                               ; No predecessors!
  store i32 0, ptr %10, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %44, !llvm.loop !28

87:                                               ; preds = %84, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %88 = load i32, ptr %8, align 4
  switch i32 %88, label %96 [
    i32 8, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89, %39
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %5, align 4, !tbaa !9
  %93 = icmp ne i32 %92, 0
  %94 = xor i1 %93, true
  %95 = zext i1 %94 to i32
  store i32 %95, ptr %5, align 4, !tbaa !9
  br label %35, !llvm.loop !29

96:                                               ; preds = %87, %38
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #4
  %97 = load i32, ptr %8, align 4
  switch i32 %97, label %106 [
    i32 5, label %98
  ]

98:                                               ; preds = %96
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %5, align 4, !tbaa !9
  %101 = icmp ne i32 %100, 0
  %102 = xor i1 %101, true
  %103 = zext i1 %102 to i32
  store i32 %103, ptr %5, align 4, !tbaa !9
  %104 = load i32, ptr %6, align 4, !tbaa !9
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %6, align 4, !tbaa !9
  br label %14, !llvm.loop !30

106:                                              ; preds = %96, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %107 = load i32, ptr %8, align 4
  switch i32 %107, label %111 [
    i32 2, label %108
    i32 1, label %109
  ]

108:                                              ; preds = %106
  store ptr null, ptr %3, align 8
  br label %109

109:                                              ; preds = %108, %106
  %110 = load ptr, ptr %3, align 8
  ret ptr %110

111:                                              ; preds = %106
  unreachable
}

; 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: inlinehint nounwind uwtable
declare hidden zeroext i16 @read_16u(ptr noundef) #3

; 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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"", !10, i64 0, !13, i64 4, !13, i64 6, !13, i64 8, !13, i64 10, !6, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{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}
!16 = !{!17, !10, i64 0}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!18 = !{!19, !6, i64 48}
!19 = !{!"__otfcc_IClassDef", !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}
!20 = !{!13, !13, i64 0}
!21 = !{!17, !10, i64 12}
!22 = !{!19, !6, i64 64}
!23 = !{!24, !6, i64 64}
!24 = !{!"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}
!25 = !{!17, !6, i64 16}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}
!29 = distinct !{!29, !27}
!30 = distinct !{!30, !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_IClassDef = type { 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.otfcc_Packet = type { i32, i16, i16, i16, i16, ptr }
%struct.otfcc_PacketPiece = type { i32, i32, i32, i32, ptr }

@otl_iClassDef = external local_unnamed_addr constant %struct.__otfcc_IClassDef, align 8
@otfcc_iHandle = external local_unnamed_addr constant %struct.otfcc_HandlePackage, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @otfcc_readTSI5(ptr nocapture noundef readonly byval(%struct.otfcc_Packet) align 8 %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i16, ptr %3, align 4
  %.not40.not = icmp eq i16 %4, 0
  br i1 %.not40.not, label %.critedge, label %.lr.ph43

.lr.ph43:                                         ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr getelementptr inbounds (i8, ptr @otl_iClassDef, i64 48), align 8
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @otl_iClassDef, i64 64), align 8
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @otfcc_iHandle, i64 64), align 8
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  %9 = zext i16 %4 to i64
  br label %10

10:                                               ; preds = %.lr.ph43, %.thread
  %indvars.iv = phi i64 [ 0, %.lr.ph43 ], [ %indvars.iv.next, %.thread ]
  %11 = getelementptr inbounds %struct.otfcc_PacketPiece, ptr %.pre, i64 %indvars.iv
  %.sroa.08.0.copyload = load i32, ptr %11, align 8, !tbaa !12
  %.sroa.08.0.copyload.fr = freeze i32 %.sroa.08.0.copyload
  %12 = icmp eq i32 %.sroa.08.0.copyload.fr, 1414744373
  br i1 %12, label %.split38.us, label %.thread, !llvm.loop !13

.split38.us:                                      ; preds = %10
  %.sroa.49.0..sroa_idx.le = getelementptr inbounds i8, ptr %11, i64 12
  %.sroa.49.0.copyload.le = load i32, ptr %.sroa.49.0..sroa_idx.le, align 4, !tbaa !12
  %.sroa.5.0..sroa_idx.le = getelementptr inbounds i8, ptr %11, i64 16
  %.sroa.5.0.copyload.le = load ptr, ptr %.sroa.5.0..sroa_idx.le, align 8, !tbaa !15
  %13 = tail call ptr (...) %6() #2
  %.not46 = icmp eq i32 %.sroa.49.0.copyload.le, 0
  br i1 %.not46, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.split38.us, %.lr.ph
  %14 = phi i32 [ %23, %.lr.ph ], [ 0, %.split38.us ]
  %.02439 = phi i16 [ %21, %.lr.ph ], [ 0, %.split38.us ]
  %15 = tail call { i64, ptr } %8(i16 noundef zeroext %.02439) #2
  %16 = extractvalue { i64, ptr } %15, 0
  %17 = extractvalue { i64, ptr } %15, 1
  %18 = zext nneg i32 %14 to i64
  %19 = getelementptr inbounds i8, ptr %.sroa.5.0.copyload.le, i64 %18
  %20 = tail call zeroext i16 @read_16u(ptr noundef %19)
  tail call void %7(ptr noundef %13, i64 %16, ptr %17, i16 noundef zeroext %20) #2
  %21 = add i16 %.02439, 1
  %22 = zext i16 %21 to i32
  %23 = shl nuw nsw i32 %22, 1
  %24 = icmp ult i32 %23, %.sroa.49.0.copyload.le
  br i1 %24, label %.lr.ph, label %.critedge, !llvm.loop !16

.thread:                                          ; preds = %10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not = icmp ult i64 %indvars.iv.next, %9
  br i1 %.not, label %10, label %.critedge, !llvm.loop !17

.critedge:                                        ; preds = %.thread, %.lr.ph, %.split38.us, %2
  %spec.select = phi ptr [ null, %2 ], [ %13, %.split38.us ], [ %13, %.lr.ph ], [ null, %.thread ]
  ret ptr %spec.select
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @read_16u(ptr 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 = { 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 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; 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