; LLVM IR from tangjz/acm-icpc :: hdu/5324.ll (Z5solveii)

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

@tt = external dso_local global i32, align 4
@f = external dso_local global [50010 x i32], align 16
@p = external dso_local global [50010 x i32], align 16
@a = external dso_local global [50010 x %struct.Point], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRK5PointS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3quei(i32 noundef) #0

; 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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveii(i32 noundef %0, i32 noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %137

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = add nsw i32 %13, %14
  %16 = ashr i32 %15, 1
  store i32 %16, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  %19 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z5solveii(i32 noundef %18, i32 noundef %19)
  %20 = load i32, ptr @tt, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr @tt, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.Point, ptr @a, i64 %23
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %struct.Point, ptr @a, i64 %26
  %28 = getelementptr inbounds %struct.Point, ptr %27, i64 1
  call void @_ZSt4sortIP5PointEvT_S2_(ptr noundef %24, ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %29 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %29, ptr %6, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %124, %12
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp sge i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %127

35:                                               ; preds = %30
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.Point, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = icmp sgt i32 %40, %41
  br i1 %42, label %43, label %54

43:                                               ; preds = %35
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.Point, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.Point, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 4, !tbaa !9
  call void @_Z3updii(i32 noundef %48, i32 noundef %53)
  br label %123

54:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %56
  %58 = getelementptr inbounds %struct.Point, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 4, !tbaa !11
  %60 = call noundef i32 @_Z3quei(i32 noundef %59)
  store i32 %60, ptr %7, align 4, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.Point, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  %74 = icmp slt i32 %68, %73
  br i1 %74, label %101, label %75

75:                                               ; preds = %54
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Point, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  %89 = icmp eq i32 %83, %88
  br i1 %89, label %90, label %122

90:                                               ; preds = %75
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.Point, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [50010 x i32], ptr @p, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = icmp sgt i32 %98, %99
  br i1 %100, label %101, label %122

101:                                              ; preds = %90, %54
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = load i32, ptr %6, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.Point, ptr %105, i32 0, i32 0
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [50010 x i32], ptr @p, i64 0, i64 %108
  store i32 %102, ptr %109, align 4, !tbaa !5
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %116
  %118 = getelementptr inbounds %struct.Point, ptr %117, i32 0, i32 0
  %119 = load i32, ptr %118, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %120
  store i32 %114, ptr %121, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %101, %90, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %123

123:                                              ; preds = %122, %43
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = add nsw i32 %125, -1
  store i32 %126, ptr %6, align 4, !tbaa !5
  br label %30, !llvm.loop !12

127:                                              ; preds = %34
  %128 = load i32, ptr %3, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds %struct.Point, ptr @a, i64 %129
  %131 = load i32, ptr %4, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds %struct.Point, ptr @a, i64 %132
  %134 = getelementptr inbounds %struct.Point, ptr %133, i64 1
  call void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef %130, ptr noundef %134, ptr noundef @_Z3cmpRK5PointS1_)
  %135 = load i32, ptr %3, align 4, !tbaa !5
  %136 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z5solveii(i32 noundef %135, i32 noundef %136)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %137

137:                                              ; preds = %127, %11
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointEvT_S2_(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) #3

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 = { mustprogress 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 = { inlinehint mustprogress 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 #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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS5Point", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

%struct.Point = type { i32, i32, i32 }

@tt = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local local_unnamed_addr global [50010 x i32], align 16
@p = external dso_local local_unnamed_addr global [50010 x i32], align 16
@a = external dso_local global [50010 x %struct.Point], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRK5PointS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3quei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq i32 %0, %1
  br i1 %3, label %tailrecurse._crit_edge, label %.lr.ph42

.lr.ph42:                                         ; preds = %2
  %4 = sext i32 %0 to i64
  %5 = getelementptr inbounds %struct.Point, ptr @a, i64 %4
  br label %6

6:                                                ; preds = %.lr.ph42, %tailrecurse
  %.tr3740 = phi i32 [ %1, %.lr.ph42 ], [ %8, %tailrecurse ]
  %7 = add nsw i32 %.tr3740, %0
  %8 = ashr i32 %7, 1
  %9 = add nsw i32 %8, 1
  tail call void @_Z5solveii(i32 noundef %9, i32 noundef %.tr3740)
  %10 = load i32, ptr @tt, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr @tt, align 4, !tbaa !5
  %12 = sext i32 %.tr3740 to i64
  %gep = getelementptr %struct.Point, ptr getelementptr inbounds (i8, ptr @a, i64 12), i64 %12
  tail call void @_ZSt4sortIP5PointEvT_S2_(ptr noundef nonnull %5, ptr noundef nonnull %gep)
  %.not38 = icmp slt i32 %.tr3740, %0
  br i1 %.not38, label %tailrecurse, label %.lr.ph

tailrecurse:                                      ; preds = %37, %6
  tail call void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef nonnull %5, ptr noundef nonnull %gep, ptr noundef nonnull @_Z3cmpRK5PointS1_)
  %13 = icmp eq i32 %8, %0
  br i1 %13, label %tailrecurse._crit_edge, label %6

.lr.ph:                                           ; preds = %6, %37
  %indvars.iv = phi i64 [ %indvars.iv.next, %37 ], [ %12, %6 ]
  %14 = getelementptr inbounds [50010 x %struct.Point], ptr @a, i64 0, i64 %indvars.iv
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp sgt i32 %15, %8
  %17 = getelementptr inbounds i8, ptr %14, i64 8
  %18 = load i32, ptr %17, align 4, !tbaa !11
  br i1 %16, label %19, label %20

19:                                               ; preds = %.lr.ph
  tail call void @_Z3updii(i32 noundef %18, i32 noundef %15)
  br label %37

20:                                               ; preds = %.lr.ph
  %21 = tail call noundef i32 @_Z3quei(i32 noundef %18)
  %22 = load i32, ptr %14, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %21 to i64
  %27 = getelementptr inbounds [50010 x i32], ptr @f, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %.not36 = icmp sgt i32 %25, %28
  %29 = add nsw i32 %28, 1
  br i1 %.not36, label %30, label %._crit_edge

30:                                               ; preds = %20
  %31 = icmp eq i32 %25, %29
  br i1 %31, label %32, label %37

32:                                               ; preds = %30
  %33 = getelementptr inbounds [50010 x i32], ptr @p, i64 0, i64 %23
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp sgt i32 %34, %21
  br i1 %35, label %._crit_edge, label %37

._crit_edge:                                      ; preds = %20, %32
  %36 = getelementptr inbounds [50010 x i32], ptr @p, i64 0, i64 %23
  store i32 %21, ptr %36, align 4, !tbaa !5
  store i32 %29, ptr %24, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %30, %32, %._crit_edge, %19
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not.not = icmp sgt i64 %indvars.iv, %4
  br i1 %.not.not, label %.lr.ph, label %tailrecurse, !llvm.loop !12

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %2
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointEvT_S2_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS5Point", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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