; LLVM IR from weicao/cascadb :: src/store/file.ll (ZN7cascadb7AIOFile4readEmNS_5SliceE)

; 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.cascadb::AIOStatus" = type { i8, i64 }
%"class.cascadb::Slice" = type <{ ptr, i32, [4 x i8] }>
%class.BlockingAIOReqest = type { %"class.cascadb::Mutex", %"class.cascadb::CondVar", %"struct.cascadb::AIOStatus" }
%"class.cascadb::Mutex" = type { i8, %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.cascadb::CondVar" = type { %union.pthread_cond_t, ptr }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local { i8, i64 } @_ZN7cascadb7AIOFile4readEmNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef %1, ptr %2, i32 %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"struct.cascadb::AIOStatus", align 8
  %6 = alloca %"class.cascadb::Slice", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %"class.cascadb::Slice", align 8
  %13 = getelementptr inbounds { ptr, i32 }, ptr %6, i32 0, i32 0
  store ptr %2, ptr %13, align 8
  %14 = getelementptr inbounds { ptr, i32 }, ptr %6, i32 0, i32 1
  store i32 %3, ptr %14, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 120) #8
  invoke void @_ZN17BlockingAIOReqestC2Ev(ptr noundef nonnull align 8 dereferenceable(120) %16)
          to label %17 unwind label %40

17:                                               ; preds = %4
  store ptr %16, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.BlockingAIOReqest, ptr %18, i32 0, i32 0
  call void @_ZN7cascadb5Mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(48) %19)
  %20 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !11
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds { ptr, i32 }, ptr %12, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8
  %24 = getelementptr inbounds { ptr, i32 }, ptr %12, i32 0, i32 1
  %25 = load i32, ptr %24, align 8
  %26 = load ptr, ptr %15, align 8, !tbaa !14
  %27 = getelementptr inbounds ptr, ptr %26, i64 4
  %28 = load ptr, ptr %27, align 8
  call void %28(ptr noundef nonnull align 8 dereferenceable(8) %15, i64 noundef %20, ptr %23, i32 %25, ptr noundef %21, ptr noundef @_ZL20blocking_aio_handlerPvN7cascadb9AIOStatusE)
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.BlockingAIOReqest, ptr %29, i32 0, i32 1
  call void @_ZN7cascadb7CondVar4waitEv(ptr noundef nonnull align 8 dereferenceable(56) %30)
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %class.BlockingAIOReqest, ptr %31, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %32, i64 16, i1 false), !tbaa.struct !16
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.BlockingAIOReqest, ptr %33, i32 0, i32 0
  call void @_ZN7cascadb5Mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(48) %34)
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %17
  call void @_ZN17BlockingAIOReqestD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %35) #7
  call void @_ZdlPvm(ptr noundef %35, i64 noundef 120) #9
  br label %38

38:                                               ; preds = %37, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  %39 = load { i8, i64 }, ptr %5, align 8
  ret { i8, i64 } %39

40:                                               ; preds = %4
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %10, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %11, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 120) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %44

44:                                               ; preds = %40
  %45 = load ptr, ptr %10, align 8
  %46 = load i32, ptr %11, align 4
  %47 = insertvalue { ptr, i32 } poison, ptr %45, 0
  %48 = insertvalue { ptr, i32 } %47, i32 %46, 1
  resume { ptr, i32 } %48
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17BlockingAIOReqestC2Ev(ptr noundef nonnull align 8 dereferenceable(120)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

declare void @_ZN7cascadb5Mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(48)) #4

; 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) #5

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL20blocking_aio_handlerPvN7cascadb9AIOStatusE(ptr noundef, i8, i64) #0

declare void @_ZN7cascadb7CondVar4waitEv(ptr noundef nonnull align 8 dereferenceable(56)) #4

declare void @_ZN7cascadb5Mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(48)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN17BlockingAIOReqestD2Ev(ptr noundef nonnull align 8 dereferenceable(120)) unnamed_addr #6 align 2

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

attributes #0 = { mustprogress 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 = { nobuiltin allocsize(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 = { nobuiltin 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { inlinehint mustprogress 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{i64 0, i64 8, !5, i64 8, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !8, i64 0}
!16 = !{i64 0, i64 1, !17, i64 8, i64 8, !9}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !7, i64 0}


; 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 uwtable
define dso_local { i8, i64 } @_ZN7cascadb7AIOFile4readEmNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef %1, ptr %2, i32 %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = tail call noalias noundef nonnull dereferenceable(120) ptr @_Znwm(i64 noundef 120) #5
  invoke void @_ZN17BlockingAIOReqestC2Ev(ptr noundef nonnull align 8 dereferenceable(120) %5)
          to label %6 unwind label %12

6:                                                ; preds = %4
  tail call void @_ZN7cascadb5Mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(48) %5)
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 32
  %9 = load ptr, ptr %8, align 8
  tail call void %9(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef %1, ptr %2, i32 %3, ptr noundef nonnull %5, ptr noundef nonnull @_ZL20blocking_aio_handlerPvN7cascadb9AIOStatusE)
  %10 = getelementptr inbounds i8, ptr %5, i64 48
  tail call void @_ZN7cascadb7CondVar4waitEv(ptr noundef nonnull align 8 dereferenceable(56) %10)
  %11 = getelementptr inbounds i8, ptr %5, i64 104
  %.sroa.011.0.copyload = load i8, ptr %11, align 8, !tbaa !8
  %.sroa.213.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 112
  %.sroa.213.0.copyload = load i64, ptr %.sroa.213.0..sroa_idx, align 8, !tbaa !11
  tail call void @_ZN7cascadb5Mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(48) %5)
  tail call void @_ZN17BlockingAIOReqestD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %5) #6
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 120) #7
  %.fca.0.insert = insertvalue { i8, i64 } poison, i8 %.sroa.011.0.copyload, 0
  %.fca.1.insert = insertvalue { i8, i64 } %.fca.0.insert, i64 %.sroa.213.0.copyload, 1
  ret { i8, i64 } %.fca.1.insert

12:                                               ; preds = %4
  %13 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 120) #7
  resume { ptr, i32 } %13
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17BlockingAIOReqestC2Ev(ptr noundef nonnull align 8 dereferenceable(120)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @_ZN7cascadb5Mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL20blocking_aio_handlerPvN7cascadb9AIOStatusE(ptr noundef, i8, i64) #0

declare void @_ZN7cascadb7CondVar4waitEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #3

declare void @_ZN7cascadb5Mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN17BlockingAIOReqestD2Ev(ptr noundef nonnull align 8 dereferenceable(120)) unnamed_addr #4 align 2

attributes #0 = { mustprogress 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 = { nobuiltin allocsize(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 = { nobuiltin 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 = { "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 = { inlinehint mustprogress 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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"bool", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !10, i64 0}


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