; 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.VV = type { i64, i64, ptr }
%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

declare ptr @json_array_new(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @json_new_VVp(ptr noundef %0, ptr noundef %1) #2 {
  %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 ptr, align 8
  %10 = alloca [4 x i8], align 1
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = 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
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.table_fvar, ptr %14, i32 0, i32 2
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %86

18:                                               ; preds = %2
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.vf_Axes, ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.VV, ptr %22, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = icmp eq i64 %21, %24
  br i1 %25, label %26, label %86

26:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.vf_Axes, ptr %27, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %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 !12
  br label %31

31:                                               ; preds = %80, %26
  %32 = load i64, ptr %8, align 8, !tbaa !12
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.VV, ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = icmp ult i64 %32, %35
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.vf_Axes, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load i64, ptr %8, align 8, !tbaa !12
  %43 = getelementptr inbounds %struct.vf_Axis, ptr %41, i64 %42
  store ptr %43, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.vf_Axis, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !14
  %47 = and i32 %46, -16777216
  %48 = lshr i32 %47, 24
  %49 = trunc i32 %48 to i8
  store i8 %49, ptr %10, align 1, !tbaa !19
  %50 = getelementptr inbounds i8, ptr %10, i64 1
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.vf_Axis, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !14
  %54 = and i32 %53, 16711680
  %55 = lshr i32 %54, 16
  %56 = trunc i32 %55 to i8
  store i8 %56, ptr %50, align 1, !tbaa !19
  %57 = getelementptr inbounds i8, ptr %10, i64 2
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.vf_Axis, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !14
  %61 = and i32 %60, 65280
  %62 = lshr i32 %61, 8
  %63 = trunc i32 %62 to i8
  store i8 %63, ptr %57, align 1, !tbaa !19
  %64 = getelementptr inbounds i8, ptr %10, i64 3
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.vf_Axis, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !14
  %68 = and i32 %67, 255
  %69 = trunc i32 %68 to i8
  store i8 %69, ptr %64, align 1, !tbaa !19
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 0
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.VV, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = load i64, ptr %8, align 8, !tbaa !12
  %76 = getelementptr inbounds double, ptr %74, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !20
  %78 = call ptr @json_new_position(double noundef %77)
  %79 = call ptr @json_object_push_length(ptr noundef %70, i32 noundef 4, ptr noundef %71, ptr noundef %78)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %80

80:                                               ; preds = %38
  %81 = load i64, ptr %8, align 8, !tbaa !12
  %82 = add i64 %81, 1
  store i64 %82, ptr %8, align 8, !tbaa !12
  br label %31, !llvm.loop !21

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

86:                                               ; preds = %18, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.VV, ptr %87, i32 0, i32 0
  %89 = load i64, ptr %88, align 8, !tbaa !9
  %90 = call ptr @json_array_new(i64 noundef %89)
  store ptr %90, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !12
  br label %91

91:                                               ; preds = %108, %86
  %92 = load i64, ptr %13, align 8, !tbaa !12
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.VV, ptr %93, i32 0, i32 0
  %95 = load i64, ptr %94, align 8, !tbaa !9
  %96 = icmp ult i64 %92, %95
  br i1 %96, label %98, label %97

97:                                               ; preds = %91
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %111

98:                                               ; preds = %91
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.VV, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !13
  %103 = load i64, ptr %13, align 8, !tbaa !12
  %104 = getelementptr inbounds double, ptr %102, i64 %103
  %105 = load double, ptr %104, align 8, !tbaa !20
  %106 = call ptr @json_new_position(double noundef %105)
  %107 = call ptr @json_array_push(ptr noundef %99, ptr noundef %106)
  br label %108

108:                                              ; preds = %98
  %109 = load i64, ptr %13, align 8, !tbaa !12
  %110 = add i64 %109, 1
  store i64 %110, ptr %13, align 8, !tbaa !12
  br label %91, !llvm.loop !23

111:                                              ; preds = %97
  %112 = load ptr, ptr %12, align 8, !tbaa !5
  %113 = call ptr @preserialize(ptr noundef %112)
  store ptr %113, ptr %3, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %114

114:                                              ; preds = %111, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %115 = load ptr, ptr %3, align 8
  ret ptr %115
}

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

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

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

