; LLVM IR from PaddlePaddle/Serving :: core/predictor/tools/ocrtools/clipper.ll (ZN10ClipperLib9Int128MulExx)

; 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.ClipperLib::Int128" = 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 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 @_ZN10ClipperLib9Int128MulExx(ptr dead_on_unwind noalias writable sret(%"class.ClipperLib::Int128") align 8 %0, i64 noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca %"class.ClipperLib::Int128", align 8
  store ptr %0, ptr %4, align 8
  store i64 %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  %16 = load i64, ptr %5, align 8, !tbaa !5
  %17 = icmp slt i64 %16, 0
  %18 = zext i1 %17 to i32
  %19 = load i64, ptr %6, align 8, !tbaa !5
  %20 = icmp slt i64 %19, 0
  %21 = zext i1 %20 to i32
  %22 = icmp ne i32 %18, %21
  %23 = zext i1 %22 to i8
  store i8 %23, ptr %7, align 1, !tbaa !9
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = icmp slt i64 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %3
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = sub nsw i64 0, %27
  store i64 %28, ptr %5, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %26, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %30 = load i64, ptr %5, align 8, !tbaa !5
  %31 = lshr i64 %30, 32
  store i64 %31, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %32 = load i64, ptr %5, align 8, !tbaa !5
  %33 = and i64 %32, 4294967295
  store i64 %33, ptr %9, align 8, !tbaa !5
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %29
  %37 = load i64, ptr %6, align 8, !tbaa !5
  %38 = sub nsw i64 0, %37
  store i64 %38, ptr %6, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %36, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = lshr i64 %40, 32
  store i64 %41, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = and i64 %42, 4294967295
  store i64 %43, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %44 = load i64, ptr %8, align 8, !tbaa !5
  %45 = load i64, ptr %10, align 8, !tbaa !5
  %46 = mul i64 %44, %45
  store i64 %46, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %47 = load i64, ptr %9, align 8, !tbaa !5
  %48 = load i64, ptr %11, align 8, !tbaa !5
  %49 = mul i64 %47, %48
  store i64 %49, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %50 = load i64, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %11, align 8, !tbaa !5
  %52 = mul i64 %50, %51
  %53 = load i64, ptr %9, align 8, !tbaa !5
  %54 = load i64, ptr %10, align 8, !tbaa !5
  %55 = mul i64 %53, %54
  %56 = add i64 %52, %55
  store i64 %56, ptr %14, align 8, !tbaa !5
  call void @_ZN10ClipperLib6Int128C2Ex(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef 0)
  %57 = load i64, ptr %12, align 8, !tbaa !5
  %58 = load i64, ptr %14, align 8, !tbaa !5
  %59 = lshr i64 %58, 32
  %60 = add i64 %57, %59
  %61 = getelementptr inbounds %"class.ClipperLib::Int128", ptr %0, i32 0, i32 1
  store i64 %60, ptr %61, align 8, !tbaa !11
  %62 = load i64, ptr %14, align 8, !tbaa !5
  %63 = shl i64 %62, 32
  %64 = getelementptr inbounds %"class.ClipperLib::Int128", ptr %0, i32 0, i32 0
  store i64 %63, ptr %64, align 8, !tbaa !13
  %65 = load i64, ptr %13, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.ClipperLib::Int128", ptr %0, i32 0, i32 0
  %67 = load i64, ptr %66, align 8, !tbaa !13
  %68 = add i64 %67, %65
  store i64 %68, ptr %66, align 8, !tbaa !13
  %69 = getelementptr inbounds %"class.ClipperLib::Int128", ptr %0, i32 0, i32 0
  %70 = load i64, ptr %69, align 8, !tbaa !13
  %71 = load i64, ptr %13, align 8, !tbaa !5
  %72 = icmp ult i64 %70, %71
  br i1 %72, label %73, label %77

73:                                               ; preds = %39
  %74 = getelementptr inbounds %"class.ClipperLib::Int128", ptr %0, i32 0, i32 1
  %75 = load i64, ptr %74, align 8, !tbaa !11
  %76 = add nsw i64 %75, 1
  store i64 %76, ptr %74, align 8, !tbaa !11
  br label %77

77:                                               ; preds = %73, %39
  %78 = load i8, ptr %7, align 1, !tbaa !9, !range !14, !noundef !15
  %79 = trunc i8 %78 to i1
  br i1 %79, label %80, label %81

80:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  call void @_ZNK10ClipperLib6Int128ngEv(ptr dead_on_unwind writable sret(%"class.ClipperLib::Int128") align 8 %15, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %15, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  br label %81

81:                                               ; preds = %80, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10ClipperLib6Int128C2Ex(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10ClipperLib6Int128ngEv(ptr dead_on_unwind noalias writable sret(%"class.ClipperLib::Int128") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !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, !6, i64 8}
!12 = !{!"_ZTSN10ClipperLib6Int128E", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{i64 0, i64 8, !5, i64 8, i64 8, !5}


; 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.ClipperLib::Int128" = 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 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 @_ZN10ClipperLib9Int128MulExx(ptr dead_on_unwind noalias nonnull writable sret(%"class.ClipperLib::Int128") align 8 %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = alloca %"class.ClipperLib::Int128", align 8
  %.not.unshifted = xor i64 %2, %1
  %.not = icmp sgt i64 %.not.unshifted, -1
  %spec.select = tail call i64 @llvm.abs.i64(i64 %1, i1 true)
  %5 = lshr i64 %spec.select, 32
  %6 = and i64 %spec.select, 4294967295
  %.024 = tail call i64 @llvm.abs.i64(i64 %2, i1 true)
  %7 = lshr i64 %.024, 32
  %8 = and i64 %.024, 4294967295
  %9 = mul nuw nsw i64 %7, %5
  %10 = mul nuw i64 %8, %6
  %11 = mul nuw nsw i64 %8, %5
  %12 = mul nuw nsw i64 %7, %6
  %13 = add nuw i64 %11, %12
  tail call void @_ZN10ClipperLib6Int128C2Ex(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef 0)
  %14 = lshr i64 %13, 32
  %15 = add nuw nsw i64 %14, %9
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %15, ptr %16, align 8, !tbaa !5
  %17 = shl i64 %13, 32
  %18 = add i64 %17, %10
  store i64 %18, ptr %0, align 8, !tbaa !10
  %19 = icmp ult i64 %18, %10
  br i1 %19, label %20, label %22

20:                                               ; preds = %3
  %21 = add nuw nsw i64 %15, 1
  store i64 %21, ptr %16, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %20, %3
  br i1 %.not, label %24, label %23

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  call void @_ZNK10ClipperLib6Int128ngEv(ptr dead_on_unwind nonnull writable sret(%"class.ClipperLib::Int128") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %4, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  br label %24

24:                                               ; preds = %23, %22
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10ClipperLib6Int128C2Ex(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10ClipperLib6Int128ngEv(ptr dead_on_unwind noalias writable sret(%"class.ClipperLib::Int128") align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #4

attributes #0 = { mustprogress 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 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"_ZTSN10ClipperLib6Int128E", !7, i64 0, !7, i64 8}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{i64 0, i64 8, !12, i64 8, i64 8, !12}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass