; 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_string_t = type { ptr, %struct.gravity_gc_s, ptr, i32, i32, i32 }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }
%struct.gravity_value_t = type { ptr, %union.anon }
%union.anon = type { i64 }
%struct.gravity_instance_t = type { ptr, %struct.gravity_gc_s, ptr, ptr, ptr }

@gravity_class_string = external global ptr, align 8
@.str.68 = external hidden unnamed_addr constant [7 x i8], align 1

; 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: inlinehint nounwind uwtable
declare dso_local ptr @gravity_class_lookup_closure(ptr noundef, ptr, i64) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @gravity_hash_compute_buffer(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @gravity_instance_deinit(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.gravity_string_t, align 8
  %6 = alloca %struct.gravity_value_t, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.gravity_value_t, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr %5) #5
  %9 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 0
  %10 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  store ptr %10, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 1
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 40, i1 false)
  %12 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 2
  store ptr @.str.68, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 3
  store i32 0, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 4
  store i32 6, ptr %14, align 4, !tbaa !16
  %15 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 5
  store i32 0, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 4
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %20 = call i32 @gravity_hash_compute_buffer(ptr noundef %17, i32 noundef %19)
  %21 = getelementptr inbounds %struct.gravity_string_t, ptr %5, i32 0, i32 3
  store i32 %20, ptr %21, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  %22 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 0
  %23 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  store ptr %23, ptr %22, align 8, !tbaa !18
  %24 = getelementptr inbounds %struct.gravity_value_t, ptr %6, i32 0, i32 1
  store ptr %5, ptr %24, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.gravity_instance_t, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %28 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8
  %30 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 1
  %31 = load i64, ptr %30, align 8
  %32 = call ptr @gravity_class_lookup_closure(ptr noundef %27, ptr %29, i64 %31)
  store ptr %32, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %49

35:                                               ; preds = %2
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.gravity_value_t, ptr %8, i32 0, i32 0
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.gravity_instance_t, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !23
  store ptr %41, ptr %38, align 8, !tbaa !18
  %42 = getelementptr inbounds %struct.gravity_value_t, ptr %8, i32 0, i32 1
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %43, ptr %42, align 8, !tbaa !20
  %44 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8
  %46 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 1
  %47 = load i64, ptr %46, align 8
  %48 = call zeroext i1 @gravity_vm_runclosure(ptr noundef %36, ptr noundef %37, ptr %45, i64 %47, ptr noundef null, i16 noundef zeroext 0)
  br label %49

49:                                               ; preds = %35, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 72, ptr %5) #5
  ret void
}

declare zeroext i1 @gravity_vm_runclosure(ptr noundef, ptr noundef, ptr, i64, ptr noundef, i16 noundef zeroext) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #4 = { 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 #5 = { 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 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48, !13, i64 56, !13, i64 60, !13, i64 64}
!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, !6, i64 48}
!15 = !{!10, !13, i64 56}
!16 = !{!10, !13, i64 60}
!17 = !{!10, !13, i64 64}
!18 = !{!19, !6, i64 0}
!19 = !{!"", !6, i64 0, !7, i64 8}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !6, i64 48}
!22 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48, !6, i64 56, !6, i64 64}
!23 = !{!22, !6, 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"

%struct.gravity_string_t = type { ptr, %struct.gravity_gc_s, ptr, i32, i32, i32 }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }

@gravity_class_string = external local_unnamed_addr global ptr, align 8
@.str.68 = external hidden unnamed_addr constant [7 x i8], align 1

; 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

; Function Attrs: inlinehint nounwind uwtable
declare dso_local ptr @gravity_class_lookup_closure(ptr noundef, ptr, i64) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @gravity_hash_compute_buffer(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @gravity_instance_deinit(ptr noundef %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = alloca %struct.gravity_string_t, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #5
  %4 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  store ptr %4, ptr %3, align 8, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %5, i8 0, i64 40, i1 false)
  %6 = getelementptr inbounds i8, ptr %3, i64 48
  store ptr @.str.68, ptr %6, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %3, i64 56
  %8 = getelementptr inbounds i8, ptr %3, i64 60
  store i32 6, ptr %8, align 4, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %3, i64 64
  store i32 0, ptr %9, align 8, !tbaa !16
  %10 = tail call i32 @gravity_hash_compute_buffer(ptr noundef nonnull @.str.68, i32 noundef 6) #5
  store i32 %10, ptr %7, align 8, !tbaa !17
  %11 = load ptr, ptr @gravity_class_string, align 8, !tbaa !5
  %12 = ptrtoint ptr %3 to i64
  %13 = getelementptr inbounds i8, ptr %1, i64 48
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %15 = call ptr @gravity_class_lookup_closure(ptr noundef %14, ptr %11, i64 %12)
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %20, label %16

16:                                               ; preds = %2
  %17 = load ptr, ptr %1, align 8, !tbaa !20
  %18 = ptrtoint ptr %1 to i64
  %19 = call zeroext i1 @gravity_vm_runclosure(ptr noundef %0, ptr noundef nonnull %15, ptr %17, i64 %18, ptr noundef null, i16 noundef zeroext 0) #5
  br label %20

20:                                               ; preds = %16, %2
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #5
  ret void
}

declare zeroext i1 @gravity_vm_runclosure(ptr noundef, ptr noundef, ptr, i64, ptr noundef, i16 noundef zeroext) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #4 = { 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 #5 = { 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 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48, !13, i64 56, !13, i64 60, !13, i64 64}
!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, !6, i64 48}
!15 = !{!10, !13, i64 60}
!16 = !{!10, !13, i64 64}
!17 = !{!10, !13, i64 56}
!18 = !{!19, !6, i64 48}
!19 = !{!"", !6, i64 0, !11, i64 8, !6, i64 48, !6, i64 56, !6, i64 64}
!20 = !{!19, !6, i64 0}


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