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

; 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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @gravity_class_grow(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @gravity_class_setsuper(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %64

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.gravity_class_s, ptr %15, i32 0, i32 9
  store ptr %14, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %13
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call ptr @gravity_class_get_meta(ptr noundef %20)
  br label %23

22:                                               ; preds = %13
  br label %23

23:                                               ; preds = %22, %19
  %24 = phi ptr [ %21, %19 ], [ null, %22 ]
  store ptr %24, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %23
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.gravity_class_s, ptr %28, i32 0, i32 12
  %30 = load i32, ptr %29, align 8, !tbaa !14
  br label %32

31:                                               ; preds = %23
  br label %32

32:                                               ; preds = %31, %27
  %33 = phi i32 [ %30, %27 ], [ 0, %31 ]
  store i32 %33, ptr %7, align 4, !tbaa !15
  %34 = load i32, ptr %7, align 4, !tbaa !15
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %43

36:                                               ; preds = %32
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call ptr @gravity_class_get_meta(ptr noundef %37)
  %39 = load i32, ptr %7, align 4, !tbaa !15
  %40 = call zeroext i1 @gravity_class_grow(ptr noundef %38, i32 noundef %39)
  br i1 %40, label %42, label %41

41:                                               ; preds = %36
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %63

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42, %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %50

46:                                               ; preds = %43
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.gravity_class_s, ptr %47, i32 0, i32 12
  %49 = load i32, ptr %48, align 8, !tbaa !14
  br label %51

50:                                               ; preds = %43
  br label %51

51:                                               ; preds = %50, %46
  %52 = phi i32 [ %49, %46 ], [ 0, %50 ]
  store i32 %52, ptr %9, align 4, !tbaa !15
  %53 = load i32, ptr %9, align 4, !tbaa !15
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %51
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !15
  %58 = call zeroext i1 @gravity_class_grow(ptr noundef %56, i32 noundef %57)
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %62

60:                                               ; preds = %55
  br label %61

61:                                               ; preds = %60, %51
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %62

62:                                               ; preds = %61, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %63

63:                                               ; preds = %62, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %64

64:                                               ; preds = %63, %12
  %65 = load i1, ptr %3, align 1
  ret i1 %65
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @gravity_class_get_meta(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 }

!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 80}
!10 = !{!"gravity_class_s", !6, i64 0, !11, i64 8, !6, i64 48, !6, i64 56, !12, i64 64, !12, i64 65, !12, i64 66, !12, i64 67, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !13, i64 104, !6, i64 112}
!11 = !{!"gravity_gc_s", !12, i64 0, !12, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !13, i64 104}
!15 = !{!13, !13, 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"

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @gravity_class_grow(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @gravity_class_setsuper(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %17, label %3

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = tail call ptr @gravity_class_get_meta(ptr noundef nonnull %1)
  %.not19 = icmp eq ptr %5, null
  br i1 %.not19, label %.thread, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %5, i64 104
  %8 = load i32, ptr %7, align 8, !tbaa !13
  %.not20 = icmp eq i32 %8, 0
  br i1 %.not20, label %.thread, label %9

9:                                                ; preds = %6
  %10 = tail call ptr @gravity_class_get_meta(ptr noundef nonnull %0)
  %11 = tail call zeroext i1 @gravity_class_grow(ptr noundef %10, i32 noundef %8)
  br i1 %11, label %.thread, label %17

.thread:                                          ; preds = %3, %6, %9
  %12 = getelementptr inbounds i8, ptr %1, i64 104
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %.not21 = icmp eq i32 %13, 0
  br i1 %.not21, label %16, label %14

14:                                               ; preds = %.thread
  %15 = tail call zeroext i1 @gravity_class_grow(ptr noundef nonnull %0, i32 noundef %13)
  br i1 %15, label %16, label %17

16:                                               ; preds = %14, %.thread
  br label %17

17:                                               ; preds = %9, %14, %16, %2
  %.2 = phi i1 [ true, %2 ], [ false, %9 ], [ true, %16 ], [ false, %14 ]
  ret i1 %.2
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @gravity_class_get_meta(ptr noundef) local_unnamed_addr #0

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 80}
!6 = !{!"gravity_class_s", !7, i64 0, !10, i64 8, !7, i64 48, !7, i64 56, !11, i64 64, !11, i64 65, !11, i64 66, !11, i64 67, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !12, i64 104, !7, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"gravity_gc_s", !11, i64 0, !11, i64 1, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !12, i64 104}


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