; LLVM IR from tangjz/acm-icpc :: hdu (5236)

; 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
@x = external dso_local global i32, align 4
@p = external dso_local global double, align 8
@f = external dso_local global [100001 x double], align 16
@ans = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updRdRKd(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #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 double, align 8
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %80, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @t, align 4, !tbaa !5
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %9
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @p, ptr noundef @x)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %34, %14
  %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
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %37

21:                                               ; preds = %16
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = fadd double %26, 1.000000e+00
  %28 = load double, ptr @p, align 8, !tbaa !9
  %29 = fsub double 1.000000e+00, %28
  %30 = fdiv double %27, %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %32
  store double %30, ptr %33, align 8, !tbaa !9
  br label %34

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

37:                                               ; preds = %20
  store double 2.000000e+07, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %38

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

42:                                               ; preds = %38
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %76

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = srem i32 %44, %45
  store i32 %46, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sdiv i32 %47, %48
  %50 = add nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = sitofp i32 %54 to double
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sdiv i32 %56, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = sub nsw i32 %62, %63
  %65 = sitofp i32 %64 to double
  %66 = fmul double %61, %65
  %67 = call double @llvm.fmuladd.f64(double %53, double %55, double %66)
  %68 = load i32, ptr @x, align 4, !tbaa !5
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = mul nsw i32 %68, %69
  %71 = sitofp i32 %70 to double
  %72 = fadd double %67, %71
  store double %72, ptr %7, align 8, !tbaa !9
  call void @_Z3updRdRKd(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %73

73:                                               ; preds = %43
  %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 %38, !llvm.loop !13

76:                                               ; preds = %42
  %77 = load i32, ptr %2, align 4, !tbaa !5
  %78 = load double, ptr @ans, align 8, !tbaa !9
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %77, double noundef %78)
  br label %80

80:                                               ; preds = %76
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !14

83:                                               ; preds = %13
  ret i32 0
}

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

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

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

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

declare i32 @printf(ptr noundef, ...) #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!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
@x = external dso_local global i32, align 4
@p = external dso_local global double, align 8
@f = external dso_local local_unnamed_addr global [100001 x double], align 16
@ans = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updRdRKd(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca double, align 8
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %.not28 = icmp slt i32 %3, 1
  br i1 %.not28, label %._crit_edge32, label %.lr.ph31

._crit_edge32:                                    ; preds = %._crit_edge27, %0
  ret i32 0

.lr.ph31:                                         ; preds = %0, %._crit_edge27
  %.029 = phi i32 [ %30, %._crit_edge27 ], [ 1, %0 ]
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @p, ptr noundef nonnull @x)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not1921 = icmp slt i32 %5, 1
  br i1 %.not1921, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %.lr.ph31
  store double 2.000000e+07, ptr @ans, align 8, !tbaa !9
  br label %._crit_edge27

.lr.ph:                                           ; preds = %.lr.ph31
  %6 = load double, ptr @p, align 8, !tbaa !9
  %7 = fsub double 1.000000e+00, %6
  %.pre = load double, ptr @f, align 16, !tbaa !9
  %8 = zext nneg i32 %5 to i64
  %xtraiter = and i64 %8, 3
  %9 = icmp ult i32 %5, 4
  br i1 %9, label %._crit_edge.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %8, 2147483644
  br label %14

._crit_edge.unr-lcssa:                            ; preds = %14, %.lr.ph
  %.unr = phi double [ %.pre, %.lr.ph ], [ %26, %14 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next.3, %14 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.unr-lcssa, %.epil.preheader
  %10 = phi double [ %12, %.epil.preheader ], [ %.unr, %._crit_edge.unr-lcssa ]
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.unr-lcssa ]
  %11 = fadd double %10, 1.000000e+00
  %12 = fdiv double %11, %7
  %13 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %indvars.iv.epil
  store double %12, ptr %13, align 8, !tbaa !9
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %.epil.preheader, %._crit_edge.unr-lcssa
  store double 2.000000e+07, ptr @ans, align 8, !tbaa !9
  br i1 %.not1921, label %._crit_edge27, label %.lr.ph26

14:                                               ; preds = %14, %.lr.ph.new
  %15 = phi double [ %.pre, %.lr.ph.new ], [ %26, %14 ]
  %indvars.iv = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next.3, %14 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %14 ]
  %16 = fadd double %15, 1.000000e+00
  %17 = fdiv double %16, %7
  %18 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %indvars.iv
  store double %17, ptr %18, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = fadd double %17, 1.000000e+00
  %20 = fdiv double %19, %7
  %21 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %indvars.iv.next
  store double %20, ptr %21, align 8, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %22 = fadd double %20, 1.000000e+00
  %23 = fdiv double %22, %7
  %24 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %indvars.iv.next.1
  store double %23, ptr %24, align 8, !tbaa !9
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %25 = fadd double %23, 1.000000e+00
  %26 = fdiv double %25, %7
  %27 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %indvars.iv.next.2
  store double %26, ptr %27, align 8, !tbaa !9
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %14, !llvm.loop !13

._crit_edge27.loopexit:                           ; preds = %.lr.ph26
  %.pre34 = load double, ptr @ans, align 8, !tbaa !9
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge.thread, %._crit_edge27.loopexit, %._crit_edge
  %28 = phi double [ %.pre34, %._crit_edge27.loopexit ], [ 2.000000e+07, %._crit_edge ], [ 2.000000e+07, %._crit_edge.thread ]
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.029, double noundef %28)
  %30 = add nuw nsw i32 %.029, 1
  %31 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.029, %31
  br i1 %.not.not, label %.lr.ph31, label %._crit_edge32, !llvm.loop !15

.lr.ph26:                                         ; preds = %._crit_edge, %.lr.ph26
  %32 = phi i32 [ %52, %.lr.ph26 ], [ %5, %._crit_edge ]
  %.01624 = phi i32 [ %51, %.lr.ph26 ], [ 1, %._crit_edge ]
  %33 = srem i32 %32, %.01624
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %34 = sdiv i32 %32, %.01624
  %35 = add nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = sitofp i32 %33 to double
  %40 = sext i32 %34 to i64
  %41 = getelementptr inbounds [100001 x double], ptr @f, i64 0, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = sub nsw i32 %.01624, %33
  %44 = sitofp i32 %43 to double
  %45 = fmul double %42, %44
  %46 = call double @llvm.fmuladd.f64(double %38, double %39, double %45)
  %47 = load i32, ptr @x, align 4, !tbaa !5
  %48 = mul nsw i32 %47, %.01624
  %49 = sitofp i32 %48 to double
  %50 = fadd double %46, %49
  store double %50, ptr %1, align 8, !tbaa !9
  call void @_Z3updRdRKd(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  %51 = add nuw nsw i32 %.01624, 1
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %.not20.not = icmp slt i32 %.01624, %52
  br i1 %.not20.not, label %.lr.ph26, label %._crit_edge27.loopexit, !llvm.loop !16
}

; 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.start.p0(i64 immarg, ptr nocapture) #3

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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