; LLVM IR from bnidia/push_swap :: score (score_process)

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

; 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: nounwind uwtable
define dso_local void @score_process(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %28, %3
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_listc, ptr %11, i32 0, i32 3
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_listc, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = add nsw i32 %13, %16
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_listc, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 8, !tbaa !14
  %21 = add nsw i32 %17, %20
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_listc, ptr %22, i32 0, i32 2
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = add nsw i32 %21, %24
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp ne i32 %25, %26
  br i1 %27, label %28, label %32

28:                                               ; preds = %10
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.s_listc, ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  store ptr %31, ptr %7, align 8, !tbaa !5
  br label %10, !llvm.loop !17

32:                                               ; preds = %10
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  call void @score_rr_rrr(ptr noundef %33, ptr noundef %34, ptr noundef %35, i1 noundef zeroext true)
  br label %36

36:                                               ; preds = %42, %32
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.s_listc, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !13
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %38, align 4, !tbaa !13
  %41 = icmp sgt i32 %39, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %36
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ra(ptr noundef %43, i1 noundef zeroext true)
  br label %36, !llvm.loop !19

44:                                               ; preds = %36
  br label %45

45:                                               ; preds = %51, %44
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_listc, ptr %46, i32 0, i32 3
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %47, align 4, !tbaa !11
  %50 = icmp sgt i32 %48, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %45
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  call void @rb(ptr noundef %52, i1 noundef zeroext true)
  br label %45, !llvm.loop !20

53:                                               ; preds = %45
  br label %54

54:                                               ; preds = %60, %53
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.s_listc, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 8, !tbaa !15
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %56, align 8, !tbaa !15
  %59 = icmp sgt i32 %57, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %54
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  call void @rra(ptr noundef %61, i1 noundef zeroext true)
  br label %54, !llvm.loop !21

62:                                               ; preds = %54
  br label %63

63:                                               ; preds = %69, %62
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.s_listc, ptr %64, i32 0, i32 4
  %66 = load i32, ptr %65, align 8, !tbaa !14
  %67 = add nsw i32 %66, -1
  store i32 %67, ptr %65, align 8, !tbaa !14
  %68 = icmp sgt i32 %66, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %63
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  call void @rrb(ptr noundef %70, i1 noundef zeroext true)
  br label %63, !llvm.loop !22

71:                                               ; preds = %63
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  call void @pa(ptr noundef %72, ptr noundef %73, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @score_rr_rrr(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #1

declare void @ra(ptr noundef, i1 noundef zeroext) #2

declare void @rb(ptr noundef, i1 noundef zeroext) #2

declare void @rra(ptr noundef, i1 noundef zeroext) #2

declare void @rrb(ptr noundef, i1 noundef zeroext) #2

declare void @pa(ptr noundef, ptr noundef, i1 noundef zeroext) #2

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


; 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
define dso_local void @score_process(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  br label %4

4:                                                ; preds = %4, %3
  %.0.in = phi ptr [ %1, %3 ], [ %8, %4 ]
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %.0, i64 4
  %6 = load <4 x i32>, ptr %5, align 4, !tbaa !9
  %7 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %6)
  %.not = icmp eq i32 %7, %2
  %8 = getelementptr inbounds i8, ptr %.0, i64 32
  br i1 %.not, label %9, label %4, !llvm.loop !11

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %.0, i64 12
  %11 = getelementptr inbounds i8, ptr %.0, i64 4
  %12 = getelementptr inbounds i8, ptr %.0, i64 16
  %13 = getelementptr inbounds i8, ptr %.0, i64 8
  tail call void @score_rr_rrr(ptr noundef nonnull %.0, ptr noundef %0, ptr noundef %1, i1 noundef zeroext true)
  %14 = load i32, ptr %11, align 4, !tbaa !13
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %11, align 4, !tbaa !13
  %16 = icmp sgt i32 %14, 0
  br i1 %16, label %.lr.ph, label %.preheader20

.preheader20:                                     ; preds = %.lr.ph, %9
  %17 = load i32, ptr %10, align 4, !tbaa !15
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr %10, align 4, !tbaa !15
  %19 = icmp sgt i32 %17, 0
  br i1 %19, label %.lr.ph28, label %.preheader19

.lr.ph:                                           ; preds = %9, %.lr.ph
  tail call void @ra(ptr noundef %0, i1 noundef zeroext true) #3
  %20 = load i32, ptr %11, align 4, !tbaa !13
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %11, align 4, !tbaa !13
  %22 = icmp sgt i32 %20, 0
  br i1 %22, label %.lr.ph, label %.preheader20, !llvm.loop !16

.preheader19:                                     ; preds = %.lr.ph28, %.preheader20
  %23 = load i32, ptr %13, align 8, !tbaa !17
  %24 = add nsw i32 %23, -1
  store i32 %24, ptr %13, align 8, !tbaa !17
  %25 = icmp sgt i32 %23, 0
  br i1 %25, label %.lr.ph29, label %.preheader

.lr.ph28:                                         ; preds = %.preheader20, %.lr.ph28
  tail call void @rb(ptr noundef %1, i1 noundef zeroext true) #3
  %26 = load i32, ptr %10, align 4, !tbaa !15
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %10, align 4, !tbaa !15
  %28 = icmp sgt i32 %26, 0
  br i1 %28, label %.lr.ph28, label %.preheader19, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph29, %.preheader19
  %29 = load i32, ptr %12, align 8, !tbaa !19
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr %12, align 8, !tbaa !19
  %31 = icmp sgt i32 %29, 0
  br i1 %31, label %.lr.ph30, label %._crit_edge

.lr.ph29:                                         ; preds = %.preheader19, %.lr.ph29
  tail call void @rra(ptr noundef %0, i1 noundef zeroext true) #3
  %32 = load i32, ptr %13, align 8, !tbaa !17
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %13, align 8, !tbaa !17
  %34 = icmp sgt i32 %32, 0
  br i1 %34, label %.lr.ph29, label %.preheader, !llvm.loop !20

.lr.ph30:                                         ; preds = %.preheader, %.lr.ph30
  tail call void @rrb(ptr noundef %1, i1 noundef zeroext true) #3
  %35 = load i32, ptr %12, align 8, !tbaa !19
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %12, align 8, !tbaa !19
  %37 = icmp sgt i32 %35, 0
  br i1 %37, label %.lr.ph30, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %.lr.ph30, %.preheader
  tail call void @pa(ptr noundef %0, ptr noundef %1, i1 noundef zeroext true) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @score_rr_rrr(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #0

declare void @ra(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @rb(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @rra(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @rrb(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @pa(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #2

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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 4}
!14 = !{!"s_listc", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!14, !10, i64 12}
!16 = distinct !{!16, !12}
!17 = !{!14, !10, i64 8}
!18 = distinct !{!18, !12}
!19 = !{!14, !10, i64 16}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}


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