; 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._json_value = type { ptr, i32, %union.anon.0, %union.anon.3 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { i32, ptr }
%union.anon.3 = type { ptr }
%struct.anon.1 = type { i32, ptr }
%struct._json_object_entry = type { ptr, i32, ptr }

@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [6 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

18:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  br label %137

19:                                               ; preds = %2
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._json_value, ptr %20, i32 0, i32 2
  %22 = getelementptr inbounds %struct.anon.1, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !12
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %19
  store ptr null, ptr %3, align 8
  br label %137

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._json_value, ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds %struct.anon.1, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !12
  %31 = getelementptr inbounds %struct._json_object_entry, ptr %30, i64 0
  %32 = getelementptr inbounds %struct._json_object_entry, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  store ptr %33, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._json_value, ptr %34, i32 0, i32 2
  %36 = getelementptr inbounds %struct.anon.1, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !12
  %38 = getelementptr inbounds %struct._json_object_entry, ptr %37, i64 0
  %39 = getelementptr inbounds %struct._json_object_entry, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call i32 @string_casencmp(ptr noundef %41, ptr noundef @.str.5, i64 noundef 4)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call ptr @gravity_map_deserialize(ptr noundef %45, ptr noundef %46)
  store ptr %47, ptr %8, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %48, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %136

49:                                               ; preds = %26
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._json_value, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !9
  %53 = icmp ne i32 %52, 5
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %136

55:                                               ; preds = %49
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._json_value, ptr %56, i32 0, i32 2
  %58 = getelementptr inbounds %struct.anon, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !12
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._json_value, ptr %60, i32 0, i32 2
  %62 = getelementptr inbounds %struct.anon, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !12
  %64 = zext i32 %63 to i64
  %65 = call i32 @string_casencmp(ptr noundef %59, ptr noundef @.str.29, i64 noundef %64)
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %72

67:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = call ptr @gravity_function_deserialize(ptr noundef %68, ptr noundef %69)
  store ptr %70, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %71, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %136

72:                                               ; preds = %55
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._json_value, ptr %73, i32 0, i32 2
  %75 = getelementptr inbounds %struct.anon, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !12
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._json_value, ptr %77, i32 0, i32 2
  %79 = getelementptr inbounds %struct.anon, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !12
  %81 = zext i32 %80 to i64
  %82 = call i32 @string_casencmp(ptr noundef %76, ptr noundef @.str.6, i64 noundef %81)
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %89

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

89:                                               ; preds = %72
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._json_value, ptr %90, i32 0, i32 2
  %92 = getelementptr inbounds %struct.anon, ptr %91, i32 0, i32 1
  %93 = load ptr, ptr %92, align 8, !tbaa !12
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._json_value, ptr %94, i32 0, i32 2
  %96 = getelementptr inbounds %struct.anon, ptr %95, i32 0, i32 0
  %97 = load i32, ptr %96, align 8, !tbaa !12
  %98 = zext i32 %97 to i64
  %99 = call i32 @string_casencmp(ptr noundef %93, ptr noundef @.str.48, i64 noundef %98)
  %100 = icmp eq i32 %99, 0
  br i1 %100, label %113, label %101

101:                                              ; preds = %89
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._json_value, ptr %102, i32 0, i32 2
  %104 = getelementptr inbounds %struct.anon, ptr %103, i32 0, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !12
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct._json_value, ptr %106, i32 0, i32 2
  %108 = getelementptr inbounds %struct.anon, ptr %107, i32 0, i32 0
  %109 = load i32, ptr %108, align 8, !tbaa !12
  %110 = zext i32 %109 to i64
  %111 = call i32 @string_casencmp(ptr noundef %105, ptr noundef @.str.49, i64 noundef %110)
  %112 = icmp eq i32 %111, 0
  br i1 %112, label %113, label %118

113:                                              ; preds = %101, %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = call ptr @gravity_map_deserialize(ptr noundef %114, ptr noundef %115)
  store ptr %116, ptr %12, align 8, !tbaa !5
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %117, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %136

118:                                              ; preds = %101
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct._json_value, ptr %119, i32 0, i32 2
  %121 = getelementptr inbounds %struct.anon, ptr %120, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !12
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._json_value, ptr %123, i32 0, i32 2
  %125 = getelementptr inbounds %struct.anon, ptr %124, i32 0, i32 0
  %126 = load i32, ptr %125, align 8, !tbaa !12
  %127 = zext i32 %126 to i64
  %128 = call i32 @string_casencmp(ptr noundef %122, ptr noundef @.str.50, i64 noundef %127)
  %129 = icmp eq i32 %128, 0
  br i1 %129, label %130, label %135

130:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = load ptr, ptr %5, align 8, !tbaa !5
  %133 = call ptr @gravity_range_deserialize(ptr noundef %131, ptr noundef %132)
  store ptr %133, ptr %13, align 8, !tbaa !5
  %134 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %134, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %136

135:                                              ; preds = %118
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %136

136:                                              ; preds = %135, %130, %113, %84, %67, %54, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %137

137:                                              ; preds = %136, %25, %18
  %138 = load ptr, ptr %3, align 8
  ret ptr %138
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 8}
!10 = !{!"_json_value", !6, i64 0, !11, i64 8, !7, i64 16, !7, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_json_object_entry", !6, i64 0, !11, i64 8, !6, i64 16}
!15 = !{!14, !6, i64 16}


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

@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @gravity_class_deserialize(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @gravity_object_deserialize(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 1
  br i1 %.not, label %5, label %61

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %61, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %11, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = tail call i32 @string_casencmp(ptr noundef %12, ptr noundef nonnull @.str.5, i64 noundef 4) #2
  %.not32 = icmp eq i32 %15, 0
  br i1 %.not32, label %18, label %16

16:                                               ; preds = %9
  %17 = tail call ptr @gravity_map_deserialize(ptr noundef %0, ptr noundef nonnull %1)
  br label %61

18:                                               ; preds = %9
  %19 = getelementptr inbounds i8, ptr %14, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !5
  %.not33 = icmp eq i32 %20, 5
  br i1 %.not33, label %21, label %61

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %14, i64 16
  %23 = getelementptr inbounds i8, ptr %14, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = load i32, ptr %22, align 8, !tbaa !11
  %26 = zext i32 %25 to i64
  %27 = tail call i32 @string_casencmp(ptr noundef %24, ptr noundef nonnull @.str.29, i64 noundef %26) #2
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = tail call ptr @gravity_function_deserialize(ptr noundef %0, ptr noundef nonnull %1)
  br label %61

31:                                               ; preds = %21
  %32 = load ptr, ptr %23, align 8, !tbaa !11
  %33 = load i32, ptr %22, align 8, !tbaa !11
  %34 = zext i32 %33 to i64
  %35 = tail call i32 @string_casencmp(ptr noundef %32, ptr noundef nonnull @.str.6, i64 noundef %34) #2
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %31
  %38 = tail call ptr @gravity_class_deserialize(ptr noundef %0, ptr noundef nonnull %1)
  br label %61

39:                                               ; preds = %31
  %40 = load ptr, ptr %23, align 8, !tbaa !11
  %41 = load i32, ptr %22, align 8, !tbaa !11
  %42 = zext i32 %41 to i64
  %43 = tail call i32 @string_casencmp(ptr noundef %40, ptr noundef nonnull @.str.48, i64 noundef %42) #2
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %51, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %23, align 8, !tbaa !11
  %47 = load i32, ptr %22, align 8, !tbaa !11
  %48 = zext i32 %47 to i64
  %49 = tail call i32 @string_casencmp(ptr noundef %46, ptr noundef nonnull @.str.49, i64 noundef %48) #2
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %45, %39
  %52 = tail call ptr @gravity_map_deserialize(ptr noundef %0, ptr noundef nonnull %1)
  br label %61

53:                                               ; preds = %45
  %54 = load ptr, ptr %23, align 8, !tbaa !11
  %55 = load i32, ptr %22, align 8, !tbaa !11
  %56 = zext i32 %55 to i64
  %57 = tail call i32 @string_casencmp(ptr noundef %54, ptr noundef nonnull @.str.50, i64 noundef %56) #2
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %53
  %60 = tail call ptr @gravity_range_deserialize(ptr noundef %0, ptr noundef nonnull %1)
  br label %61

61:                                               ; preds = %16, %29, %37, %51, %59, %18, %53, %5, %2
  %.1 = phi ptr [ null, %2 ], [ null, %5 ], [ %17, %16 ], [ %30, %29 ], [ %38, %37 ], [ %52, %51 ], [ %60, %59 ], [ null, %18 ], [ null, %53 ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @gravity_function_deserialize(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @gravity_range_deserialize(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 }

!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 0}
!13 = !{!"_json_object_entry", !7, i64 0, !10, i64 8, !7, i64 16}
!14 = !{!13, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass