; LLVM IR from tangjz/acm-icpc :: codeforces/gym (100506F)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@w = external dso_local global double, align 8
@p = external dso_local global double, align 8
@s = external dso_local global [51 x double], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5checkv() #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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %7

7:                                                ; preds = %61, %59, %0
  %8 = load i32, ptr @t, align 4, !tbaa !5
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr @t, align 4, !tbaa !5
  %10 = icmp ne i32 %8, 0
  br i1 %10, label %11, label %62

11:                                               ; preds = %7
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @w, ptr noundef @p, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store double 0.000000e+00, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %13 = load double, ptr @w, align 8, !tbaa !9
  store double %13, ptr %3, align 8, !tbaa !9
  %14 = load double, ptr @p, align 8, !tbaa !9
  %15 = fdiv double %14, 1.000000e+02
  store double %15, ptr @p, align 8, !tbaa !9
  store double 0.000000e+00, ptr @s, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %32, %11
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %35

21:                                               ; preds = %16
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds double, ptr @s, i64 %23
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %24)
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [51 x double], ptr @s, i64 0, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = load double, ptr %3, align 8, !tbaa !9
  %31 = fsub double %30, %29
  store double %31, ptr %3, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %21
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !11

35:                                               ; preds = %20
  %36 = call noundef zeroext i1 @_Z5checkv()
  br i1 %36, label %39, label %37

37:                                               ; preds = %35
  %38 = call i32 @puts(ptr noundef @.str.3)
  store i32 2, ptr %5, align 4
  br label %59, !llvm.loop !13

39:                                               ; preds = %35
  br label %40

40:                                               ; preds = %55, %39
  %41 = load double, ptr %3, align 8, !tbaa !9
  %42 = load double, ptr %2, align 8, !tbaa !9
  %43 = fsub double %41, %42
  %44 = fcmp oge double %43, 1.000000e-09
  br i1 %44, label %45, label %56

45:                                               ; preds = %40
  %46 = load double, ptr %2, align 8, !tbaa !9
  %47 = load double, ptr %3, align 8, !tbaa !9
  %48 = fadd double %46, %47
  %49 = fdiv double %48, 2.000000e+00
  store double %49, ptr @s, align 16, !tbaa !9
  %50 = call noundef zeroext i1 @_Z5checkv()
  br i1 %50, label %51, label %53

51:                                               ; preds = %45
  %52 = load double, ptr @s, align 16, !tbaa !9
  store double %52, ptr %2, align 8, !tbaa !9
  br label %55

53:                                               ; preds = %45
  %54 = load double, ptr @s, align 16, !tbaa !9
  store double %54, ptr %3, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %53, %51
  br label %40, !llvm.loop !14

56:                                               ; preds = %40
  %57 = load double, ptr %2, align 8, !tbaa !9
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %57)
  store i32 0, ptr %5, align 4
  br label %59

59:                                               ; preds = %56, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %60 = load i32, ptr %5, align 4
  switch i32 %60, label %63 [
    i32 0, label %61
    i32 2, label %7
  ]

61:                                               ; preds = %59
  br label %7, !llvm.loop !13

62:                                               ; preds = %7
  ret i32 0

63:                                               ; preds = %59
  unreachable
}

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

declare i32 @puts(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #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 = { 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 = { 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}
!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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@w = external dso_local global double, align 8
@p = external dso_local global double, align 8
@s = external dso_local global [51 x double], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 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 @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not21 = icmp eq i32 %2, 0
  br i1 %.not21, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %0, %26
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @w, ptr noundef nonnull @p, ptr noundef nonnull @n)
  %5 = load double, ptr @w, align 8, !tbaa !9
  %6 = load double, ptr @p, align 8, !tbaa !9
  %7 = fdiv double %6, 1.000000e+02
  store double %7, ptr @p, align 8, !tbaa !9
  store double 0.000000e+00, ptr @s, align 16, !tbaa !9
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %.not1213 = icmp slt i32 %8, 1
  br i1 %.not1213, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph23
  %.09.lcssa = phi double [ %5, %.lr.ph23 ], [ %14, %.lr.ph ]
  %9 = tail call noundef zeroext i1 @_Z5checkv()
  br i1 %9, label %.preheader, label %17

.preheader:                                       ; preds = %._crit_edge
  %10 = fcmp ult double %.09.lcssa, 1.000000e-09
  br i1 %10, label %._crit_edge19, label %.lr.ph18

.lr.ph:                                           ; preds = %.lr.ph23, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph23 ]
  %.0914 = phi double [ %14, %.lr.ph ], [ %5, %.lr.ph23 ]
  %11 = getelementptr inbounds double, ptr @s, i64 %indvars.iv
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %11)
  %13 = load double, ptr %11, align 8, !tbaa !9
  %14 = fsub double %.0914, %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %.not12.not = icmp slt i64 %indvars.iv, %16
  br i1 %.not12.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

17:                                               ; preds = %._crit_edge
  %18 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %26, !llvm.loop !13

.lr.ph18:                                         ; preds = %.preheader, %.lr.ph18
  %.117 = phi double [ %.2, %.lr.ph18 ], [ %.09.lcssa, %.preheader ]
  %.01016 = phi double [ %.111, %.lr.ph18 ], [ 0.000000e+00, %.preheader ]
  %19 = fadd double %.01016, %.117
  %20 = fmul double %19, 5.000000e-01
  store double %20, ptr @s, align 16, !tbaa !9
  %21 = tail call noundef zeroext i1 @_Z5checkv()
  %22 = load double, ptr @s, align 16
  %.111 = select i1 %21, double %22, double %.01016
  %.2 = select i1 %21, double %.117, double %22
  %23 = fsub double %.2, %.111
  %24 = fcmp ult double %23, 1.000000e-09
  br i1 %24, label %._crit_edge19, label %.lr.ph18, !llvm.loop !14

._crit_edge19:                                    ; preds = %.lr.ph18, %.preheader
  %.010.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %.111, %.lr.ph18 ]
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %.010.lcssa)
  br label %26

26:                                               ; preds = %._crit_edge19, %17
  %27 = load i32, ptr @t, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  store i32 %28, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %._crit_edge24, label %.lr.ph23

._crit_edge24:                                    ; preds = %26, %0
  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 @puts(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 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" }

!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}
!14 = distinct !{!14, !12}


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