; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_array)

; 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.HandleList = type { %struct.MList, i32, i32, i32, i32 }
%struct.MList = type { i32, ptr }
%struct.MHandle = type { i32, i32, ptr, ptr }
%struct._MArray = type { i32, i16, i16, %union.anon.0 }
%union.anon.0 = type { ptr }
%struct.HandleArrayCreate = type { ptr, ptr, [8 x i64], i32, i32, 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 void @mArrayDataExchange(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, 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) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.HandleList, ptr %11, i64 -1
  %13 = getelementptr inbounds %struct.HandleList, ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %struct.MList, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds ptr, ptr %15, i64 0
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.MHandle, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.HandleList, ptr %20, i64 -1
  %22 = getelementptr inbounds %struct.HandleList, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.MList, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds ptr, ptr %24, i64 0
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.MHandle, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  store ptr %28, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %29, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %30, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._MArray, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !15
  store i32 %33, ptr %9, align 4, !tbaa !18
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._MArray, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MArray, ptr %37, i32 0, i32 0
  store i32 %36, ptr %38, align 8, !tbaa !15
  %39 = load i32, ptr %9, align 4, !tbaa !18
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._MArray, ptr %40, i32 0, i32 0
  store i32 %39, ptr %41, align 8, !tbaa !15
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._MArray, ptr %42, i32 0, i32 1
  %44 = load i16, ptr %43, align 4, !tbaa !19
  %45 = sext i16 %44 to i32
  store i32 %45, ptr %9, align 4, !tbaa !18
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._MArray, ptr %46, i32 0, i32 1
  %48 = load i16, ptr %47, align 4, !tbaa !19
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._MArray, ptr %49, i32 0, i32 1
  store i16 %48, ptr %50, align 4, !tbaa !19
  %51 = load i32, ptr %9, align 4, !tbaa !18
  %52 = trunc i32 %51 to i16
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._MArray, ptr %53, i32 0, i32 1
  store i16 %52, ptr %54, align 4, !tbaa !19
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._MArray, ptr %55, i32 0, i32 2
  %57 = load i16, ptr %56, align 2, !tbaa !20
  %58 = zext i16 %57 to i32
  store i32 %58, ptr %9, align 4, !tbaa !18
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._MArray, ptr %59, i32 0, i32 2
  %61 = load i16, ptr %60, align 2, !tbaa !20
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._MArray, ptr %62, i32 0, i32 2
  store i16 %61, ptr %63, align 2, !tbaa !20
  %64 = load i32, ptr %9, align 4, !tbaa !18
  %65 = trunc i32 %64 to i16
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._MArray, ptr %66, i32 0, i32 2
  store i16 %65, ptr %67, align 2, !tbaa !20
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._MArray, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  store ptr %70, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._MArray, ptr %71, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !21
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._MArray, ptr %74, i32 0, i32 3
  store ptr %73, ptr %75, align 8, !tbaa !21
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._MArray, ptr %77, i32 0, i32 3
  store ptr %76, ptr %78, align 8, !tbaa !21
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.HandleArrayCreate, ptr %79, i32 0, i32 4
  %81 = load i32, ptr %80, align 4, !tbaa !22
  store i32 %81, ptr %9, align 4, !tbaa !18
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.HandleArrayCreate, ptr %82, i32 0, i32 4
  %84 = load i32, ptr %83, align 4, !tbaa !22
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.HandleArrayCreate, ptr %85, i32 0, i32 4
  store i32 %84, ptr %86, align 4, !tbaa !22
  %87 = load i32, ptr %9, align 4, !tbaa !18
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HandleArrayCreate, ptr %88, i32 0, i32 4
  store i32 %87, ptr %89, align 4, !tbaa !22
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.HandleArrayCreate, ptr %90, i32 0, i32 5
  %92 = load i32, ptr %91, align 8, !tbaa !24
  store i32 %92, ptr %9, align 4, !tbaa !18
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.HandleArrayCreate, ptr %93, i32 0, i32 5
  %95 = load i32, ptr %94, align 8, !tbaa !24
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.HandleArrayCreate, ptr %96, i32 0, i32 5
  store i32 %95, ptr %97, align 8, !tbaa !24
  %98 = load i32, ptr %9, align 4, !tbaa !18
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.HandleArrayCreate, ptr %99, i32 0, i32 5
  store i32 %98, ptr %100, align 8, !tbaa !24
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.HandleArrayCreate, ptr %101, i32 0, i32 6
  %103 = load ptr, ptr %102, align 8, !tbaa !25
  store ptr %103, ptr %10, align 8, !tbaa !5
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.HandleArrayCreate, ptr %104, i32 0, i32 6
  %106 = load ptr, ptr %105, align 8, !tbaa !25
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.HandleArrayCreate, ptr %107, i32 0, i32 6
  store ptr %106, ptr %108, align 8, !tbaa !25
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.HandleArrayCreate, ptr %110, i32 0, i32 6
  store ptr %109, ptr %111, align 8, !tbaa !25
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.HandleArrayCreate, ptr %112, i32 0, i32 7
  store i32 0, ptr %113, align 8, !tbaa !26
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.HandleArrayCreate, ptr %114, i32 0, i32 7
  store i32 0, ptr %115, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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 = { 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 8}
!10 = !{!"HandleList", !11, i64 0, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!11 = !{!"MList", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"MHandle", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16}
!15 = !{!16, !12, i64 0}
!16 = !{!"_MArray", !12, i64 0, !17, i64 4, !17, i64 6, !7, i64 8}
!17 = !{!"short", !7, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{!16, !17, i64 4}
!20 = !{!16, !17, i64 6}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !12, i64 84}
!23 = !{!"HandleArrayCreate", !6, i64 0, !6, i64 8, !7, i64 16, !12, i64 80, !12, i64 84, !12, i64 88, !6, i64 96, !12, i64 104}
!24 = !{!23, !12, i64 88}
!25 = !{!23, !6, i64 96}
!26 = !{!23, !12, 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: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @mArrayDataExchange(ptr nocapture noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 -24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %1, i64 -24
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = load i32, ptr %0, align 8, !tbaa !15
  %14 = load i32, ptr %1, align 8, !tbaa !15
  store i32 %14, ptr %0, align 8, !tbaa !15
  store i32 %13, ptr %1, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = getelementptr inbounds i8, ptr %1, i64 4
  %17 = load <2 x i16>, ptr %16, align 4, !tbaa !18
  %18 = load <2 x i16>, ptr %15, align 4, !tbaa !18
  store <2 x i16> %17, ptr %15, align 4, !tbaa !18
  store <2 x i16> %18, ptr %16, align 4, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  store ptr %22, ptr %19, align 8, !tbaa !19
  store ptr %20, ptr %21, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %7, i64 84
  %24 = getelementptr inbounds i8, ptr %12, i64 84
  %25 = load <2 x i32>, ptr %24, align 4, !tbaa !20
  %26 = load <2 x i32>, ptr %23, align 4, !tbaa !20
  store <2 x i32> %25, ptr %23, align 4, !tbaa !20
  store <2 x i32> %26, ptr %24, align 4, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %7, i64 96
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %12, i64 96
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  store ptr %30, ptr %27, align 8, !tbaa !21
  store ptr %28, ptr %29, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %7, i64 104
  store i32 0, ptr %31, align 8, !tbaa !23
  %32 = getelementptr inbounds i8, ptr %12, i64 104
  store i32 0, ptr %32, align 8, !tbaa !23
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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" }

!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 8}
!6 = !{!"HandleList", !7, i64 0, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28}
!7 = !{!"MList", !8, i64 0, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 16}
!14 = !{!"MHandle", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16}
!15 = !{!16, !8, i64 0}
!16 = !{!"_MArray", !8, i64 0, !17, i64 4, !17, i64 6, !9, i64 8}
!17 = !{!"short", !9, i64 0}
!18 = !{!17, !17, i64 0}
!19 = !{!9, !9, i64 0}
!20 = !{!8, !8, i64 0}
!21 = !{!22, !11, i64 96}
!22 = !{!"HandleArrayCreate", !11, i64 0, !11, i64 8, !9, i64 16, !8, i64 80, !8, i64 84, !8, i64 88, !11, i64 96, !8, i64 104}
!23 = !{!22, !8, i64 104}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass