; LLVM IR from xirc/cp-algorithm :: atcoder/abc087/B/main.ll (Z5solveiiii)

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

15:                                               ; preds = %56, %4
  %16 = load i32, ptr %10, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %59

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %52, %20
  %22 = load i32, ptr %12, align 4, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %55

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %48, %26
  %28 = load i32, ptr %13, align 4, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp sle i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 8, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %51

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %33 = load i32, ptr %10, align 4, !tbaa !5
  %34 = mul nsw i32 500, %33
  %35 = load i32, ptr %12, align 4, !tbaa !5
  %36 = mul nsw i32 100, %35
  %37 = add nsw i32 %34, %36
  %38 = load i32, ptr %13, align 4, !tbaa !5
  %39 = mul nsw i32 50, %38
  %40 = add nsw i32 %37, %39
  store i32 %40, ptr %14, align 4, !tbaa !5
  %41 = load i32, ptr %14, align 4, !tbaa !5
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = icmp eq i32 %41, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %32
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %9, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %44, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %13, align 4, !tbaa !5
  br label %27, !llvm.loop !9

51:                                               ; preds = %31
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %12, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %12, align 4, !tbaa !5
  br label %21, !llvm.loop !11

55:                                               ; preds = %25
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %10, align 4, !tbaa !5
  br label %15, !llvm.loop !12

59:                                               ; preds = %19
  %60 = load i32, ptr %9, align 4, !tbaa !5
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret i32 %60
}

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress 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 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i32 @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = or i32 %0, %1
  %6 = or i32 %5, %2
  %or.cond46.not = icmp sgt i32 %6, -1
  br i1 %or.cond46.not, label %.preheader21.preheader, label %._crit_edge33

.preheader21.preheader:                           ; preds = %4
  %7 = add i32 %2, 1
  %min.iters.check = icmp ult i32 %7, 8
  %n.vec = and i32 %7, -8
  %broadcast.splatinsert49 = insertelement <4 x i32> poison, i32 %3, i64 0
  %broadcast.splat50 = shufflevector <4 x i32> %broadcast.splatinsert49, <4 x i32> poison, <4 x i32> zeroinitializer
  %cmp.n = icmp eq i32 %7, %n.vec
  br label %.preheader21

.preheader21:                                     ; preds = %.preheader21.preheader, %._crit_edge28.split
  %.032 = phi i32 [ %spec.select.lcssa, %._crit_edge28.split ], [ 0, %.preheader21.preheader ]
  %.01831 = phi i32 [ %25, %._crit_edge28.split ], [ 0, %.preheader21.preheader ]
  %8 = mul nuw nsw i32 %.01831, 500
  br label %.preheader

._crit_edge33:                                    ; preds = %._crit_edge28.split, %4
  %.0.lcssa = phi i32 [ 0, %4 ], [ %spec.select.lcssa, %._crit_edge28.split ]
  ret i32 %.0.lcssa

.preheader:                                       ; preds = %.preheader21, %._crit_edge
  %.127 = phi i32 [ %.032, %.preheader21 ], [ %spec.select.lcssa, %._crit_edge ]
  %.01726 = phi i32 [ 0, %.preheader21 ], [ %26, %._crit_edge ]
  %9 = mul nuw nsw i32 %.01726, 100
  %10 = add nuw nsw i32 %9, %8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader
  %.224.ph = phi i32 [ %.127, %.preheader ], [ %24, %middle.block ]
  %.01623.ph = phi i32 [ 0, %.preheader ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.preheader
  %11 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.127, i64 0
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %10, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %11, %vector.ph ], [ %21, %vector.body ]
  %vec.phi47 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %22, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %12 = mul nuw nsw <4 x i32> %vec.ind, <i32 50, i32 50, i32 50, i32 50>
  %13 = mul <4 x i32> %vec.ind, <i32 50, i32 50, i32 50, i32 50>
  %14 = add <4 x i32> %13, <i32 200, i32 200, i32 200, i32 200>
  %15 = add nuw nsw <4 x i32> %broadcast.splat, %12
  %16 = add nuw nsw <4 x i32> %broadcast.splat, %14
  %17 = icmp eq <4 x i32> %15, %broadcast.splat50
  %18 = icmp eq <4 x i32> %16, %broadcast.splat50
  %19 = zext <4 x i1> %17 to <4 x i32>
  %20 = zext <4 x i1> %18 to <4 x i32>
  %21 = add <4 x i32> %vec.phi, %19
  %22 = add <4 x i32> %vec.phi47, %20
  %index.next = add nuw i32 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %23 = icmp eq i32 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !5

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %22, %21
  %24 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge28.split:                              ; preds = %._crit_edge
  %25 = add nuw i32 %.01831, 1
  %exitcond45.not = icmp eq i32 %.01831, %0
  br i1 %exitcond45.not, label %._crit_edge33, label %.preheader21, !llvm.loop !9

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %spec.select.lcssa = phi i32 [ %24, %middle.block ], [ %spec.select, %scalar.ph ]
  %26 = add nuw i32 %.01726, 1
  %exitcond44.not = icmp eq i32 %.01726, %1
  br i1 %exitcond44.not, label %._crit_edge28.split, label %.preheader, !llvm.loop !10

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.224 = phi i32 [ %spec.select, %scalar.ph ], [ %.224.ph, %scalar.ph.preheader ]
  %.01623 = phi i32 [ %31, %scalar.ph ], [ %.01623.ph, %scalar.ph.preheader ]
  %27 = mul nuw nsw i32 %.01623, 50
  %28 = add nuw nsw i32 %10, %27
  %29 = icmp eq i32 %28, %3
  %30 = zext i1 %29 to i32
  %spec.select = add nsw i32 %.224, %30
  %31 = add nuw i32 %.01623, 1
  %exitcond.not = icmp eq i32 %.01623, %2
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !11
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 speculatable willreturn memory(none) }

!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 = distinct !{!5, !6, !7, !8}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.isvectorized", i32 1}
!8 = !{!"llvm.loop.unroll.runtime.disable"}
!9 = distinct !{!9, !6}
!10 = distinct !{!10, !6}
!11 = distinct !{!11, !6, !8, !7}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass