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

@gravity_class_null = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@gravity_class_int = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 x i8], align 1
@gravity_class_float = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local { ptr, i64 } @gravity_vm_get(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca %struct.gravity_value_t, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %88

8:                                                ; preds = %2
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = call i32 @strcmp(ptr noundef %9, ptr noundef @.str.8) #2
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %20

12:                                               ; preds = %8
  %13 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %14 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  store ptr %14, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.gravity_vm, ptr %16, i32 0, i32 16
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = sext i32 %18 to i64
  store i64 %19, ptr %15, align 8, !tbaa !18
  br label %92

20:                                               ; preds = %8
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i32 @strcmp(ptr noundef %21, ptr noundef @.str.9) #2
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %31

24:                                               ; preds = %20
  %25 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %26 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  store ptr %26, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.gravity_vm, ptr %28, i32 0, i32 20
  %30 = load i64, ptr %29, align 8, !tbaa !19
  store i64 %30, ptr %27, align 8, !tbaa !18
  br label %92

31:                                               ; preds = %20
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i32 @strcmp(ptr noundef %32, ptr noundef @.str.10) #2
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %42

35:                                               ; preds = %31
  %36 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %37 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  store ptr %37, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.gravity_vm, ptr %39, i32 0, i32 21
  %41 = load i64, ptr %40, align 8, !tbaa !20
  store i64 %41, ptr %38, align 8, !tbaa !18
  br label %92

42:                                               ; preds = %31
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call i32 @strcmp(ptr noundef %43, ptr noundef @.str.11) #2
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %53

46:                                               ; preds = %42
  %47 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %48 = load ptr, ptr @gravity_class_float, align 8, !tbaa !5
  store ptr %48, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gravity_vm, ptr %50, i32 0, i32 23
  %52 = load double, ptr %51, align 8, !tbaa !21
  store double %52, ptr %49, align 8, !tbaa !18
  br label %92

53:                                               ; preds = %42
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call i32 @strcmp(ptr noundef %54, ptr noundef @.str.12) #2
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %65

57:                                               ; preds = %53
  %58 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %59 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  store ptr %59, ptr %58, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.gravity_vm, ptr %61, i32 0, i32 7
  %63 = load i32, ptr %62, align 4, !tbaa !22
  %64 = zext i32 %63 to i64
  store i64 %64, ptr %60, align 8, !tbaa !18
  br label %92

65:                                               ; preds = %53
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = call i32 @strcmp(ptr noundef %66, ptr noundef @.str.13) #2
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %76

69:                                               ; preds = %65
  %70 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %71 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  store ptr %71, ptr %70, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.gravity_vm, ptr %73, i32 0, i32 18
  %75 = load i64, ptr %74, align 8, !tbaa !23
  store i64 %75, ptr %72, align 8, !tbaa !18
  br label %92

76:                                               ; preds = %65
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = call i32 @strcmp(ptr noundef %77, ptr noundef @.str.14) #2
  %79 = icmp eq i32 %78, 0
  br i1 %79, label %80, label %87

80:                                               ; preds = %76
  %81 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %82 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  store ptr %82, ptr %81, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.gravity_vm, ptr %84, i32 0, i32 9
  %86 = load i64, ptr %85, align 8, !tbaa !24
  store i64 %86, ptr %83, align 8, !tbaa !18
  br label %92

87:                                               ; preds = %76
  br label %88

88:                                               ; preds = %87, %2
  %89 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 0
  %90 = load ptr, ptr @gravity_class_null, align 8, !tbaa !5
  store ptr %90, ptr %89, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.gravity_value_t, ptr %3, i32 0, i32 1
  store i64 0, ptr %91, align 8, !tbaa !18
  br label %92

92:                                               ; preds = %88, %80, %69, %57, %46, %35, %24, %12
  %93 = load { ptr, i64 }, ptr %3, align 8
  ret { ptr, i64 } %93
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

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" }
attributes #1 = { 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 #2 = { 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, !6, i64 0}
!10 = !{!"", !6, i64 0, !7, i64 8}
!11 = !{!12, !13, i64 176}
!12 = !{!"gravity_vm", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 40, !15, i64 48, !13, i64 52, !13, i64 56, !16, i64 64, !16, i64 72, !13, i64 80, !7, i64 84, !6, i64 152, !6, i64 160, !6, i64 168, !13, i64 176, !16, i64 184, !16, i64 192, !6, i64 200, !16, i64 208, !16, i64 216, !16, i64 224, !14, i64 232, !16, i64 240, !17, i64 248, !17, i64 272}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"", !16, i64 0, !16, i64 8, !6, i64 16}
!18 = !{!7, !7, i64 0}
!19 = !{!12, !16, i64 208}
!20 = !{!12, !16, i64 216}
!21 = !{!12, !14, i64 232}
!22 = !{!12, !13, i64 52}
!23 = !{!12, !16, i64 192}
!24 = !{!12, !16, i64 64}


; 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_null = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@gravity_class_int = external local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 x i8], align 1
@gravity_class_float = external local_unnamed_addr global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local { ptr, i64 } @gravity_vm_get(ptr nocapture noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %47, label %3

3:                                                ; preds = %2
  %4 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.8) #2
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %10

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 176
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = sext i32 %8 to i64
  br label %47

10:                                               ; preds = %3
  %11 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.9) #2
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 208
  %15 = load i64, ptr %14, align 8, !tbaa !15
  br label %47

16:                                               ; preds = %10
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.10) #2
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 216
  %21 = load i64, ptr %20, align 8, !tbaa !16
  br label %47

22:                                               ; preds = %16
  %23 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.11) #2
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = getelementptr inbounds i8, ptr %0, i64 232
  %27 = load i64, ptr %26, align 8, !tbaa !17
  br label %47

28:                                               ; preds = %22
  %29 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.12) #2
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = getelementptr inbounds i8, ptr %0, i64 52
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = zext i32 %33 to i64
  br label %47

35:                                               ; preds = %28
  %36 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.13) #2
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = getelementptr inbounds i8, ptr %0, i64 192
  %40 = load i64, ptr %39, align 8, !tbaa !19
  br label %47

41:                                               ; preds = %35
  %42 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.14) #2
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %47

44:                                               ; preds = %41
  %45 = getelementptr inbounds i8, ptr %0, i64 64
  %46 = load i64, ptr %45, align 8, !tbaa !20
  br label %47

47:                                               ; preds = %2, %41, %44, %38, %31, %25, %19, %13, %6
  %.sroa.0.0.in = phi ptr [ @gravity_class_int, %6 ], [ @gravity_class_int, %13 ], [ @gravity_class_int, %19 ], [ @gravity_class_float, %25 ], [ @gravity_class_int, %31 ], [ @gravity_class_int, %38 ], [ @gravity_class_int, %44 ], [ @gravity_class_null, %41 ], [ @gravity_class_null, %2 ]
  %.sroa.9.0 = phi i64 [ %9, %6 ], [ %15, %13 ], [ %21, %19 ], [ %27, %25 ], [ %34, %31 ], [ %40, %38 ], [ %46, %44 ], [ 0, %41 ], [ 0, %2 ]
  %.sroa.0.0 = load ptr, ptr %.sroa.0.0.in, align 8, !tbaa !21
  %.fca.0.insert = insertvalue { ptr, i64 } poison, ptr %.sroa.0.0, 0
  %.fca.1.insert = insertvalue { ptr, i64 } %.fca.0.insert, i64 %.sroa.9.0, 1
  ret { ptr, i64 } %.fca.1.insert
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(read, 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" }
attributes #1 = { 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 #2 = { 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 176}
!6 = !{!"gravity_vm", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !12, i64 48, !10, i64 52, !10, i64 56, !13, i64 64, !13, i64 72, !10, i64 80, !8, i64 84, !7, i64 152, !7, i64 160, !7, i64 168, !10, i64 176, !13, i64 184, !13, i64 192, !7, i64 200, !13, i64 208, !13, i64 216, !13, i64 224, !11, i64 232, !13, i64 240, !14, i64 248, !14, i64 272}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 8, !7, i64 16}
!15 = !{!6, !13, i64 208}
!16 = !{!6, !13, i64 216}
!17 = !{!6, !11, i64 232}
!18 = !{!6, !10, i64 52}
!19 = !{!6, !13, i64 192}
!20 = !{!6, !13, i64 64}
!21 = !{!7, !7, i64 0}


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