; 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 = external hidden unnamed_addr constant [19 x i8], align 1
@.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_upload = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @part_has(ptr noundef, i32 noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @part_upload(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = call zeroext i1 @part_has(ptr noundef %3, i32 noundef 1)
  br i1 %4, label %5, label %6

5:                                                ; preds = %1
  br label %7

6:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 178, ptr noundef @__PRETTY_FUNCTION__.part_upload) #3
  unreachable

7:                                                ; preds = %5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Part, ptr %8, i32 0, i32 11
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %7
  br label %14

13:                                               ; preds = %7
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 179, ptr noundef @__PRETTY_FUNCTION__.part_upload) #3
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  call void @part_delete(ptr noundef %15, i32 noundef 16)
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @part_create(ptr noundef %16, i32 noundef 16)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Part, ptr %17, i32 0, i32 11
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Part, ptr %20, i32 0, i32 12
  %22 = load ptr, ptr %21, align 8, !tbaa !23
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Part, ptr %23, i32 0, i32 0
  call void @cloud_upload(ptr noundef %19, ptr noundef %22, ptr noundef %24)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  call void @part_rename(ptr noundef %25, i32 noundef 16, i32 noundef 8)
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cloud_upload(ptr noundef, ptr noundef, 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 = { 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 = { 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 #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, !6, i64 496}
!10 = !{!"Part", !11, i64 0, !13, i64 16, !12, i64 24, !12, i64 32, !14, i64 40, !6, i64 48, !15, i64 56, !15, i64 168, !19, i64 280, !21, i64 336, !22, i64 472, !6, i64 496, !6, i64 504, !6, i64 512, !17, i64 520}
!11 = !{!"Id", !12, i64 0, !12, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!"Memtable", !6, i64 0, !16, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !17, i64 56, !13, i64 72, !18, i64 80}
!16 = !{!"Rbtree", !6, i64 0}
!17 = !{!"List", !6, i64 0, !6, i64 8}
!18 = !{!"Heap", !6, i64 0, !6, i64 8, !13, i64 16, !6, i64 24}
!19 = !{!"File", !13, i64 0, !12, i64 8, !20, i64 16, !17, i64 40}
!20 = !{!"Str", !6, i64 0, !6, i64 8, !14, i64 16}
!21 = !{!"Index", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !11, i64 16, !13, i64 32, !13, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !13, i64 72, !12, i64 76, !12, i64 84, !12, i64 92, !13, i64 100, !12, i64 104, !7, i64 112, !7, i64 113, !7, i64 114}
!22 = !{!"Buf", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!10, !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 = external hidden unnamed_addr constant [19 x i8], align 1
@.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_upload = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @part_has(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @part_upload(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call zeroext i1 @part_has(ptr noundef %0, i32 noundef 1)
  br i1 %2, label %4, label %3

3:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 178, ptr noundef nonnull @__PRETTY_FUNCTION__.part_upload) #3
  unreachable

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

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 179, ptr noundef nonnull @__PRETTY_FUNCTION__.part_upload) #3
  unreachable

8:                                                ; preds = %4
  tail call void @part_delete(ptr noundef nonnull %0, i32 noundef 16)
  tail call void @part_create(ptr noundef nonnull %0, i32 noundef 16)
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 504
  %11 = load ptr, ptr %10, align 8, !tbaa !22
  tail call void @cloud_upload(ptr noundef %9, ptr noundef %11, ptr noundef nonnull %0)
  tail call void @part_rename(ptr noundef nonnull %0, i32 noundef 16, i32 noundef 8)
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cloud_upload(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { 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 = { 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 #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