; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @words_mul_64(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca %struct.Dword_st, align 8
  %12 = alloca %struct.Dword_st, 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 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = mul i64 2, %14
  %16 = mul i64 %15, 8
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 %16, i1 false)
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %63, %4
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %21, label %66

21:                                               ; preds = %17
  %22 = getelementptr inbounds %struct.Dword_st, ptr %11, i32 0, i32 1
  store i64 0, ptr %22, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.Dword_st, ptr %11, i32 0, i32 0
  store i64 0, ptr %23, align 8, !tbaa !13
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %52, %21
  %25 = load i64, ptr %10, align 8, !tbaa !9
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %28, label %55

28:                                               ; preds = %24
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds i64, ptr %29, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i64, ptr %10, align 8, !tbaa !9
  %35 = getelementptr inbounds i64, ptr %33, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !9
  call void @word_mul_64(i64 noundef %32, i64 noundef %36, ptr noundef %12)
  %37 = getelementptr inbounds %struct.Dword_st, ptr %11, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !11
  call void @word_add_word_64(ptr noundef %12, i64 noundef %38, ptr noundef %11)
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = load i64, ptr %10, align 8, !tbaa !9
  %42 = add i64 %40, %41
  %43 = getelementptr inbounds i64, ptr %39, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !9
  call void @word_add_word_64(ptr noundef %11, i64 noundef %44, ptr noundef %11)
  %45 = getelementptr inbounds %struct.Dword_st, ptr %11, i32 0, i32 0
  %46 = load i64, ptr %45, align 8, !tbaa !13
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %49 = load i64, ptr %10, align 8, !tbaa !9
  %50 = add i64 %48, %49
  %51 = getelementptr inbounds i64, ptr %47, i64 %50
  store i64 %46, ptr %51, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %28
  %53 = load i64, ptr %10, align 8, !tbaa !9
  %54 = add i64 %53, 1
  store i64 %54, ptr %10, align 8, !tbaa !9
  br label %24, !llvm.loop !14

55:                                               ; preds = %24
  %56 = getelementptr inbounds %struct.Dword_st, ptr %11, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !11
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = load i64, ptr %7, align 8, !tbaa !9
  %61 = add i64 %59, %60
  %62 = getelementptr inbounds i64, ptr %58, i64 %61
  store i64 %57, ptr %62, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %55
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = add i64 %64, 1
  store i64 %65, ptr %9, align 8, !tbaa !9
  br label %17, !llvm.loop !16

66:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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"}
!16 = distinct !{!16, !15}


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

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

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

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

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

9:                                                ; preds = %.lr.ph, %21
  %.02023 = phi i64 [ 0, %.lr.ph ], [ %23, %21 ]
  %10 = getelementptr inbounds i64, ptr %0, i64 %.02023
  %11 = getelementptr i64, ptr %3, i64 %.02023
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  br label %12

12:                                               ; preds = %9, %12
  %.022 = phi i64 [ 0, %9 ], [ %20, %12 ]
  %13 = load i64, ptr %10, align 8, !tbaa !5
  %14 = getelementptr inbounds i64, ptr %1, i64 %.022
  %15 = load i64, ptr %14, align 8, !tbaa !5
  call void @word_mul_64(i64 noundef %13, i64 noundef %15, ptr noundef nonnull %6)
  %16 = load i64, ptr %8, align 8, !tbaa !9
  call void @word_add_word_64(ptr noundef nonnull %6, i64 noundef %16, ptr noundef nonnull %5)
  %17 = getelementptr i64, ptr %11, i64 %.022
  %18 = load i64, ptr %17, align 8, !tbaa !5
  call void @word_add_word_64(ptr noundef nonnull %5, i64 noundef %18, ptr noundef nonnull %5)
  %19 = load i64, ptr %5, align 8, !tbaa !11
  store i64 %19, ptr %17, align 8, !tbaa !5
  %20 = add nuw i64 %.022, 1
  %exitcond.not = icmp eq i64 %20, %2
  br i1 %exitcond.not, label %21, label %12, !llvm.loop !12

21:                                               ; preds = %12
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %gep = getelementptr i64, ptr %invariant.gep, i64 %.02023
  store i64 %22, ptr %gep, align 8, !tbaa !5
  %23 = add nuw i64 %.02023, 1
  %exitcond24.not = icmp eq i64 %23, %2
  br i1 %exitcond24.not, label %._crit_edge, label %9, !llvm.loop !14

._crit_edge:                                      ; preds = %21, %4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  ret void
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass