; LLVM IR from AllAlgorithms/c :: algorithms/data-structures (Add_Ploynomial_Linklist)

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

@poly1 = external dso_local global ptr, align 8
@poly2 = external dso_local global ptr, align 8
@poly3 = external dso_local global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [50 x i8], align 1

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

declare i32 @printf(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 @insert_end(ptr noundef, float noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @add_polynomials() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %3 = load ptr, ptr @poly1, align 8, !tbaa !5
  store ptr %3, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %4 = load ptr, ptr @poly2, align 8, !tbaa !5
  store ptr %4, ptr %2, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %73, %0
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %11

8:                                                ; preds = %5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br label %11

11:                                               ; preds = %8, %5
  %12 = phi i1 [ false, %5 ], [ %10, %8 ]
  br i1 %12, label %13, label %74

13:                                               ; preds = %11
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.node, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.node, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = icmp sgt i32 %16, %19
  br i1 %20, label %21, label %33

21:                                               ; preds = %13
  %22 = load ptr, ptr @poly3, align 8, !tbaa !5
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.node, ptr %23, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !13
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.node, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = call ptr @insert_end(ptr noundef %22, float noundef %25, i32 noundef %28)
  store ptr %29, ptr @poly3, align 8, !tbaa !5
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.node, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  store ptr %32, ptr %1, align 8, !tbaa !5
  br label %73

33:                                               ; preds = %13
  %34 = load ptr, ptr %1, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.node, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.node, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = icmp eq i32 %36, %39
  br i1 %40, label %41, label %60

41:                                               ; preds = %33
  %42 = load ptr, ptr @poly3, align 8, !tbaa !5
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.node, ptr %43, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !13
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.node, ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !13
  %49 = fadd float %45, %48
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.node, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !9
  %53 = call ptr @insert_end(ptr noundef %42, float noundef %49, i32 noundef %52)
  store ptr %53, ptr @poly3, align 8, !tbaa !5
  %54 = load ptr, ptr %1, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.node, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  store ptr %56, ptr %1, align 8, !tbaa !5
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.node, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  store ptr %59, ptr %2, align 8, !tbaa !5
  br label %72

60:                                               ; preds = %33
  %61 = load ptr, ptr @poly3, align 8, !tbaa !5
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.node, ptr %62, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !13
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.node, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !9
  %68 = call ptr @insert_end(ptr noundef %61, float noundef %64, i32 noundef %67)
  store ptr %68, ptr @poly3, align 8, !tbaa !5
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.node, ptr %69, i32 0, i32 2
  %71 = load ptr, ptr %70, align 8, !tbaa !14
  store ptr %71, ptr %2, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %60, %41
  br label %73

73:                                               ; preds = %72, %21
  br label %5, !llvm.loop !15

74:                                               ; preds = %11
  br label %75

75:                                               ; preds = %78, %74
  %76 = load ptr, ptr %1, align 8, !tbaa !5
  %77 = icmp ne ptr %76, null
  br i1 %77, label %78, label %90

78:                                               ; preds = %75
  %79 = load ptr, ptr @poly3, align 8, !tbaa !5
  %80 = load ptr, ptr %1, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.node, ptr %80, i32 0, i32 1
  %82 = load float, ptr %81, align 4, !tbaa !13
  %83 = load ptr, ptr %1, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.node, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !9
  %86 = call ptr @insert_end(ptr noundef %79, float noundef %82, i32 noundef %85)
  store ptr %86, ptr @poly3, align 8, !tbaa !5
  %87 = load ptr, ptr %1, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.node, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !14
  store ptr %89, ptr %1, align 8, !tbaa !5
  br label %75, !llvm.loop !17

90:                                               ; preds = %75
  br label %91

91:                                               ; preds = %94, %90
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = icmp ne ptr %92, null
  br i1 %93, label %94, label %106

94:                                               ; preds = %91
  %95 = load ptr, ptr @poly3, align 8, !tbaa !5
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.node, ptr %96, i32 0, i32 1
  %98 = load float, ptr %97, align 4, !tbaa !13
  %99 = load ptr, ptr %2, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.node, ptr %99, i32 0, i32 0
  %101 = load i32, ptr %100, align 8, !tbaa !9
  %102 = call ptr @insert_end(ptr noundef %95, float noundef %98, i32 noundef %101)
  store ptr %102, ptr @poly3, align 8, !tbaa !5
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.node, ptr %103, i32 0, i32 2
  %105 = load ptr, ptr %104, align 8, !tbaa !14
  store ptr %105, ptr %2, align 8, !tbaa !5
  br label %91, !llvm.loop !18

106:                                              ; preds = %91
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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, !11, i64 0}
!10 = !{!"node", !11, i64 0, !12, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !12, i64 4}
!14 = !{!10, !6, i64 8}
!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"

@poly1 = external dso_local local_unnamed_addr global ptr, align 8
@poly2 = external dso_local local_unnamed_addr global ptr, align 8
@poly3 = external dso_local local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @insert_end(ptr noundef, float noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @add_polynomials() local_unnamed_addr #1 {
  %1 = load ptr, ptr @poly1, align 8, !tbaa !5
  %2 = load ptr, ptr @poly2, align 8, !tbaa !5
  %3 = icmp ne ptr %1, null
  %4 = icmp ne ptr %2, null
  %5 = select i1 %3, i1 %4, i1 false
  br i1 %5, label %.lr.ph, label %.preheader32

.preheader32:                                     ; preds = %34, %0
  %.025.lcssa = phi ptr [ %1, %0 ], [ %.126, %34 ]
  %.0.lcssa = phi ptr [ %2, %0 ], [ %.1, %34 ]
  %.not36 = icmp eq ptr %.025.lcssa, null
  br i1 %.not36, label %.preheader, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %.preheader32
  %.pre = load ptr, ptr @poly3, align 8, !tbaa !5
  br label %.lr.ph38

.lr.ph:                                           ; preds = %0, %34
  %.034 = phi ptr [ %.1, %34 ], [ %2, %0 ]
  %.02533 = phi ptr [ %.126, %34 ], [ %1, %0 ]
  %6 = load i32, ptr %.02533, align 8, !tbaa !9
  %7 = load i32, ptr %.034, align 8, !tbaa !9
  %8 = icmp sgt i32 %6, %7
  br i1 %8, label %9, label %16

9:                                                ; preds = %.lr.ph
  %10 = load ptr, ptr @poly3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %.02533, i64 4
  %12 = load float, ptr %11, align 4, !tbaa !13
  %13 = tail call ptr @insert_end(ptr noundef %10, float noundef %12, i32 noundef %6)
  store ptr %13, ptr @poly3, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %.02533, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  br label %34

16:                                               ; preds = %.lr.ph
  %17 = icmp eq i32 %6, %7
  %18 = load ptr, ptr @poly3, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.034, i64 4
  %20 = load float, ptr %19, align 4, !tbaa !13
  br i1 %17, label %21, label %30

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %.02533, i64 4
  %23 = load float, ptr %22, align 4, !tbaa !13
  %24 = fadd float %20, %23
  %25 = tail call ptr @insert_end(ptr noundef %18, float noundef %24, i32 noundef %6)
  store ptr %25, ptr @poly3, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.02533, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %.034, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  br label %34

30:                                               ; preds = %16
  %31 = tail call ptr @insert_end(ptr noundef %18, float noundef %20, i32 noundef %7)
  store ptr %31, ptr @poly3, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.034, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  br label %34

34:                                               ; preds = %21, %30, %9
  %.126 = phi ptr [ %15, %9 ], [ %27, %21 ], [ %.02533, %30 ]
  %.1 = phi ptr [ %.034, %9 ], [ %29, %21 ], [ %33, %30 ]
  %35 = icmp ne ptr %.126, null
  %36 = icmp ne ptr %.1, null
  %37 = select i1 %35, i1 %36, i1 false
  br i1 %37, label %.lr.ph, label %.preheader32, !llvm.loop !15

.preheader:                                       ; preds = %.lr.ph38, %.preheader32
  %.not3139 = icmp eq ptr %.0.lcssa, null
  br i1 %.not3139, label %._crit_edge, label %.lr.ph41.preheader

.lr.ph41.preheader:                               ; preds = %.preheader
  %.pre42 = load ptr, ptr @poly3, align 8, !tbaa !5
  br label %.lr.ph41

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %.lr.ph38
  %38 = phi ptr [ %42, %.lr.ph38 ], [ %.pre, %.lr.ph38.preheader ]
  %.22737 = phi ptr [ %44, %.lr.ph38 ], [ %.025.lcssa, %.lr.ph38.preheader ]
  %39 = getelementptr inbounds i8, ptr %.22737, i64 4
  %40 = load float, ptr %39, align 4, !tbaa !13
  %41 = load i32, ptr %.22737, align 8, !tbaa !9
  %42 = tail call ptr @insert_end(ptr noundef %38, float noundef %40, i32 noundef %41)
  store ptr %42, ptr @poly3, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %.22737, i64 8
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %.not = icmp eq ptr %44, null
  br i1 %.not, label %.preheader, label %.lr.ph38, !llvm.loop !17

.lr.ph41:                                         ; preds = %.lr.ph41.preheader, %.lr.ph41
  %45 = phi ptr [ %49, %.lr.ph41 ], [ %.pre42, %.lr.ph41.preheader ]
  %.240 = phi ptr [ %51, %.lr.ph41 ], [ %.0.lcssa, %.lr.ph41.preheader ]
  %46 = getelementptr inbounds i8, ptr %.240, i64 4
  %47 = load float, ptr %46, align 4, !tbaa !13
  %48 = load i32, ptr %.240, align 8, !tbaa !9
  %49 = tail call ptr @insert_end(ptr noundef %45, float noundef %47, i32 noundef %48)
  store ptr %49, ptr @poly3, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %.240, i64 8
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %.not31 = icmp eq ptr %51, null
  br i1 %.not31, label %._crit_edge, label %.lr.ph41, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph41, %.preheader
  %52 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  ret void
}

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


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