; LLVM IR from berry-lang/berry :: src (be_func)

; 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.bgcobject = type { ptr, i8, i8 }
%struct.bproto = type { ptr, i8, i8, i8, i8, i8, i8, i16, i16, i16, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32 }

; 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
define dso_local ptr @be_newproto(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = call ptr @be_newgcobj(ptr noundef %5, i32 noundef 19, i64 noundef 112)
  store ptr %6, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %17

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.bgcobject, ptr %10, i32 0, i32 1
  %12 = load i8, ptr %11, align 8, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = icmp eq i32 %13, 19
  br i1 %14, label %15, label %17

15:                                               ; preds = %9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  br label %18

17:                                               ; preds = %9, %1
  br label %18

18:                                               ; preds = %17, %15
  %19 = phi ptr [ %16, %15 ], [ null, %17 ]
  store ptr %19, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %61

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.bproto, ptr %23, i32 0, i32 11
  store ptr null, ptr %24, align 8, !tbaa !11
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.bproto, ptr %25, i32 0, i32 12
  store ptr null, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.bproto, ptr %27, i32 0, i32 13
  store ptr null, ptr %28, align 8, !tbaa !16
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.bproto, ptr %29, i32 0, i32 14
  store ptr null, ptr %30, align 8, !tbaa !17
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.bproto, ptr %31, i32 0, i32 15
  store ptr null, ptr %32, align 8, !tbaa !18
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.bproto, ptr %33, i32 0, i32 10
  store ptr null, ptr %34, align 8, !tbaa !19
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.bproto, ptr %35, i32 0, i32 7
  store i16 0, ptr %36, align 2, !tbaa !20
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.bproto, ptr %37, i32 0, i32 4
  store i8 0, ptr %38, align 1, !tbaa !21
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.bproto, ptr %39, i32 0, i32 9
  store i16 0, ptr %40, align 2, !tbaa !22
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.bproto, ptr %41, i32 0, i32 8
  store i16 0, ptr %42, align 8, !tbaa !23
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.bproto, ptr %43, i32 0, i32 3
  store i8 0, ptr %44, align 2, !tbaa !24
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.bproto, ptr %45, i32 0, i32 7
  store i16 0, ptr %46, align 2, !tbaa !20
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.bproto, ptr %47, i32 0, i32 5
  store i8 0, ptr %48, align 4, !tbaa !25
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.bproto, ptr %49, i32 0, i32 6
  store i8 0, ptr %50, align 1, !tbaa !26
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.bproto, ptr %51, i32 0, i32 16
  store ptr null, ptr %52, align 8, !tbaa !27
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bproto, ptr %53, i32 0, i32 17
  store ptr null, ptr %54, align 8, !tbaa !28
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.bproto, ptr %55, i32 0, i32 18
  store i32 0, ptr %56, align 8, !tbaa !29
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.bproto, ptr %57, i32 0, i32 19
  store ptr null, ptr %58, align 8, !tbaa !30
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.bproto, ptr %59, i32 0, i32 20
  store i32 0, ptr %60, align 8, !tbaa !31
  br label %61

61:                                               ; preds = %22, %18
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %62
}

declare ptr @be_newgcobj(ptr noundef, i32 noundef, i64 noundef) #2

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 = { "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, !7, i64 8}
!10 = !{!"bgcobject", !6, i64 0, !7, i64 8, !7, i64 9}
!11 = !{!12, !6, i64 32}
!12 = !{!"bproto", !6, i64 0, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !13, i64 14, !13, i64 16, !13, i64 18, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !14, i64 88, !6, i64 96, !14, i64 104}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !6, i64 48}
!17 = !{!12, !6, i64 56}
!18 = !{!12, !6, i64 64}
!19 = !{!12, !6, i64 24}
!20 = !{!12, !13, i64 14}
!21 = !{!12, !7, i64 11}
!22 = !{!12, !13, i64 18}
!23 = !{!12, !13, i64 16}
!24 = !{!12, !7, i64 10}
!25 = !{!12, !7, i64 12}
!26 = !{!12, !7, i64 13}
!27 = !{!12, !6, i64 72}
!28 = !{!12, !6, i64 80}
!29 = !{!12, !14, i64 88}
!30 = !{!12, !6, i64 96}
!31 = !{!12, !14, i64 104}


; 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
define dso_local ptr @be_newproto(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @be_newgcobj(ptr noundef %0, i32 noundef 19, i64 noundef 112) #3
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.thread, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %5 = load i8, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i8 %5, 19
  br i1 %6, label %7, label %.thread

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %2, i64 24
  %9 = getelementptr inbounds i8, ptr %2, i64 10
  %10 = getelementptr inbounds i8, ptr %2, i64 96
  store ptr null, ptr %10, align 8, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %2, i64 104
  store i32 0, ptr %11, align 8, !tbaa !14
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(10) %9, i8 0, i64 10, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(68) %8, i8 0, i64 68, i1 false)
  br label %.thread

.thread:                                          ; preds = %3, %1, %7
  %12 = phi ptr [ %2, %7 ], [ null, %1 ], [ null, %3 ]
  ret ptr %12
}

declare ptr @be_newgcobj(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

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

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" }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !8, i64 8}
!6 = !{!"bgcobject", !7, i64 0, !8, i64 8, !8, i64 9}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 96}
!11 = !{!"bproto", !7, i64 0, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !12, i64 14, !12, i64 16, !12, i64 18, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !13, i64 88, !7, i64 96, !13, i64 104}
!12 = !{!"short", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!11, !13, i64 104}


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