declare ptr @json_object_push_length(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

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 = { 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 = { 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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 16}
!14 = !{!15, !16, i64 0}
!15 = !{!"", !16, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !18, i64 32, !18, i64 34}
!16 = !{!"int", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{!17, !17, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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 }

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

; Function Attrs: mustprogress 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) local_unnamed_addr #1

declare ptr @json_array_new(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @json_new_VVp(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca [4 x i8], align 1
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = load i64, ptr %0, align 8, !tbaa !5
  %7 = icmp eq i64 %5, %6
  br i1 %7, label %8, label %39

8:                                                ; preds = %2
  %9 = tail call ptr @json_object_new(i64 noundef %5) #4
  %10 = load i64, ptr %0, align 8, !tbaa !5
  %.not34 = icmp eq i64 %10, 0
  br i1 %.not34, label %._crit_edge33, label %.lr.ph32

.lr.ph32:                                         ; preds = %8
  %11 = getelementptr inbounds i8, ptr %1, i64 24
  %12 = getelementptr inbounds i8, ptr %3, i64 1
  %13 = getelementptr inbounds i8, ptr %3, i64 2
  %14 = getelementptr inbounds i8, ptr %3, i64 3
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  br label %17

._crit_edge33:                                    ; preds = %17, %8
  %16 = call ptr @preserialize(ptr noundef %9)
  br label %53

17:                                               ; preds = %.lr.ph32, %17
  %.02730 = phi i64 [ 0, %.lr.ph32 ], [ %36, %17 ]
  %18 = load ptr, ptr %11, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.vf_Axis, ptr %18, i64 %.02730
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %20 = load i32, ptr %19, align 8, !tbaa !12
  %21 = lshr i32 %20, 24
  %22 = trunc nuw i32 %21 to i8
  store i8 %22, ptr %3, align 1, !tbaa !17
  %23 = load i32, ptr %19, align 8, !tbaa !12
  %24 = lshr i32 %23, 16
  %25 = trunc i32 %24 to i8
  store i8 %25, ptr %12, align 1, !tbaa !17
  %26 = load i32, ptr %19, align 8, !tbaa !12
  %27 = lshr i32 %26, 8
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %13, align 1, !tbaa !17
  %29 = load i32, ptr %19, align 8, !tbaa !12
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %14, align 1, !tbaa !17
  %31 = load ptr, ptr %15, align 8, !tbaa !11
  %32 = getelementptr inbounds double, ptr %31, i64 %.02730
  %33 = load double, ptr %32, align 8, !tbaa !18
  %34 = call ptr @json_new_position(double noundef %33)
  %35 = call ptr @json_object_push_length(ptr noundef %9, i32 noundef 4, ptr noundef nonnull %3, ptr noundef %34) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %36 = add nuw i64 %.02730, 1
  %37 = load i64, ptr %0, align 8, !tbaa !5
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %17, label %._crit_edge33, !llvm.loop !19

39:                                               ; preds = %2
  %40 = tail call ptr @json_array_new(i64 noundef %6) #4
  %41 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i64 %41, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %39
  %42 = getelementptr inbounds i8, ptr %0, i64 16
  br label %44

._crit_edge:                                      ; preds = %44, %39
  %43 = tail call ptr @preserialize(ptr noundef %40)
  br label %53

44:                                               ; preds = %.lr.ph, %44
  %.029 = phi i64 [ 0, %.lr.ph ], [ %50, %44 ]
  %45 = load ptr, ptr %42, align 8, !tbaa !11
  %46 = getelementptr inbounds double, ptr %45, i64 %.029
  %47 = load double, ptr %46, align 8, !tbaa !18
  %48 = tail call ptr @json_new_position(double noundef %47)
  %49 = tail call ptr @json_array_push(ptr noundef %40, ptr noundef %48) #4
  %50 = add nuw i64 %.029, 1
  %51 = load i64, ptr %0, align 8, !tbaa !5
  %52 = icmp ult i64 %50, %51
  br i1 %52, label %44, label %._crit_edge, !llvm.loop !21

53:                                               ; preds = %._crit_edge, %._crit_edge33
  %.026 = phi ptr [ %16, %._crit_edge33 ], [ %43, %._crit_edge ]
  ret ptr %.026
}

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @json_new_position(double noundef) local_unnamed_addr #3

declare ptr @json_object_push_length(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 = { 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, !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 = !{!6, !10, i64 16}
!12 = !{!13, !14, i64 0}
!13 = !{!"", !14, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !16, i64 32, !16, i64 34}
!14 = !{!"int", !8, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!"short", !8, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!15, !15, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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