; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (math-int-internal)

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

%struct.Dword_st = type { i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local i32 @words_add_64(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.Dword_st, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %33, %4
  %12 = load i64, ptr %10, align 8, !tbaa !9
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = icmp ult i64 %12, %13
  br i1 %14, label %15, label %36

15:                                               ; preds = %11
  %16 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 0
  store i64 %17, ptr %18, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 1
  store i64 0, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = getelementptr inbounds i64, ptr %20, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !9
  call void @word_add_word_64(ptr noundef %9, i64 noundef %23, ptr noundef %9)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i64, ptr %10, align 8, !tbaa !9
  %26 = getelementptr inbounds i64, ptr %24, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !9
  call void @word_add_word_64(ptr noundef %9, i64 noundef %27, ptr noundef %9)
  %28 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %10, align 8, !tbaa !9
  %32 = getelementptr inbounds i64, ptr %30, i64 %31
  store i64 %29, ptr %32, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %15
  %34 = load i64, ptr %10, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %10, align 8, !tbaa !9
  br label %11, !llvm.loop !14

36:                                               ; preds = %11
  %37 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !11
  %39 = trunc i64 %38 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  ret i32 %39
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare hidden void @word_add_word_64(ptr noundef, i64 noundef, ptr noundef) #0

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

attributes #0 = { 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: write) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"Dword_st", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.Dword_st = type { i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local i32 @words_add_64(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i64 noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = alloca %struct.Dword_st, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  br label %7

7:                                                ; preds = %.lr.ph, %7
  %.08 = phi i64 [ 0, %.lr.ph ], [ %15, %7 ]
  %8 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %8, ptr %5, align 8, !tbaa !10
  store i64 0, ptr %6, align 8, !tbaa !5
  %9 = getelementptr inbounds i64, ptr %0, i64 %.08
  %10 = load i64, ptr %9, align 8, !tbaa !11
  call void @word_add_word_64(ptr noundef nonnull %5, i64 noundef %10, ptr noundef nonnull %5)
  %11 = getelementptr inbounds i64, ptr %1, i64 %.08
  %12 = load i64, ptr %11, align 8, !tbaa !11
  call void @word_add_word_64(ptr noundef nonnull %5, i64 noundef %12, ptr noundef nonnull %5)
  %13 = load i64, ptr %5, align 8, !tbaa !10
  %14 = getelementptr inbounds i64, ptr %3, i64 %.08
  store i64 %13, ptr %14, align 8, !tbaa !11
  %15 = add nuw i64 %.08, 1
  %exitcond.not = icmp eq i64 %15, %2
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %7, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %7
  %.pre = load i64, ptr %6, align 8, !tbaa !5
  %16 = trunc i64 %.pre to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %4
  %17 = phi i32 [ %16, %._crit_edge.loopexit ], [ 0, %4 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  ret i32 %17
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare hidden void @word_add_word_64(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

attributes #0 = { 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 8}
!6 = !{!"Dword_st", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass