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

@.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
@gravity_class_bool = external global ptr, align 8

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @gravity_vm_set(ptr noundef %0, ptr noundef %1, ptr %2, i64 %3) #1 {
  %5 = alloca i1, align 1
  %6 = alloca %struct.gravity_value_t, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 0
  store ptr %2, ptr %9, align 8
  %10 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 1
  store i64 %3, ptr %10, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %8, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %128

13:                                               ; preds = %4
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = call i32 @strcmp(ptr noundef %14, ptr noundef @.str.8) #2
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %38

17:                                               ; preds = %13
  %18 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr @gravity_class_bool, align 8, !tbaa !5
  %21 = icmp eq ptr %19, %20
  br i1 %21, label %22, label %38

22:                                               ; preds = %17
  %23 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.gravity_vm, ptr %27, i32 0, i32 16
  %29 = load i32, ptr %28, align 8, !tbaa !12
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 8, !tbaa !12
  br label %36

31:                                               ; preds = %22
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.gravity_vm, ptr %32, i32 0, i32 16
  %34 = load i32, ptr %33, align 8, !tbaa !12
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %33, align 8, !tbaa !12
  br label %36

36:                                               ; preds = %31, %26
  %37 = phi i32 [ %30, %26 ], [ %35, %31 ]
  store i1 true, ptr %5, align 1
  br label %129

38:                                               ; preds = %17, %13
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = call i32 @strcmp(ptr noundef %39, ptr noundef @.str.9) #2
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %52

42:                                               ; preds = %38
  %43 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  %46 = icmp eq ptr %44, %45
  br i1 %46, label %47, label %52

47:                                               ; preds = %42
  %48 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %49 = load i64, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gravity_vm, ptr %50, i32 0, i32 20
  store i64 %49, ptr %51, align 8, !tbaa !19
  store i1 true, ptr %5, align 1
  br label %129

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

56:                                               ; preds = %52
  %57 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  %60 = icmp eq ptr %58, %59
  br i1 %60, label %61, label %66

61:                                               ; preds = %56
  %62 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %63 = load i64, ptr %62, align 8, !tbaa !11
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.gravity_vm, ptr %64, i32 0, i32 21
  store i64 %63, ptr %65, align 8, !tbaa !20
  store i1 true, ptr %5, align 1
  br label %129

66:                                               ; preds = %56, %52
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = call i32 @strcmp(ptr noundef %67, ptr noundef @.str.11) #2
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %80

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

75:                                               ; preds = %70
  %76 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %77 = load double, ptr %76, align 8, !tbaa !11
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.gravity_vm, ptr %78, i32 0, i32 23
  store double %77, ptr %79, align 8, !tbaa !21
  store i1 true, ptr %5, align 1
  br label %129

80:                                               ; preds = %70, %66
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = call i32 @strcmp(ptr noundef %81, ptr noundef @.str.12) #2
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %95

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

89:                                               ; preds = %84
  %90 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %91 = load i64, ptr %90, align 8, !tbaa !11
  %92 = trunc i64 %91 to i32
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.gravity_vm, ptr %93, i32 0, i32 7
  store i32 %92, ptr %94, align 4, !tbaa !22
  store i1 true, ptr %5, align 1
  br label %129

95:                                               ; preds = %84, %80
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = call i32 @strcmp(ptr noundef %96, ptr noundef @.str.13) #2
  %98 = icmp eq i32 %97, 0
  br i1 %98, label %99, label %111

99:                                               ; preds = %95
  %100 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  %103 = icmp eq ptr %101, %102
  br i1 %103, label %104, label %111

104:                                              ; preds = %99
  %105 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %106 = load i64, ptr %105, align 8, !tbaa !11
  %107 = trunc i64 %106 to i32
  %108 = zext i32 %107 to i64
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.gravity_vm, ptr %109, i32 0, i32 18
  store i64 %108, ptr %110, align 8, !tbaa !23
  store i1 true, ptr %5, align 1
  br label %129

111:                                              ; preds = %99, %95
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = call i32 @strcmp(ptr noundef %112, ptr noundef @.str.14) #2
  %114 = icmp eq i32 %113, 0
  br i1 %114, label %115, label %127

115:                                              ; preds = %111
  %116 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !9
  %118 = load ptr, ptr @gravity_class_int, align 8, !tbaa !5
  %119 = icmp eq ptr %117, %118
  br i1 %119, label %120, label %127

120:                                              ; preds = %115
  %121 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  %122 = load i64, ptr %121, align 8, !tbaa !11
  %123 = trunc i64 %122 to i32
  %124 = zext i32 %123 to i64
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.gravity_vm, ptr %125, i32 0, i32 9
  store i64 %124, ptr %126, align 8, !tbaa !24
  store i1 true, ptr %5, align 1
  br label %129

127:                                              ; preds = %115, %111
  br label %128

128:                                              ; preds = %127, %4
  store i1 false, ptr %5, align 1
  br label %129

129:                                              ; preds = %128, %120, %104, %89, %75, %61, %47, %36
  %130 = load i1, ptr %5, align 1
  ret i1 %130
}

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

@.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
@gravity_class_bool = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @gravity_vm_set(ptr nocapture noundef %0, ptr noundef readonly %1, ptr readnone %2, i64 %3) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %54, label %5

5:                                                ; preds = %4
  %6 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.8) #2
  %7 = icmp eq i32 %6, 0
  %8 = load ptr, ptr @gravity_class_bool, align 8
  %9 = icmp eq ptr %8, %2
  %or.cond = select i1 %7, i1 %9, i1 false
  br i1 %or.cond, label %10, label %17

10:                                               ; preds = %5
  %.not29 = icmp eq i64 %3, 0
  %11 = getelementptr inbounds i8, ptr %0, i64 176
  %12 = load i32, ptr %11, align 8, !tbaa !5
  br i1 %.not29, label %15, label %13

13:                                               ; preds = %10
  %14 = add nsw i32 %12, 1
  store i32 %14, ptr %11, align 8, !tbaa !5
  br label %54

15:                                               ; preds = %10
  %16 = add nsw i32 %12, -1
  store i32 %16, ptr %11, align 8, !tbaa !5
  br label %54

17:                                               ; preds = %5
  %18 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.9) #2
  %19 = icmp eq i32 %18, 0
  %20 = load ptr, ptr @gravity_class_int, align 8
  %21 = icmp eq ptr %20, %2
  %or.cond32 = select i1 %19, i1 %21, i1 false
  br i1 %or.cond32, label %22, label %24

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr %0, i64 208
  store i64 %3, ptr %23, align 8, !tbaa !15
  br label %54

24:                                               ; preds = %17
  %25 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.10) #2
  %26 = icmp eq i32 %25, 0
  %or.cond34 = select i1 %26, i1 %21, i1 false
  br i1 %or.cond34, label %27, label %29

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 216
  store i64 %3, ptr %28, align 8, !tbaa !16
  br label %54

29:                                               ; preds = %24
  %30 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.11) #2
  %31 = icmp eq i32 %30, 0
  %32 = load ptr, ptr @gravity_class_float, align 8
  %33 = icmp eq ptr %32, %2
  %or.cond36 = select i1 %31, i1 %33, i1 false
  br i1 %or.cond36, label %34, label %36

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %0, i64 232
  store i64 %3, ptr %35, align 8, !tbaa !17
  br label %54

36:                                               ; preds = %29
  %37 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.12) #2
  %38 = icmp eq i32 %37, 0
  %or.cond38 = select i1 %38, i1 %21, i1 false
  br i1 %or.cond38, label %39, label %42

39:                                               ; preds = %36
  %40 = trunc i64 %3 to i32
  %41 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %40, ptr %41, align 4, !tbaa !18
  br label %54

42:                                               ; preds = %36
  %43 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.13) #2
  %44 = icmp eq i32 %43, 0
  %or.cond40 = select i1 %44, i1 %21, i1 false
  br i1 %or.cond40, label %45, label %48

45:                                               ; preds = %42
  %46 = and i64 %3, 4294967295
  %47 = getelementptr inbounds i8, ptr %0, i64 192
  store i64 %46, ptr %47, align 8, !tbaa !19
  br label %54

48:                                               ; preds = %42
  %49 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.14) #2
  %50 = icmp eq i32 %49, 0
  %or.cond42 = select i1 %50, i1 %21, i1 false
  br i1 %or.cond42, label %51, label %54

51:                                               ; preds = %48
  %52 = and i64 %3, 4294967295
  %53 = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %52, ptr %53, align 8, !tbaa !20
  br label %54

54:                                               ; preds = %4, %48, %13, %15, %51, %45, %39, %34, %27, %22
  %.0 = phi i1 [ true, %22 ], [ true, %27 ], [ true, %34 ], [ true, %39 ], [ true, %45 ], [ true, %51 ], [ true, %15 ], [ true, %13 ], [ false, %48 ], [ false, %4 ]
  ret i1 %.0
}

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(read, argmem: readwrite, 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 #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}


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