; LLVM IR from marcobambini/gravity :: src/shared (gravity_value)

; 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.gravity_value_t = type { ptr, %union.anon }
%union.anon = type { i64 }
%struct.gravity_closure_s = type { ptr, %struct.gravity_gc_s, ptr, ptr, ptr, ptr, i32 }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }
%struct.gravity_string_t = type { ptr, %struct.gravity_gc_s, ptr, i32, i32, i32 }
%struct.gravity_list_t = type { ptr, %struct.gravity_gc_s, %struct.gravity_value_r }
%struct.gravity_value_r = type { i64, i64, ptr }
%struct.gravity_map_t = type { ptr, %struct.gravity_gc_s, ptr }

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@gravity_class_class = external global ptr, align 8
@gravity_class_null = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@gravity_class_function = external global ptr, align 8
@gravity_class_closure = external global ptr, align 8
@gravity_class_string = external global ptr, align 8
@gravity_class_int = external global ptr, align 8
@gravity_class_float = external global ptr, align 8
@gravity_class_bool = external global ptr, align 8
@gravity_class_fiber = external global ptr, align 8
@.str.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [4 x i8], align 1
@gravity_class_instance = external global ptr, align 8
@gravity_class_range = external global ptr, align 8
@gravity_class_list = external global ptr, align 8
@gravity_class_map = external global ptr, align 8
@__PRETTY_FUNCTION__.gravity_value_serialize = external hidden unnamed_addr constant [70 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

declare void @gravity_hash_iterate(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local void @gravity_class_serialize(ptr noundef, ptr noundef) #4

declare void @json_begin_object(ptr noundef, ptr noundef) #2

declare void @json_add_cstring(ptr noundef, ptr noundef, ptr noundef) #2

declare void @json_add_int(ptr noundef, ptr noundef, i64 noundef) #2

declare void @json_add_bool(ptr noundef, ptr noundef, i1 noundef zeroext) #2

declare void @json_begin_array(ptr noundef, ptr noundef) #2

declare void @json_end_array(ptr noundef) #2

declare void @json_end_object(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @gravity_function_serialize(ptr noundef, ptr noundef) #4

declare void @json_add_double(ptr noundef, ptr noundef, double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @gravity_instance_serialize(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @gravity_value_serialize(ptr noundef %0, ptr %1, i64 %2, ptr noundef %3) #4 {
  %5 = alloca %struct.gravity_value_t, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca %struct.gravity_value_t, align 8
  %13 = alloca ptr, align 8
  %14 = getelementptr inbounds { ptr, i64 }, ptr %5, i32 0, i32 0
  store ptr %1, ptr %14, align 8
  %15 = getelementptr inbounds { ptr, i64 }, ptr %5, i32 0, i32 1
  store i64 %2, ptr %15, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %3, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr @gravity_class_null, align 8, !tbaa !5
  %19 = icmp eq ptr %17, %18
  br i1 %19, label %20, label %27

20:                                               ; preds = %4
  %21 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %22 = load i64, ptr %21, align 8, !tbaa !11
  %23 = icmp eq i64 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %20
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_add_null(ptr noundef %25, ptr noundef %26)
  br label %218

27:                                               ; preds = %20, %4
  %28 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr @gravity_class_null, align 8, !tbaa !5
  %31 = icmp eq ptr %29, %30
  br i1 %31, label %32, label %47

32:                                               ; preds = %27
  %33 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %34 = load i64, ptr %33, align 8, !tbaa !11
  %35 = icmp eq i64 %34, 1
  br i1 %35, label %36, label %47

36:                                               ; preds = %32
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call zeroext i1 @json_option_isset(ptr noundef %37, i32 noundef 8)
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_add_null(ptr noundef %40, ptr noundef %41)
  br label %46

42:                                               ; preds = %36
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_begin_object(ptr noundef %43, ptr noundef %44)
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  call void @json_end_object(ptr noundef %45)
  br label %46

46:                                               ; preds = %42, %39
  br label %218

47:                                               ; preds = %32, %27
  %48 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = load ptr, ptr @gravity_class_bool, align 8, !tbaa !5
  %51 = icmp eq ptr %49, %50
  br i1 %51, label %52, label %61

52:                                               ; preds = %47
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !11
  %57 = icmp eq i64 %56, 0
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 0, i32 1
  %60 = icmp ne i32 %59, 0
  call void @json_add_bool(ptr noundef %53, ptr noundef %54, i1 noundef zeroext %60)
  br label %218

61:                                               ; preds = %47
  %62 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  %65 = icmp eq ptr %63, %64
  br i1 %65, label %66, label %71

66:                                               ; preds = %61
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %70 = load i64, ptr %69, align 8, !tbaa !11
  call void @json_add_int(ptr noundef %67, ptr noundef %68, i64 noundef %70)
  br label %218

71:                                               ; preds = %61
  %72 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !9
  %74 = load ptr, ptr @gravity_class_float, align 8, !tbaa !5
  %75 = icmp eq ptr %73, %74
  br i1 %75, label %76, label %81

76:                                               ; preds = %71
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %80 = load double, ptr %79, align 8, !tbaa !11
  call void @json_add_double(ptr noundef %77, ptr noundef %78, double noundef %80)
  br label %218

81:                                               ; preds = %71
  %82 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  %84 = load ptr, ptr @gravity_class_function, align 8, !tbaa !5
  %85 = icmp eq ptr %83, %84
  br i1 %85, label %86, label %92

86:                                               ; preds = %81
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_set_label(ptr noundef %87, ptr noundef %88)
  %89 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !11
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  call void @gravity_function_serialize(ptr noundef %90, ptr noundef %91)
  br label %218

92:                                               ; preds = %81
  %93 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !9
  %95 = load ptr, ptr @gravity_class_closure, align 8, !tbaa !5
  %96 = icmp eq ptr %94, %95
  br i1 %96, label %97, label %105

97:                                               ; preds = %92
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_set_label(ptr noundef %98, ptr noundef %99)
  %100 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %101 = load ptr, ptr %100, align 8, !tbaa !11
  %102 = getelementptr inbounds %struct.gravity_closure_s, ptr %101, i32 0, i32 3
  %103 = load ptr, ptr %102, align 8, !tbaa !12
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  call void @gravity_function_serialize(ptr noundef %103, ptr noundef %104)
  br label %218

105:                                              ; preds = %92
  %106 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !9
  %108 = load ptr, ptr @gravity_class_class, align 8, !tbaa !5
  %109 = icmp eq ptr %107, %108
  br i1 %109, label %110, label %116

110:                                              ; preds = %105
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_set_label(ptr noundef %111, ptr noundef %112)
  %113 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %114 = load ptr, ptr %113, align 8, !tbaa !11
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  call void @gravity_class_serialize(ptr noundef %114, ptr noundef %115)
  br label %218

116:                                              ; preds = %105
  %117 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !9
  %119 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  %120 = icmp eq ptr %118, %119
  br i1 %120, label %121, label %133

121:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %122 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %123 = load ptr, ptr %122, align 8, !tbaa !11
  store ptr %123, ptr %8, align 8, !tbaa !5
  %124 = load ptr, ptr %7, align 8, !tbaa !5
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = load ptr, ptr %8, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.gravity_string_t, ptr %126, i32 0, i32 2
  %128 = load ptr, ptr %127, align 8, !tbaa !17
  %129 = load ptr, ptr %8, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.gravity_string_t, ptr %129, i32 0, i32 4
  %131 = load i32, ptr %130, align 4, !tbaa !19
  %132 = zext i32 %131 to i64
  call void @json_add_string(ptr noundef %124, ptr noundef %125, ptr noundef %128, i64 noundef %132)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %218

133:                                              ; preds = %116
  %134 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !9
  %136 = load ptr, ptr @gravity_class_list, align 8, !tbaa !5
  %137 = icmp eq ptr %135, %136
  br i1 %137, label %138, label %169

138:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %139 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %140 = load ptr, ptr %139, align 8, !tbaa !11
  store ptr %140, ptr %9, align 8, !tbaa !5
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_begin_array(ptr noundef %141, ptr noundef %142)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.gravity_list_t, ptr %143, i32 0, i32 2
  %145 = getelementptr inbounds %struct.gravity_value_r, ptr %144, i32 0, i32 0
  %146 = load i64, ptr %145, align 8, !tbaa !20
  store i64 %146, ptr %10, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !24
  br label %147

147:                                              ; preds = %164, %138
  %148 = load i64, ptr %11, align 8, !tbaa !24
  %149 = load i64, ptr %10, align 8, !tbaa !24
  %150 = icmp ult i64 %148, %149
  br i1 %150, label %152, label %151

151:                                              ; preds = %147
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %167

152:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  %153 = load ptr, ptr %9, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.gravity_list_t, ptr %153, i32 0, i32 2
  %155 = getelementptr inbounds %struct.gravity_value_r, ptr %154, i32 0, i32 2
  %156 = load ptr, ptr %155, align 8, !tbaa !25
  %157 = load i64, ptr %11, align 8, !tbaa !24
  %158 = getelementptr inbounds %struct.gravity_value_t, ptr %156, i64 %157
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %158, i64 16, i1 false), !tbaa.struct !26
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = getelementptr inbounds { ptr, i64 }, ptr %12, i32 0, i32 0
  %161 = load ptr, ptr %160, align 8
  %162 = getelementptr inbounds { ptr, i64 }, ptr %12, i32 0, i32 1
  %163 = load i64, ptr %162, align 8
  call void @gravity_value_serialize(ptr noundef null, ptr %161, i64 %163, ptr noundef %159)
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  br label %164

164:                                              ; preds = %152
  %165 = load i64, ptr %11, align 8, !tbaa !24
  %166 = add i64 %165, 1
  store i64 %166, ptr %11, align 8, !tbaa !24
  br label %147, !llvm.loop !27

167:                                              ; preds = %151
  %168 = load ptr, ptr %7, align 8, !tbaa !5
  call void @json_end_array(ptr noundef %168)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %218

169:                                              ; preds = %133
  %170 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %171 = load ptr, ptr %170, align 8, !tbaa !9
  %172 = load ptr, ptr @gravity_class_map, align 8, !tbaa !5
  %173 = icmp eq ptr %171, %172
  br i1 %173, label %174, label %189

174:                                              ; preds = %169
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %175 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %176 = load ptr, ptr %175, align 8, !tbaa !11
  store ptr %176, ptr %13, align 8, !tbaa !5
  %177 = load ptr, ptr %7, align 8, !tbaa !5
  %178 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_begin_object(ptr noundef %177, ptr noundef %178)
  %179 = load ptr, ptr %7, align 8, !tbaa !5
  %180 = call zeroext i1 @json_option_isset(ptr noundef %179, i32 noundef 4)
  br i1 %180, label %183, label %181

181:                                              ; preds = %174
  %182 = load ptr, ptr %7, align 8, !tbaa !5
  call void @json_add_cstring(ptr noundef %182, ptr noundef @.str.5, ptr noundef @.str.48)
  br label %183

183:                                              ; preds = %181, %174
  %184 = load ptr, ptr %13, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.gravity_map_t, ptr %184, i32 0, i32 2
  %186 = load ptr, ptr %185, align 8, !tbaa !29
  %187 = load ptr, ptr %7, align 8, !tbaa !5
  call void @gravity_hash_iterate(ptr noundef %186, ptr noundef @gravity_map_serialize_iterator, ptr noundef %187)
  %188 = load ptr, ptr %7, align 8, !tbaa !5
  call void @json_end_object(ptr noundef %188)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %218

189:                                              ; preds = %169
  %190 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %191 = load ptr, ptr %190, align 8, !tbaa !9
  %192 = load ptr, ptr @gravity_class_range, align 8, !tbaa !5
  %193 = icmp eq ptr %191, %192
  br i1 %193, label %194, label %200

194:                                              ; preds = %189
  %195 = load ptr, ptr %7, align 8, !tbaa !5
  %196 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_set_label(ptr noundef %195, ptr noundef %196)
  %197 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %198 = load ptr, ptr %197, align 8, !tbaa !11
  %199 = load ptr, ptr %7, align 8, !tbaa !5
  call void @gravity_range_serialize(ptr noundef %198, ptr noundef %199)
  br label %218

200:                                              ; preds = %189
  %201 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %202 = load ptr, ptr %201, align 8, !tbaa !9
  %203 = load ptr, ptr @gravity_class_instance, align 8, !tbaa !5
  %204 = icmp eq ptr %202, %203
  br i1 %204, label %205, label %211

205:                                              ; preds = %200
  %206 = load ptr, ptr %7, align 8, !tbaa !5
  %207 = load ptr, ptr %6, align 8, !tbaa !5
  call void @json_set_label(ptr noundef %206, ptr noundef %207)
  %208 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 1
  %209 = load ptr, ptr %208, align 8, !tbaa !11
  %210 = load ptr, ptr %7, align 8, !tbaa !5
  call void @gravity_instance_serialize(ptr noundef %209, ptr noundef %210)
  br label %218

211:                                              ; preds = %200
  %212 = getelementptr inbounds %struct.gravity_value_t, ptr %5, i32 0, i32 0
  %213 = load ptr, ptr %212, align 8, !tbaa !9
  %214 = load ptr, ptr @gravity_class_fiber, align 8, !tbaa !5
  %215 = icmp eq ptr %213, %214
  br i1 %215, label %216, label %217

216:                                              ; preds = %211
  br label %218

217:                                              ; preds = %211
  call void @__assert_fail(ptr noundef @.str.47, ptr noundef @.str.1, i32 noundef 1984, ptr noundef @__PRETTY_FUNCTION__.gravity_value_serialize) #6
  unreachable

218:                                              ; preds = %216, %205, %194, %183, %167, %121, %110, %97, %86, %76, %66, %52, %46, %24
  ret void
}

declare void @json_add_null(ptr noundef, ptr noundef) #2

declare zeroext i1 @json_option_isset(ptr noundef, i32 noundef) #2

declare void @json_set_label(ptr noundef, ptr noundef) #2

declare void @json_add_string(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @gravity_map_serialize_iterator(ptr noundef, ptr, i64, ptr, i64, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @gravity_range_serialize(ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 0}
!10 = !{!"", !6, i64 0, !7, i64 8}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 56}
!13 = !{!"gravity_closure_s", !6, i64 0, !14, i64 8, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !16, i64 80}
!14 = !{!"gravity_gc_s", !15, i64 0, !15, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !6, i64 48}
!18 = !{!"", !6, i64 0, !14, i64 8, !6, i64 48, !16, i64 56, !16, i64 60, !16, i64 64}
!19 = !{!18, !16, i64 60}
!20 = !{!21, !23, i64 48}
!21 = !{!"", !6, i64 0, !14, i64 8, !22, i64 48}
!22 = !{!"", !23, i64 0, !23, i64 8, !6, i64 16}
!23 = !{!"long", !7, i64 0}
!24 = !{!23, !23, i64 0}
!25 = !{!21, !6, i64 64}
!26 = !{i64 0, i64 8, !5, i64 8, i64 8, !11}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!30, !6, i64 48}
!30 = !{!"", !6, i64 0, !14, i64 8, !6, i64 48}


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

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@gravity_class_class = external local_unnamed_addr global ptr, align 8
@gravity_class_null = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@gravity_class_function = external local_unnamed_addr global ptr, align 8
@gravity_class_closure = external local_unnamed_addr global ptr, align 8
@gravity_class_string = external local_unnamed_addr global ptr, align 8
@gravity_class_int = external local_unnamed_addr global ptr, align 8
@gravity_class_float = external local_unnamed_addr global ptr, align 8
@gravity_class_bool = external local_unnamed_addr global ptr, align 8
@gravity_class_fiber = external local_unnamed_addr global ptr, align 8
@.str.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [4 x i8], align 1
@gravity_class_instance = external local_unnamed_addr global ptr, align 8
@gravity_class_range = external local_unnamed_addr global ptr, align 8
@gravity_class_list = external local_unnamed_addr global ptr, align 8
@gravity_class_map = external local_unnamed_addr global ptr, align 8
@__PRETTY_FUNCTION__.gravity_value_serialize = external hidden unnamed_addr constant [70 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @gravity_hash_iterate(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare void @json_begin_object(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @json_add_cstring(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @json_add_int(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @json_add_bool(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @json_begin_array(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @json_end_array(ptr noundef) local_unnamed_addr #1

declare void @json_end_object(ptr noundef) local_unnamed_addr #1

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

declare void @json_add_double(ptr noundef, ptr noundef, double noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @gravity_value_serialize(ptr noundef %0, ptr readnone %1, i64 %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = load ptr, ptr @gravity_class_null, align 8, !tbaa !5
  %6 = icmp eq ptr %5, %1
  %7 = icmp eq i64 %2, 0
  %or.cond = select i1 %6, i1 %7, i1 false
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %4
  tail call void @json_add_null(ptr noundef %3, ptr noundef %0) #3
  br label %91

9:                                                ; preds = %4
  %10 = icmp eq i64 %2, 1
  %or.cond5 = select i1 %6, i1 %10, i1 false
  br i1 %or.cond5, label %11, label %15

11:                                               ; preds = %9
  %12 = tail call zeroext i1 @json_option_isset(ptr noundef %3, i32 noundef 8) #3
  br i1 %12, label %13, label %14

13:                                               ; preds = %11
  tail call void @json_add_null(ptr noundef %3, ptr noundef %0) #3
  br label %91

14:                                               ; preds = %11
  tail call void @json_begin_object(ptr noundef %3, ptr noundef %0) #3
  tail call void @json_end_object(ptr noundef %3) #3
  br label %91

15:                                               ; preds = %9
  %16 = load ptr, ptr @gravity_class_bool, align 8, !tbaa !5
  %17 = icmp eq ptr %16, %1
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  %not. = xor i1 %7, true
  tail call void @json_add_bool(ptr noundef %3, ptr noundef %0, i1 noundef zeroext %not.) #3
  br label %91

19:                                               ; preds = %15
  %20 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  %21 = icmp eq ptr %20, %1
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  tail call void @json_add_int(ptr noundef %3, ptr noundef %0, i64 noundef %2) #3
  br label %91

23:                                               ; preds = %19
  %24 = load ptr, ptr @gravity_class_float, align 8, !tbaa !5
  %25 = icmp eq ptr %24, %1
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = bitcast i64 %2 to double
  tail call void @json_add_double(ptr noundef %3, ptr noundef %0, double noundef %27) #3
  br label %91

28:                                               ; preds = %23
  %29 = load ptr, ptr @gravity_class_function, align 8, !tbaa !5
  %30 = icmp eq ptr %29, %1
  br i1 %30, label %31, label %33

31:                                               ; preds = %28
  tail call void @json_set_label(ptr noundef %3, ptr noundef %0) #3
  %32 = inttoptr i64 %2 to ptr
  tail call void @gravity_function_serialize(ptr noundef %32, ptr noundef %3)
  br label %91

33:                                               ; preds = %28
  %34 = load ptr, ptr @gravity_class_closure, align 8, !tbaa !5
  %35 = icmp eq ptr %34, %1
  br i1 %35, label %36, label %40

36:                                               ; preds = %33
  tail call void @json_set_label(ptr noundef %3, ptr noundef %0) #3
  %37 = inttoptr i64 %2 to ptr
  %38 = getelementptr inbounds i8, ptr %37, i64 56
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  tail call void @gravity_function_serialize(ptr noundef %39, ptr noundef %3)
  br label %91

40:                                               ; preds = %33
  %41 = load ptr, ptr @gravity_class_class, align 8, !tbaa !5
  %42 = icmp eq ptr %41, %1
  br i1 %42, label %43, label %45

43:                                               ; preds = %40
  tail call void @json_set_label(ptr noundef %3, ptr noundef %0) #3
  %44 = inttoptr i64 %2 to ptr
  tail call void @gravity_class_serialize(ptr noundef %44, ptr noundef %3)
  br label %91

45:                                               ; preds = %40
  %46 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  %47 = icmp eq ptr %46, %1
  br i1 %47, label %48, label %55

48:                                               ; preds = %45
  %49 = inttoptr i64 %2 to ptr
  %50 = getelementptr inbounds i8, ptr %49, i64 48
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = getelementptr inbounds i8, ptr %49, i64 60
  %53 = load i32, ptr %52, align 4, !tbaa !16
  %54 = zext i32 %53 to i64
  tail call void @json_add_string(ptr noundef %3, ptr noundef %0, ptr noundef %51, i64 noundef %54) #3
  br label %91

55:                                               ; preds = %45
  %56 = load ptr, ptr @gravity_class_list, align 8, !tbaa !5
  %57 = icmp eq ptr %56, %1
  br i1 %57, label %58, label %67

58:                                               ; preds = %55
  %59 = inttoptr i64 %2 to ptr
  tail call void @json_begin_array(ptr noundef %3, ptr noundef %0) #3
  %60 = getelementptr inbounds i8, ptr %59, i64 48
  %61 = load i64, ptr %60, align 8, !tbaa !17
  %.not = icmp eq i64 %61, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %58
  %62 = getelementptr inbounds i8, ptr %59, i64 64
  br label %63

._crit_edge:                                      ; preds = %63, %58
  tail call void @json_end_array(ptr noundef %3) #3
  br label %91

63:                                               ; preds = %.lr.ph, %63
  %.080 = phi i64 [ 0, %.lr.ph ], [ %66, %63 ]
  %64 = load ptr, ptr %62, align 8, !tbaa !21
  %65 = getelementptr inbounds %struct.gravity_value_t, ptr %64, i64 %.080
  %.sroa.0.0.copyload = load ptr, ptr %65, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %65, i64 8
  %.sroa.4.0.copyload = load i64, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !22
  tail call void @gravity_value_serialize(ptr noundef null, ptr %.sroa.0.0.copyload, i64 %.sroa.4.0.copyload, ptr noundef %3)
  %66 = add nuw i64 %.080, 1
  %exitcond.not = icmp eq i64 %66, %61
  br i1 %exitcond.not, label %._crit_edge, label %63, !llvm.loop !23

67:                                               ; preds = %55
  %68 = load ptr, ptr @gravity_class_map, align 8, !tbaa !5
  %69 = icmp eq ptr %68, %1
  br i1 %69, label %70, label %77

70:                                               ; preds = %67
  %71 = inttoptr i64 %2 to ptr
  tail call void @json_begin_object(ptr noundef %3, ptr noundef %0) #3
  %72 = tail call zeroext i1 @json_option_isset(ptr noundef %3, i32 noundef 4) #3
  br i1 %72, label %74, label %73

73:                                               ; preds = %70
  tail call void @json_add_cstring(ptr noundef %3, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.48) #3
  br label %74

74:                                               ; preds = %73, %70
  %75 = getelementptr inbounds i8, ptr %71, i64 48
  %76 = load ptr, ptr %75, align 8, !tbaa !25
  tail call void @gravity_hash_iterate(ptr noundef %76, ptr noundef nonnull @gravity_map_serialize_iterator, ptr noundef %3) #3
  tail call void @json_end_object(ptr noundef %3) #3
  br label %91

77:                                               ; preds = %67
  %78 = load ptr, ptr @gravity_class_range, align 8, !tbaa !5
  %79 = icmp eq ptr %78, %1
  br i1 %79, label %80, label %82

80:                                               ; preds = %77
  tail call void @json_set_label(ptr noundef %3, ptr noundef %0) #3
  %81 = inttoptr i64 %2 to ptr
  tail call void @gravity_range_serialize(ptr noundef %81, ptr noundef %3)
  br label %91

82:                                               ; preds = %77
  %83 = load ptr, ptr @gravity_class_instance, align 8, !tbaa !5
  %84 = icmp eq ptr %83, %1
  br i1 %84, label %85, label %87

85:                                               ; preds = %82
  tail call void @json_set_label(ptr noundef %3, ptr noundef %0) #3
  %86 = inttoptr i64 %2 to ptr
  tail call void @gravity_instance_serialize(ptr noundef %86, ptr noundef %3)
  br label %91

87:                                               ; preds = %82
  %88 = load ptr, ptr @gravity_class_fiber, align 8, !tbaa !5
  %89 = icmp eq ptr %88, %1
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  tail call void @__assert_fail(ptr noundef nonnull @.str.47, ptr noundef nonnull @.str.1, i32 noundef 1984, ptr noundef nonnull @__PRETTY_FUNCTION__.gravity_value_serialize) #4
  unreachable

91:                                               ; preds = %87, %13, %14, %85, %80, %74, %._crit_edge, %48, %43, %36, %31, %26, %22, %18, %8
  ret void
}

declare void @json_add_null(ptr noundef, ptr noundef) local_unnamed_addr #1

declare zeroext i1 @json_option_isset(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @json_set_label(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @json_add_string(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @gravity_map_serialize_iterator(ptr noundef, ptr, i64, ptr, i64, ptr noundef) #2

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

attributes #0 = { noreturn nounwind "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 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 }
attributes #4 = { noreturn 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 56}
!10 = !{!"gravity_closure_s", !6, i64 0, !11, i64 8, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80}
!11 = !{!"gravity_gc_s", !12, i64 0, !12, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 48}
!15 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48, !13, i64 56, !13, i64 60, !13, i64 64}
!16 = !{!15, !13, i64 60}
!17 = !{!18, !20, i64 48}
!18 = !{!"", !6, i64 0, !11, i64 8, !19, i64 48}
!19 = !{!"", !20, i64 0, !20, i64 8, !6, i64 16}
!20 = !{!"long", !7, i64 0}
!21 = !{!18, !6, i64 64}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !6, i64 48}
!26 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48}


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