; LLVM IR from QAQdev/mini-sql-engine :: src/record/types.ll (ZNK8TypeChar15DeserializeFromEPcPP5FieldbP7MemHeap)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5FieldC2E6TypeId(ptr noundef nonnull align 8 dereferenceable(18), i32 noundef) unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8TypeChar15DeserializeFromEPcPP5FieldbP7MemHeap(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3, ptr noundef %4) unnamed_addr #2 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %10, align 1, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8
  %15 = load i8, ptr %10, align 1, !tbaa !9, !range !11, !noundef !12
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %24

17:                                               ; preds = %5
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds ptr, ptr %19, i64 2
  %21 = load ptr, ptr %20, align 8
  %22 = call noundef ptr %21(ptr noundef nonnull align 8 dereferenceable(8) %18, i64 noundef 24)
  call void @_ZN5FieldC2E6TypeId(ptr noundef nonnull align 8 dereferenceable(18) %22, i32 noundef 3)
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %22, ptr %23, align 8, !tbaa !5
  store i32 0, ptr %6, align 4
  br label %40

24:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !15
  store i32 %26, ptr %12, align 4, !tbaa !15
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  %29 = getelementptr inbounds ptr, ptr %28, i64 2
  %30 = load ptr, ptr %29, align 8
  %31 = call noundef ptr %30(ptr noundef nonnull align 8 dereferenceable(8) %27, i64 noundef 24)
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 4
  %34 = load i32, ptr %12, align 4, !tbaa !15
  call void @_ZN5FieldC2E6TypeIdPcjb(ptr noundef nonnull align 8 dereferenceable(18) %31, i32 noundef 3, ptr noundef %33, i32 noundef %34, i1 noundef zeroext true)
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %31, ptr %35, align 8, !tbaa !5
  %36 = load i32, ptr %12, align 4, !tbaa !15
  %37 = zext i32 %36 to i64
  %38 = add i64 %37, 4
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %40

40:                                               ; preds = %24, %17
  %41 = load i32, ptr %6, align 4
  ret i32 %41
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5FieldC2E6TypeIdPcjb(ptr noundef nonnull align 8 dereferenceable(18), i32 noundef, ptr noundef, i32 noundef, i1 noundef zeroext) unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !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 nounwind uwtable
declare dso_local void @_ZN5FieldC2E6TypeId(ptr noundef nonnull align 8 dereferenceable(18), i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8TypeChar15DeserializeFromEPcPP5FieldbP7MemHeap(ptr nocapture noundef nonnull readnone align 8 dereferenceable(12) %0, ptr noundef %1, ptr nocapture noundef writeonly %2, i1 noundef zeroext %3, ptr noundef %4) unnamed_addr #1 align 2 {
  br i1 %3, label %6, label %11

6:                                                ; preds = %5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load ptr, ptr %8, align 8
  %10 = tail call noundef ptr %9(ptr noundef nonnull align 8 dereferenceable(8) %4, i64 noundef 24)
  tail call void @_ZN5FieldC2E6TypeId(ptr noundef nonnull align 8 dereferenceable(18) %10, i32 noundef 3)
  br label %19

11:                                               ; preds = %5
  %12 = load i32, ptr %1, align 4, !tbaa !8
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8
  %16 = tail call noundef ptr %15(ptr noundef nonnull align 8 dereferenceable(8) %4, i64 noundef 24)
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  tail call void @_ZN5FieldC2E6TypeIdPcjb(ptr noundef nonnull align 8 dereferenceable(18) %16, i32 noundef 3, ptr noundef nonnull %17, i32 noundef %12, i1 noundef zeroext true)
  %18 = add i32 %12, 4
  br label %19

19:                                               ; preds = %11, %6
  %.sink = phi ptr [ %10, %6 ], [ %16, %11 ]
  %.0 = phi i32 [ 0, %6 ], [ %18, %11 ]
  store ptr %.sink, ptr %2, align 8
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5FieldC2E6TypeIdPcjb(ptr noundef nonnull align 8 dereferenceable(18), i32 noundef, ptr noundef, i32 noundef, i1 noundef zeroext) unnamed_addr #1 align 2

attributes #0 = { 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 #1 = { 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" }

!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 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}


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