; LLVM IR from pingcap/tidb-bench :: abm/src/main.ll (ZN3abm5TableC2Emm)

; 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.abm::Table" = type { i64, i64, i64, ptr, ptr, ptr }

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__._ZN3abm5TableC2Emm = external hidden unnamed_addr constant [34 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

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

; 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 void @_ZN3abm5TableC2Emm(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %1, i64 noundef %2) unnamed_addr #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 0
  store i64 10, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 1
  %12 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %12, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 2
  %14 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %14, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !14
  %17 = icmp ugt i64 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  br label %21

19:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.5, i32 noundef 34, ptr noundef @__PRETTY_FUNCTION__._ZN3abm5TableC2Emm) #4
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  %22 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 2
  %23 = load i64, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !13
  %26 = icmp ule i64 %23, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %21
  br label %30

28:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.5, i32 noundef 35, ptr noundef @__PRETTY_FUNCTION__._ZN3abm5TableC2Emm) #4
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  %31 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !11
  %33 = mul i64 %32, 16
  %34 = call noalias noundef nonnull ptr @_Znam(i64 noundef %33) #5
  %35 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 3
  store ptr %34, ptr %35, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !16
  br label %36

36:                                               ; preds = %53, %30
  %37 = load i32, ptr %7, align 4, !tbaa !16
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 0
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = icmp ult i64 %38, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %56

43:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %44 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = load i32, ptr %7, align 4, !tbaa !16
  %47 = sext i32 %46 to i64
  %48 = mul i64 %47, 16
  %49 = getelementptr inbounds i8, ptr %45, i64 %48
  store ptr %49, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 1
  %52 = load i64, ptr %51, align 8, !tbaa !13
  call void @_ZN3abm6ColumnIlEC2Em(ptr noundef nonnull align 8 dereferenceable(16) %50, i64 noundef %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %53

53:                                               ; preds = %43
  %54 = load i32, ptr %7, align 4, !tbaa !16
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %7, align 4, !tbaa !16
  br label %36, !llvm.loop !18

56:                                               ; preds = %42
  %57 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = getelementptr inbounds i8, ptr %58, i64 0
  %60 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 4
  store ptr %59, ptr %60, align 8, !tbaa !20
  %61 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = getelementptr inbounds i8, ptr %62, i64 16
  %64 = getelementptr inbounds %"class.abm::Table", ptr %9, i32 0, i32 5
  store ptr %63, ptr %64, align 8, !tbaa !21
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3abm6ColumnIlEC2Em(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) unnamed_addr #2 align 2

attributes #0 = { 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 #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 = { 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 #4 = { noreturn nounwind }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { 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 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN3abm5TableE", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !6, i64 32}
!21 = !{!12, !6, i64 40}


; 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.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__._ZN3abm5TableC2Emm = external hidden unnamed_addr constant [34 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3abm5TableC2Emm(ptr nocapture noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %1, i64 noundef %2) unnamed_addr #1 align 2 {
  store i64 10, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %1, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %2, ptr %5, align 8, !tbaa !12
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %6, label %7

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, i32 noundef 34, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN3abm5TableC2Emm) #3
  unreachable

7:                                                ; preds = %3
  %.not8 = icmp ult i64 %1, %2
  br i1 %.not8, label %8, label %.lr.ph.preheader

8:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.5, i32 noundef 35, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN3abm5TableC2Emm) #3
  unreachable

.lr.ph.preheader:                                 ; preds = %7
  %9 = tail call noalias noundef nonnull dereferenceable(160) ptr @_Znam(i64 noundef 160) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %9, ptr %10, align 8, !tbaa !13
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %.pre = load ptr, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %.pre, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %.pre, i64 16
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %12, ptr %13, align 8, !tbaa !15
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %14 = load ptr, ptr %10, align 8, !tbaa !13
  %15 = shl nuw nsw i64 %indvars.iv, 4
  %16 = getelementptr inbounds i8, ptr %14, i64 %15
  %17 = load i64, ptr %4, align 8, !tbaa !11
  tail call void @_ZN3abm6ColumnIlEC2Em(ptr noundef nonnull align 8 dereferenceable(16) %16, i64 noundef %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i64, ptr %0, align 8, !tbaa !5
  %19 = icmp ugt i64 %18, %indvars.iv.next
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !16
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3abm6ColumnIlEC2Em(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) unnamed_addr #1 align 2

attributes #0 = { 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 #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" }
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 = { noreturn nounwind }
attributes #4 = { builtin allocsize(0) }

!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, !7, i64 0}
!6 = !{!"_ZTSN3abm5TableE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !10, i64 24}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 40}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass