; LLVM IR from kenjin/Awesome-LC-C-Cracker :: leetcode-c-sol/1010_pairs-of-songs-with-total-durations-divisible-by-60 (numPairsDivisibleBy60)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @numPairsDivisibleBy60(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca [60 x i32], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 240, ptr %5) #3
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 240, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %29, %2
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %32

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %18, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = srem i32 %22, 60
  store i32 %23, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %29

29:                                               ; preds = %17
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %7, align 4, !tbaa !9
  br label %12, !llvm.loop !11

32:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %52, %32
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp sle i32 %34, 29
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %55

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %38 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %38, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = sub nsw i32 60, %39
  store i32 %40, ptr %11, align 4, !tbaa !9
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = mul nsw i32 %44, %48
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = add nsw i32 %50, %49
  store i32 %51, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %52

52:                                               ; preds = %37
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %9, align 4, !tbaa !9
  br label %33, !llvm.loop !13

55:                                               ; preds = %36
  %56 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 0
  %57 = load i32, ptr %56, align 16, !tbaa !9
  %58 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 0
  %59 = load i32, ptr %58, align 16, !tbaa !9
  %60 = sub nsw i32 %59, 1
  %61 = mul nsw i32 %57, %60
  %62 = sdiv i32 %61, 2
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = add nsw i32 %63, %62
  store i32 %64, ptr %6, align 4, !tbaa !9
  %65 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 30
  %66 = load i32, ptr %65, align 8, !tbaa !9
  %67 = getelementptr inbounds [60 x i32], ptr %5, i64 0, i64 30
  %68 = load i32, ptr %67, align 8, !tbaa !9
  %69 = sub nsw i32 %68, 1
  %70 = mul nsw i32 %66, %69
  %71 = sdiv i32 %70, 2
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = add nsw i32 %72, %71
  store i32 %73, ptr %6, align 4, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 240, ptr %5) #3
  ret i32 %74
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!13, !12}


; 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: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local i32 @numPairsDivisibleBy60(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [60 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 240, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(240) %3, i8 0, i64 240, i1 false)
  %4 = icmp sgt i32 %1, 0
  br i1 %4, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %5 = icmp eq i32 %1, 1
  br i1 %5, label %.preheader.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph

.preheader.loopexit.unr-lcssa:                    ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader.loopexit.unr-lcssa
  %6 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.unr
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = srem i32 %7, 60
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [60 x i32], ptr %3, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = add nsw i32 %11, 1
  store i32 %12, ptr %10, align 4, !tbaa !5
  br label %.preheader.loopexit

.preheader.loopexit:                              ; preds = %.preheader.loopexit.unr-lcssa, %.lr.ph.epil
  %.phi.trans.insert = getelementptr inbounds i8, ptr %3, i64 4
  %.phi.trans.insert85 = getelementptr inbounds i8, ptr %3, i64 176
  %.phi.trans.insert87 = getelementptr inbounds i8, ptr %3, i64 68
  %.pre88 = load i32, ptr %.phi.trans.insert87, align 4, !tbaa !5
  %.phi.trans.insert89 = getelementptr inbounds i8, ptr %3, i64 172
  %.pre90 = load i32, ptr %.phi.trans.insert89, align 4, !tbaa !5
  %13 = load <16 x i32>, ptr %.phi.trans.insert, align 4, !tbaa !5
  %14 = shufflevector <16 x i32> %13, <16 x i32> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %15 = load <16 x i32>, ptr %.phi.trans.insert85, align 16, !tbaa !5
  %16 = mul nsw <16 x i32> %15, %14
  %17 = mul nsw i32 %.pre90, %.pre88
  %18 = tail call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %16)
  %op.rdx = add i32 %18, %17
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %2
  %19 = phi i32 [ %op.rdx, %.preheader.loopexit ], [ 0, %2 ]
  %20 = getelementptr inbounds i8, ptr %3, i64 72
  %21 = getelementptr inbounds i8, ptr %3, i64 140
  %22 = load <8 x i32>, ptr %20, align 8, !tbaa !5
  %23 = load <8 x i32>, ptr %21, align 4, !tbaa !5
  %24 = shufflevector <8 x i32> %23, <8 x i32> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %25 = mul nsw <8 x i32> %24, %22
  %26 = getelementptr inbounds i8, ptr %3, i64 104
  %27 = getelementptr inbounds i8, ptr %3, i64 124
  %28 = load <4 x i32>, ptr %26, align 8, !tbaa !5
  %29 = load <4 x i32>, ptr %27, align 4, !tbaa !5
  %30 = shufflevector <4 x i32> %29, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  %31 = mul nsw <4 x i32> %30, %28
  %32 = load i32, ptr %3, align 16, !tbaa !5
  %33 = add nsw i32 %32, -1
  %34 = mul nsw i32 %33, %32
  %35 = sdiv i32 %34, 2
  %36 = getelementptr inbounds i8, ptr %3, i64 120
  %37 = load i32, ptr %36, align 8, !tbaa !5
  %38 = add nsw i32 %37, -1
  %39 = mul nsw i32 %38, %37
  %40 = sdiv i32 %39, 2
  %41 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %25)
  %42 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %31)
  %op.rdx91 = add i32 %41, %42
  %op.rdx92 = add i32 %op.rdx91, %35
  %op.rdx93 = add i32 %40, %19
  %op.rdx94 = add i32 %op.rdx92, %op.rdx93
  call void @llvm.lifetime.end.p0(i64 240, ptr nonnull %3) #4
  ret i32 %op.rdx94

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %43 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = srem i32 %44, 60
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [60 x i32], ptr %3, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %47, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %50 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = srem i32 %51, 60
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [60 x i32], ptr %3, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %54, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.preheader.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

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

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass