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

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

%class.Column = type <{ %"class.std::__cxx11::basic_string", i32, i32, i32, i8, i8, [2 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK6Column11SerializeToEPc(ptr noundef nonnull align 8 dereferenceable(46) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  br label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 210928, ptr %9, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %8
  br label %11

11:                                               ; preds = %10
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = add i64 %13, 4
  %15 = trunc i64 %14 to i32
  store i32 %15, ptr %5, align 4, !tbaa !9
  %16 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 0
  %17 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %16) #3
  %18 = mul i64 %17, 1
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr %6, align 4, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %20, i64 %22
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %23, ptr align 4 %6, i64 4, i1 false)
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = add i64 %25, 4
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %5, align 4, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 0
  %33 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %32) #3
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %33, i64 %35, i1 false)
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = add i32 %37, %36
  store i32 %38, ptr %5, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %11
  %40 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %42, i64 %44
  store i32 %41, ptr %45, align 4, !tbaa !18
  br label %46

46:                                               ; preds = %39
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = add i64 %49, 4
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %5, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %47
  %53 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 2
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %55, i64 %57
  store i32 %54, ptr %58, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %52
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = add i64 %62, 4
  %64 = trunc i64 %63 to i32
  store i32 %64, ptr %5, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %60
  %66 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 3
  %67 = load i32, ptr %66, align 8, !tbaa !20
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i8, ptr %68, i64 %70
  store i32 %67, ptr %71, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %65
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = add i64 %75, 4
  %77 = trunc i64 %76 to i32
  store i32 %77, ptr %5, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %73
  %79 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 4
  %80 = load i8, ptr %79, align 4, !tbaa !21, !range !22, !noundef !23
  %81 = trunc i8 %80 to i1
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load i32, ptr %5, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %82, i64 %84
  %86 = zext i1 %81 to i8
  store i8 %86, ptr %85, align 1, !tbaa !24
  br label %87

87:                                               ; preds = %78
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %5, align 4, !tbaa !9
  %90 = zext i32 %89 to i64
  %91 = add i64 %90, 1
  %92 = trunc i64 %91 to i32
  store i32 %92, ptr %5, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %88
  %94 = getelementptr inbounds %class.Column, ptr %7, i32 0, i32 5
  %95 = load i8, ptr %94, align 1, !tbaa !25, !range !22, !noundef !23
  %96 = trunc i8 %95 to i1
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load i32, ptr %5, align 4, !tbaa !9
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds i8, ptr %97, i64 %99
  %101 = zext i1 %96 to i8
  store i8 %101, ptr %100, align 1, !tbaa !24
  br label %102

102:                                              ; preds = %93
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %5, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = add i64 %105, 1
  %107 = trunc i64 %106 to i32
  store i32 %107, ptr %5, align 4, !tbaa !9
  %108 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %108
}

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !16, i64 32}
!12 = !{!"_ZTS6Column", !13, i64 0, !16, i64 32, !10, i64 36, !10, i64 40, !17, i64 44, !17, i64 45}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8, !7, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTS6TypeId", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!16, !16, i64 0}
!19 = !{!12, !10, i64 36}
!20 = !{!12, !10, i64 40}
!21 = !{!12, !17, i64 44}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!17, !17, i64 0}
!25 = !{!12, !17, i64 45}


; 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
define dso_local noundef i32 @_ZNK6Column11SerializeToEPc(ptr noundef nonnull align 8 dereferenceable(46) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 align 2 {
  store i32 210928, ptr %1, align 4, !tbaa !5
  %3 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %4 = trunc i64 %3 to i32
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %4, ptr %5, align 1
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %8 = and i64 %3, 4294967295
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %6, ptr align 1 %7, i64 %8, i1 false)
  %9 = add i64 %3, 8
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = and i64 %9, 4294967295
  %13 = getelementptr inbounds i8, ptr %1, i64 %12
  store i32 %11, ptr %13, align 4, !tbaa !17
  %14 = add i64 %3, 12
  %15 = getelementptr inbounds i8, ptr %0, i64 36
  %16 = load i32, ptr %15, align 4, !tbaa !18
  %17 = and i64 %14, 4294967295
  %18 = getelementptr inbounds i8, ptr %1, i64 %17
  store i32 %16, ptr %18, align 4, !tbaa !5
  %19 = add i64 %3, 16
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load i32, ptr %20, align 8, !tbaa !19
  %22 = and i64 %19, 4294967295
  %23 = getelementptr inbounds i8, ptr %1, i64 %22
  store i32 %21, ptr %23, align 4, !tbaa !5
  %24 = add i64 %3, 20
  %25 = getelementptr inbounds i8, ptr %0, i64 44
  %26 = load i8, ptr %25, align 4, !tbaa !20, !range !21, !noundef !22
  %27 = and i64 %24, 4294967295
  %28 = getelementptr inbounds i8, ptr %1, i64 %27
  store i8 %26, ptr %28, align 1, !tbaa !23
  %29 = add i64 %3, 21
  %30 = getelementptr inbounds i8, ptr %0, i64 45
  %31 = load i8, ptr %30, align 1, !tbaa !24, !range !21, !noundef !22
  %32 = and i64 %29, 4294967295
  %33 = getelementptr inbounds i8, ptr %1, i64 %32
  store i8 %31, ptr %33, align 1, !tbaa !23
  %34 = add i32 %4, 22
  ret i32 %34
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !15, i64 32}
!10 = !{!"_ZTS6Column", !11, i64 0, !15, i64 32, !6, i64 36, !6, i64 40, !16, i64 44, !16, i64 45}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !14, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTS6TypeId", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!15, !15, i64 0}
!18 = !{!10, !6, i64 36}
!19 = !{!10, !6, i64 40}
!20 = !{!10, !16, i64 44}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!16, !16, i64 0}
!24 = !{!10, !16, i64 45}


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