; 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_function_t = type { ptr, %struct.gravity_gc_s, ptr, ptr, i16, i16, i16, i16, i32, %union.anon.4 }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { %struct.gravity_value_r, %struct.gravity_value_r, %struct.gravity_value_r, i32, ptr, ptr, float, i8 }
%struct.gravity_value_r = type { i64, i64, ptr }

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@gravity_class_function = external global ptr, align 8
@.str.18 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.gravity_function_new = external hidden unnamed_addr constant [107 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

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare ptr @string_dup(ptr noundef) #1

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

; 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
define dso_local ptr @gravity_function_new(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i16 noundef zeroext %4, ptr noundef %5) #3 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i16, align 2
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i16 %2, ptr %9, align 2, !tbaa !9
  store i16 %3, ptr %10, align 2, !tbaa !9
  store i16 %4, ptr %11, align 2, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %14 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 184)
  store ptr %14, ptr %13, align 8, !tbaa !5
  %15 = load ptr, ptr %13, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %6
  br label %19

18:                                               ; preds = %6
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 478, ptr noundef @__PRETTY_FUNCTION__.gravity_function_new) #5
  unreachable

19:                                               ; preds = %17
  %20 = load ptr, ptr @gravity_class_function, align 8, !tbaa !5
  %21 = load ptr, ptr %13, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.gravity_function_t, ptr %21, i32 0, i32 0
  store ptr %20, ptr %22, align 8, !tbaa !11
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %28

25:                                               ; preds = %19
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call ptr @string_dup(ptr noundef %26)
  br label %29

28:                                               ; preds = %19
  br label %29

29:                                               ; preds = %28, %25
  %30 = phi ptr [ %27, %25 ], [ null, %28 ]
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.gravity_function_t, ptr %31, i32 0, i32 3
  store ptr %30, ptr %32, align 8, !tbaa !16
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.gravity_function_t, ptr %33, i32 0, i32 8
  store i32 0, ptr %34, align 8, !tbaa !17
  %35 = load i16, ptr %9, align 2, !tbaa !9
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.gravity_function_t, ptr %36, i32 0, i32 4
  store i16 %35, ptr %37, align 8, !tbaa !18
  %38 = load i16, ptr %10, align 2, !tbaa !9
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.gravity_function_t, ptr %39, i32 0, i32 5
  store i16 %38, ptr %40, align 2, !tbaa !19
  %41 = load i16, ptr %11, align 2, !tbaa !9
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.gravity_function_t, ptr %42, i32 0, i32 6
  store i16 %41, ptr %43, align 4, !tbaa !20
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.gravity_function_t, ptr %44, i32 0, i32 7
  store i16 0, ptr %45, align 2, !tbaa !21
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %92

48:                                               ; preds = %29
  %49 = load ptr, ptr %13, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.gravity_function_t, ptr %49, i32 0, i32 9
  %51 = getelementptr inbounds %struct.anon.5, ptr %50, i32 0, i32 7
  store i8 0, ptr %51, align 4, !tbaa !22
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.gravity_function_t, ptr %53, i32 0, i32 9
  %55 = getelementptr inbounds %struct.anon.5, ptr %54, i32 0, i32 4
  store ptr %52, ptr %55, align 8, !tbaa !22
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.gravity_function_t, ptr %56, i32 0, i32 9
  %58 = getelementptr inbounds %struct.anon.5, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.gravity_value_r, ptr %58, i32 0, i32 1
  store i64 0, ptr %59, align 8, !tbaa !22
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.gravity_function_t, ptr %60, i32 0, i32 9
  %62 = getelementptr inbounds %struct.anon.5, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds %struct.gravity_value_r, ptr %62, i32 0, i32 0
  store i64 0, ptr %63, align 8, !tbaa !22
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.gravity_function_t, ptr %64, i32 0, i32 9
  %66 = getelementptr inbounds %struct.anon.5, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.gravity_value_r, ptr %66, i32 0, i32 2
  store ptr null, ptr %67, align 8, !tbaa !22
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.gravity_function_t, ptr %68, i32 0, i32 9
  %70 = getelementptr inbounds %struct.anon.5, ptr %69, i32 0, i32 1
  %71 = getelementptr inbounds %struct.gravity_value_r, ptr %70, i32 0, i32 1
  store i64 0, ptr %71, align 8, !tbaa !22
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.gravity_function_t, ptr %72, i32 0, i32 9
  %74 = getelementptr inbounds %struct.anon.5, ptr %73, i32 0, i32 1
  %75 = getelementptr inbounds %struct.gravity_value_r, ptr %74, i32 0, i32 0
  store i64 0, ptr %75, align 8, !tbaa !22
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.gravity_function_t, ptr %76, i32 0, i32 9
  %78 = getelementptr inbounds %struct.anon.5, ptr %77, i32 0, i32 1
  %79 = getelementptr inbounds %struct.gravity_value_r, ptr %78, i32 0, i32 2
  store ptr null, ptr %79, align 8, !tbaa !22
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.gravity_function_t, ptr %80, i32 0, i32 9
  %82 = getelementptr inbounds %struct.anon.5, ptr %81, i32 0, i32 2
  %83 = getelementptr inbounds %struct.gravity_value_r, ptr %82, i32 0, i32 1
  store i64 0, ptr %83, align 8, !tbaa !22
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.gravity_function_t, ptr %84, i32 0, i32 9
  %86 = getelementptr inbounds %struct.anon.5, ptr %85, i32 0, i32 2
  %87 = getelementptr inbounds %struct.gravity_value_r, ptr %86, i32 0, i32 0
  store i64 0, ptr %87, align 8, !tbaa !22
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.gravity_function_t, ptr %88, i32 0, i32 9
  %90 = getelementptr inbounds %struct.anon.5, ptr %89, i32 0, i32 2
  %91 = getelementptr inbounds %struct.gravity_value_r, ptr %90, i32 0, i32 2
  store ptr null, ptr %91, align 8, !tbaa !22
  br label %92

92:                                               ; preds = %48, %29
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %95, label %98

95:                                               ; preds = %92
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = load ptr, ptr %13, align 8, !tbaa !5
  call void @gravity_vm_transfer(ptr noundef %96, ptr noundef %97)
  br label %98

98:                                               ; preds = %95, %92
  %99 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret ptr %99
}

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 = { noreturn nounwind "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 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 #4 = { nounwind }
attributes #5 = { noreturn 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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 66, !10, i64 68, !10, i64 70, !15, i64 72, !7, i64 80}
!13 = !{!"gravity_gc_s", !14, i64 0, !14, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!12, !6, i64 56}
!17 = !{!12, !15, i64 72}
!18 = !{!12, !10, i64 64}
!19 = !{!12, !10, i64 66}
!20 = !{!12, !10, i64 68}
!21 = !{!12, !10, i64 70}
!22 = !{!7, !7, 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"

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@gravity_class_function = external local_unnamed_addr global ptr, align 8
@.str.18 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.gravity_function_new = external hidden unnamed_addr constant [107 x i8], align 1

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @string_dup(ptr noundef) local_unnamed_addr #0

declare void @gravity_vm_transfer(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @gravity_function_new(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i16 noundef zeroext %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 184) #4
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %9

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i32 noundef 478, ptr noundef nonnull @__PRETTY_FUNCTION__.gravity_function_new) #5
  unreachable

9:                                                ; preds = %6
  %10 = load ptr, ptr @gravity_class_function, align 8, !tbaa !5
  store ptr %10, ptr %7, align 8, !tbaa !9
  %.not32 = icmp eq ptr %1, null
  br i1 %.not32, label %13, label %11

11:                                               ; preds = %9
  %12 = tail call ptr @string_dup(ptr noundef nonnull %1) #4
  br label %13

13:                                               ; preds = %9, %11
  %14 = phi ptr [ %12, %11 ], [ null, %9 ]
  %15 = getelementptr inbounds i8, ptr %7, i64 56
  store ptr %14, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %7, i64 72
  store i32 0, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %7, i64 64
  store i16 %2, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %7, i64 66
  store i16 %3, ptr %18, align 2, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %7, i64 68
  store i16 %4, ptr %19, align 4, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %7, i64 70
  store i16 0, ptr %20, align 2, !tbaa !20
  %.not33 = icmp eq ptr %5, null
  br i1 %.not33, label %25, label %21

21:                                               ; preds = %13
  %22 = getelementptr inbounds i8, ptr %7, i64 80
  %23 = getelementptr inbounds i8, ptr %7, i64 180
  store i8 0, ptr %23, align 4, !tbaa !21
  %24 = getelementptr inbounds i8, ptr %7, i64 160
  store ptr %5, ptr %24, align 8, !tbaa !21
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %22, i8 0, i64 72, i1 false)
  br label %25

25:                                               ; preds = %21, %13
  %.not34 = icmp eq ptr %0, null
  br i1 %.not34, label %27, label %26

26:                                               ; preds = %25
  tail call void @gravity_vm_transfer(ptr noundef nonnull %0, ptr noundef nonnull %7) #4
  br label %27

27:                                               ; preds = %26, %25
  ret ptr %7
}

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

attributes #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 = { noreturn nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
attributes #5 = { noreturn 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, !6, i64 56, !13, i64 64, !13, i64 66, !13, i64 68, !13, i64 70, !14, i64 72, !7, i64 80}
!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 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !6, i64 56}
!16 = !{!10, !14, i64 72}
!17 = !{!10, !13, i64 64}
!18 = !{!10, !13, i64 66}
!19 = !{!10, !13, i64 68}
!20 = !{!10, !13, i64 70}
!21 = !{!7, !7, i64 0}


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