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

; 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_subtable_gpos_cursive = 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_GposCursiveEntry = type { %struct.otfcc_Handle, %struct.otl_Anchor, %struct.otl_Anchor }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.otl_Anchor = type { i8, double, double }
%struct._json_value = type { ptr, i32, %union.anon.0, %union.anon.4 }
%union.anon.0 = type { %struct.anon.1 }
%struct.anon.1 = type { i32, ptr }
%union.anon.4 = type { ptr }
%struct.anon.2 = type { i32, ptr }
%struct._json_object_entry = type { ptr, i32, ptr }

@iSubtable_gpos_cursive = external dso_local constant %struct.__caryll_vectorinterface_subtable_gpos_cursive, align 8
@otfcc_iHandle = external constant %struct.otfcc_HandlePackage, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.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
define dso_local ptr @otl_gpos_parse_cursive(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca ptr, align 8
  %8 = alloca %struct.otl_GposCursiveEntry, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_subtable_gpos_cursive, ptr @iSubtable_gpos_cursive, i32 0, i32 6), align 8, !tbaa !9
  %10 = call ptr (...) %9()
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #4
  store i16 0, ptr %6, align 2, !tbaa !11
  br label %11

11:                                               ; preds = %98, %2
  %12 = load i16, ptr %6, align 2, !tbaa !11
  %13 = zext i16 %12 to i32
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._json_value, ptr %14, i32 0, i32 2
  %16 = getelementptr inbounds %struct.anon.2, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i32 %13, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #4
  br label %101

20:                                               ; preds = %11
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._json_value, ptr %21, i32 0, i32 2
  %23 = getelementptr inbounds %struct.anon.2, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = load i16, ptr %6, align 2, !tbaa !11
  %26 = zext i16 %25 to i64
  %27 = getelementptr inbounds %struct._json_object_entry, ptr %24, i64 %26
  %28 = getelementptr inbounds %struct._json_object_entry, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %97

31:                                               ; preds = %20
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._json_value, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds %struct.anon.2, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load i16, ptr %6, align 2, !tbaa !11
  %37 = zext i16 %36 to i64
  %38 = getelementptr inbounds %struct._json_object_entry, ptr %35, i64 %37
  %39 = getelementptr inbounds %struct._json_object_entry, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct._json_value, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !17
  %43 = icmp eq i32 %42, 1
  br i1 %43, label %44, label %97

44:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._json_value, ptr %45, i32 0, i32 2
  %47 = getelementptr inbounds %struct.anon.2, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i16, ptr %6, align 2, !tbaa !11
  %50 = zext i16 %49 to i64
  %51 = getelementptr inbounds %struct._json_object_entry, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct._json_object_entry, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._json_value, ptr %54, i32 0, i32 2
  %56 = getelementptr inbounds %struct.anon.2, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = load i16, ptr %6, align 2, !tbaa !11
  %59 = zext i16 %58 to i64
  %60 = getelementptr inbounds %struct._json_object_entry, ptr %57, i64 %59
  %61 = getelementptr inbounds %struct._json_object_entry, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 8, !tbaa !20
  %63 = zext i32 %62 to i64
  %64 = call ptr @sdsnewlen(ptr noundef %53, i64 noundef %63)
  store ptr %64, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_subtable_gpos_cursive, ptr @iSubtable_gpos_cursive, i32 0, i32 13), align 8, !tbaa !21
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.otl_GposCursiveEntry, ptr %8, i32 0, i32 0
  %68 = load ptr, ptr getelementptr inbounds (%struct.otfcc_HandlePackage, ptr @otfcc_iHandle, i32 0, i32 9), align 8, !tbaa !22
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = call { i64, ptr } %68(ptr noundef %69)
  %71 = getelementptr inbounds { i64, ptr }, ptr %67, i32 0, i32 0
  %72 = extractvalue { i64, ptr } %70, 0
  store i64 %72, ptr %71, align 8
  %73 = getelementptr inbounds { i64, ptr }, ptr %67, i32 0, i32 1
  %74 = extractvalue { i64, ptr } %70, 1
  store ptr %74, ptr %73, align 8
  %75 = getelementptr inbounds %struct.otl_GposCursiveEntry, ptr %8, i32 0, i32 1
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._json_value, ptr %76, i32 0, i32 2
  %78 = getelementptr inbounds %struct.anon.2, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = load i16, ptr %6, align 2, !tbaa !11
  %81 = zext i16 %80 to i64
  %82 = getelementptr inbounds %struct._json_object_entry, ptr %79, i64 %81
  %83 = getelementptr inbounds %struct._json_object_entry, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !14
  %85 = call ptr @json_obj_get(ptr noundef %84, ptr noundef @.str)
  call void @otl_parse_anchor(ptr dead_on_unwind writable sret(%struct.otl_Anchor) align 8 %75, ptr noundef %85)
  %86 = getelementptr inbounds %struct.otl_GposCursiveEntry, ptr %8, i32 0, i32 2
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._json_value, ptr %87, i32 0, i32 2
  %89 = getelementptr inbounds %struct.anon.2, ptr %88, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !13
  %91 = load i16, ptr %6, align 2, !tbaa !11
  %92 = zext i16 %91 to i64
  %93 = getelementptr inbounds %struct._json_object_entry, ptr %90, i64 %92
  %94 = getelementptr inbounds %struct._json_object_entry, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !14
  %96 = call ptr @json_obj_get(ptr noundef %95, ptr noundef @.str.1)
  call void @otl_parse_anchor(ptr dead_on_unwind writable sret(%struct.otl_Anchor) align 8 %86, ptr noundef %96)
  call void %65(ptr noundef %66, ptr noundef byval(%struct.otl_GposCursiveEntry) align 8 %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %97

97:                                               ; preds = %44, %31, %20
  br label %98

98:                                               ; preds = %97
  %99 = load i16, ptr %6, align 2, !tbaa !11
  %100 = add i16 %99, 1
  store i16 %100, ptr %6, align 2, !tbaa !11
  br label %11, !llvm.loop !24

101:                                              ; preds = %19
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %102
}

