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

@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.part_offload = external hidden unnamed_addr constant [33 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @part_delete(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @part_offload(ptr noundef %0, i1 noundef zeroext %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = zext i1 %1 to i8
  store i8 %5, ptr %4, align 1, !tbaa !9
  %6 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc i8 %6 to i1
  br i1 %7, label %8, label %12

8:                                                ; preds = %2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Part, ptr %9, i32 0, i32 8
  call void @file_close(ptr noundef %10)
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  call void @part_delete(ptr noundef %11, i32 noundef 1)
  br label %29

12:                                               ; preds = %2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Part, ptr %13, i32 0, i32 11
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  br label %19

18:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 207, ptr noundef @__PRETTY_FUNCTION__.part_offload) #3
  unreachable

19:                                               ; preds = %17
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @part_delete(ptr noundef %20, i32 noundef 8)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Part, ptr %21, i32 0, i32 11
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Part, ptr %24, i32 0, i32 12
  %26 = load ptr, ptr %25, align 8, !tbaa !26
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Part, ptr %27, i32 0, i32 0
  call void @cloud_remove(ptr noundef %23, ptr noundef %26, ptr noundef %28)
  br label %29

29:                                               ; preds = %19, %8
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cloud_remove(ptr noundef, ptr noundef, ptr noundef) #0

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


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

@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.part_offload = external hidden unnamed_addr constant [33 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @part_delete(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @part_offload(ptr noundef %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  br i1 %1, label %3, label %5

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 280
  tail call void @file_close(ptr noundef nonnull %4)
  tail call void @part_delete(ptr noundef %0, i32 noundef 1)
  br label %13

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 496
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %9

8:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 207, ptr noundef nonnull @__PRETTY_FUNCTION__.part_offload) #3
  unreachable

9:                                                ; preds = %5
  tail call void @part_delete(ptr noundef nonnull %0, i32 noundef 8)
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 504
  %12 = load ptr, ptr %11, align 8, !tbaa !22
  tail call void @cloud_remove(ptr noundef %10, ptr noundef %12, ptr noundef nonnull %0)
  br label %13

13:                                               ; preds = %9, %3
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cloud_remove(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass