; LLVM IR from tangjz/acm-icpc :: codeforces/complete/489E.ll (Z5judgev)

; 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
@l = external dso_local global i32, align 4
@x = external dso_local global [1010 x i32], align 16
@b = external dso_local global [1010 x i32], align 16
@p = external dso_local global [1010 x i32], align 16
@f = external dso_local global [1010 x double], align 16
@M = external dso_local global double, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5judgev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %96, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = icmp sle i32 %5, %6
  br i1 %7, label %9, label %8

8:                                                ; preds = %4
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %99

9:                                                ; preds = %4
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = load i32, ptr @l, align 4, !tbaa !5
  %15 = sub nsw i32 %13, %14
  %16 = call i32 @llvm.abs.i32(i32 %15, i1 true)
  %17 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %16)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %19
  store double %17, ptr %20, align 8, !tbaa !9
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %22
  store i32 0, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %80, %9
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %83

29:                                               ; preds = %24
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sub nsw i32 %41, %45
  %47 = load i32, ptr @l, align 4, !tbaa !5
  %48 = sub nsw i32 %46, %47
  %49 = call i32 @llvm.abs.i32(i32 %48, i1 true)
  %50 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %49)
  %51 = fadd double %37, %50
  %52 = fcmp ogt double %33, %51
  br i1 %52, label %53, label %79

53:                                               ; preds = %29
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sub nsw i32 %61, %65
  %67 = load i32, ptr @l, align 4, !tbaa !5
  %68 = sub nsw i32 %66, %67
  %69 = call i32 @llvm.abs.i32(i32 %68, i1 true)
  %70 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %69)
  %71 = fadd double %57, %70
  %72 = load i32, ptr %1, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %73
  store double %71, ptr %74, align 8, !tbaa !9
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = load i32, ptr %1, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %77
  store i32 %75, ptr %78, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %53, %29
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %3, align 4, !tbaa !5
  br label %24, !llvm.loop !11

83:                                               ; preds = %28
  %84 = load double, ptr @M, align 8, !tbaa !9
  %85 = load i32, ptr %1, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1010 x i32], ptr @b, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sitofp i32 %88 to double
  %90 = load i32, ptr %1, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %91
  %93 = load double, ptr %92, align 8, !tbaa !9
  %94 = fneg double %84
  %95 = call double @llvm.fmuladd.f64(double %94, double %89, double %93)
  store double %95, ptr %92, align 8, !tbaa !9
  br label %96

96:                                               ; preds = %83
  %97 = load i32, ptr %1, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !13

99:                                               ; preds = %8
  %100 = load i32, ptr @n, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %101
  %103 = load double, ptr %102, align 8, !tbaa !9
  %104 = fcmp oge double %103, 0.000000e+00
  ret i1 %104
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

@n = external dso_local local_unnamed_addr global i32, align 4
@l = external dso_local local_unnamed_addr global i32, align 4
@x = external dso_local local_unnamed_addr global [1010 x i32], align 16
@b = external dso_local local_unnamed_addr global [1010 x i32], align 16
@p = external dso_local local_unnamed_addr global [1010 x i32], align 16
@f = external dso_local local_unnamed_addr global [1010 x double], align 16
@M = external dso_local local_unnamed_addr global double, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5judgev() local_unnamed_addr #0 {
  %1 = load i32, ptr @n, align 4, !tbaa !5
  %.not28 = icmp slt i32 %1, 1
  br i1 %.not28, label %.._crit_edge32_crit_edge, label %.lr.ph31

.._crit_edge32_crit_edge:                         ; preds = %0
  %.pre38 = sext i32 %1 to i64
  br label %._crit_edge32

._crit_edge32:                                    ; preds = %._crit_edge, %.._crit_edge32_crit_edge
  %.pre-phi = phi i64 [ %.pre38, %.._crit_edge32_crit_edge ], [ %22, %._crit_edge ]
  %2 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %.pre-phi
  %3 = load double, ptr %2, align 8, !tbaa !9
  %4 = fcmp oge double %3, 0.000000e+00
  ret i1 %4

.lr.ph31:                                         ; preds = %0, %._crit_edge
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %._crit_edge ], [ 1, %0 ]
  %5 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %indvars.iv35
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = load i32, ptr @l, align 4, !tbaa !5
  %8 = sub nsw i32 %6, %7
  %9 = tail call i32 @llvm.abs.i32(i32 %8, i1 true)
  %10 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %9)
  %11 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %indvars.iv35
  store double %10, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %indvars.iv35
  store i32 0, ptr %12, align 4, !tbaa !5
  %13 = icmp ugt i64 %indvars.iv35, 1
  br i1 %13, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %47
  %.pre = load double, ptr %11, align 8, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph31
  %14 = phi double [ %.pre, %._crit_edge.loopexit ], [ %10, %.lr.ph31 ]
  %15 = load double, ptr @M, align 8, !tbaa !9
  %16 = getelementptr inbounds [1010 x i32], ptr @b, i64 0, i64 %indvars.iv35
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = sitofp i32 %17 to double
  %19 = fneg double %15
  %20 = tail call double @llvm.fmuladd.f64(double %19, double %18, double %14)
  store double %20, ptr %11, align 8, !tbaa !9
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %.not.not = icmp slt i64 %indvars.iv35, %22
  br i1 %.not.not, label %.lr.ph31, label %._crit_edge32, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph31, %47
  %indvars.iv = phi i64 [ %indvars.iv.next, %47 ], [ 1, %.lr.ph31 ]
  %23 = load double, ptr %11, align 8, !tbaa !9
  %24 = getelementptr inbounds [1010 x double], ptr @f, i64 0, i64 %indvars.iv
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = getelementptr inbounds [1010 x i32], ptr @x, i64 0, i64 %indvars.iv
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = load i32, ptr @l, align 4, !tbaa !5
  %30 = add i32 %28, %29
  %31 = sub i32 %26, %30
  %32 = tail call i32 @llvm.abs.i32(i32 %31, i1 true)
  %33 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %32)
  %34 = fadd double %25, %33
  %35 = fcmp ogt double %23, %34
  br i1 %35, label %36, label %47

36:                                               ; preds = %.lr.ph
  %37 = load double, ptr %24, align 8, !tbaa !9
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr %27, align 4, !tbaa !5
  %40 = load i32, ptr @l, align 4, !tbaa !5
  %41 = add i32 %39, %40
  %42 = sub i32 %38, %41
  %43 = tail call i32 @llvm.abs.i32(i32 %42, i1 true)
  %44 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %43)
  %45 = fadd double %37, %44
  store double %45, ptr %11, align 8, !tbaa !9
  %46 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %46, ptr %12, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %.lr.ph, %36
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %indvars.iv35
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !13
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { 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 #2 = { mustprogress 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 = !{!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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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