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

; 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: nounwind uwtable
define dso_local void @score_rr_rrr(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %9 = zext i1 %3 to i8
  store i8 %9, ptr %8, align 1, !tbaa !9
  br label %10

10:                                               ; preds = %22, %4
  %11 = load ptr, ptr %5, 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 = icmp sgt i32 %13, 0
  br i1 %14, label %15, label %20

15:                                               ; preds = %10
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s_listc, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = icmp sgt i32 %18, 0
  br label %20

20:                                               ; preds = %15, %10
  %21 = phi i1 [ false, %10 ], [ %19, %15 ]
  br i1 %21, label %22, label %35

22:                                               ; preds = %20
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load i8, ptr %8, align 1, !tbaa !9, !range !15, !noundef !16
  %26 = trunc i8 %25 to i1
  call void @rr(ptr noundef %23, ptr noundef %24, i1 noundef zeroext %26)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.s_listc, ptr %27, i32 0, i32 3
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr %28, align 4, !tbaa !11
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.s_listc, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !14
  %34 = add nsw i32 %33, -1
  store i32 %34, ptr %32, align 4, !tbaa !14
  br label %10, !llvm.loop !17

35:                                               ; preds = %20
  br label %36

36:                                               ; preds = %48, %35
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.s_listc, ptr %37, i32 0, i32 4
  %39 = load i32, ptr %38, align 8, !tbaa !19
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %41, label %46

41:                                               ; preds = %36
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.s_listc, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 8, !tbaa !20
  %45 = icmp sgt i32 %44, 0
  br label %46

46:                                               ; preds = %41, %36
  %47 = phi i1 [ false, %36 ], [ %45, %41 ]
  br i1 %47, label %48, label %61

48:                                               ; preds = %46
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i8, ptr %8, align 1, !tbaa !9, !range !15, !noundef !16
  %52 = trunc i8 %51 to i1
  call void @rrr(ptr noundef %49, ptr noundef %50, i1 noundef zeroext %52)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.s_listc, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 8, !tbaa !19
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %54, align 8, !tbaa !19
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.s_listc, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !20
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr %58, align 8, !tbaa !20
  br label %36, !llvm.loop !21

61:                                               ; preds = %46
  ret void
}

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

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

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" }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !13, i64 12}
!12 = !{!"s_listc", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !13, i64 16}
!20 = !{!12, !13, i64 8}
!21 = distinct !{!21, !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_rr_rrr(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %4
  %.pre = load i32, ptr %5, align 4, !tbaa !11
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %11
  %9 = phi i32 [ %.pre, %.lr.ph.preheader ], [ %15, %11 ]
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %11, label %.critedge

11:                                               ; preds = %.lr.ph
  tail call void @rr(ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #2
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr %5, align 4, !tbaa !11
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %5, align 4, !tbaa !11
  %16 = icmp sgt i32 %12, 1
  br i1 %16, label %.lr.ph, label %.critedge, !llvm.loop !12

.critedge:                                        ; preds = %.lr.ph, %11, %4
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph16.preheader, label %.critedge2

.lr.ph16.preheader:                               ; preds = %.critedge
  %.pre18 = load i32, ptr %17, align 8, !tbaa !15
  br label %.lr.ph16

.lr.ph16:                                         ; preds = %.lr.ph16.preheader, %23
  %21 = phi i32 [ %.pre18, %.lr.ph16.preheader ], [ %27, %23 ]
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %.critedge2

23:                                               ; preds = %.lr.ph16
  tail call void @rrr(ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #2
  %24 = load i32, ptr %18, align 8, !tbaa !14
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %18, align 8, !tbaa !14
  %26 = load i32, ptr %17, align 8, !tbaa !15
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %17, align 8, !tbaa !15
  %28 = icmp sgt i32 %24, 1
  br i1 %28, label %.lr.ph16, label %.critedge2, !llvm.loop !16

.critedge2:                                       ; preds = %.lr.ph16, %23, %.critedge
  ret void
}

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

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

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


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