; LLVM IR from xxks-kkk/algo :: linkedList/polynomial (polynomial)

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

; Function Attrs: nounwind uwtable
declare dso_local void @insert(i32 noundef, i32 noundef, ptr noundef) #0

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @deletePolynomial(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @add(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @multiply2(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Node, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %19, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Node, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  store ptr %22, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %23 = call noalias ptr @malloc(i64 noundef 16) #4
  store ptr %23, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %24 = call noalias ptr @malloc(i64 noundef 16) #4
  store ptr %24, ptr %14, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %28, %2
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %5, align 4, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Node, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  store ptr %33, ptr %7, align 8, !tbaa !5
  br label %25, !llvm.loop !13

34:                                               ; preds = %25
  br label %35

35:                                               ; preds = %38, %34
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %44

38:                                               ; preds = %35
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %6, align 4, !tbaa !9
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Node, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  store ptr %43, ptr %8, align 8, !tbaa !5
  br label %35, !llvm.loop !15

44:                                               ; preds = %35
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %48, label %56

48:                                               ; preds = %44
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Node, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  store ptr %51, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Node, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  store ptr %54, ptr %12, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %55, ptr %13, align 8, !tbaa !5
  br label %64

56:                                               ; preds = %44
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.Node, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  store ptr %59, ptr %11, align 8, !tbaa !5
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Node, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  store ptr %62, ptr %12, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %63, ptr %13, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %56, %48
  br label %65

65:                                               ; preds = %97, %64
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %108

68:                                               ; preds = %65
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %69, ptr %10, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %73, %68
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %97

73:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.Node, ptr %74, i32 0, i32 0
  %76 = load i32, ptr %75, align 8, !tbaa !16
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Node, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 8, !tbaa !16
  %80 = mul nsw i32 %76, %79
  store i32 %80, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.Node, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !17
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.Node, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 4, !tbaa !17
  %87 = add nsw i32 %83, %86
  store i32 %87, ptr %16, align 4, !tbaa !9
  %88 = load i32, ptr %15, align 4, !tbaa !9
  %89 = load i32, ptr %16, align 4, !tbaa !9
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  call void @insert(i32 noundef %88, i32 noundef %89, ptr noundef %90)
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.Node, ptr %91, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !11
  store ptr %93, ptr %10, align 8, !tbaa !5
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.Node, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  store ptr %96, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %70, !llvm.loop !18

97:                                               ; preds = %70
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = load ptr, ptr %14, align 8, !tbaa !5
  %100 = call ptr @add(ptr noundef %98, ptr noundef %99)
  store ptr %100, ptr %9, align 8, !tbaa !5
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.Node, ptr %101, i32 0, i32 2
  %103 = load ptr, ptr %102, align 8, !tbaa !11
  store ptr %103, ptr %12, align 8, !tbaa !5
  %104 = load ptr, ptr %14, align 8, !tbaa !5
  call void @deletePolynomial(ptr noundef %104)
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.Node, ptr %105, i32 0, i32 2
  %107 = load ptr, ptr %106, align 8, !tbaa !11
  store ptr %107, ptr %11, align 8, !tbaa !5
  br label %65, !llvm.loop !19

108:                                              ; preds = %65
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret ptr %109
}

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 = { nounwind allocsize(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 }
attributes #4 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"Node", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!12, !10, i64 0}
!17 = !{!12, !10, i64 4}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


; 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: nounwind uwtable
declare dso_local void @insert(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @deletePolynomial(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @add(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @multiply2(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #2
  %7 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #2
  %.03448 = load ptr, ptr %3, align 8, !tbaa !5
  %.not49 = icmp eq ptr %.03448, null
  br i1 %.not49, label %.preheader47, label %.lr.ph

.preheader47:                                     ; preds = %.lr.ph, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %8, %.lr.ph ]
  %.not4252 = icmp eq ptr %5, null
  br i1 %.not4252, label %._crit_edge, label %.lr.ph55

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.03451 = phi ptr [ %.034, %.lr.ph ], [ %.03448, %2 ]
  %.050 = phi i32 [ %8, %.lr.ph ], [ 0, %2 ]
  %8 = add nuw nsw i32 %.050, 1
  %9 = getelementptr inbounds i8, ptr %.03451, i64 8
  %.034 = load ptr, ptr %9, align 8, !tbaa !5
  %.not = icmp eq ptr %.034, null
  br i1 %.not, label %.preheader47, label %.lr.ph, !llvm.loop !11

.lr.ph55:                                         ; preds = %.preheader47, %.lr.ph55
  %.03354 = phi i32 [ %10, %.lr.ph55 ], [ 0, %.preheader47 ]
  %.04153 = phi ptr [ %12, %.lr.ph55 ], [ %5, %.preheader47 ]
  %10 = add nuw nsw i32 %.03354, 1
  %11 = getelementptr inbounds i8, ptr %.04153, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %.not42 = icmp eq ptr %12, null
  br i1 %.not42, label %._crit_edge, label %.lr.ph55, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph55, %.preheader47
  %.033.lcssa = phi i32 [ 0, %.preheader47 ], [ %10, %.lr.ph55 ]
  %13 = icmp ult i32 %.0.lcssa, %.033.lcssa
  %. = select i1 %13, ptr %3, ptr %4
  %.13862 = load ptr, ptr %., align 8, !tbaa !5
  %.not4363 = icmp eq ptr %.13862, null
  br i1 %.not4363, label %._crit_edge67, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %._crit_edge
  %.45 = select i1 %13, ptr %4, ptr %3
  %.036 = load ptr, ptr %.45, align 8, !tbaa !5
  %.46 = select i1 %13, ptr %1, ptr %0
  %14 = getelementptr inbounds i8, ptr %.46, i64 8
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge61
  %.13866 = phi ptr [ %.13862, %.preheader.lr.ph ], [ %.138, %._crit_edge61 ]
  %.165 = phi ptr [ %.036, %.preheader.lr.ph ], [ %29, %._crit_edge61 ]
  %.04064 = phi ptr [ %6, %.preheader.lr.ph ], [ %28, %._crit_edge61 ]
  %.not4457 = icmp eq ptr %.165, null
  br i1 %.not4457, label %._crit_edge61, label %.lr.ph60

.lr.ph60:                                         ; preds = %.preheader
  %15 = getelementptr inbounds i8, ptr %.13866, i64 4
  br label %16

16:                                               ; preds = %.lr.ph60, %16
  %.259 = phi ptr [ %.165, %.lr.ph60 ], [ %27, %16 ]
  %.03958 = phi ptr [ %7, %.lr.ph60 ], [ %25, %16 ]
  %17 = load i32, ptr %.13866, align 8, !tbaa !14
  %18 = load i32, ptr %.259, align 8, !tbaa !14
  %19 = mul nsw i32 %18, %17
  %20 = load i32, ptr %15, align 4, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %.259, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = add nsw i32 %22, %20
  tail call void @insert(i32 noundef %19, i32 noundef %23, ptr noundef %.03958)
  %24 = getelementptr inbounds i8, ptr %.03958, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.259, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %.not44 = icmp eq ptr %27, null
  br i1 %.not44, label %._crit_edge61, label %16, !llvm.loop !16

._crit_edge61:                                    ; preds = %16, %.preheader
  %28 = tail call ptr @add(ptr noundef %.04064, ptr noundef %7)
  %29 = load ptr, ptr %14, align 8, !tbaa !5
  tail call void @deletePolynomial(ptr noundef %7)
  %30 = getelementptr inbounds i8, ptr %.13866, i64 8
  %.138 = load ptr, ptr %30, align 8, !tbaa !5
  %.not43 = icmp eq ptr %.138, null
  br i1 %.not43, label %._crit_edge67, label %.preheader, !llvm.loop !17

._crit_edge67:                                    ; preds = %._crit_edge61, %._crit_edge
  %.040.lcssa = phi ptr [ %6, %._crit_edge ], [ %28, %._crit_edge61 ]
  ret ptr %.040.lcssa
}

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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind allocsize(0) }

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


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