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

; 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] }

; 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 uwtable
define dso_local void @_Z14UintToArith256RK7uint256(ptr dead_on_unwind noalias writable sret(%class.arith_uint256) align 4 %0, ptr noundef nonnull align 1 dereferenceable(32) %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @_ZN13arith_uint256C2Ev(ptr noundef nonnull align 4 dereferenceable(32) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %22, %2
  %7 = load i32, ptr %5, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 8
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %25

10:                                               ; preds = %6
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %11)
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = mul nsw i32 %13, 4
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %12, i64 %15
  %17 = call noundef i32 @_ZL8ReadLE32PKh(ptr noundef %16)
  %18 = getelementptr inbounds %class.base_uint, ptr %0, i32 0, i32 0
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [8 x i32], ptr %18, i64 0, i64 %20
  store i32 %17, ptr %21, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %10
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %5, align 4, !tbaa !9
  br label %6, !llvm.loop !11

25:                                               ; preds = %9
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL8ReadLE32PKh(ptr noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #4 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14UintToArith256RK7uint256(ptr dead_on_unwind noalias nonnull writable sret(%class.arith_uint256) align 4 %0, ptr noundef nonnull align 1 dereferenceable(32) %1) local_unnamed_addr #0 {
  tail call void @_ZN13arith_uint256C2Ev(ptr noundef nonnull align 4 dereferenceable(32) %0)
  %3 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %4 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef %3)
  store i32 %4, ptr %0, align 4, !tbaa !5
  %5 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  %7 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %7, ptr %8, align 4, !tbaa !5
  %9 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %11, ptr %12, align 4, !tbaa !5
  %13 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %14 = getelementptr inbounds i8, ptr %13, i64 12
  %15 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %14)
  %16 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %15, ptr %16, align 4, !tbaa !5
  %17 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %18)
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %19, ptr %20, align 4, !tbaa !5
  %21 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %22 = getelementptr inbounds i8, ptr %21, i64 20
  %23 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %22)
  %24 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %23, ptr %24, align 4, !tbaa !5
  %25 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %26 = getelementptr inbounds i8, ptr %25, i64 24
  %27 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %26)
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %27, ptr %28, align 4, !tbaa !5
  %29 = tail call noundef ptr @_ZNK9base_blobILj256EE5beginEv(ptr noundef nonnull align 1 dereferenceable(32) %1)
  %30 = getelementptr inbounds i8, ptr %29, i64 28
  %31 = tail call noundef i32 @_ZL8ReadLE32PKh(ptr noundef nonnull %30)
  %32 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %31, ptr %32, align 4, !tbaa !5
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL8ReadLE32PKh(ptr noundef) local_unnamed_addr #1

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

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

!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"}


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