; LLVM IR from vergecurrency/verge :: src/arith_uint256.ll (ZNK13arith_uint25610GetCompactEb)

; 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.arith_uint256 = type { %class.base_uint }
%class.base_uint = type { [8 x i32] }

@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1
@__PRETTY_FUNCTION__._ZNK13arith_uint25610GetCompactEb = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9base_uintILj256EE4bitsEv(ptr noundef nonnull align 4 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13arith_uint256C2ERK9base_uintILj256EE(ptr noundef nonnull align 4 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK13arith_uint25610GetCompactEb(ptr noundef nonnull align 4 dereferenceable(32) %0, i1 noundef zeroext %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %class.arith_uint256, align 4
  %8 = alloca %class.base_uint, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %4, align 1, !tbaa !9
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %11 = call noundef i32 @_ZNK9base_uintILj256EE4bitsEv(ptr noundef nonnull align 4 dereferenceable(32) %10)
  %12 = add i32 %11, 7
  %13 = udiv i32 %12, 8
  store i32 %13, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !11
  %14 = load i32, ptr %5, align 4, !tbaa !11
  %15 = icmp sle i32 %14, 3
  br i1 %15, label %16, label %24

16:                                               ; preds = %2
  %17 = call noundef i64 @_ZNK9base_uintILj256EE8GetLow64Ev(ptr noundef nonnull align 4 dereferenceable(32) %10)
  %18 = load i32, ptr %5, align 4, !tbaa !11
  %19 = sub nsw i32 3, %18
  %20 = mul nsw i32 8, %19
  %21 = zext i32 %20 to i64
  %22 = shl i64 %17, %21
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %6, align 4, !tbaa !11
  br label %30

24:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #5
  %25 = load i32, ptr %5, align 4, !tbaa !11
  %26 = sub nsw i32 %25, 3
  %27 = mul nsw i32 8, %26
  call void @_ZrsRK9base_uintILj256EEi(ptr dead_on_unwind writable sret(%class.base_uint) align 4 %8, ptr noundef nonnull align 4 dereferenceable(32) %10, i32 noundef %27)
  call void @_ZN13arith_uint256C2ERK9base_uintILj256EE(ptr noundef nonnull align 4 dereferenceable(32) %7, ptr noundef nonnull align 4 dereferenceable(32) %8)
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #5
  %28 = call noundef i64 @_ZNK9base_uintILj256EE8GetLow64Ev(ptr noundef nonnull align 4 dereferenceable(32) %7)
  %29 = trunc i64 %28 to i32
  store i32 %29, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  br label %30

30:                                               ; preds = %24, %16
  %31 = load i32, ptr %6, align 4, !tbaa !11
  %32 = and i32 %31, 8388608
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %30
  %35 = load i32, ptr %6, align 4, !tbaa !11
  %36 = lshr i32 %35, 8
  store i32 %36, ptr %6, align 4, !tbaa !11
  %37 = load i32, ptr %5, align 4, !tbaa !11
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %5, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %34, %30
  %40 = load i32, ptr %6, align 4, !tbaa !11
  %41 = and i32 %40, -8388608
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  br label %46

44:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 243, ptr noundef @__PRETTY_FUNCTION__._ZNK13arith_uint25610GetCompactEb) #6
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  %47 = load i32, ptr %5, align 4, !tbaa !11
  %48 = icmp slt i32 %47, 256
  br i1 %48, label %49, label %50

49:                                               ; preds = %46
  br label %52

50:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 244, ptr noundef @__PRETTY_FUNCTION__._ZNK13arith_uint25610GetCompactEb) #6
  unreachable

51:                                               ; No predecessors!
  br label %52

52:                                               ; preds = %51, %49
  %53 = load i32, ptr %5, align 4, !tbaa !11
  %54 = shl i32 %53, 24
  %55 = load i32, ptr %6, align 4, !tbaa !11
  %56 = or i32 %55, %54
  store i32 %56, ptr %6, align 4, !tbaa !11
  %57 = load i8, ptr %4, align 1, !tbaa !9, !range !13, !noundef !14
  %58 = trunc i8 %57 to i1
  br i1 %58, label %59, label %63

59:                                               ; preds = %52
  %60 = load i32, ptr %6, align 4, !tbaa !11
  %61 = and i32 %60, 8388607
  %62 = icmp ne i32 %61, 0
  br label %63

63:                                               ; preds = %59, %52
  %64 = phi i1 [ false, %52 ], [ %62, %59 ]
  %65 = zext i1 %64 to i64
  %66 = select i1 %64, i32 8388608, i32 0
  %67 = load i32, ptr %6, align 4, !tbaa !11
  %68 = or i32 %67, %66
  store i32 %68, ptr %6, align 4, !tbaa !11
  %69 = load i32, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret i32 %69
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9base_uintILj256EE8GetLow64Ev(ptr noundef nonnull align 4 dereferenceable(32)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZrsRK9base_uintILj256EEi(ptr dead_on_unwind noalias writable sret(%class.base_uint) align 4, ptr noundef nonnull align 4 dereferenceable(32), i32 noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { inlinehint 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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

%class.arith_uint256 = type { %class.base_uint }
%class.base_uint = type { [8 x i32] }

@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1
@__PRETTY_FUNCTION__._ZNK13arith_uint25610GetCompactEb = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9base_uintILj256EE4bitsEv(ptr noundef nonnull align 4 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13arith_uint256C2ERK9base_uintILj256EE(ptr noundef nonnull align 4 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK13arith_uint25610GetCompactEb(ptr noundef nonnull align 4 dereferenceable(32) %0, i1 noundef zeroext %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %class.arith_uint256, align 4
  %4 = alloca %class.base_uint, align 4
  %5 = tail call noundef i32 @_ZNK9base_uintILj256EE4bitsEv(ptr noundef nonnull align 4 dereferenceable(32) %0)
  %6 = add i32 %5, 7
  %7 = lshr i32 %6, 3
  %8 = icmp ult i32 %6, 32
  br i1 %8, label %9, label %14

9:                                                ; preds = %2
  %10 = tail call noundef i64 @_ZNK9base_uintILj256EE8GetLow64Ev(ptr noundef nonnull align 4 dereferenceable(32) %0)
  %.not = sub nsw i32 24, %5
  %11 = and i32 %.not, 24
  %12 = zext nneg i32 %11 to i64
  %13 = shl i64 %10, %12
  br label %18

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #5
  %15 = and i32 %6, -8
  %16 = add i32 %15, -24
  call void @_ZrsRK9base_uintILj256EEi(ptr dead_on_unwind nonnull writable sret(%class.base_uint) align 4 %4, ptr noundef nonnull align 4 dereferenceable(32) %0, i32 noundef %16)
  call void @_ZN13arith_uint256C2ERK9base_uintILj256EE(ptr noundef nonnull align 4 dereferenceable(32) %3, ptr noundef nonnull align 4 dereferenceable(32) %4)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  %17 = call noundef i64 @_ZNK9base_uintILj256EE8GetLow64Ev(ptr noundef nonnull align 4 dereferenceable(32) %3)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  br label %18

18:                                               ; preds = %14, %9
  %.0.in = phi i64 [ %13, %9 ], [ %17, %14 ]
  %.0 = trunc i64 %.0.in to i32
  %19 = and i32 %.0, 8388608
  %20 = lshr exact i32 %19, 23
  %.014 = add nuw nsw i32 %20, %7
  %21 = lshr exact i32 %19, 20
  %.1 = lshr i32 %.0, %21
  %22 = icmp ult i32 %.1, 8388608
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 243, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK13arith_uint25610GetCompactEb) #6
  unreachable

24:                                               ; preds = %18
  %25 = icmp ult i32 %.014, 256
  br i1 %25, label %27, label %26

26:                                               ; preds = %24
  call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 244, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK13arith_uint25610GetCompactEb) #6
  unreachable

27:                                               ; preds = %24
  %28 = shl nuw i32 %.014, 24
  %29 = icmp ne i32 %.1, 0
  %30 = and i1 %29, %1
  %31 = select i1 %30, i32 8388608, i32 0
  %32 = or disjoint i32 %31, %28
  %33 = or disjoint i32 %32, %.1
  ret i32 %33
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9base_uintILj256EE8GetLow64Ev(ptr noundef nonnull align 4 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZrsRK9base_uintILj256EEi(ptr dead_on_unwind noalias writable sret(%class.base_uint) align 4, ptr noundef nonnull align 4 dereferenceable(32), i32 noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { inlinehint 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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)"}


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