; LLVM IR from marcobambini/gravity :: src/runtime (gravity_vm)

; 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.void_r = type { i64, i64, ptr }
%struct.gravity_value_t = type { ptr, %union.anon }
%union.anon = type { i64 }
%struct._json_value = type { ptr, i32, %union.anon.2, %union.anon.6 }
%union.anon.2 = type { %struct.anon.3 }
%struct.anon.3 = type { i32, ptr }
%union.anon.6 = type { ptr }
%struct.anon.4 = type { i32, ptr }
%struct._json_object_entry = type { ptr, i32, ptr }
%struct.gravity_class_s = type { ptr, %struct.gravity_gc_s, ptr, ptr, i8, i8, i8, i8, ptr, ptr, ptr, ptr, i32, ptr }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }
%struct.gravity_function_t = type { ptr, %struct.gravity_gc_s, ptr, ptr, i16, i16, i16, i16, i32, %union.anon.0 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { %struct.gravity_value_r, %struct.gravity_value_r, %struct.gravity_value_r, i32, ptr, ptr, float, i8 }
%struct.gravity_value_r = type { i64, i64, ptr }
%struct.gravity_closure_s = type { ptr, %struct.gravity_gc_s, ptr, ptr, ptr, ptr, i32 }
%struct.gravity_vm = type { ptr, ptr, ptr, ptr, i32, double, i8, i32, i32, i64, i64, i32, [64 x i8], ptr, ptr, ptr, i32, i64, i64, ptr, i64, i64, i64, double, i64, %struct.gravity_object_r, %struct.gravity_object_r }
%struct.gravity_object_r = type { i64, i64, ptr }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@gravity_class_function = external global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [38 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: nounwind uwtable
declare dso_local void @gravity_gc_setenabled(ptr noundef, i1 noundef zeroext) #1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @gravity_vm_setvalue(ptr noundef, ptr noundef, ptr, i64) #3

; Function Attrs: nounwind uwtable
declare hidden void @report_runtime_error(ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @gravity_vm_loadbuffer(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca %struct.void_r, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca %struct.gravity_value_t, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca %struct.void_r, align 8
  %23 = alloca i64, align 8
  %24 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #7
  %25 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 1
  store i64 0, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 0
  store i64 0, ptr %26, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  store ptr null, ptr %27, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !9
  %30 = call ptr @json_parse(ptr noundef %28, i64 noundef %29)
  store ptr %30, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %34, label %33

33:                                               ; preds = %3
  br label %220

34:                                               ; preds = %3
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._json_value, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = icmp ne i32 %37, 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  br label %220

40:                                               ; preds = %34
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  call void @gravity_gc_setenabled(ptr noundef %41, i1 noundef zeroext false)
  store ptr null, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._json_value, ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds %struct.anon.4, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !18
  store i32 %45, ptr %11, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !19
  br label %46

46:                                               ; preds = %152, %40
  %47 = load i32, ptr %12, align 4, !tbaa !19
  %48 = load i32, ptr %11, align 4, !tbaa !19
  %49 = icmp ult i32 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 3, ptr %13, align 4
  br label %155

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._json_value, ptr %52, i32 0, i32 2
  %54 = getelementptr inbounds %struct.anon.4, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !18
  %56 = load i32, ptr %12, align 4, !tbaa !19
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds %struct._json_object_entry, ptr %55, i64 %57
  %59 = getelementptr inbounds %struct._json_object_entry, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  store ptr %60, ptr %14, align 8, !tbaa !5
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._json_value, ptr %61, i32 0, i32 2
  %63 = getelementptr inbounds %struct.anon.4, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !18
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %51
  store i32 5, ptr %13, align 4
  br label %149

67:                                               ; preds = %51
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._json_value, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 8, !tbaa !15
  %71 = icmp ne i32 %70, 1
  br i1 %71, label %72, label %73

72:                                               ; preds = %67
  store i32 2, ptr %13, align 4
  br label %149

73:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = call ptr @gravity_object_deserialize(ptr noundef %74, ptr noundef %75)
  store ptr %76, ptr %15, align 8, !tbaa !5
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %80, label %79

79:                                               ; preds = %73
  store i32 2, ptr %13, align 4
  br label %148

80:                                               ; preds = %73
  %81 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 0
  %82 = load i64, ptr %81, align 8, !tbaa !13
  %83 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 1
  %84 = load i64, ptr %83, align 8, !tbaa !11
  %85 = icmp eq i64 %82, %84
  br i1 %85, label %86, label %105

86:                                               ; preds = %80
  %87 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 1
  %88 = load i64, ptr %87, align 8, !tbaa !11
  %89 = icmp ne i64 %88, 0
  br i1 %89, label %90, label %94

90:                                               ; preds = %86
  %91 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 1
  %92 = load i64, ptr %91, align 8, !tbaa !11
  %93 = shl i64 %92, 1
  br label %95

94:                                               ; preds = %86
  br label %95

95:                                               ; preds = %94, %90
  %96 = phi i64 [ %93, %90 ], [ 8, %94 ]
  %97 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 1
  store i64 %96, ptr %97, align 8, !tbaa !11
  %98 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !14
  %100 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 1
  %101 = load i64, ptr %100, align 8, !tbaa !11
  %102 = mul i64 8, %101
  %103 = call ptr @realloc(ptr noundef %99, i64 noundef %102) #8
  %104 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  store ptr %103, ptr %104, align 8, !tbaa !14
  br label %105

105:                                              ; preds = %95, %80
  %106 = load ptr, ptr %15, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %108 = load ptr, ptr %107, align 8, !tbaa !14
  %109 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 0
  %110 = load i64, ptr %109, align 8, !tbaa !13
  %111 = add i64 %110, 1
  store i64 %111, ptr %109, align 8, !tbaa !13
  %112 = getelementptr inbounds ptr, ptr %108, i64 %110
  store ptr %106, ptr %112, align 8, !tbaa !5
  %113 = load ptr, ptr %15, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.gravity_class_s, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !22
  %116 = load ptr, ptr @gravity_class_function, align 8, !tbaa !5
  %117 = icmp eq ptr %115, %116
  br i1 %117, label %118, label %147

118:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %119 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %119, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %120 = load ptr, ptr %16, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.gravity_function_t, ptr %120, i32 0, i32 3
  %122 = load ptr, ptr %121, align 8, !tbaa !26
  store ptr %122, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = load ptr, ptr %16, align 8, !tbaa !5
  %125 = call ptr @gravity_closure_new(ptr noundef %123, ptr noundef %124)
  store ptr %125, ptr %18, align 8, !tbaa !5
  %126 = load ptr, ptr %17, align 8, !tbaa !5
  %127 = load ptr, ptr %17, align 8, !tbaa !5
  %128 = call i64 @strlen(ptr noundef %127) #9
  %129 = call i32 @string_casencmp(ptr noundef %126, ptr noundef @.str.1, i64 noundef %128)
  %130 = icmp eq i32 %129, 0
  br i1 %130, label %131, label %133

131:                                              ; preds = %118
  %132 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %132, ptr %10, align 8, !tbaa !5
  br label %146

133:                                              ; preds = %118
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = load ptr, ptr %17, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.gravity_value_t, ptr %19, i32 0, i32 0
  %137 = load ptr, ptr %18, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.gravity_closure_s, ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !29
  store ptr %139, ptr %136, align 8, !tbaa !31
  %140 = getelementptr inbounds %struct.gravity_value_t, ptr %19, i32 0, i32 1
  %141 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %141, ptr %140, align 8, !tbaa !18
  %142 = getelementptr inbounds { ptr, i64 }, ptr %19, i32 0, i32 0
  %143 = load ptr, ptr %142, align 8
  %144 = getelementptr inbounds { ptr, i64 }, ptr %19, i32 0, i32 1
  %145 = load i64, ptr %144, align 8
  call void @gravity_vm_setvalue(ptr noundef %134, ptr noundef %135, ptr %143, i64 %145)
  br label %146

146:                                              ; preds = %133, %131
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %147

147:                                              ; preds = %146, %105
  store i32 0, ptr %13, align 4
  br label %148

148:                                              ; preds = %147, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %149

149:                                              ; preds = %148, %72, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  %150 = load i32, ptr %13, align 4
  switch i32 %150, label %155 [
    i32 0, label %151
    i32 5, label %152
  ]

151:                                              ; preds = %149
  br label %152

152:                                              ; preds = %151, %149
  %153 = load i32, ptr %12, align 4, !tbaa !19
  %154 = add i32 %153, 1
  store i32 %154, ptr %12, align 4, !tbaa !19
  br label %46, !llvm.loop !33

155:                                              ; preds = %149, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %156 = load i32, ptr %13, align 4
  switch i32 %156, label %236 [
    i32 3, label %157
    i32 2, label %220
  ]

157:                                              ; preds = %155
  %158 = load ptr, ptr %9, align 8, !tbaa !5
  call void @json_value_free(ptr noundef %158)
  store ptr null, ptr %9, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 0
  %160 = load i64, ptr %159, align 8, !tbaa !13
  store i64 %160, ptr %20, align 8, !tbaa !9
  %161 = load i64, ptr %20, align 8, !tbaa !9
  %162 = icmp ne i64 %161, 0
  br i1 %162, label %163, label %217

163:                                              ; preds = %157
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.gravity_vm, ptr %164, i32 0, i32 3
  %166 = load ptr, ptr %165, align 8, !tbaa !35
  store ptr %166, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %22) #7
  %167 = getelementptr inbounds %struct.void_r, ptr %22, i32 0, i32 1
  store i64 0, ptr %167, align 8, !tbaa !11
  %168 = getelementptr inbounds %struct.void_r, ptr %22, i32 0, i32 0
  store i64 0, ptr %168, align 8, !tbaa !13
  %169 = getelementptr inbounds %struct.void_r, ptr %22, i32 0, i32 2
  store ptr null, ptr %169, align 8, !tbaa !14
  %170 = load ptr, ptr %5, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.gravity_vm, ptr %170, i32 0, i32 3
  store ptr %22, ptr %171, align 8, !tbaa !35
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %172

172:                                              ; preds = %191, %163
  %173 = load i64, ptr %23, align 8, !tbaa !9
  %174 = load i64, ptr %20, align 8, !tbaa !9
  %175 = icmp ult i64 %173, %174
  br i1 %175, label %177, label %176

176:                                              ; preds = %172
  store i32 6, ptr %13, align 4
  br label %194

177:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %178 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %179 = load ptr, ptr %178, align 8, !tbaa !14
  %180 = load i64, ptr %23, align 8, !tbaa !9
  %181 = getelementptr inbounds ptr, ptr %179, i64 %180
  %182 = load ptr, ptr %181, align 8, !tbaa !5
  store ptr %182, ptr %24, align 8, !tbaa !5
  %183 = load ptr, ptr %5, align 8, !tbaa !5
  %184 = load ptr, ptr %24, align 8, !tbaa !5
  %185 = call zeroext i1 @vm_set_superclass(ptr noundef %183, ptr noundef %184)
  br i1 %185, label %187, label %186

186:                                              ; preds = %177
  store i32 9, ptr %13, align 4
  br label %188

187:                                              ; preds = %177
  store i32 0, ptr %13, align 4
  br label %188

188:                                              ; preds = %187, %186
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  %189 = load i32, ptr %13, align 4
  switch i32 %189, label %194 [
    i32 0, label %190
  ]

190:                                              ; preds = %188
  br label %191

191:                                              ; preds = %190
  %192 = load i64, ptr %23, align 8, !tbaa !9
  %193 = add i64 %192, 1
  store i64 %193, ptr %23, align 8, !tbaa !9
  br label %172, !llvm.loop !38

194:                                              ; preds = %188, %176
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  %195 = load i32, ptr %13, align 4
  switch i32 %195, label %214 [
    i32 6, label %196
  ]

196:                                              ; preds = %194
  %197 = getelementptr inbounds %struct.void_r, ptr %22, i32 0, i32 2
  %198 = load ptr, ptr %197, align 8, !tbaa !14
  %199 = icmp ne ptr %198, null
  br i1 %199, label %200, label %203

200:                                              ; preds = %196
  %201 = getelementptr inbounds %struct.void_r, ptr %22, i32 0, i32 2
  %202 = load ptr, ptr %201, align 8, !tbaa !14
  call void @free(ptr noundef %202) #7
  br label %203

203:                                              ; preds = %200, %196
  %204 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %205 = load ptr, ptr %204, align 8, !tbaa !14
  %206 = icmp ne ptr %205, null
  br i1 %206, label %207, label %210

207:                                              ; preds = %203
  %208 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %209 = load ptr, ptr %208, align 8, !tbaa !14
  call void @free(ptr noundef %209) #7
  br label %210

210:                                              ; preds = %207, %203
  %211 = load ptr, ptr %21, align 8, !tbaa !5
  %212 = load ptr, ptr %5, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct.gravity_vm, ptr %212, i32 0, i32 3
  store ptr %211, ptr %213, align 8, !tbaa !35
  store i32 0, ptr %13, align 4
  br label %214

214:                                              ; preds = %210, %194
  call void @llvm.lifetime.end.p0(i64 24, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  %215 = load i32, ptr %13, align 4
  switch i32 %215, label %236 [
    i32 0, label %216
    i32 9, label %222
  ]

216:                                              ; preds = %214
  br label %217

217:                                              ; preds = %216, %157
  %218 = load ptr, ptr %5, align 8, !tbaa !5
  call void @gravity_gc_setenabled(ptr noundef %218, i1 noundef zeroext true)
  %219 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %219, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %236

220:                                              ; preds = %155, %39, %33
  %221 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, i32, ptr, ...) @report_runtime_error(ptr noundef %221, i32 noundef 3, ptr noundef @.str, ptr noundef @.str.15)
  br label %222

222:                                              ; preds = %220, %214
  %223 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %224 = load ptr, ptr %223, align 8, !tbaa !14
  %225 = icmp ne ptr %224, null
  br i1 %225, label %226, label %229

226:                                              ; preds = %222
  %227 = getelementptr inbounds %struct.void_r, ptr %8, i32 0, i32 2
  %228 = load ptr, ptr %227, align 8, !tbaa !14
  call void @free(ptr noundef %228) #7
  br label %229

229:                                              ; preds = %226, %222
  %230 = load ptr, ptr %9, align 8, !tbaa !5
  %231 = icmp ne ptr %230, null
  br i1 %231, label %232, label %234

232:                                              ; preds = %229
  %233 = load ptr, ptr %9, align 8, !tbaa !5
  call void @json_value_free(ptr noundef %233)
  br label %234

234:                                              ; preds = %232, %229
  %235 = load ptr, ptr %5, align 8, !tbaa !5
  call void @gravity_gc_setenabled(ptr noundef %235, i1 noundef zeroext true)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %236

236:                                              ; preds = %234, %217, %214, %155
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #7
  %237 = load ptr, ptr %4, align 8
  ret ptr %237
}

declare ptr @json_parse(ptr noundef, i64 noundef) #4

declare ptr @gravity_object_deserialize(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #5

declare ptr @gravity_closure_new(ptr noundef, ptr noundef) #4

declare i32 @string_casencmp(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #6

declare void @json_value_free(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @vm_set_superclass(ptr noundef, ptr noundef) #1

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 = { 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 #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 = { "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 allocsize(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 #6 = { nounwind willreturn memory(read) "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(1) }
attributes #9 = { nounwind willreturn memory(read) }

!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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !17, i64 8}
!16 = !{!"_json_value", !6, i64 0, !17, i64 8, !7, i64 16, !7, i64 32}
!17 = !{!"int", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!17, !17, i64 0}
!20 = !{!21, !6, i64 16}
!21 = !{!"_json_object_entry", !6, i64 0, !17, i64 8, !6, i64 16}
!22 = !{!23, !6, i64 0}
!23 = !{!"gravity_class_s", !6, i64 0, !24, i64 8, !6, i64 48, !6, i64 56, !25, i64 64, !25, i64 65, !25, i64 66, !25, i64 67, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !17, i64 104, !6, i64 112}
!24 = !{!"gravity_gc_s", !25, i64 0, !25, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!25 = !{!"_Bool", !7, i64 0}
!26 = !{!27, !6, i64 56}
!27 = !{!"", !6, i64 0, !24, i64 8, !6, i64 48, !6, i64 56, !28, i64 64, !28, i64 66, !28, i64 68, !28, i64 70, !17, i64 72, !7, i64 80}
!28 = !{!"short", !7, i64 0}
!29 = !{!30, !6, i64 0}
!30 = !{!"gravity_closure_s", !6, i64 0, !24, i64 8, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !17, i64 80}
!31 = !{!32, !6, i64 0}
!32 = !{!"", !6, i64 0, !7, i64 8}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{!36, !6, i64 24}
!36 = !{!"gravity_vm", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !17, i64 32, !37, i64 40, !25, i64 48, !17, i64 52, !17, i64 56, !10, i64 64, !10, i64 72, !17, i64 80, !7, i64 84, !6, i64 152, !6, i64 160, !6, i64 168, !17, i64 176, !10, i64 184, !10, i64 192, !6, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !37, i64 232, !10, i64 240, !12, i64 248, !12, i64 272}
!37 = !{!"double", !7, i64 0}
!38 = distinct !{!38, !34}


; 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.void_r = type { i64, i64, ptr }
%struct._json_object_entry = type { ptr, i32, ptr }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@gravity_class_function = external local_unnamed_addr global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [38 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @gravity_gc_setenabled(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @gravity_vm_setvalue(ptr noundef, ptr noundef, ptr, i64) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @report_runtime_error(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @gravity_vm_loadbuffer(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = alloca %struct.void_r, align 8
  %5 = tail call ptr @json_parse(ptr noundef %1, i64 noundef %2) #8
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.thread97, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %.not78 = icmp eq i32 %8, 1
  br i1 %.not78, label %9, label %.thread97

9:                                                ; preds = %6
  tail call void @gravity_gc_setenabled(ptr noundef %0, i1 noundef zeroext false)
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %.not118 = icmp eq i32 %11, 0
  br i1 %.not118, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %9
  tail call void @json_value_free(ptr noundef nonnull %5) #8
  br label %67

.lr.ph:                                           ; preds = %9
  %12 = getelementptr inbounds i8, ptr %5, i64 24
  %wide.trip.count = zext i32 %11 to i64
  br label %13

13:                                               ; preds = %.lr.ph, %48
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %48 ]
  %.sroa.13.0114 = phi ptr [ null, %.lr.ph ], [ %.sroa.13.3.ph, %48 ]
  %.sroa.7.0113 = phi i64 [ 0, %.lr.ph ], [ %.sroa.7.3.ph, %48 ]
  %.sroa.039.0112 = phi i64 [ 0, %.lr.ph ], [ %.sroa.039.2.ph, %48 ]
  %.067111 = phi ptr [ null, %.lr.ph ], [ %.4.ph, %48 ]
  %14 = load ptr, ptr %12, align 8, !tbaa !11
  %15 = getelementptr inbounds %struct._json_object_entry, ptr %14, i64 %indvars.iv, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %48, label %20

20:                                               ; preds = %13
  %21 = getelementptr inbounds i8, ptr %16, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !5
  %.not79 = icmp eq i32 %22, 1
  br i1 %.not79, label %23, label %.thread97

23:                                               ; preds = %20
  %24 = tail call ptr @gravity_object_deserialize(ptr noundef %0, ptr noundef nonnull %16) #8
  %.not80 = icmp eq ptr %24, null
  br i1 %.not80, label %.thread97, label %25

25:                                               ; preds = %23
  %26 = icmp eq i64 %.sroa.039.0112, %.sroa.7.0113
  br i1 %26, label %27, label %32

27:                                               ; preds = %25
  %.not81 = icmp eq i64 %.sroa.7.0113, 0
  %28 = shl i64 %.sroa.7.0113, 1
  %29 = select i1 %.not81, i64 8, i64 %28
  %30 = shl i64 %29, 3
  %31 = tail call ptr @realloc(ptr noundef %.sroa.13.0114, i64 noundef %30) #9
  br label %32

32:                                               ; preds = %27, %25
  %.sroa.7.1 = phi i64 [ %29, %27 ], [ %.sroa.7.0113, %25 ]
  %.sroa.13.1 = phi ptr [ %31, %27 ], [ %.sroa.13.0114, %25 ]
  %33 = add i64 %.sroa.039.0112, 1
  %34 = getelementptr inbounds ptr, ptr %.sroa.13.1, i64 %.sroa.039.0112
  store ptr %24, ptr %34, align 8, !tbaa !14
  %35 = load ptr, ptr %24, align 8, !tbaa !15
  %36 = load ptr, ptr @gravity_class_function, align 8, !tbaa !14
  %37 = icmp eq ptr %35, %36
  br i1 %37, label %38, label %48

38:                                               ; preds = %32
  %39 = getelementptr inbounds i8, ptr %24, i64 56
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = tail call ptr @gravity_closure_new(ptr noundef %0, ptr noundef nonnull %24) #8
  %42 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %40) #10
  %43 = tail call i32 @string_casencmp(ptr noundef %40, ptr noundef nonnull @.str.1, i64 noundef %42) #8
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %48, label %45

45:                                               ; preds = %38
  %46 = load ptr, ptr %41, align 8, !tbaa !22
  %47 = ptrtoint ptr %41 to i64
  tail call void @gravity_vm_setvalue(ptr noundef %0, ptr noundef %40, ptr %46, i64 %47)
  br label %48

48:                                               ; preds = %13, %45, %38, %32
  %.4.ph = phi ptr [ %41, %38 ], [ %.067111, %45 ], [ %.067111, %32 ], [ %.067111, %13 ]
  %.sroa.039.2.ph = phi i64 [ %33, %38 ], [ %33, %45 ], [ %33, %32 ], [ %.sroa.039.0112, %13 ]
  %.sroa.7.3.ph = phi i64 [ %.sroa.7.1, %38 ], [ %.sroa.7.1, %45 ], [ %.sroa.7.1, %32 ], [ %.sroa.7.0113, %13 ]
  %.sroa.13.3.ph = phi ptr [ %.sroa.13.1, %38 ], [ %.sroa.13.1, %45 ], [ %.sroa.13.1, %32 ], [ %.sroa.13.0114, %13 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %13, !llvm.loop !24

._crit_edge:                                      ; preds = %48
  tail call void @json_value_free(ptr noundef nonnull %5) #8
  %.not82 = icmp eq i64 %.sroa.039.2.ph, 0
  br i1 %.not82, label %67, label %49

49:                                               ; preds = %._crit_edge
  %50 = getelementptr inbounds i8, ptr %0, i64 24
  %51 = load ptr, ptr %50, align 8, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #8
  %52 = getelementptr inbounds i8, ptr %4, i64 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, i8 0, i64 24, i1 false)
  store ptr %4, ptr %50, align 8, !tbaa !26
  br label %55

53:                                               ; preds = %55
  %54 = add nuw i64 %.065117, 1
  %exitcond121.not = icmp eq i64 %54, %.sroa.039.2.ph
  br i1 %exitcond121.not, label %59, label %55, !llvm.loop !31

55:                                               ; preds = %49, %53
  %.065117 = phi i64 [ 0, %49 ], [ %54, %53 ]
  %56 = getelementptr inbounds ptr, ptr %.sroa.13.3.ph, i64 %.065117
  %57 = load ptr, ptr %56, align 8, !tbaa !14
  %58 = call zeroext i1 @vm_set_superclass(ptr noundef %0, ptr noundef %57)
  br i1 %58, label %53, label %62

59:                                               ; preds = %53
  %60 = load ptr, ptr %52, align 8, !tbaa !32
  %.not83 = icmp eq ptr %60, null
  br i1 %.not83, label %.thread105, label %61

61:                                               ; preds = %59
  call void @free(ptr noundef nonnull %60) #8
  br label %.thread105

.thread105:                                       ; preds = %59, %61
  call void @free(ptr noundef nonnull %.sroa.13.3.ph) #8
  store ptr %51, ptr %50, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  br label %67

62:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  br label %63

.thread97:                                        ; preds = %20, %23, %6, %3
  %.sroa.13.5 = phi ptr [ null, %6 ], [ null, %3 ], [ %.sroa.13.0114, %23 ], [ %.sroa.13.0114, %20 ]
  tail call void (ptr, i32, ptr, ...) @report_runtime_error(ptr noundef %0, i32 noundef 3, ptr noundef nonnull @.str, ptr noundef nonnull @.str.15)
  br label %63

63:                                               ; preds = %62, %.thread97
  %.066 = phi ptr [ %5, %.thread97 ], [ null, %62 ]
  %.sroa.13.6 = phi ptr [ %.sroa.13.5, %.thread97 ], [ %.sroa.13.3.ph, %62 ]
  %.not85 = icmp eq ptr %.sroa.13.6, null
  br i1 %.not85, label %65, label %64

64:                                               ; preds = %63
  call void @free(ptr noundef nonnull %.sroa.13.6) #8
  br label %65

65:                                               ; preds = %64, %63
  %.not86 = icmp eq ptr %.066, null
  br i1 %.not86, label %67, label %66

66:                                               ; preds = %65
  call void @json_value_free(ptr noundef nonnull %.066) #8
  br label %67

67:                                               ; preds = %65, %66, %._crit_edge, %.thread105, %._crit_edge.thread
  %.0 = phi ptr [ null, %._crit_edge.thread ], [ %.4.ph, %.thread105 ], [ %.4.ph, %._crit_edge ], [ null, %66 ], [ null, %65 ]
  call void @gravity_gc_setenabled(ptr noundef %0, i1 noundef zeroext true)
  ret ptr %.0
}

declare ptr @json_parse(ptr noundef, i64 noundef) local_unnamed_addr #4

declare ptr @gravity_object_deserialize(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #5

declare ptr @gravity_closure_new(ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @string_casencmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #6

declare void @json_value_free(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @vm_set_superclass(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

attributes #0 = { mustprogress 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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(1) }
attributes #10 = { nounwind willreturn memory(read) }

!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, !10, i64 8}
!6 = !{!"_json_value", !7, i64 0, !10, i64 8, !8, i64 16, !8, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!8, !8, i64 0}
!12 = !{!13, !7, i64 16}
!13 = !{!"_json_object_entry", !7, i64 0, !10, i64 8, !7, i64 16}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !7, i64 0}
!16 = !{!"gravity_class_s", !7, i64 0, !17, i64 8, !7, i64 48, !7, i64 56, !18, i64 64, !18, i64 65, !18, i64 66, !18, i64 67, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !10, i64 104, !7, i64 112}
!17 = !{!"gravity_gc_s", !18, i64 0, !18, i64 1, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!18 = !{!"_Bool", !8, i64 0}
!19 = !{!20, !7, i64 56}
!20 = !{!"", !7, i64 0, !17, i64 8, !7, i64 48, !7, i64 56, !21, i64 64, !21, i64 66, !21, i64 68, !21, i64 70, !10, i64 72, !8, i64 80}
!21 = !{!"short", !8, i64 0}
!22 = !{!23, !7, i64 0}
!23 = !{!"gravity_closure_s", !7, i64 0, !17, i64 8, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !10, i64 80}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!27, !7, i64 24}
!27 = !{!"gravity_vm", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !28, i64 40, !18, i64 48, !10, i64 52, !10, i64 56, !29, i64 64, !29, i64 72, !10, i64 80, !8, i64 84, !7, i64 152, !7, i64 160, !7, i64 168, !10, i64 176, !29, i64 184, !29, i64 192, !7, i64 200, !29, i64 208, !29, i64 216, !29, i64 224, !28, i64 232, !29, i64 240, !30, i64 248, !30, i64 272}
!28 = !{!"double", !8, i64 0}
!29 = !{!"long", !8, i64 0}
!30 = !{!"", !29, i64 0, !29, i64 8, !7, i64 16}
!31 = distinct !{!31, !25}
!32 = !{!30, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass