; 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: 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 @word_div(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.Dword_st, align 8
  %10 = alloca %struct.Dword_st, align 8
  %11 = alloca %struct.Dword_st, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = call i32 @word_bit_len(i64 noundef %14)
  store i32 %15, ptr %12, align 4, !tbaa !11
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Dword_st, ptr %16, i32 0, i32 1
  store i64 0, ptr %17, align 8, !tbaa !13
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Dword_st, ptr %18, i32 0, i32 0
  store i64 0, ptr %19, align 8, !tbaa !15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Dword_st, ptr %20, i32 0, i32 1
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 1
  store i64 %22, ptr %23, align 8, !tbaa !13
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Dword_st, ptr %24, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 0
  store i64 %26, ptr %27, align 8, !tbaa !15
  br label %28

28:                                               ; preds = %64, %4
  %29 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !13
  %31 = icmp ugt i64 %30, 0
  br i1 %31, label %37, label %32

32:                                               ; preds = %28
  %33 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !15
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = icmp uge i64 %34, %35
  br label %37

37:                                               ; preds = %32, %28
  %38 = phi i1 [ true, %28 ], [ %36, %32 ]
  br i1 %38, label %39, label %68

39:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %40 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !13
  %42 = call i32 @word_bit_len(i64 noundef %41)
  store i32 %42, ptr %13, align 4, !tbaa !11
  %43 = load i32, ptr %13, align 4, !tbaa !11
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %49

45:                                               ; preds = %39
  %46 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 0
  %47 = load i64, ptr %46, align 8, !tbaa !15
  %48 = call i32 @word_bit_len(i64 noundef %47)
  br label %50

49:                                               ; preds = %39
  br label %50

50:                                               ; preds = %49, %45
  %51 = phi i32 [ %48, %45 ], [ 64, %49 ]
  %52 = load i32, ptr %13, align 4, !tbaa !11
  %53 = add nsw i32 %52, %51
  store i32 %53, ptr %13, align 4, !tbaa !11
  %54 = load i32, ptr %12, align 4, !tbaa !11
  %55 = load i32, ptr %13, align 4, !tbaa !11
  %56 = sub nsw i32 %55, %54
  store i32 %56, ptr %13, align 4, !tbaa !11
  %57 = load i64, ptr %6, align 8, !tbaa !9
  %58 = load i32, ptr %13, align 4, !tbaa !11
  call void @word_lshift_64(i64 noundef %57, i32 noundef %58, ptr noundef %11)
  %59 = call i32 @word_cmp_64(ptr noundef %10, ptr noundef %11)
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %50
  %62 = load i32, ptr %13, align 4, !tbaa !11
  %63 = add nsw i32 %62, -1
  store i32 %63, ptr %13, align 4, !tbaa !11
  br label %64

64:                                               ; preds = %61, %50
  %65 = load i64, ptr %6, align 8, !tbaa !9
  %66 = load i32, ptr %13, align 4, !tbaa !11
  call void @word_lshift_64(i64 noundef %65, i32 noundef %66, ptr noundef %11)
  call void @word_sub_64(ptr noundef %10, ptr noundef %11, ptr noundef %10)
  %67 = load i32, ptr %13, align 4, !tbaa !11
  call void @word_lshift_64(i64 noundef 1, i32 noundef %67, ptr noundef %11)
  call void @word_add_64(ptr noundef %9, ptr noundef %11, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %28, !llvm.loop !16

68:                                               ; preds = %37
  %69 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 1
  %70 = load i64, ptr %69, align 8, !tbaa !13
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Dword_st, ptr %71, i32 0, i32 1
  store i64 %70, ptr %72, align 8, !tbaa !13
  %73 = getelementptr inbounds %struct.Dword_st, ptr %9, i32 0, i32 0
  %74 = load i64, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Dword_st, ptr %75, i32 0, i32 0
  store i64 %74, ptr %76, align 8, !tbaa !15
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %83

79:                                               ; preds = %68
  %80 = getelementptr inbounds %struct.Dword_st, ptr %10, i32 0, i32 0
  %81 = load i64, ptr %80, align 8, !tbaa !15
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %81, ptr %82, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %79, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  ret void
}

declare i32 @word_bit_len(i64 noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @word_cmp_64(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @word_add_64(ptr noundef, ptr 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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"Dword_st", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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: 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: 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 @word_div(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef writeonly %2, ptr noundef writeonly %3) local_unnamed_addr #2 {
  %5 = alloca %struct.Dword_st, align 16
  %6 = alloca %struct.Dword_st, align 8
  %7 = alloca %struct.Dword_st, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %8 = tail call i32 @word_bit_len(i64 noundef %1) #4
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %6, i64 8
  store i64 %10, ptr %11, align 8, !tbaa !5
  %12 = load i64, ptr %0, align 8, !tbaa !10
  store i64 %12, ptr %6, align 8, !tbaa !10
  %13 = icmp ne i64 %10, 0
  %14 = icmp uge i64 %12, %1
  %15 = select i1 %13, i1 true, i1 %14
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4, %22
  %16 = phi i64 [ %27, %22 ], [ %10, %4 ]
  %17 = call i32 @word_bit_len(i64 noundef %16) #4
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %.lr.ph
  %20 = load i64, ptr %6, align 8, !tbaa !10
  %21 = call i32 @word_bit_len(i64 noundef %20) #4
  br label %22

22:                                               ; preds = %.lr.ph, %19
  %23 = phi i32 [ %21, %19 ], [ 64, %.lr.ph ]
  %24 = sub i32 %17, %8
  %25 = add i32 %24, %23
  call void @word_lshift_64(i64 noundef %1, i32 noundef %25, ptr noundef nonnull %7)
  %26 = call i32 @word_cmp_64(ptr noundef nonnull %6, ptr noundef nonnull %7)
  %.lobit = ashr i32 %26, 31
  %spec.select = add nsw i32 %.lobit, %25
  call void @word_lshift_64(i64 noundef %1, i32 noundef %spec.select, ptr noundef nonnull %7)
  call void @word_sub_64(ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %6)
  call void @word_lshift_64(i64 noundef 1, i32 noundef %spec.select, ptr noundef nonnull %7)
  call void @word_add_64(ptr noundef nonnull %5, ptr noundef nonnull %7, ptr noundef nonnull %5)
  %27 = load i64, ptr %11, align 8, !tbaa !5
  %28 = icmp ne i64 %27, 0
  %29 = load i64, ptr %6, align 8
  %30 = icmp uge i64 %29, %1
  %31 = select i1 %28, i1 true, i1 %30
  br i1 %31, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %22
  %32 = load <2 x i64>, ptr %5, align 16, !tbaa !13
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %4
  %.lcssa = phi i64 [ %12, %4 ], [ %29, %._crit_edge.loopexit ]
  %33 = phi <2 x i64> [ zeroinitializer, %4 ], [ %32, %._crit_edge.loopexit ]
  store <2 x i64> %33, ptr %2, align 8, !tbaa !13
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %35, label %34

34:                                               ; preds = %._crit_edge
  store i64 %.lcssa, ptr %3, align 8, !tbaa !13
  br label %35

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

declare i32 @word_bit_len(i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @word_cmp_64(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden void @word_add_64(ptr noundef, ptr 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 = { "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, !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass