; LLVM IR from haoming-Yu/MINISQL :: 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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = 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
  br label %7

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

9:                                                ; preds = %7
  br label %10

10:                                               ; preds = %9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = add i64 %12, 4
  %14 = trunc i64 %13 to i32
  store i32 %14, ptr %5, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 0
  %17 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %16) #3
  %18 = trunc i64 %17 to i32
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  store i32 %18, ptr %22, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %15
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = add i64 %26, 4
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %5, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %24
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %30, i64 %32
  %34 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 0
  %35 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %34) #3
  %36 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 0
  %37 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %36) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %33, ptr align 1 %35, i64 %37, i1 false)
  br label %38

38:                                               ; preds = %29
  br label %39

39:                                               ; preds = %38
  %40 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 0
  %41 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %40) #3
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = add i64 %43, %41
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %5, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %39
  %47 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 1
  %48 = load i32, ptr %47, align 8, !tbaa !11
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %49, i64 %51
  store i32 %48, ptr %52, align 4, !tbaa !18
  br label %53

53:                                               ; preds = %46
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = add i64 %56, 4
  %58 = trunc i64 %57 to i32
  store i32 %58, ptr %5, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %54
  %60 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 2
  %61 = load i32, ptr %60, align 4, !tbaa !19
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  store i32 %61, ptr %65, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %59
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %5, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = add i64 %69, 4
  %71 = trunc i64 %70 to i32
  store i32 %71, ptr %5, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %67
  %73 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 3
  %74 = load i32, ptr %73, align 8, !tbaa !20
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds i8, ptr %75, i64 %77
  store i32 %74, ptr %78, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %72
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %5, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = add i64 %82, 4
  %84 = trunc i64 %83 to i32
  store i32 %84, ptr %5, align 4, !tbaa !9
  br label %85

85:                                               ; preds = %80
  %86 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 4
  %87 = load i8, ptr %86, align 4, !tbaa !21, !range !22, !noundef !23
  %88 = trunc i8 %87 to i1
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  %93 = zext i1 %88 to i8
  store i8 %93, ptr %92, align 1, !tbaa !24
  br label %94

94:                                               ; preds = %85
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = add i64 %97, 1
  %99 = trunc i64 %98 to i32
  store i32 %99, ptr %5, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %95
  %101 = getelementptr inbounds %class.Column, ptr %6, i32 0, i32 5
  %102 = load i8, ptr %101, align 1, !tbaa !25, !range !22, !noundef !23
  %103 = trunc i8 %102 to i1
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = load i32, ptr %5, align 4, !tbaa !9
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds i8, ptr %104, i64 %106
  %108 = zext i1 %103 to i8
  store i8 %108, ptr %107, align 1, !tbaa !24
  br label %109

109:                                              ; preds = %100
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %5, align 4, !tbaa !9
  %112 = zext i32 %111 to i64
  %113 = add i64 %112, 1
  %114 = trunc i64 %113 to i32
  store i32 %114, ptr %5, align 4, !tbaa !9
  %115 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %115
}

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

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

; 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

; 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

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