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

; 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_single = 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_GposSingleEntry = type { %struct.otfcc_Handle, %struct.otl_PositionValue }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.otl_PositionValue = type { double, double, 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_single = external dso_local constant %struct.__caryll_vectorinterface_subtable_gpos_single, align 8
@otfcc_iHandle = external constant %struct.otfcc_HandlePackage, align 8

; 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_single(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_GposSingleEntry, 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) #3
  %9 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_subtable_gpos_single, ptr @iSubtable_gpos_single, 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) #3
  store i16 0, ptr %6, align 2, !tbaa !11
  br label %11

11:                                               ; preds = %86, %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) #3
  br label %89

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 %85

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 %85

44:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %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_single, ptr @iSubtable_gpos_single, i32 0, i32 13), align 8, !tbaa !21
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.otl_GposSingleEntry, 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_GposSingleEntry, 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
  call void @gpos_parse_value(ptr dead_on_unwind writable sret(%struct.otl_PositionValue) align 8 %75, ptr noundef %84)
  call void %65(ptr noundef %66, ptr noundef byval(%struct.otl_GposSingleEntry) align 8 %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %85

85:                                               ; preds = %44, %31, %20
  br label %86

86:                                               ; preds = %85
  %87 = load i16, ptr %6, align 2, !tbaa !11
  %88 = add i16 %87, 1
  store i16 %88, ptr %6, align 2, !tbaa !11
  br label %11, !llvm.loop !24

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

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

declare void @gpos_parse_value(ptr dead_on_unwind writable sret(%struct.otl_PositionValue) align 8, 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 = { "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, !6, i64 48}
!10 = !{!"__caryll_vectorinterface_subtable_gpos_single", !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_single = 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_GposSingleEntry = type { %struct.otfcc_Handle, %struct.otl_PositionValue }
%struct.otfcc_Handle = type { i32, i16, ptr }
%struct.otl_PositionValue = type { double, double, double, double }
%struct._json_object_entry = type { ptr, i32, ptr }

@iSubtable_gpos_single = external dso_local local_unnamed_addr constant %struct.__caryll_vectorinterface_subtable_gpos_single, align 8
@otfcc_iHandle = external local_unnamed_addr constant %struct.otfcc_HandlePackage, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @otl_gpos_parse_single(ptr nocapture noundef readonly %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.otl_GposSingleEntry, align 8
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @iSubtable_gpos_single, i64 48), align 8, !tbaa !5
  %5 = tail call ptr (...) %4() #2
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !10
  %.not17 = icmp eq i32 %7, 0
  br i1 %.not17, 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_single, 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
  br label %13

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

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

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

24:                                               ; preds = %20
  %25 = load ptr, ptr %17, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %17, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !17
  %28 = zext i32 %27 to i64
  %29 = call ptr @sdsnewlen(ptr noundef %25, i64 noundef %28) #2
  %30 = call { i64, ptr } %10(ptr noundef %29) #2
  %31 = extractvalue { i64, ptr } %30, 0
  store i64 %31, ptr %3, align 8
  %32 = extractvalue { i64, ptr } %30, 1
  store ptr %32, ptr %11, align 8
  %33 = load ptr, ptr %8, align 8, !tbaa !10
  %34 = getelementptr inbounds %struct._json_object_entry, ptr %33, i64 %16, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  call void @gpos_parse_value(ptr dead_on_unwind nonnull writable sret(%struct.otl_PositionValue) align 8 %12, ptr noundef %35) #2
  call void %9(ptr noundef %5, ptr noundef nonnull byval(%struct.otl_GposSingleEntry) align 8 %3) #2
  %.pre = load i32, ptr %6, align 8, !tbaa !10
  br label %36

36:                                               ; preds = %13, %20, %24
  %37 = phi i32 [ %14, %13 ], [ %14, %20 ], [ %.pre, %24 ]
  %38 = add i16 %.016, 1
  %39 = zext i16 %38 to i32
  %40 = icmp ugt i32 %37, %39
  br i1 %40, label %13, label %._crit_edge, !llvm.loop !18
}

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

declare void @gpos_parse_value(ptr dead_on_unwind writable sret(%struct.otl_PositionValue) align 8, 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 = { "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 48}
!6 = !{!"__caryll_vectorinterface_subtable_gpos_single", !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