; LLVM IR from pmwkaa/monotone :: monotone/engine/engine (refresh)

; 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.Refresh = type { ptr, ptr, ptr, ptr, ptr, ptr, %struct.Merger, ptr }
%struct.Merger = type { ptr, %struct.PartIterator, %struct.MemtableIterator, %struct.MergeIterator, %struct.Writer }
%struct.PartIterator = type { %struct.Iterator, %struct.RegionIterator, %struct.IndexIterator, ptr, ptr, %struct.Reader }
%struct.Iterator = type { ptr, ptr, ptr, ptr }
%struct.RegionIterator = type { %struct.Iterator, ptr, i32, ptr, ptr }
%struct.IndexIterator = type { ptr, ptr, ptr, i32 }
%struct.Reader = type { ptr, ptr, ptr, %struct.Buf, %struct.Buf, %struct.Buf }
%struct.Buf = type { ptr, ptr, ptr }
%struct.MemtableIterator = type { %struct.Iterator, ptr, ptr, i32, ptr, %struct.List }
%struct.List = type { ptr, ptr }
%struct.MergeIterator = type { %struct.Iterator, ptr, %struct.Buf, i32, ptr }
%struct.Writer = type { ptr, %struct.Iov, %struct.RegionWriter, %struct.IndexWriter, ptr, ptr, ptr }
%struct.Iov = type { %struct.Buf, i32, i32 }
%struct.RegionWriter = type { %struct.Buf, %struct.Buf, %struct.Buf, %struct.Buf, ptr, i32, ptr, ptr }
%struct.IndexWriter = type { i8, %struct.Buf, %struct.Buf, ptr, i32, %struct.Buf, ptr, ptr, i8, %struct.Index }
%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.Id = type { i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @refresh_init(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.Refresh, ptr %5, i32 0, i32 0
  store ptr null, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.Refresh, ptr %7, i32 0, i32 1
  store ptr null, ptr %8, align 8, !tbaa !30
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Refresh, ptr %9, i32 0, i32 2
  store ptr null, ptr %10, align 8, !tbaa !31
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Refresh, ptr %11, i32 0, i32 3
  store ptr null, ptr %12, align 8, !tbaa !32
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Refresh, ptr %13, i32 0, i32 4
  store ptr null, ptr %14, align 8, !tbaa !33
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Refresh, ptr %15, i32 0, i32 5
  store ptr null, ptr %16, align 8, !tbaa !34
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Refresh, ptr %18, i32 0, i32 7
  store ptr %17, ptr %19, align 8, !tbaa !35
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Refresh, ptr %20, i32 0, i32 6
  call void @merger_init(ptr noundef %21)
  ret void
}

declare void @merger_init(ptr noundef) #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 = { "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, !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 = !{!"Refresh", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !6, i64 896}
!11 = !{!"Merger", !6, i64 0, !12, i64 8, !19, i64 248, !21, i64 328, !22, i64 408}
!12 = !{!"PartIterator", !13, i64 0, !14, i64 32, !16, i64 96, !6, i64 128, !6, i64 136, !17, i64 144}
!13 = !{!"Iterator", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!"RegionIterator", !13, i64 0, !6, i64 32, !15, i64 40, !6, i64 48, !6, i64 56}
!15 = !{!"int", !7, i64 0}
!16 = !{!"IndexIterator", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24}
!17 = !{!"Reader", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24, !18, i64 48, !18, i64 72}
!18 = !{!"Buf", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"MemtableIterator", !13, i64 0, !6, i64 32, !6, i64 40, !15, i64 48, !6, i64 56, !20, i64 64}
!20 = !{!"List", !6, i64 0, !6, i64 8}
!21 = !{!"MergeIterator", !13, i64 0, !6, i64 32, !18, i64 40, !15, i64 64, !6, i64 72}
!22 = !{!"Writer", !6, i64 0, !23, i64 8, !24, i64 40, !25, i64 168, !6, i64 416, !6, i64 424, !6, i64 432}
!23 = !{!"Iov", !18, i64 0, !15, i64 24, !15, i64 28}
!24 = !{!"RegionWriter", !18, i64 0, !18, i64 24, !18, i64 48, !18, i64 72, !6, i64 96, !15, i64 104, !6, i64 112, !6, i64 120}
!25 = !{!"IndexWriter", !26, i64 0, !18, i64 8, !18, i64 32, !6, i64 56, !15, i64 64, !18, i64 72, !6, i64 96, !6, i64 104, !26, i64 112, !27, i64 113}
!26 = !{!"_Bool", !7, i64 0}
!27 = !{!"Index", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !28, i64 16, !15, i64 32, !15, i64 36, !29, i64 40, !29, i64 48, !29, i64 56, !29, i64 64, !15, i64 72, !29, i64 76, !29, i64 84, !29, i64 92, !15, i64 100, !29, i64 104, !7, i64 112, !7, i64 113, !7, i64 114}
!28 = !{!"Id", !29, i64 0, !29, i64 8}
!29 = !{!"long", !7, i64 0}
!30 = !{!10, !6, i64 8}
!31 = !{!10, !6, i64 16}
!32 = !{!10, !6, i64 24}
!33 = !{!10, !6, i64 32}
!34 = !{!10, !6, i64 40}
!35 = !{!10, !6, i64 896}


; 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 void @refresh_init(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 896
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %0, i8 0, i64 48, i1 false)
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @merger_init(ptr noundef nonnull %4) #3
  ret void
}

declare void @merger_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) #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, !7, i64 896}
!6 = !{!"Refresh", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !7, i64 896}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"Merger", !7, i64 0, !11, i64 8, !18, i64 248, !20, i64 328, !21, i64 408}
!11 = !{!"PartIterator", !12, i64 0, !13, i64 32, !15, i64 96, !7, i64 128, !7, i64 136, !16, i64 144}
!12 = !{!"Iterator", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!13 = !{!"RegionIterator", !12, i64 0, !7, i64 32, !14, i64 40, !7, i64 48, !7, i64 56}
!14 = !{!"int", !8, i64 0}
!15 = !{!"IndexIterator", !7, i64 0, !7, i64 8, !7, i64 16, !14, i64 24}
!16 = !{!"Reader", !7, i64 0, !7, i64 8, !7, i64 16, !17, i64 24, !17, i64 48, !17, i64 72}
!17 = !{!"Buf", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!"MemtableIterator", !12, i64 0, !7, i64 32, !7, i64 40, !14, i64 48, !7, i64 56, !19, i64 64}
!19 = !{!"List", !7, i64 0, !7, i64 8}
!20 = !{!"MergeIterator", !12, i64 0, !7, i64 32, !17, i64 40, !14, i64 64, !7, i64 72}
!21 = !{!"Writer", !7, i64 0, !22, i64 8, !23, i64 40, !24, i64 168, !7, i64 416, !7, i64 424, !7, i64 432}
!22 = !{!"Iov", !17, i64 0, !14, i64 24, !14, i64 28}
!23 = !{!"RegionWriter", !17, i64 0, !17, i64 24, !17, i64 48, !17, i64 72, !7, i64 96, !14, i64 104, !7, i64 112, !7, i64 120}
!24 = !{!"IndexWriter", !25, i64 0, !17, i64 8, !17, i64 32, !7, i64 56, !14, i64 64, !17, i64 72, !7, i64 96, !7, i64 104, !25, i64 112, !26, i64 113}
!25 = !{!"_Bool", !8, i64 0}
!26 = !{!"Index", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !27, i64 16, !14, i64 32, !14, i64 36, !28, i64 40, !28, i64 48, !28, i64 56, !28, i64 64, !14, i64 72, !28, i64 76, !28, i64 84, !28, i64 92, !14, i64 100, !28, i64 104, !8, i64 112, !8, i64 113, !8, i64 114}
!27 = !{!"Id", !28, i64 0, !28, i64 8}
!28 = !{!"long", !8, i64 0}


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