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

; 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 [100010 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

19:                                               ; preds = %29, %17
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp sle i64 %20, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %19
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %27)
  br label %29

29:                                               ; preds = %25
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %7, align 8, !tbaa !9
  br label %19, !llvm.loop !11

32:                                               ; preds = %24
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i64, ptr @a, i64 %34
  %36 = getelementptr inbounds i64, ptr %35, i64 1
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @a, ptr noundef %36)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  store i64 %39, ptr %10, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %89, %32
  %41 = load i64, ptr %10, align 8, !tbaa !9
  %42 = icmp sge i64 %41, 1
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store i32 7, ptr %11, align 4
  br label %92

44:                                               ; preds = %40
  %45 = load i64, ptr %10, align 8, !tbaa !9
  %46 = add nsw i64 %45, 1
  %47 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = load i64, ptr %10, align 8, !tbaa !9
  %50 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = sub nsw i64 %48, %51
  %53 = add nsw i64 %52, 1
  store i64 %53, ptr %8, align 8, !tbaa !9
  %54 = load i64, ptr %10, align 8, !tbaa !9
  %55 = add nsw i64 %54, 1
  %56 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = load i64, ptr %10, align 8, !tbaa !9
  %59 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = add nsw i64 %57, %60
  %62 = sub nsw i64 %61, 1
  store i64 %62, ptr %9, align 8, !tbaa !9
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = load i64, ptr %4, align 8, !tbaa !9
  %65 = icmp sgt i64 %63, %64
  br i1 %65, label %70, label %66

66:                                               ; preds = %44
  %67 = load i64, ptr %9, align 8, !tbaa !9
  %68 = load i64, ptr %5, align 8, !tbaa !9
  %69 = icmp slt i64 %67, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %66, %44
  br label %89

71:                                               ; preds = %66
  %72 = load i64, ptr %4, align 8, !tbaa !9
  %73 = load i64, ptr %9, align 8, !tbaa !9
  %74 = icmp sgt i64 %72, %73
  br i1 %74, label %75, label %81

75:                                               ; preds = %71
  %76 = load i64, ptr %4, align 8, !tbaa !9
  %77 = load i64, ptr %9, align 8, !tbaa !9
  %78 = sub nsw i64 %76, %77
  %79 = load i64, ptr %6, align 8, !tbaa !9
  %80 = add nsw i64 %79, %78
  store i64 %80, ptr %6, align 8, !tbaa !9
  br label %81

81:                                               ; preds = %75, %71
  %82 = load i64, ptr %8, align 8, !tbaa !9
  %83 = sub nsw i64 %82, 1
  store i64 %83, ptr %4, align 8, !tbaa !9
  %84 = load i64, ptr %5, align 8, !tbaa !9
  %85 = load i64, ptr %4, align 8, !tbaa !9
  %86 = icmp sgt i64 %84, %85
  br i1 %86, label %87, label %88

87:                                               ; preds = %81
  store i32 7, ptr %11, align 4
  br label %92

88:                                               ; preds = %81
  br label %89

89:                                               ; preds = %88, %70
  %90 = load i64, ptr %10, align 8, !tbaa !9
  %91 = add nsw i64 %90, -1
  store i64 %91, ptr %10, align 8, !tbaa !9
  br label %40, !llvm.loop !13

92:                                               ; preds = %87, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %93

93:                                               ; preds = %92
  %94 = load i64, ptr %5, align 8, !tbaa !9
  %95 = load i64, ptr %4, align 8, !tbaa !9
  %96 = icmp sle i64 %94, %95
  br i1 %96, label %97, label %104

97:                                               ; preds = %93
  %98 = load i64, ptr %4, align 8, !tbaa !9
  %99 = load i64, ptr %5, align 8, !tbaa !9
  %100 = sub nsw i64 %98, %99
  %101 = add nsw i64 %100, 1
  %102 = load i64, ptr %6, align 8, !tbaa !9
  %103 = add nsw i64 %102, %101
  store i64 %103, ptr %6, align 8, !tbaa !9
  br label %104

104:                                              ; preds = %97, %93
  %105 = load i64, ptr %6, align 8, !tbaa !9
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %105)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %13, !llvm.loop !14

