; 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
define dso_local ptr @multiply1(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = 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 8, ptr %5) #3
  %12 = call noalias ptr @malloc(i64 noundef 16) #4
  store ptr %12, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %14, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Node, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  store ptr %17, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  store ptr %20, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  br label %21

21:                                               ; preds = %78, %2
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %85

24:                                               ; preds = %21
  br label %25

25:                                               ; preds = %73, %24
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %78

28:                                               ; preds = %25
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.Node, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !12
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Node, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !12
  %35 = add nsw i32 %31, %34
  store i32 %35, ptr %10, align 4, !tbaa !13
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Node, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !14
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Node, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !14
  %42 = mul nsw i32 %38, %41
  store i32 %42, ptr %11, align 4, !tbaa !13
  br label %43

43:                                               ; preds = %65, %28
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %66

46:                                               ; preds = %43
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !12
  %50 = load i32, ptr %10, align 4, !tbaa !13
  %51 = icmp eq i32 %49, %50
  br i1 %51, label %52, label %60

52:                                               ; preds = %46
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Node, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !14
  %56 = load i32, ptr %11, align 4, !tbaa !13
  %57 = add nsw i32 %55, %56
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Node, ptr %58, i32 0, i32 0
  store i32 %57, ptr %59, align 8, !tbaa !14
  br label %66

60:                                               ; preds = %46
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %61, ptr %6, align 8, !tbaa !5
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Node, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  store ptr %64, ptr %7, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %60
  br label %43, !llvm.loop !15

66:                                               ; preds = %52, %43
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %73

69:                                               ; preds = %66
  %70 = load i32, ptr %11, align 4, !tbaa !13
  %71 = load i32, ptr %10, align 4, !tbaa !13
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  call void @insert(i32 noundef %70, i32 noundef %71, ptr noundef %72)
  br label %73

73:                                               ; preds = %69, %66
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %74, ptr %7, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Node, ptr %75, i32 0, i32 2
  %77 = load ptr, ptr %76, align 8, !tbaa !9
  store ptr %77, ptr %9, align 8, !tbaa !5
  br label %25, !llvm.loop !17

78:                                               ; preds = %25
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.Node, ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %80, align 8, !tbaa !9
  store ptr %81, ptr %9, align 8, !tbaa !5
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.Node, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !9
  store ptr %84, ptr %8, align 8, !tbaa !5
  br label %21, !llvm.loop !18

85:                                               ; preds = %21
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, 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 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %86
}

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


; 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
define dso_local noundef ptr @multiply1(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #2
  %.031.in48 = getelementptr inbounds i8, ptr %0, i64 8
  %.03149 = load ptr, ptr %.031.in48, align 8, !tbaa !5
  %.not50 = icmp eq ptr %.03149, null
  br i1 %.not50, label %._crit_edge53, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %2
  %.130.in41 = getelementptr inbounds i8, ptr %1, i64 8
  %cond38 = icmp eq ptr %3, null
  %4 = load ptr, ptr %.130.in41, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %._crit_edge53, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %6 = getelementptr inbounds i8, ptr %3, i64 4
  br label %.preheader

.loopexit:                                        ; preds = %32, %.lr.ph46.split.us, %.preheader
  %.1.lcssa = phi ptr [ %.051, %.preheader ], [ %.051, %.lr.ph46.split.us ], [ %.236, %32 ]
  %.031.in = getelementptr inbounds i8, ptr %.03152, i64 8
  %.031 = load ptr, ptr %.031.in, align 8, !tbaa !5
  %.not = icmp eq ptr %.031, null
  br i1 %.not, label %._crit_edge53, label %.preheaderthread-pre-split, !llvm.loop !11

.preheaderthread-pre-split:                       ; preds = %.loopexit
  %.13042.pr = load ptr, ptr %.130.in41, align 8, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheaderthread-pre-split
  %.13042 = phi ptr [ %.13042.pr, %.preheaderthread-pre-split ], [ %4, %.preheader.preheader ]
  %.03152 = phi ptr [ %.031, %.preheaderthread-pre-split ], [ %.03149, %.preheader.preheader ]
  %.051 = phi ptr [ %.1.lcssa, %.preheaderthread-pre-split ], [ %3, %.preheader.preheader ]
  %.not3243 = icmp eq ptr %.13042, null
  br i1 %.not3243, label %.loopexit, label %.lr.ph46

.lr.ph46:                                         ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %.03152, i64 4
  br i1 %cond38, label %.lr.ph46.split.us, label %.lr.ph

.lr.ph46.split.us:                                ; preds = %.lr.ph46, %.lr.ph46.split.us
  %.13045.us = phi ptr [ %.130.us, %.lr.ph46.split.us ], [ %.13042, %.lr.ph46 ]
  %8 = load i32, ptr %7, align 4, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %.13045.us, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !14
  %11 = add nsw i32 %10, %8
  %12 = load i32, ptr %.03152, align 8, !tbaa !15
  %13 = load i32, ptr %.13045.us, align 8, !tbaa !15
  %14 = mul nsw i32 %13, %12
  tail call void @insert(i32 noundef %14, i32 noundef %11, ptr noundef %.051)
  %.130.in.us = getelementptr inbounds i8, ptr %.13045.us, i64 8
  %.130.us = load ptr, ptr %.130.in.us, align 8, !tbaa !5
  %.not32.us = icmp eq ptr %.130.us, null
  br i1 %.not32.us, label %.loopexit, label %.lr.ph46.split.us, !llvm.loop !16

.lr.ph:                                           ; preds = %.lr.ph46, %32
  %.13045 = phi ptr [ %.130, %32 ], [ %.13042, %.lr.ph46 ]
  %.144 = phi ptr [ %.236, %32 ], [ %.051, %.lr.ph46 ]
  %15 = load i32, ptr %7, align 4, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %.13045, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = add nsw i32 %17, %15
  %19 = load i32, ptr %.03152, align 8, !tbaa !15
  %20 = load i32, ptr %.13045, align 8, !tbaa !15
  %21 = mul nsw i32 %20, %19
  %22 = load i32, ptr %6, align 4, !tbaa !14
  %23 = icmp eq i32 %22, %18
  br i1 %23, label %._crit_edge66, label %.lr.ph65

24:                                               ; preds = %.lr.ph65
  %25 = getelementptr inbounds i8, ptr %31, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = icmp eq i32 %26, %18
  br i1 %27, label %._crit_edge66, label %.lr.ph65, !llvm.loop !17

._crit_edge66:                                    ; preds = %24, %.lr.ph
  %.240.lcssa = phi ptr [ %.144, %.lr.ph ], [ %.2283964, %24 ]
  %.22839.lcssa = phi ptr [ %3, %.lr.ph ], [ %31, %24 ]
  %28 = load i32, ptr %.22839.lcssa, align 8, !tbaa !15
  %29 = add nsw i32 %28, %21
  store i32 %29, ptr %.22839.lcssa, align 8, !tbaa !15
  br label %32

.lr.ph65:                                         ; preds = %.lr.ph, %24
  %.2283964 = phi ptr [ %31, %24 ], [ %3, %.lr.ph ]
  %30 = getelementptr inbounds i8, ptr %.2283964, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %cond = icmp eq ptr %31, null
  br i1 %cond, label %._crit_edge, label %24, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph65
  tail call void @insert(i32 noundef %21, i32 noundef %18, ptr noundef nonnull %.2283964)
  br label %32

32:                                               ; preds = %._crit_edge66, %._crit_edge
  %.236 = phi ptr [ %.240.lcssa, %._crit_edge66 ], [ %.2283964, %._crit_edge ]
  %.130.in = getelementptr inbounds i8, ptr %.13045, i64 8
  %.130 = load ptr, ptr %.130.in, align 8, !tbaa !5
  %.not32 = icmp eq ptr %.130, null
  br i1 %.not32, label %.loopexit, label %.lr.ph, !llvm.loop !16

._crit_edge53:                                    ; preds = %.loopexit, %.preheader.lr.ph, %2
  ret ptr %3
}

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, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.unswitch.partial.disable"}
!14 = !{!6, !7, i64 4}
!15 = !{!6, !7, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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