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

@gravity_class_module = external global ptr, align 8
@gravity_class_class = external global ptr, align 8
@gravity_class_null = external global ptr, align 8
@gravity_class_object = external global ptr, align 8
@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_upvalue = external global ptr, align 8
@gravity_class_fiber = external global ptr, align 8
@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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @gravity_value_isobject(ptr %0, i64 %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca %struct.gravity_value_t, align 8
  %5 = getelementptr inbounds { ptr, i64 }, ptr %4, i32 0, i32 0
  store ptr %0, ptr %5, align 8
  %6 = getelementptr inbounds { ptr, i64 }, ptr %4, i32 0, i32 1
  store i64 %1, ptr %6, align 8
  %7 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %34, label %10

10:                                               ; preds = %2
  %11 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr @gravity_class_int, align 8, !tbaa !10
  %14 = icmp eq ptr %12, %13
  br i1 %14, label %34, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = load ptr, ptr @gravity_class_float, align 8, !tbaa !10
  %19 = icmp eq ptr %17, %18
  br i1 %19, label %34, label %20

20:                                               ; preds = %15
  %21 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = load ptr, ptr @gravity_class_bool, align 8, !tbaa !10
  %24 = icmp eq ptr %22, %23
  br i1 %24, label %34, label %25

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

30:                                               ; preds = %25
  %31 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %30, %25, %20, %15, %10, %2
  store i1 false, ptr %3, align 1
  br label %97

35:                                               ; preds = %30
  %36 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load ptr, ptr @gravity_class_string, align 8, !tbaa !10
  %39 = icmp eq ptr %37, %38
  br i1 %39, label %95, label %40

40:                                               ; preds = %35
  %41 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load ptr, ptr @gravity_class_object, align 8, !tbaa !10
  %44 = icmp eq ptr %42, %43
  br i1 %44, label %95, label %45

45:                                               ; preds = %40
  %46 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = load ptr, ptr @gravity_class_function, align 8, !tbaa !10
  %49 = icmp eq ptr %47, %48
  br i1 %49, label %95, label %50

50:                                               ; preds = %45
  %51 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = load ptr, ptr @gravity_class_closure, align 8, !tbaa !10
  %54 = icmp eq ptr %52, %53
  br i1 %54, label %95, label %55

55:                                               ; preds = %50
  %56 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  %58 = load ptr, ptr @gravity_class_fiber, align 8, !tbaa !10
  %59 = icmp eq ptr %57, %58
  br i1 %59, label %95, label %60

60:                                               ; preds = %55
  %61 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load ptr, ptr @gravity_class_class, align 8, !tbaa !10
  %64 = icmp eq ptr %62, %63
  br i1 %64, label %95, label %65

65:                                               ; preds = %60
  %66 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load ptr, ptr @gravity_class_instance, align 8, !tbaa !10
  %69 = icmp eq ptr %67, %68
  br i1 %69, label %95, label %70

70:                                               ; preds = %65
  %71 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = load ptr, ptr @gravity_class_module, align 8, !tbaa !10
  %74 = icmp eq ptr %72, %73
  br i1 %74, label %95, label %75

75:                                               ; preds = %70
  %76 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !5
  %78 = load ptr, ptr @gravity_class_list, align 8, !tbaa !10
  %79 = icmp eq ptr %77, %78
  br i1 %79, label %95, label %80

80:                                               ; preds = %75
  %81 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  %83 = load ptr, ptr @gravity_class_map, align 8, !tbaa !10
  %84 = icmp eq ptr %82, %83
  br i1 %84, label %95, label %85

85:                                               ; preds = %80
  %86 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !5
  %88 = load ptr, ptr @gravity_class_range, align 8, !tbaa !10
  %89 = icmp eq ptr %87, %88
  br i1 %89, label %95, label %90

90:                                               ; preds = %85
  %91 = getelementptr inbounds %struct.gravity_value_t, ptr %4, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  %93 = load ptr, ptr @gravity_class_upvalue, align 8, !tbaa !10
  %94 = icmp eq ptr %92, %93
  br i1 %94, label %95, label %96

95:                                               ; preds = %90, %85, %80, %75, %70, %65, %60, %55, %50, %45, %40, %35
  store i1 true, ptr %3, align 1
  br label %97

96:                                               ; preds = %90
  store i1 false, ptr %3, align 1
  br label %97

97:                                               ; preds = %96, %95, %34
  %98 = load i1, ptr %3, align 1
  ret i1 %98
}

attributes #0 = { 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" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"", !7, i64 0, !8, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!8, !8, i64 0}


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

@gravity_class_module = external local_unnamed_addr global ptr, align 8
@gravity_class_class = external local_unnamed_addr global ptr, align 8
@gravity_class_null = external local_unnamed_addr global ptr, align 8
@gravity_class_object = external local_unnamed_addr global ptr, align 8
@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_upvalue = external local_unnamed_addr global ptr, align 8
@gravity_class_fiber = external local_unnamed_addr global ptr, align 8
@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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local zeroext i1 @gravity_value_isobject(ptr readnone %0, i64 %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = load ptr, ptr @gravity_class_int, align 8
  %5 = icmp eq ptr %4, %0
  %or.cond21 = select i1 %3, i1 true, i1 %5
  %6 = load ptr, ptr @gravity_class_float, align 8
  %7 = icmp eq ptr %6, %0
  %or.cond23 = select i1 %or.cond21, i1 true, i1 %7
  %8 = load ptr, ptr @gravity_class_bool, align 8
  %9 = icmp eq ptr %8, %0
  %or.cond25 = select i1 %or.cond23, i1 true, i1 %9
  br i1 %or.cond25, label %47, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr @gravity_class_null, align 8, !tbaa !5
  %12 = icmp eq ptr %11, %0
  %13 = icmp eq i64 %1, 0
  %or.cond = select i1 %12, i1 true, i1 %13
  br i1 %or.cond, label %47, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  %16 = load ptr, ptr @gravity_class_object, align 8
  %17 = load ptr, ptr @gravity_class_function, align 8
  %18 = load ptr, ptr @gravity_class_closure, align 8
  %19 = load ptr, ptr @gravity_class_fiber, align 8
  %20 = load ptr, ptr @gravity_class_class, align 8
  %21 = load ptr, ptr @gravity_class_instance, align 8
  %22 = load ptr, ptr @gravity_class_module, align 8
  %23 = insertelement <8 x ptr> poison, ptr %15, i64 0
  %24 = insertelement <8 x ptr> %23, ptr %16, i64 1
  %25 = insertelement <8 x ptr> %24, ptr %17, i64 2
  %26 = insertelement <8 x ptr> %25, ptr %18, i64 3
  %27 = insertelement <8 x ptr> %26, ptr %19, i64 4
  %28 = insertelement <8 x ptr> %27, ptr %20, i64 5
  %29 = insertelement <8 x ptr> %28, ptr %21, i64 6
  %30 = insertelement <8 x ptr> %29, ptr %22, i64 7
  %31 = insertelement <8 x ptr> poison, ptr %0, i64 0
  %32 = shufflevector <8 x ptr> %31, <8 x ptr> poison, <8 x i32> zeroinitializer
  %33 = icmp eq <8 x ptr> %30, %32
  %34 = load ptr, ptr @gravity_class_list, align 8
  %35 = icmp eq ptr %34, %0
  %36 = load ptr, ptr @gravity_class_map, align 8
  %37 = icmp eq ptr %36, %0
  %38 = load ptr, ptr @gravity_class_range, align 8
  %39 = icmp eq ptr %38, %0
  %40 = load ptr, ptr @gravity_class_upvalue, align 8
  %41 = icmp eq ptr %40, %0
  %42 = freeze <8 x i1> %33
  %43 = bitcast <8 x i1> %42 to i8
  %44 = icmp ne i8 %43, 0
  %.fr = freeze i1 %35
  %op.rdx = or i1 %44, %.fr
  %45 = freeze i1 %37
  %46 = or i1 %op.rdx, %45
  %.fr51 = freeze i1 %39
  %op.rdx49 = or i1 %46, %.fr51
  %op.rdx50 = select i1 %op.rdx49, i1 true, i1 %41
  br label %47

47:                                               ; preds = %14, %2, %10
  %.0 = phi i1 [ false, %10 ], [ false, %2 ], [ %op.rdx50, %14 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

!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"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass