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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @json_new_VV(ptr noundef byval(%struct.VV) align 8 %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 i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [4 x i8], align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.table_fvar, ptr %13, i32 0, i32 2
  store ptr %14, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %82

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

24:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.vf_Axes, ptr %25, i32 0, i32 0
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = call ptr @json_object_new(i64 noundef %27)
  store ptr %28, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !12
  br label %29

29:                                               ; preds = %76, %24
  %30 = load i64, ptr %7, align 8, !tbaa !12
  %31 = getelementptr inbounds %struct.VV, ptr %0, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = icmp ult i64 %30, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %79

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

76:                                               ; preds = %35
  %77 = load i64, ptr %7, align 8, !tbaa !12
  %78 = add i64 %77, 1
  store i64 %78, ptr %7, align 8, !tbaa !12
  br label %29, !llvm.loop !21

79:                                               ; preds = %34
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call ptr @preserialize(ptr noundef %80)
  store ptr %81, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %107

82:                                               ; preds = %17, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %83 = getelementptr inbounds %struct.VV, ptr %0, i32 0, i32 0
  %84 = load i64, ptr %83, align 8, !tbaa !9
  %85 = call ptr @json_array_new(i64 noundef %84)
  store ptr %85, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !12
  br label %86

86:                                               ; preds = %101, %82
  %87 = load i64, ptr %12, align 8, !tbaa !12
  %88 = getelementptr inbounds %struct.VV, ptr %0, i32 0, i32 0
  %89 = load i64, ptr %88, align 8, !tbaa !9
  %90 = icmp ult i64 %87, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %86
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %104

92:                                               ; preds = %86
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.VV, ptr %0, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !13
  %96 = load i64, ptr %12, align 8, !tbaa !12
  %97 = getelementptr inbounds double, ptr %95, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !20
  %99 = call ptr @json_new_position(double noundef %98)
  %100 = call ptr @json_array_push(ptr noundef %93, ptr noundef %99)
  br label %101

101:                                              ; preds = %92
  %102 = load i64, ptr %12, align 8, !tbaa !12
  %103 = add i64 %102, 1
  store i64 %103, ptr %12, align 8, !tbaa !12
  br label %86, !llvm.loop !23

104:                                              ; preds = %91
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = call ptr @preserialize(ptr noundef %105)
  store ptr %106, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %107

107:                                              ; preds = %104, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %108 = load ptr, ptr %3, align 8
  ret ptr %108
}

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

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 #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @json_new_VV(ptr nocapture noundef readonly byval(%struct.VV) align 8 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %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 %36

8:                                                ; preds = %2
  %9 = tail call ptr @json_object_new(i64 noundef %5) #4
  %.not28 = icmp eq i64 %5, 0
  br i1 %.not28, label %._crit_edge27, label %.lr.ph26

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

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

17:                                               ; preds = %.lr.ph26, %17
  %.02124 = phi i64 [ 0, %.lr.ph26 ], [ %35, %17 ]
  %18 = load ptr, ptr %10, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.vf_Axis, ptr %18, i64 %.02124
  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 %11, 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 %12, align 1, !tbaa !17
  %29 = load i32, ptr %19, align 8, !tbaa !12
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %13, align 1, !tbaa !17
  %31 = getelementptr inbounds double, ptr %15, i64 %.02124
  %32 = load double, ptr %31, align 8, !tbaa !18
  %33 = call ptr @json_new_position(double noundef %32)
  %34 = call ptr @json_object_push_length(ptr noundef %9, i32 noundef 4, ptr noundef nonnull %3, ptr noundef %33) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %35 = add nuw i64 %.02124, 1
  %exitcond29.not = icmp eq i64 %35, %5
  br i1 %exitcond29.not, label %._crit_edge27, label %17, !llvm.loop !19

36:                                               ; preds = %2
  %37 = tail call ptr @json_array_new(i64 noundef %6) #4
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %36
  %38 = getelementptr inbounds i8, ptr %0, i64 16
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  br label %41

._crit_edge:                                      ; preds = %41, %36
  %40 = tail call ptr @preserialize(ptr noundef %37)
  br label %47

41:                                               ; preds = %.lr.ph, %41
  %.023 = phi i64 [ 0, %.lr.ph ], [ %46, %41 ]
  %42 = getelementptr inbounds double, ptr %39, i64 %.023
  %43 = load double, ptr %42, align 8, !tbaa !18
  %44 = tail call ptr @json_new_position(double noundef %43)
  %45 = tail call ptr @json_array_push(ptr noundef %37, ptr noundef %44) #4
  %46 = add nuw i64 %.023, 1
  %exitcond.not = icmp eq i64 %46, %6
  br i1 %exitcond.not, label %._crit_edge, label %41, !llvm.loop !21

47:                                               ; preds = %._crit_edge, %._crit_edge27
  %.020 = phi ptr [ %16, %._crit_edge27 ], [ %40, %._crit_edge ]
  ret ptr %.020
}

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 = { 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, !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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass