; LLVM IR from pmwkaa/monotone :: monotone/engine/io (part)

; 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.Part = type { %struct.Id, i32, i64, i64, i8, ptr, %struct.Memtable, %struct.Memtable, %struct.File, %struct.Index, %struct.Buf, ptr, ptr, ptr, %struct.List }
%struct.Id = type { i64, i64 }
%struct.Memtable = type { ptr, %struct.Rbtree, i32, i32, i32, i64, i64, i64, %struct.List, i32, %struct.Heap }
%struct.Rbtree = type { ptr }
%struct.Heap = type { ptr, ptr, i32, ptr }
%struct.File = type { i32, i64, %struct.Str, %struct.List }
%struct.Str = type { ptr, ptr, i8 }
%struct.Index = type <{ i32, i32, i32, i32, %struct.Id, i32, i32, i64, i64, i64, i64, i32, i64, i64, i64, i32, i64, i8, i8, [4 x i32] }>
%struct.Buf = type { ptr, ptr, ptr }
%struct.List = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @part_allocate(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %8 = call ptr @mn_malloc(i64 noundef 536)
  store ptr %8, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Part, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 1 %11, i64 16, i1 false), !tbaa.struct !9
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Part, ptr %12, i32 0, i32 1
  store i32 0, ptr %13, align 8, !tbaa !12
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Part, ptr %14, i32 0, i32 2
  store i64 0, ptr %15, align 8, !tbaa !25
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Part, ptr %16, i32 0, i32 3
  store i64 0, ptr %17, align 8, !tbaa !26
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Part, ptr %18, i32 0, i32 4
  store i8 0, ptr %19, align 8, !tbaa !27
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Part, ptr %20, i32 0, i32 11
  store ptr null, ptr %21, align 8, !tbaa !28
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Part, ptr %23, i32 0, i32 12
  store ptr %22, ptr %24, align 8, !tbaa !29
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Part, ptr %26, i32 0, i32 13
  store ptr %25, ptr %27, align 8, !tbaa !30
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Part, ptr %28, i32 0, i32 8
  call void @file_init(ptr noundef %29)
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Part, ptr %30, i32 0, i32 6
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Part, ptr %32, i32 0, i32 5
  store ptr %31, ptr %33, align 8, !tbaa !31
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Part, ptr %34, i32 0, i32 6
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  call void @memtable_init(ptr noundef %35, i32 noundef 512, i32 noundef 508, ptr noundef %36)
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Part, ptr %37, i32 0, i32 7
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  call void @memtable_init(ptr noundef %38, i32 noundef 512, i32 noundef 508, ptr noundef %39)
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Part, ptr %40, i32 0, i32 9
  call void @index_init(ptr noundef %41)
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Part, ptr %42, i32 0, i32 10
  call void @buf_init(ptr noundef %43)
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Part, ptr %44, i32 0, i32 14
  call void @list_init(ptr noundef %45)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %46
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mn_malloc(i64 noundef) #2

; 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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @file_init(ptr noundef) #2

declare void @memtable_init(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @index_init(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_init(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @list_init(ptr noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = !{i64 0, i64 8, !10, i64 8, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !15, i64 16}
!13 = !{!"Part", !14, i64 0, !15, i64 16, !11, i64 24, !11, i64 32, !16, i64 40, !6, i64 48, !17, i64 56, !17, i64 168, !21, i64 280, !23, i64 336, !24, i64 472, !6, i64 496, !6, i64 504, !6, i64 512, !19, i64 520}
!14 = !{!"Id", !11, i64 0, !11, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"Memtable", !6, i64 0, !18, i64 8, !15, i64 16, !15, i64 20, !15, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !19, i64 56, !15, i64 72, !20, i64 80}
!18 = !{!"Rbtree", !6, i64 0}
!19 = !{!"List", !6, i64 0, !6, i64 8}
!20 = !{!"Heap", !6, i64 0, !6, i64 8, !15, i64 16, !6, i64 24}
!21 = !{!"File", !15, i64 0, !11, i64 8, !22, i64 16, !19, i64 40}
!22 = !{!"Str", !6, i64 0, !6, i64 8, !16, i64 16}
!23 = !{!"Index", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !14, i64 16, !15, i64 32, !15, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !15, i64 72, !11, i64 76, !11, i64 84, !11, i64 92, !15, i64 100, !11, i64 104, !7, i64 112, !7, i64 113, !7, i64 114}
!24 = !{!"Buf", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!13, !11, i64 24}
!26 = !{!13, !11, i64 32}
!27 = !{!13, !16, i64 40}
!28 = !{!13, !6, i64 496}
!29 = !{!13, !6, i64 504}
!30 = !{!13, !6, i64 512}
!31 = !{!13, !6, i64 48}


; 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 noundef ptr @part_allocate(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = tail call ptr @mn_malloc(i64 noundef 536)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 1 dereferenceable(16) %2, i64 16, i1 false), !tbaa.struct !5
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 0, ptr %5, align 8, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %4, i64 24
  %7 = getelementptr inbounds i8, ptr %4, i64 496
  store ptr null, ptr %7, align 8, !tbaa !24
  %8 = getelementptr inbounds i8, ptr %4, i64 504
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %6, i8 0, i64 17, i1 false)
  store ptr %1, ptr %8, align 8, !tbaa !25
  %9 = getelementptr inbounds i8, ptr %4, i64 512
  store ptr %0, ptr %9, align 8, !tbaa !26
  %10 = getelementptr inbounds i8, ptr %4, i64 280
  tail call void @file_init(ptr noundef nonnull %10)
  %11 = getelementptr inbounds i8, ptr %4, i64 56
  %12 = getelementptr inbounds i8, ptr %4, i64 48
  store ptr %11, ptr %12, align 8, !tbaa !27
  tail call void @memtable_init(ptr noundef nonnull %11, i32 noundef 512, i32 noundef 508, ptr noundef %0) #5
  %13 = getelementptr inbounds i8, ptr %4, i64 168
  tail call void @memtable_init(ptr noundef nonnull %13, i32 noundef 512, i32 noundef 508, ptr noundef %0) #5
  %14 = getelementptr inbounds i8, ptr %4, i64 336
  tail call void @index_init(ptr noundef nonnull %14)
  %15 = getelementptr inbounds i8, ptr %4, i64 472
  tail call void @buf_init(ptr noundef nonnull %15)
  %16 = getelementptr inbounds i8, ptr %4, i64 520
  tail call void @list_init(ptr noundef nonnull %16)
  ret ptr %4
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mn_malloc(i64 noundef) local_unnamed_addr #1

; 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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @file_init(ptr noundef) local_unnamed_addr #1

declare void @memtable_init(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @index_init(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_init(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @list_init(ptr 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) #4

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 = { 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: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !13, i64 16}
!11 = !{!"Part", !12, i64 0, !13, i64 16, !7, i64 24, !7, i64 32, !14, i64 40, !15, i64 48, !16, i64 56, !16, i64 168, !20, i64 280, !22, i64 336, !23, i64 472, !15, i64 496, !15, i64 504, !15, i64 512, !18, i64 520}
!12 = !{!"Id", !7, i64 0, !7, i64 8}
!13 = !{!"int", !8, i64 0}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"Memtable", !15, i64 0, !17, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !18, i64 56, !13, i64 72, !19, i64 80}
!17 = !{!"Rbtree", !15, i64 0}
!18 = !{!"List", !15, i64 0, !15, i64 8}
!19 = !{!"Heap", !15, i64 0, !15, i64 8, !13, i64 16, !15, i64 24}
!20 = !{!"File", !13, i64 0, !7, i64 8, !21, i64 16, !18, i64 40}
!21 = !{!"Str", !15, i64 0, !15, i64 8, !14, i64 16}
!22 = !{!"Index", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !12, i64 16, !13, i64 32, !13, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !13, i64 72, !7, i64 76, !7, i64 84, !7, i64 92, !13, i64 100, !7, i64 104, !8, i64 112, !8, i64 113, !8, i64 114}
!23 = !{!"Buf", !15, i64 0, !15, i64 8, !15, i64 16}
!24 = !{!11, !15, i64 496}
!25 = !{!11, !15, i64 504}
!26 = !{!11, !15, i64 512}
!27 = !{!11, !15, i64 48}


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