; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (5806)

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

@a = external dso_local global [200010 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

13:                                               ; preds = %87, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %2, align 4, !tbaa !5
  %16 = icmp ne i32 %14, 0
  br i1 %16, label %17, label %90

17:                                               ; preds = %13
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %29, %17
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %19
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %27)
  br label %29

29:                                               ; preds = %24
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %6, align 4, !tbaa !5
  br label %19, !llvm.loop !9

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

33:                                               ; preds = %83, %32
  %34 = load i32, ptr %10, align 4, !tbaa !5
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 7, ptr %11, align 4
  br label %86

38:                                               ; preds = %33
  br label %39

39:                                               ; preds = %49, %38
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %43, label %47

43:                                               ; preds = %39
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br label %47

47:                                               ; preds = %43, %39
  %48 = phi i1 [ false, %39 ], [ %46, %43 ]
  br i1 %48, label %49, label %61

49:                                               ; preds = %47
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %8, align 4, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = icmp sge i32 %55, %56
  %58 = zext i1 %57 to i32
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = add nsw i32 %59, %58
  store i32 %60, ptr %7, align 4, !tbaa !5
  br label %39, !llvm.loop !13

61:                                               ; preds = %47
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  store i32 7, ptr %11, align 4
  br label %86

66:                                               ; preds = %61
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = sub nsw i32 %67, %68
  %70 = add nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = load i64, ptr %9, align 8, !tbaa !11
  %73 = add nsw i64 %72, %71
  store i64 %73, ptr %9, align 8, !tbaa !11
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = icmp sge i32 %77, %78
  %80 = zext i1 %79 to i32
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = sub nsw i32 %81, %80
  store i32 %82, ptr %7, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %66
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %10, align 4, !tbaa !5
  br label %33, !llvm.loop !14

86:                                               ; preds = %65, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %87

87:                                               ; preds = %86
  %88 = load i64, ptr %9, align 8, !tbaa !11
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %88)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %13, !llvm.loop !15

90:                                               ; preds = %13
  store i32 0, ptr %1, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %91 = load i32, ptr %1, align 4
  ret i32 %91
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress norecurse 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !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"

@a = external dso_local global [200010 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr %1, align 4, !tbaa !5
  %.not43 = icmp eq i32 %6, 0
  br i1 %.not43, label %._crit_edge46, label %.lr.ph45

.lr.ph45:                                         ; preds = %0, %._crit_edge39
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %9 = load i32, ptr %2, align 4
  %.not2226 = icmp slt i32 %9, 1
  br i1 %.not2226, label %._crit_edge39, label %.lr.ph

.preheader24:                                     ; preds = %.lr.ph
  %.not2334 = icmp slt i32 %16, 1
  br i1 %.not2334, label %._crit_edge39, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader24
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load i32, ptr %3, align 4
  %12 = add nuw i32 %16, 1
  %13 = zext nneg i32 %16 to i64
  %wide.trip.count = zext i32 %12 to i64
  br label %.preheader

.lr.ph:                                           ; preds = %.lr.ph45, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph45 ]
  %14 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %indvars.iv
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr %2, align 4
  %17 = sext i32 %16 to i64
  %.not22.not = icmp slt i64 %indvars.iv, %17
  br i1 %.not22.not, label %.lr.ph, label %.preheader24, !llvm.loop !9

.preheader:                                       ; preds = %.preheader.lr.ph, %31
  %indvars.iv55 = phi i64 [ 1, %.preheader.lr.ph ], [ %indvars.iv.next56, %31 ]
  %.01737 = phi i64 [ 0, %.preheader.lr.ph ], [ %34, %31 ]
  %.01836 = phi i32 [ 0, %.preheader.lr.ph ], [ %.1.lcssa61, %31 ]
  %.01935 = phi i32 [ 0, %.preheader.lr.ph ], [ %38, %31 ]
  %18 = icmp slt i32 %.01935, %10
  %19 = icmp slt i32 %.01836, %16
  %20 = select i1 %18, i1 %19, i1 false
  br i1 %20, label %.lr.ph30.preheader, label %._crit_edge

.lr.ph30.preheader:                               ; preds = %.preheader
  %21 = sext i32 %.01836 to i64
  br label %.lr.ph30

.lr.ph30:                                         ; preds = %.lr.ph30.preheader, %.lr.ph30
  %indvars.iv52 = phi i64 [ %21, %.lr.ph30.preheader ], [ %indvars.iv.next53, %.lr.ph30 ]
  %.12028 = phi i32 [ %.01935, %.lr.ph30.preheader ], [ %26, %.lr.ph30 ]
  %indvars.iv.next53 = add nsw i64 %indvars.iv52, 1
  %22 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %indvars.iv.next53
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp sge i32 %23, %11
  %25 = zext i1 %24 to i32
  %26 = add nsw i32 %.12028, %25
  %27 = icmp slt i32 %26, %10
  %28 = icmp slt i64 %indvars.iv.next53, %13
  %29 = and i1 %27, %28
  br i1 %29, label %.lr.ph30, label %._crit_edge.loopexit, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %.lr.ph30
  %30 = trunc nsw i64 %indvars.iv.next53 to i32
  br i1 %27, label %._crit_edge39, label %31

._crit_edge:                                      ; preds = %.preheader
  br i1 %18, label %._crit_edge39, label %31

31:                                               ; preds = %._crit_edge.loopexit, %._crit_edge
  %.1.lcssa61 = phi i32 [ %30, %._crit_edge.loopexit ], [ %.01836, %._crit_edge ]
  %.120.lcssa60 = phi i32 [ %26, %._crit_edge.loopexit ], [ %.01935, %._crit_edge ]
  %32 = sub i32 %12, %.1.lcssa61
  %33 = sext i32 %32 to i64
  %34 = add nsw i64 %.01737, %33
  %35 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %indvars.iv55
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp sge i32 %36, %11
  %.neg = sext i1 %37 to i32
  %38 = add i32 %.120.lcssa60, %.neg
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next56, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge39, label %.preheader, !llvm.loop !12

._crit_edge39:                                    ; preds = %31, %._crit_edge, %._crit_edge.loopexit, %.lr.ph45, %.preheader24
  %.017.lcssa = phi i64 [ 0, %.preheader24 ], [ 0, %.lr.ph45 ], [ %.01737, %._crit_edge.loopexit ], [ %.01737, %._crit_edge ], [ %34, %31 ]
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.017.lcssa)
  %40 = load i32, ptr %1, align 4, !tbaa !5
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %40, 0
  br i1 %.not, label %._crit_edge46, label %.lr.ph45, !llvm.loop !13

._crit_edge46:                                    ; preds = %._crit_edge39, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse 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 = { nofree nounwind "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 = !{!"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}
!13 = distinct !{!13, !10}


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