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

; 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.blist = type { ptr, i8, i8, ptr, i32, i32, ptr }
%struct.bvm = type { %struct.bglobaldesc, ptr, ptr, ptr, %struct.bvector, %struct.bvector, ptr, ptr, ptr, ptr, ptr, %struct.bvector, %struct.bmoduledesc, %struct.bstringtable, %struct.bvector, ptr, %struct.bgc, ptr, i8, i64, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.bglobaldesc = type { %struct.anon, %struct.anon.0 }
%struct.anon = type { ptr, %struct.bvector }
%struct.anon.0 = type { ptr, %struct.bvector }
%struct.bmoduledesc = type { ptr, ptr }
%struct.bstringtable = type { ptr, i32, i32 }
%struct.bvector = type { i32, i32, i32, ptr, ptr }
%struct.bgc = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i8, i8 }
%struct.bvalue = type { %union.bvaldata, i32 }
%union.bvaldata = type { double }

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

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

declare ptr @be_realloc(ptr noundef, ptr noundef, i64 noundef, i64 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 @be_list_copy(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, 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 8, ptr %5) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call ptr @be_newgcobj(ptr noundef %8, i32 noundef 20, i64 noundef 40)
  store ptr %9, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %20

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

18:                                               ; preds = %12
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  br label %21

20:                                               ; preds = %12, %2
  br label %21

21:                                               ; preds = %20, %18
  %22 = phi ptr [ %19, %18 ], [ null, %20 ]
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %70

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.blist, ptr %26, i32 0, i32 5
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = mul i64 %29, 16
  store i64 %30, ptr %7, align 8, !tbaa !14
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.blist, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.blist, ptr %34, i32 0, i32 4
  store i32 %33, ptr %35, align 8, !tbaa !16
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.blist, ptr %36, i32 0, i32 5
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.blist, ptr %39, i32 0, i32 5
  store i32 %38, ptr %40, align 4, !tbaa !11
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.bvm, ptr %42, i32 0, i32 8
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  %45 = getelementptr inbounds %struct.bvalue, ptr %44, i32 0, i32 0
  store ptr %41, ptr %45, align 8, !tbaa !25
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.bvm, ptr %46, i32 0, i32 8
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = getelementptr inbounds %struct.bvalue, ptr %48, i32 0, i32 1
  store i32 20, ptr %49, align 8, !tbaa !26
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.bvm, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = getelementptr inbounds %struct.bvalue, ptr %52, i32 1
  store ptr %53, ptr %51, align 8, !tbaa !17
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = load i64, ptr %7, align 8, !tbaa !14
  %56 = call ptr @be_realloc(ptr noundef %54, ptr noundef null, i64 noundef 0, i64 noundef %55)
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.blist, ptr %57, i32 0, i32 6
  store ptr %56, ptr %58, align 8, !tbaa !28
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.bvm, ptr %59, i32 0, i32 8
  %61 = load ptr, ptr %60, align 8, !tbaa !17
  %62 = getelementptr inbounds %struct.bvalue, ptr %61, i64 -1
  store ptr %62, ptr %60, align 8, !tbaa !17
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.blist, ptr %63, i32 0, i32 6
  %65 = load ptr, ptr %64, align 8, !tbaa !28
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.blist, ptr %66, i32 0, i32 6
  %68 = load ptr, ptr %67, align 8, !tbaa !28
  %69 = load i64, ptr %7, align 8, !tbaa !14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %65, ptr align 8 %68, i64 %69, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %70

70:                                               ; preds = %25, %21
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %71
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !13, i64 28}
!12 = !{!"blist", !6, i64 0, !7, i64 8, !7, i64 9, !6, i64 16, !13, i64 24, !13, i64 28, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !13, i64 24}
!17 = !{!18, !6, i64 184}
!18 = !{!"bvm", !19, i64 0, !6, i64 80, !6, i64 88, !6, i64 96, !21, i64 104, !21, i64 136, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !21, i64 208, !22, i64 240, !23, i64 256, !21, i64 272, !6, i64 304, !24, i64 312, !6, i64 376, !7, i64 384, !15, i64 392, !6, i64 400, !13, i64 408, !13, i64 412, !13, i64 416, !13, i64 420, !13, i64 424, !13, i64 428, !13, i64 432, !13, i64 436, !13, i64 440, !13, i64 444, !13, i64 448, !13, i64 452, !13, i64 456, !13, i64 460, !13, i64 464, !13, i64 468, !13, i64 472, !13, i64 476, !13, i64 480, !13, i64 484, !13, i64 488, !13, i64 492, !13, i64 496}
!19 = !{!"", !20, i64 0, !20, i64 40}
!20 = !{!"", !6, i64 0, !21, i64 8}
!21 = !{!"bvector", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!"bmoduledesc", !6, i64 0, !6, i64 8}
!23 = !{!"bstringtable", !6, i64 0, !13, i64 8, !13, i64 12}
!24 = !{!"bgc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !15, i64 40, !15, i64 48, !7, i64 56, !7, i64 57}
!25 = !{!7, !7, i64 0}
!26 = !{!27, !13, i64 8}
!27 = !{!"bvalue", !7, i64 0, !13, i64 8}
!28 = !{!12, !6, i64 32}


; 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"

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @be_list_copy(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = tail call ptr @be_newgcobj(ptr noundef %0, i32 noundef 20, i64 noundef 40) #3
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %.thread, label %4

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

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %1, i64 28
  %10 = load i32, ptr %9, align 4, !tbaa !10
  %11 = sext i32 %10 to i64
  %12 = shl nsw i64 %11, 4
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %14, ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %3, i64 28
  store i32 %10, ptr %16, align 4, !tbaa !10
  %17 = getelementptr inbounds i8, ptr %0, i64 184
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  store ptr %3, ptr %18, align 8, !tbaa !23
  %19 = load ptr, ptr %17, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  store i32 20, ptr %20, align 8, !tbaa !24
  %21 = getelementptr inbounds i8, ptr %19, i64 16
  store ptr %21, ptr %17, align 8, !tbaa !14
  %22 = tail call ptr @be_realloc(ptr noundef %0, ptr noundef null, i64 noundef 0, i64 noundef %12) #3
  %23 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr %22, ptr %23, align 8, !tbaa !26
  %24 = load ptr, ptr %17, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %24, i64 -16
  store ptr %25, ptr %17, align 8, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %1, i64 32
  %27 = load ptr, ptr %26, align 8, !tbaa !26
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %22, ptr align 8 %27, i64 %12, i1 false)
  br label %.thread

.thread:                                          ; preds = %4, %2, %8
  %28 = phi ptr [ %3, %8 ], [ null, %2 ], [ null, %4 ]
  ret ptr %28
}

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

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 = { 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: readwrite) }
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, !12, i64 28}
!11 = !{!"blist", !7, i64 0, !8, i64 8, !8, i64 9, !7, i64 16, !12, i64 24, !12, i64 28, !7, i64 32}
!12 = !{!"int", !8, i64 0}
!13 = !{!11, !12, i64 24}
!14 = !{!15, !7, i64 184}
!15 = !{!"bvm", !16, i64 0, !7, i64 80, !7, i64 88, !7, i64 96, !18, i64 104, !18, i64 136, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !18, i64 208, !19, i64 240, !20, i64 256, !18, i64 272, !7, i64 304, !21, i64 312, !7, i64 376, !8, i64 384, !22, i64 392, !7, i64 400, !12, i64 408, !12, i64 412, !12, i64 416, !12, i64 420, !12, i64 424, !12, i64 428, !12, i64 432, !12, i64 436, !12, i64 440, !12, i64 444, !12, i64 448, !12, i64 452, !12, i64 456, !12, i64 460, !12, i64 464, !12, i64 468, !12, i64 472, !12, i64 476, !12, i64 480, !12, i64 484, !12, i64 488, !12, i64 492, !12, i64 496}
!16 = !{!"", !17, i64 0, !17, i64 40}
!17 = !{!"", !7, i64 0, !18, i64 8}
!18 = !{!"bvector", !12, i64 0, !12, i64 4, !12, i64 8, !7, i64 16, !7, i64 24}
!19 = !{!"bmoduledesc", !7, i64 0, !7, i64 8}
!20 = !{!"bstringtable", !7, i64 0, !12, i64 8, !12, i64 12}
!21 = !{!"bgc", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !22, i64 40, !22, i64 48, !8, i64 56, !8, i64 57}
!22 = !{!"long", !8, i64 0}
!23 = !{!8, !8, i64 0}
!24 = !{!25, !12, i64 8}
!25 = !{!"bvalue", !8, i64 0, !12, i64 8}
!26 = !{!11, !7, i64 32}


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