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

; 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, ptr }

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

; Function Attrs: nounwind uwtable
declare dso_local void @addDigit(i32 noundef, ptr noundef) #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
declare dso_local ptr @makeEmpty() #1

; Function Attrs: nounwind uwtable
declare dso_local void @deleteIntegerList(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @deleteAll(ptr noundef) #1

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

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

24:                                               ; preds = %71, %2
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %87

27:                                               ; preds = %24
  br label %28

28:                                               ; preds = %31, %27
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %52

31:                                               ; preds = %28
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Node, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Node, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = mul nsw i32 %34, %37
  %39 = load i32, ptr %11, align 4, !tbaa !12
  %40 = add nsw i32 %38, %39
  store i32 %40, ptr %10, align 4, !tbaa !12
  %41 = load i32, ptr %10, align 4, !tbaa !12
  %42 = sdiv i32 %41, 10
  store i32 %42, ptr %11, align 4, !tbaa !12
  %43 = load i32, ptr %10, align 4, !tbaa !12
  %44 = srem i32 %43, 10
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  call void @addDigit(i32 noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Node, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  store ptr %48, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Node, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !9
  store ptr %51, ptr %6, align 8, !tbaa !5
  br label %28, !llvm.loop !14

52:                                               ; preds = %28
  %53 = load i32, ptr %11, align 4, !tbaa !12
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %52
  %56 = load i32, ptr %11, align 4, !tbaa !12
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  call void @addDigit(i32 noundef %56, ptr noundef %57)
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Node, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  store ptr %60, ptr %8, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %55, %52
  store i32 0, ptr %12, align 4, !tbaa !12
  br label %62

62:                                               ; preds = %68, %61
  %63 = load i32, ptr %12, align 4, !tbaa !12
  %64 = load i32, ptr %13, align 4, !tbaa !12
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %66, label %71

66:                                               ; preds = %62
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  call void @addDigit(i32 noundef 0, ptr noundef %67)
  br label %68

68:                                               ; preds = %66
  %69 = load i32, ptr %12, align 4, !tbaa !12
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %12, align 4, !tbaa !12
  br label %62, !llvm.loop !16

71:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %72, ptr %14, align 8, !tbaa !5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call ptr @add(ptr noundef %73, ptr noundef %74)
  store ptr %75, ptr %9, align 8, !tbaa !5
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  call void @deleteAll(ptr noundef %76)
  %77 = load i32, ptr %13, align 4, !tbaa !12
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %13, align 4, !tbaa !12
  store i32 0, ptr %11, align 4, !tbaa !12
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  call void @deleteIntegerList(ptr noundef %79)
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %80, ptr %8, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.Node, ptr %81, i32 0, i32 1
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  store ptr %83, ptr %5, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.Node, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !9
  store ptr %86, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %24, !llvm.loop !17

87:                                               ; preds = %24
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  call void @deleteAll(ptr noundef %88)
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret ptr %89
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !6, i64 8}
!10 = !{!"Node", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !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"

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @makeEmpty() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @deleteAll(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 @multiply(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call ptr @makeEmpty()
  %8 = tail call ptr @makeEmpty()
  %.not49 = icmp eq ptr %4, null
  br i1 %.not49, label %._crit_edge54, label %.preheader

.preheader:                                       ; preds = %2, %._crit_edge48
  %.053 = phi ptr [ %25, %._crit_edge48 ], [ %4, %2 ]
  %.03152 = phi i32 [ %23, %._crit_edge48 ], [ 0, %2 ]
  %.03451 = phi ptr [ %26, %._crit_edge48 ], [ %6, %2 ]
  %.03650 = phi ptr [ %22, %._crit_edge48 ], [ %8, %2 ]
  %.not3940 = icmp eq ptr %.03451, null
  br i1 %.not3940, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.143 = phi i32 [ %13, %.lr.ph ], [ 0, %.preheader ]
  %.13542 = phi ptr [ %18, %.lr.ph ], [ %.03451, %.preheader ]
  %.13841 = phi ptr [ %16, %.lr.ph ], [ %7, %.preheader ]
  %9 = load i32, ptr %.053, align 8, !tbaa !11
  %10 = load i32, ptr %.13542, align 8, !tbaa !11
  %11 = mul nsw i32 %10, %9
  %12 = add nsw i32 %11, %.143
  %13 = sdiv i32 %12, 10
  %14 = srem i32 %12, 10
  tail call void @addDigit(i32 noundef %14, ptr noundef %.13841)
  %15 = getelementptr inbounds i8, ptr %.13841, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.13542, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %.not39 = icmp eq ptr %18, null
  br i1 %.not39, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph
  %19 = icmp sgt i32 %12, 9
  br i1 %19, label %20, label %._crit_edge.thread

20:                                               ; preds = %._crit_edge
  tail call void @addDigit(i32 noundef %13, ptr noundef %16)
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %.preheader, %20, %._crit_edge
  %.not56 = icmp eq i32 %.03152, 0
  br i1 %.not56, label %._crit_edge48, label %.lr.ph47

.lr.ph47:                                         ; preds = %._crit_edge.thread, %.lr.ph47
  %.03245 = phi i32 [ %21, %.lr.ph47 ], [ 0, %._crit_edge.thread ]
  tail call void @addDigit(i32 noundef 0, ptr noundef %7)
  %21 = add nuw nsw i32 %.03245, 1
  %exitcond.not = icmp eq i32 %21, %.03152
  br i1 %exitcond.not, label %._crit_edge48, label %.lr.ph47, !llvm.loop !14

._crit_edge48:                                    ; preds = %.lr.ph47, %._crit_edge.thread
  %22 = tail call ptr @add(ptr noundef %.03650, ptr noundef %7)
  tail call void @deleteAll(ptr noundef %.03650)
  %23 = add nuw nsw i32 %.03152, 1
  tail call void @deleteIntegerList(ptr noundef %7)
  %24 = getelementptr inbounds i8, ptr %.053, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %._crit_edge54, label %.preheader, !llvm.loop !15

._crit_edge54:                                    ; preds = %._crit_edge48, %2
  %.036.lcssa = phi ptr [ %8, %2 ], [ %22, %._crit_edge48 ]
  tail call void @deleteAll(ptr noundef %7)
  ret ptr %.036.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" }

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


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