107:                                              ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %108 = load i32, ptr %1, align 4
  ret i32 %108
}

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

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

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

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

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

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

.lr.ph44:                                         ; preds = %0, %._crit_edge38
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %4, ptr noundef nonnull %3)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %.not2532 = icmp slt i32 %9, 1
  br i1 %.not2532, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph44
  %.lcssa = phi i64 [ %10, %.lr.ph44 ], [ %19, %.lr.ph ]
  %gep = getelementptr i64, ptr getelementptr inbounds (i8, ptr @a, i64 8), i64 %.lcssa
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %gep)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 1
  %.pre = load i64, ptr %4, align 8
  br i1 %12, label %.lr.ph37, label %._crit_edge.._crit_edge38_crit_edge

._crit_edge.._crit_edge38_crit_edge:              ; preds = %._crit_edge
  %.pre48 = load i64, ptr %3, align 8, !tbaa !9
  br label %._crit_edge38

.lr.ph37:                                         ; preds = %._crit_edge
  %13 = add nsw i32 %11, -1
  %14 = zext nneg i32 %13 to i64
  %.promoted = load i64, ptr %3, align 8, !tbaa !9
  br label %20

.lr.ph:                                           ; preds = %.lr.ph44, %.lr.ph
  %.01933 = phi i64 [ %17, %.lr.ph ], [ 1, %.lr.ph44 ]
  %15 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %.01933
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %15)
  %17 = add nuw nsw i64 %.01933, 1
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %.not25.not = icmp slt i64 %.01933, %19
  br i1 %.not25.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

20:                                               ; preds = %.lr.ph37, %33
  %.035 = phi i64 [ %14, %.lr.ph37 ], [ %35, %33 ]
  %.01834 = phi i64 [ 0, %.lr.ph37 ], [ %.2, %33 ]
  %21 = phi i64 [ %.promoted, %.lr.ph37 ], [ %34, %33 ]
  %22 = add nuw nsw i64 %.035, 1
  %23 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %.035
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = sub nsw i64 %24, %26
  %28 = add nsw i64 %26, %24
  %.not26 = icmp slt i64 %27, %21
  %.not27 = icmp sgt i64 %28, %.pre
  %or.cond = select i1 %.not26, i1 %.not27, i1 false
  br i1 %or.cond, label %29, label %33

29:                                               ; preds = %20
  %.not28 = icmp slt i64 %21, %28
  %reass.sub = sub i64 %21, %28
  %30 = add i64 %reass.sub, 1
  %31 = select i1 %.not28, i64 0, i64 %30
  %.1 = add nsw i64 %31, %.01834
  store i64 %27, ptr %3, align 8, !tbaa !9
  %32 = icmp sgt i64 %.pre, %27
  br i1 %32, label %._crit_edge38, label %33

33:                                               ; preds = %29, %20
  %34 = phi i64 [ %21, %20 ], [ %27, %29 ]
  %.2 = phi i64 [ %.01834, %20 ], [ %.1, %29 ]
  %35 = add nsw i64 %.035, -1
  %36 = icmp sgt i64 %.035, 1
  br i1 %36, label %20, label %._crit_edge38, !llvm.loop !13

._crit_edge38:                                    ; preds = %33, %29, %._crit_edge.._crit_edge38_crit_edge
  %37 = phi i64 [ %.pre48, %._crit_edge.._crit_edge38_crit_edge ], [ %27, %29 ], [ %34, %33 ]
  %.3 = phi i64 [ 0, %._crit_edge.._crit_edge38_crit_edge ], [ %.1, %29 ], [ %.2, %33 ]
  %.not29 = icmp sgt i64 %.pre, %37
  %reass.sub46 = sub i64 %37, %.pre
  %38 = add i64 %reass.sub46, 1
  %39 = select i1 %.not29, i64 0, i64 %38
  %.4 = add nsw i64 %39, %.3
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.4)
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = add nsw i32 %41, -1
  store i32 %42, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %41, 0
  br i1 %.not, label %._crit_edge45, label %.lr.ph44, !llvm.loop !14

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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