; 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 }
%struct.gravity_delegate_t = type { ptr, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, 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

declare void @gravity_hash_iterate2(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

declare i32 @string_size(ptr noundef) #1

declare i32 @gravity_hash_memsize(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @gravity_class_size(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.gravity_class_s, ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds %struct.gravity_gc_s, ptr %9, i32 0, i32 1
  store i8 1, ptr %10, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.gravity_class_s, ptr %11, i32 0, i32 12
  %13 = load i32, ptr %12, align 8, !tbaa !14
  %14 = zext i32 %13 to i64
  %15 = mul i64 %14, 16
  %16 = add i64 120, %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.gravity_class_s, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = call i32 @string_size(ptr noundef %19)
  %21 = zext i32 %20 to i64
  %22 = add i64 %16, %21
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !16
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.gravity_class_s, ptr %24, i32 0, i32 11
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  call void @gravity_hash_iterate2(ptr noundef %26, ptr noundef @gravity_hash_internalsize, ptr noundef %6, ptr noundef %27)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.gravity_class_s, ptr %28, i32 0, i32 11
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = call i32 @gravity_hash_memsize(ptr noundef %30)
  %32 = load i32, ptr %6, align 4, !tbaa !16
  %33 = add i32 %32, %31
  store i32 %33, ptr %6, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = call ptr @gravity_vm_delegate(ptr noundef %34)
  store ptr %35, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.gravity_class_s, ptr %36, i32 0, i32 8
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %56

40:                                               ; preds = %2
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.gravity_delegate_t, ptr %41, i32 0, i32 23
  %43 = load ptr, ptr %42, align 8, !tbaa !19
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %56

45:                                               ; preds = %40
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.gravity_delegate_t, ptr %46, i32 0, i32 23
  %48 = load ptr, ptr %47, align 8, !tbaa !19
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gravity_class_s, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = call i32 %48(ptr noundef %49, ptr noundef %52)
  %54 = load i32, ptr %5, align 4, !tbaa !16
  %55 = add i32 %54, %53
  store i32 %55, ptr %5, align 4, !tbaa !16
  br label %56

56:                                               ; preds = %45, %40, %2
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.gravity_class_s, ptr %57, i32 0, i32 1
  %59 = getelementptr inbounds %struct.gravity_gc_s, ptr %58, i32 0, i32 1
  store i8 0, ptr %59, align 1, !tbaa !9
  %60 = load i32, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %60
}

declare ptr @gravity_vm_delegate(ptr noundef) #1

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, !12, i64 9}
!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 = !{!10, !6, i64 56}
!16 = !{!13, !13, i64 0}
!17 = !{!10, !6, i64 96}
!18 = !{!10, !6, i64 72}
!19 = !{!20, !6, i64 176}
!20 = !{!"", !6, i64 0, !12, i64 8, !12, i64 9, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @gravity_hash_iterate2(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare i32 @string_size(ptr noundef) local_unnamed_addr #1

declare i32 @gravity_hash_memsize(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @gravity_class_size(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #2 {
  %3 = alloca i32, align 4
  %4 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 1, ptr %4, align 1, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 104
  %6 = load i32, ptr %5, align 8, !tbaa !13
  %7 = shl i32 %6, 4
  %8 = add i32 %7, 120
  %9 = getelementptr inbounds i8, ptr %1, i64 56
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = tail call i32 @string_size(ptr noundef %10) #3
  %12 = add i32 %8, %11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %1, i64 96
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  call void @gravity_hash_iterate2(ptr noundef %14, ptr noundef nonnull @gravity_hash_internalsize, ptr noundef nonnull %3, ptr noundef %0) #3
  %15 = load ptr, ptr %13, align 8, !tbaa !16
  %16 = call i32 @gravity_hash_memsize(ptr noundef %15) #3
  %17 = load i32, ptr %3, align 4, !tbaa !15
  %18 = add i32 %17, %16
  store i32 %18, ptr %3, align 4, !tbaa !15
  %19 = call ptr @gravity_vm_delegate(ptr noundef %0) #3
  %20 = getelementptr inbounds i8, ptr %1, i64 72
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %.not = icmp eq ptr %21, null
  br i1 %.not, label %28, label %22

22:                                               ; preds = %2
  %23 = getelementptr inbounds i8, ptr %19, i64 176
  %24 = load ptr, ptr %23, align 8, !tbaa !18
  %.not16 = icmp eq ptr %24, null
  br i1 %.not16, label %28, label %25

25:                                               ; preds = %22
  %26 = call i32 %24(ptr noundef %0, ptr noundef nonnull %21) #3
  %27 = add i32 %26, %12
  br label %28

28:                                               ; preds = %25, %22, %2
  %.0 = phi i32 [ %27, %25 ], [ %12, %22 ], [ %12, %2 ]
  store i8 0, ptr %4, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %.0
}

declare ptr @gravity_vm_delegate(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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, !11, i64 9}
!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}
!14 = !{!6, !7, i64 56}
!15 = !{!12, !12, i64 0}
!16 = !{!6, !7, i64 96}
!17 = !{!6, !7, i64 72}
!18 = !{!19, !7, i64 176}
!19 = !{!"", !7, i64 0, !11, i64 8, !11, i64 9, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184}


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