; LLVM IR from ftylitak/qzxing :: src/zxing/bigint/BigUnsigned.ll (ZN11BigUnsignedppEv)

; 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.NumberlikeArray = type { i32, i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN15NumberlikeArrayImE15allocateAndCopyEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #0 align 2

; 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 @_ZN11BigUnsignedppEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 1, ptr %4, align 1, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %6

6:                                                ; preds = %32, %1
  %7 = load i32, ptr %3, align 4, !tbaa !11
  %8 = getelementptr inbounds %class.NumberlikeArray, ptr %5, i32 0, i32 1
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %10 = icmp ult i32 %7, %9
  br i1 %10, label %11, label %14

11:                                               ; preds = %6
  %12 = load i8, ptr %4, align 1, !tbaa !9, !range !15, !noundef !16
  %13 = trunc i8 %12 to i1
  br label %14

14:                                               ; preds = %11, %6
  %15 = phi i1 [ false, %6 ], [ %13, %11 ]
  br i1 %15, label %16, label %35

16:                                               ; preds = %14
  %17 = getelementptr inbounds %class.NumberlikeArray, ptr %5, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load i32, ptr %3, align 4, !tbaa !11
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i64, ptr %18, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !18
  %23 = add i64 %22, 1
  store i64 %23, ptr %21, align 8, !tbaa !18
  %24 = getelementptr inbounds %class.NumberlikeArray, ptr %5, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = load i32, ptr %3, align 4, !tbaa !11
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds i64, ptr %25, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !18
  %30 = icmp eq i64 %29, 0
  %31 = zext i1 %30 to i8
  store i8 %31, ptr %4, align 1, !tbaa !9
  br label %32

32:                                               ; preds = %16
  %33 = load i32, ptr %3, align 4, !tbaa !11
  %34 = add i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !11
  br label %6, !llvm.loop !20

35:                                               ; preds = %14
  %36 = load i8, ptr %4, align 1, !tbaa !9, !range !15, !noundef !16
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %50

38:                                               ; preds = %35
  %39 = getelementptr inbounds %class.NumberlikeArray, ptr %5, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !13
  %41 = add i32 %40, 1
  call void @_ZN15NumberlikeArrayImE15allocateAndCopyEj(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %41)
  %42 = getelementptr inbounds %class.NumberlikeArray, ptr %5, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !13
  %44 = add i32 %43, 1
  store i32 %44, ptr %42, align 4, !tbaa !13
  %45 = getelementptr inbounds %class.NumberlikeArray, ptr %5, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load i32, ptr %3, align 4, !tbaa !11
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i64, ptr %46, i64 %48
  store i64 1, ptr %49, align 8, !tbaa !18
  br label %50

50:                                               ; preds = %38, %35
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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 = { nocallback nofree nosync 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 = !{!"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 = !{!14, !12, i64 4}
!14 = !{!"_ZTS15NumberlikeArrayImE", !12, i64 0, !12, i64 4, !6, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!14, !6, i64 8}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN15NumberlikeArrayImE15allocateAndCopyEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11BigUnsignedppEv(ptr noundef nonnull align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = zext i32 %3 to i64
  br label %7

7:                                                ; preds = %.lr.ph, %7
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %7 ]
  %8 = getelementptr inbounds i64, ptr %5, i64 %indvars.iv
  %9 = load i64, ptr %8, align 8, !tbaa !12
  %10 = add i64 %9, 1
  store i64 %10, ptr %8, align 8, !tbaa !12
  %11 = icmp eq i64 %10, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = icmp ult i64 %indvars.iv.next, %6
  %13 = select i1 %12, i1 %11, i1 false
  br i1 %13, label %7, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %7
  %14 = and i64 %indvars.iv.next, 4294967295
  br i1 %11, label %._crit_edge.thread, label %21

._crit_edge.thread:                               ; preds = %1, %._crit_edge
  %.07.lcssa16 = phi i64 [ %14, %._crit_edge ], [ 0, %1 ]
  %15 = add i32 %3, 1
  tail call void @_ZN15NumberlikeArrayImE15allocateAndCopyEj(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %15)
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add i32 %16, 1
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds i64, ptr %19, i64 %.07.lcssa16
  store i64 1, ptr %20, align 8, !tbaa !12
  br label %21

21:                                               ; preds = %._crit_edge.thread, %._crit_edge
  ret void
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass