; LLVM IR from tangjz/acm-icpc :: uvalive (7558)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@x = external dso_local global [403 x i32], align 16
@y = external dso_local global [403 x i32], align 16
@lim = external dso_local global i64, align 8
@dis = external dso_local global [201 x [201 x i64]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 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 uwtable
declare dso_local noundef zeroext i1 @_Z5checkv() #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 i64, align 8
  %7 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  br label %8

8:                                                ; preds = %97, %0
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %102

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

12:                                               ; preds = %26, %11
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = shl i32 %14, 1
  %16 = icmp slt i32 %13, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %29

18:                                               ; preds = %12
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr @x, i64 %20
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr @y, i64 %23
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %21, ptr noundef %24)
  br label %26

26:                                               ; preds = %18
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

29:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %77, %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %80

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %73, %35
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %76

41:                                               ; preds = %36
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [403 x i32], ptr @x, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %46, %47
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [403 x i32], ptr @x, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sub nsw i32 %45, %51
  %53 = call noundef i64 @_Z3sqri(i32 noundef %52)
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [403 x i32], ptr @y, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr @n, align 4, !tbaa !5
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = add nsw i32 %58, %59
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [403 x i32], ptr @y, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sub nsw i32 %57, %63
  %65 = call noundef i64 @_Z3sqri(i32 noundef %64)
  %66 = add nsw i64 %53, %65
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [201 x [201 x i64]], ptr @dis, i64 0, i64 %68
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [201 x i64], ptr %69, i64 0, i64 %71
  store i64 %66, ptr %72, align 8, !tbaa !11
  br label %73

73:                                               ; preds = %41
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %5, align 4, !tbaa !5
  br label %36, !llvm.loop !13

76:                                               ; preds = %40
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !14

80:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 20000000000, ptr %7, align 8, !tbaa !11
  br label %81

81:                                               ; preds = %96, %80
  %82 = load i64, ptr %6, align 8, !tbaa !11
  %83 = load i64, ptr %7, align 8, !tbaa !11
  %84 = icmp slt i64 %82, %83
  br i1 %84, label %85, label %97

85:                                               ; preds = %81
  %86 = load i64, ptr %6, align 8, !tbaa !11
  %87 = load i64, ptr %7, align 8, !tbaa !11
  %88 = add nsw i64 %86, %87
  %89 = ashr i64 %88, 1
  store i64 %89, ptr @lim, align 8, !tbaa !11
  %90 = call noundef zeroext i1 @_Z5checkv()
  br i1 %90, label %91, label %93

91:                                               ; preds = %85
  %92 = load i64, ptr @lim, align 8, !tbaa !11
  store i64 %92, ptr %7, align 8, !tbaa !11
  br label %96

93:                                               ; preds = %85
  %94 = load i64, ptr @lim, align 8, !tbaa !11
  %95 = add nsw i64 %94, 1
  store i64 %95, ptr %6, align 8, !tbaa !11
  br label %96

96:                                               ; preds = %93, %91
  br label %81, !llvm.loop !15

97:                                               ; preds = %81
  %98 = load i64, ptr %6, align 8, !tbaa !11
  %99 = sitofp i64 %98 to double
  %100 = call double @sqrt(double noundef %99) #6
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %100)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %8, !llvm.loop !16

102:                                              ; preds = %8
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sqri(i32 noundef) #4

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { "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 = { inlinehint 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 #5 = { 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 #6 = { 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}
!16 = distinct !{!16, !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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@x = external dso_local global [403 x i32], align 16
@y = external dso_local global [403 x i32], align 16
@lim = external dso_local local_unnamed_addr global i64, align 8
@dis = external dso_local local_unnamed_addr global [201 x [201 x i64]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5checkv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = icmp eq i32 %1, 2
  br i1 %2, label %.preheader27, label %._crit_edge34

.preheader27:                                     ; preds = %0, %50
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = shl i32 %3, 1
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.preheader26

.preheader26:                                     ; preds = %.lr.ph, %.preheader27
  %6 = phi i32 [ %3, %.preheader27 ], [ %11, %.lr.ph ]
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader, label %.preheader25.preheader

.preheader25.preheader:                           ; preds = %._crit_edge, %.preheader26
  br label %.preheader25

.lr.ph:                                           ; preds = %.preheader27, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader27 ]
  %8 = getelementptr inbounds i32, ptr @x, i64 %indvars.iv
  %9 = getelementptr inbounds i32, ptr @y, i64 %indvars.iv
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = shl i32 %11, 1
  %13 = sext i32 %12 to i64
  %14 = icmp slt i64 %indvars.iv.next, %13
  br i1 %14, label %.lr.ph, label %.preheader26, !llvm.loop !9

.preheader:                                       ; preds = %.preheader26, %._crit_edge
  %15 = phi i32 [ %19, %._crit_edge ], [ %6, %.preheader26 ]
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %._crit_edge ], [ 0, %.preheader26 ]
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph30, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre = sext i32 %15 to i64
  br label %._crit_edge

.lr.ph30:                                         ; preds = %.preheader
  %17 = getelementptr inbounds [403 x i32], ptr @x, i64 0, i64 %indvars.iv40
  %18 = getelementptr inbounds [403 x i32], ptr @y, i64 0, i64 %indvars.iv40
  br label %21

._crit_edge:                                      ; preds = %21, %.preheader.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader.._crit_edge_crit_edge ], [ %42, %21 ]
  %19 = phi i32 [ %15, %.preheader.._crit_edge_crit_edge ], [ %41, %21 ]
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %20 = icmp slt i64 %indvars.iv.next41, %.pre-phi
  br i1 %20, label %.preheader, label %.preheader25.preheader, !llvm.loop !11

21:                                               ; preds = %.lr.ph30, %21
  %indvars.iv37 = phi i64 [ 0, %.lr.ph30 ], [ %indvars.iv.next38, %21 ]
  %22 = phi i32 [ %15, %.lr.ph30 ], [ %41, %21 ]
  %23 = load i32, ptr %17, align 4, !tbaa !5
  %24 = trunc nuw nsw i64 %indvars.iv37 to i32
  %25 = add nsw i32 %22, %24
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [403 x i32], ptr @x, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sub nsw i32 %23, %28
  %30 = tail call noundef i64 @_Z3sqri(i32 noundef %29)
  %31 = load i32, ptr %18, align 4, !tbaa !5
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = add nsw i32 %32, %24
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [403 x i32], ptr @y, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sub nsw i32 %31, %36
  %38 = tail call noundef i64 @_Z3sqri(i32 noundef %37)
  %39 = add nsw i64 %38, %30
  %40 = getelementptr inbounds [201 x [201 x i64]], ptr @dis, i64 0, i64 %indvars.iv40, i64 %indvars.iv37
  store i64 %39, ptr %40, align 8, !tbaa !13
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next38, %42
  br i1 %43, label %21, label %._crit_edge, !llvm.loop !15

.preheader25:                                     ; preds = %.preheader25.preheader, %.preheader25
  %.033 = phi i64 [ %.1, %.preheader25 ], [ 20000000000, %.preheader25.preheader ]
  %.01932 = phi i64 [ %.120, %.preheader25 ], [ 0, %.preheader25.preheader ]
  %44 = add nsw i64 %.033, %.01932
  %45 = ashr i64 %44, 1
  store i64 %45, ptr @lim, align 8, !tbaa !13
  %46 = tail call noundef zeroext i1 @_Z5checkv()
  %47 = load i64, ptr @lim, align 8
  %48 = add nsw i64 %47, 1
  %.120 = select i1 %46, i64 %.01932, i64 %48
  %.1 = select i1 %46, i64 %47, i64 %.033
  %49 = icmp slt i64 %.120, %.1
  br i1 %49, label %.preheader25, label %50, !llvm.loop !16

50:                                               ; preds = %.preheader25
  %51 = sitofp i64 %.120 to double
  %52 = tail call double @sqrt(double noundef %51) #5
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %52)
  %54 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %55 = icmp eq i32 %54, 2
  br i1 %55, label %.preheader27, label %._crit_edge34, !llvm.loop !17

._crit_edge34:                                    ; preds = %50, %0
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sqri(i32 noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #4

attributes #0 = { 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 #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 = { 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 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 #4 = { mustprogress nofree nounwind willreturn memory(write) "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 #5 = { 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}
!12 = !{!"llvm.loop.unswitch.partial.disable"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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