declare ptr @sdsnewlen(ptr noundef, i64 noundef) #2

declare void @otl_parse_anchor(ptr dead_on_unwind writable sret(%struct.otl_Anchor) align 8, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @json_obj_get(ptr noundef, ptr noundef) #3

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 = { 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, !6, i64 48}
!10 = !{!"__caryll_vectorinterface_subtable_gpos_cursive", !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}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"_json_object_entry", !6, i64 0, !16, i64 8, !6, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !16, i64 8}
!18 = !{!"_json_value", !6, i64 0, !16, i64 8, !7, i64 16, !7, i64 32}
!19 = !{!15, !6, i64 0}
!20 = !{!15, !16, i64 8}
!21 = !{!10, !6, i64 104}
!22 = !{!23, !6, i64 72}
!23 = !{!"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}
!24 = distinct !{!24, !25}
!25 = !{!"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_subtable_gpos_cursive = 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_GposCursiveEntry = type { %struct.otfcc_Handle, %struct.otl_Anchor, %struct.otl_Anchor }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.otl_Anchor = type { i8, double, double }
%struct._json_object_entry = type { ptr, i32, ptr }

@iSubtable_gpos_cursive = external dso_local local_unnamed_addr constant %struct.__caryll_vectorinterface_subtable_gpos_cursive, align 8
@otfcc_iHandle = external local_unnamed_addr constant %struct.otfcc_HandlePackage, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @otl_gpos_parse_cursive(ptr nocapture noundef readonly %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.otl_GposCursiveEntry, align 8
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @iSubtable_gpos_cursive, i64 48), align 8, !tbaa !5
  %5 = tail call ptr (...) %4() #3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !10
  %.not19 = icmp eq i32 %7, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @iSubtable_gpos_cursive, i64 104), align 8
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @otfcc_iHandle, i64 72), align 8
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  %13 = getelementptr inbounds i8, ptr %3, i64 40
  br label %14

._crit_edge:                                      ; preds = %42, %2
  ret ptr %5

14:                                               ; preds = %.lr.ph, %42
  %15 = phi i32 [ %7, %.lr.ph ], [ %43, %42 ]
  %.018 = phi i16 [ 0, %.lr.ph ], [ %44, %42 ]
  %16 = load ptr, ptr %8, align 8, !tbaa !10
  %17 = zext i16 %.018 to i64
  %18 = getelementptr inbounds %struct._json_object_entry, ptr %16, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %42, label %21

21:                                               ; preds = %14
  %22 = getelementptr inbounds i8, ptr %20, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %42

25:                                               ; preds = %21
  %26 = load ptr, ptr %18, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %18, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !17
  %29 = zext i32 %28 to i64
  %30 = call ptr @sdsnewlen(ptr noundef %26, i64 noundef %29) #3
  %31 = call { i64, ptr } %10(ptr noundef %30) #3
  %32 = extractvalue { i64, ptr } %31, 0
  store i64 %32, ptr %3, align 8
  %33 = extractvalue { i64, ptr } %31, 1
  store ptr %33, ptr %11, align 8
  %34 = load ptr, ptr %8, align 8, !tbaa !10
  %35 = getelementptr inbounds %struct._json_object_entry, ptr %34, i64 %17, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = call ptr @json_obj_get(ptr noundef %36, ptr noundef nonnull @.str)
  call void @otl_parse_anchor(ptr dead_on_unwind nonnull writable sret(%struct.otl_Anchor) align 8 %12, ptr noundef %37) #3
  %38 = load ptr, ptr %8, align 8, !tbaa !10
  %39 = getelementptr inbounds %struct._json_object_entry, ptr %38, i64 %17, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = call ptr @json_obj_get(ptr noundef %40, ptr noundef nonnull @.str.1)
  call void @otl_parse_anchor(ptr dead_on_unwind nonnull writable sret(%struct.otl_Anchor) align 8 %13, ptr noundef %41) #3
  call void %9(ptr noundef %5, ptr noundef nonnull byval(%struct.otl_GposCursiveEntry) align 8 %3) #3
  %.pre = load i32, ptr %6, align 8, !tbaa !10
  br label %42

42:                                               ; preds = %14, %21, %25
  %43 = phi i32 [ %15, %14 ], [ %15, %21 ], [ %.pre, %25 ]
  %44 = add i16 %.018, 1
  %45 = zext i16 %44 to i32
  %46 = icmp ugt i32 %43, %45
  br i1 %46, label %14, label %._crit_edge, !llvm.loop !18
}

declare ptr @sdsnewlen(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @otl_parse_anchor(ptr dead_on_unwind writable sret(%struct.otl_Anchor) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @json_obj_get(ptr noundef, ptr noundef) local_unnamed_addr #2

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 = { 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 #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, !7, i64 48}
!6 = !{!"__caryll_vectorinterface_subtable_gpos_cursive", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"_json_object_entry", !7, i64 0, !13, i64 8, !7, i64 16}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !13, i64 8}
!15 = !{!"_json_value", !7, i64 0, !13, i64 8, !8, i64 16, !8, i64 32}
!16 = !{!12, !7, i64 0}
!17 = !{!12, !13, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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