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

; 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.table_fvar = type { i16, i16, %struct.vf_Axes, %struct.fvar_InstanceList, ptr }
%struct.vf_Axes = type { i64, i64, ptr }
%struct.fvar_InstanceList = type { i64, i64, ptr }
%struct.vq_Region = type { i16, [0 x %struct.vq_AxisSpan] }
%struct.vq_AxisSpan = type { double, double, double }
%struct.vf_Axis = type { i32, double, double, double, i16, i16 }

; 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

declare ptr @json_object_new(i64 noundef) #1

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

declare ptr @json_array_new(i64 noundef) #1

declare ptr @json_array_push(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @json_new_VQRegion_Explicit(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.table_fvar, ptr %12, i32 0, i32 2
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %59

16:                                               ; preds = %2
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.vf_Axes, ptr %17, i32 0, i32 0
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.vq_Region, ptr %20, i32 0, i32 0
  %22 = load i16, ptr %21, align 8, !tbaa !12
  %23 = zext i16 %22 to i64
  %24 = icmp eq i64 %19, %23
  br i1 %24, label %25, label %59

25:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.vq_Region, ptr %26, i32 0, i32 0
  %28 = load i16, ptr %27, align 8, !tbaa !12
  %29 = zext i16 %28 to i64
  %30 = call ptr @json_object_new(i64 noundef %29)
  store ptr %30, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !14
  br label %31

31:                                               ; preds = %54, %25
  %32 = load i64, ptr %8, align 8, !tbaa !14
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.vq_Region, ptr %33, i32 0, i32 0
  %35 = load i16, ptr %34, align 8, !tbaa !12
  %36 = zext i16 %35 to i64
  %37 = icmp ult i64 %32, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %57

39:                                               ; preds = %31
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.vf_Axes, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load i64, ptr %8, align 8, !tbaa !14
  %45 = getelementptr inbounds %struct.vf_Axis, ptr %43, i64 %44
  %46 = getelementptr inbounds %struct.vf_Axis, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !16
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.vq_Region, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %8, align 8, !tbaa !14
  %51 = getelementptr inbounds [0 x %struct.vq_AxisSpan], ptr %49, i64 0, i64 %50
  %52 = call ptr @json_new_VQAxisSpan(ptr noundef %51)
  %53 = call ptr @json_object_push_tag(ptr noundef %40, i32 noundef %47, ptr noundef %52)
  br label %54

54:                                               ; preds = %39
  %55 = load i64, ptr %8, align 8, !tbaa !14
  %56 = add i64 %55, 1
  store i64 %56, ptr %8, align 8, !tbaa !14
  br label %31, !llvm.loop !20

57:                                               ; preds = %38
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %58, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %86

59:                                               ; preds = %16, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.vq_Region, ptr %60, i32 0, i32 0
  %62 = load i16, ptr %61, align 8, !tbaa !12
  %63 = zext i16 %62 to i64
  %64 = call ptr @json_array_new(i64 noundef %63)
  store ptr %64, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !14
  br label %65

65:                                               ; preds = %81, %59
  %66 = load i64, ptr %11, align 8, !tbaa !14
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.vq_Region, ptr %67, i32 0, i32 0
  %69 = load i16, ptr %68, align 8, !tbaa !12
  %70 = zext i16 %69 to i64
  %71 = icmp ult i64 %66, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %65
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %84

73:                                               ; preds = %65
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.vq_Region, ptr %75, i32 0, i32 1
  %77 = load i64, ptr %11, align 8, !tbaa !14
  %78 = getelementptr inbounds [0 x %struct.vq_AxisSpan], ptr %76, i64 0, i64 %77
  %79 = call ptr @json_new_VQAxisSpan(ptr noundef %78)
  %80 = call ptr @json_array_push(ptr noundef %74, ptr noundef %79)
  br label %81

81:                                               ; preds = %73
  %82 = load i64, ptr %11, align 8, !tbaa !14
  %83 = add i64 %82, 1
  store i64 %83, ptr %11, align 8, !tbaa !14
  br label %65, !llvm.loop !22

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

86:                                               ; preds = %84, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %87 = load ptr, ptr %3, align 8
  ret ptr %87
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @json_new_VQAxisSpan(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!17, !18, i64 0}
!17 = !{!"", !18, i64 0, !19, i64 8, !19, i64 16, !19, i64 24, !13, i64 32, !13, i64 34}
!18 = !{!"int", !7, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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.vf_Axis = type { i32, double, double, double, i16, i16 }
%struct.vq_AxisSpan = type { double, double, double }

declare ptr @json_object_new(i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @json_object_push_tag(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @json_array_new(i64 noundef) local_unnamed_addr #0

declare ptr @json_array_push(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @json_new_VQRegion_Explicit(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = load i16, ptr %0, align 8, !tbaa !11
  %6 = zext i16 %5 to i64
  %7 = icmp eq i64 %4, %6
  br i1 %7, label %8, label %24

8:                                                ; preds = %2
  %9 = tail call ptr @json_object_new(i64 noundef %4) #3
  %10 = load i16, ptr %0, align 8, !tbaa !11
  %.not29 = icmp eq i16 %10, 0
  br i1 %.not29, label %.loopexit, label %.lr.ph28

.lr.ph28:                                         ; preds = %8
  %11 = getelementptr inbounds i8, ptr %1, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  br label %13

13:                                               ; preds = %.lr.ph28, %13
  %.02327 = phi i64 [ 0, %.lr.ph28 ], [ %20, %13 ]
  %14 = load ptr, ptr %11, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.vf_Axis, ptr %14, i64 %.02327
  %16 = load i32, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds [0 x %struct.vq_AxisSpan], ptr %12, i64 0, i64 %.02327
  %18 = tail call ptr @json_new_VQAxisSpan(ptr noundef nonnull %17)
  %19 = tail call ptr @json_object_push_tag(ptr noundef %9, i32 noundef %16, ptr noundef %18)
  %20 = add nuw nsw i64 %.02327, 1
  %21 = load i16, ptr %0, align 8, !tbaa !11
  %22 = zext i16 %21 to i64
  %23 = icmp ult i64 %20, %22
  br i1 %23, label %13, label %.loopexit, !llvm.loop !18

24:                                               ; preds = %2
  %25 = tail call ptr @json_array_new(i64 noundef %6) #3
  %26 = load i16, ptr %0, align 8, !tbaa !11
  %.not = icmp eq i16 %26, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %24
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  br label %28

28:                                               ; preds = %.lr.ph, %28
  %.026 = phi i64 [ 0, %.lr.ph ], [ %32, %28 ]
  %29 = getelementptr inbounds [0 x %struct.vq_AxisSpan], ptr %27, i64 0, i64 %.026
  %30 = tail call ptr @json_new_VQAxisSpan(ptr noundef nonnull %29)
  %31 = tail call ptr @json_array_push(ptr noundef %25, ptr noundef %30) #3
  %32 = add nuw nsw i64 %.026, 1
  %33 = load i16, ptr %0, align 8, !tbaa !11
  %34 = zext i16 %33 to i64
  %35 = icmp ult i64 %32, %34
  br i1 %35, label %28, label %.loopexit, !llvm.loop !20

.loopexit:                                        ; preds = %28, %13, %24, %8
  %.022 = phi ptr [ %9, %8 ], [ %25, %24 ], [ %9, %13 ], [ %25, %28 ]
  ret ptr %.022
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @json_new_VQAxisSpan(ptr noundef) local_unnamed_addr #2

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


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