; LLVM IR from tangjz/acm-icpc :: lydsy (2318)

; 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
@p = external dso_local global double, align 8
@q = external dso_local global double, align 8
@f = external dso_local global [105 x double], align 16
@g = external dso_local global [105 x double], align 16
@e1 = external dso_local global double, align 8
@e2 = external dso_local global double, align 8
@e3 = external dso_local global double, align 8
@e4 = external dso_local global double, align 8
@e5 = external dso_local global double, align 8
@e6 = external dso_local global double, align 8
@e7 = external dso_local global double, align 8
@e8 = external dso_local global double, align 8
@tmp = 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 [9 x i8], align 1
@.str.2 = 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
  store i32 0, ptr %1, align 4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %4

4:                                                ; preds = %138, %0
  %5 = load i32, ptr @t, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @t, align 4, !tbaa !5
  %7 = icmp ne i32 %5, 0
  br i1 %7, label %8, label %144

8:                                                ; preds = %4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @p, ptr noundef @q)
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 100
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  store i32 100, ptr @n, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %12, %8
  %14 = load double, ptr @p, align 8, !tbaa !9
  %15 = load double, ptr @q, align 8, !tbaa !9
  %16 = fadd double %14, %15
  %17 = load double, ptr @p, align 8, !tbaa !9
  %18 = load double, ptr @q, align 8, !tbaa !9
  %19 = fneg double %17
  %20 = call double @llvm.fmuladd.f64(double %19, double %18, double %16)
  store double %20, ptr @tmp, align 8, !tbaa !9
  %21 = load double, ptr @p, align 8, !tbaa !9
  %22 = load double, ptr @tmp, align 8, !tbaa !9
  %23 = fdiv double %21, %22
  store double %23, ptr @e1, align 8, !tbaa !9
  %24 = load double, ptr @e1, align 8, !tbaa !9
  %25 = fsub double 1.000000e+00, %24
  store double %25, ptr @e2, align 8, !tbaa !9
  %26 = load double, ptr @q, align 8, !tbaa !9
  %27 = load double, ptr @tmp, align 8, !tbaa !9
  %28 = fdiv double %26, %27
  store double %28, ptr @e4, align 8, !tbaa !9
  %29 = load double, ptr @e4, align 8, !tbaa !9
  %30 = fsub double 1.000000e+00, %29
  store double %30, ptr @e3, align 8, !tbaa !9
  %31 = load double, ptr @p, align 8, !tbaa !9
  %32 = load double, ptr @q, align 8, !tbaa !9
  %33 = fneg double %31
  %34 = call double @llvm.fmuladd.f64(double %33, double %32, double 1.000000e+00)
  store double %34, ptr @tmp, align 8, !tbaa !9
  %35 = load double, ptr @p, align 8, !tbaa !9
  %36 = fsub double 1.000000e+00, %35
  %37 = load double, ptr @tmp, align 8, !tbaa !9
  %38 = fdiv double %36, %37
  store double %38, ptr @e5, align 8, !tbaa !9
  %39 = load double, ptr @e5, align 8, !tbaa !9
  %40 = fsub double 1.000000e+00, %39
  store double %40, ptr @e6, align 8, !tbaa !9
  %41 = load double, ptr @q, align 8, !tbaa !9
  %42 = fsub double 1.000000e+00, %41
  %43 = load double, ptr @tmp, align 8, !tbaa !9
  %44 = fdiv double %42, %43
  store double %44, ptr @e8, align 8, !tbaa !9
  %45 = load double, ptr @e8, align 8, !tbaa !9
  %46 = fsub double 1.000000e+00, %45
  store double %46, ptr @e7, align 8, !tbaa !9
  store double 0.000000e+00, ptr @f, align 16, !tbaa !9
  store double 1.000000e+00, ptr @g, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %135, %13
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %138

52:                                               ; preds = %47
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = sub nsw i32 %53, 1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = fcmp olt double %57, %62
  br i1 %63, label %64, label %99

64:                                               ; preds = %52
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !9
  %70 = load double, ptr @e2, align 8, !tbaa !9
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = sub nsw i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %73
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = load double, ptr @e1, align 8, !tbaa !9
  %77 = fmul double %75, %76
  %78 = call double @llvm.fmuladd.f64(double %69, double %70, double %77)
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %80
  store double %78, ptr %81, align 8, !tbaa !9
  %82 = load i32, ptr %2, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %84
  %86 = load double, ptr %85, align 8, !tbaa !9
  %87 = load double, ptr @e4, align 8, !tbaa !9
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = sub nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %90
  %92 = load double, ptr %91, align 8, !tbaa !9
  %93 = load double, ptr @e3, align 8, !tbaa !9
  %94 = fmul double %92, %93
  %95 = call double @llvm.fmuladd.f64(double %86, double %87, double %94)
  %96 = load i32, ptr %2, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %97
  store double %95, ptr %98, align 8, !tbaa !9
  br label %134

99:                                               ; preds = %52
  %100 = load i32, ptr %2, align 4, !tbaa !5
  %101 = sub nsw i32 %100, 1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %102
  %104 = load double, ptr %103, align 8, !tbaa !9
  %105 = load double, ptr @e6, align 8, !tbaa !9
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = sub nsw i32 %106, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %108
  %110 = load double, ptr %109, align 8, !tbaa !9
  %111 = load double, ptr @e5, align 8, !tbaa !9
  %112 = fmul double %110, %111
  %113 = call double @llvm.fmuladd.f64(double %104, double %105, double %112)
  %114 = load i32, ptr %2, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %115
  store double %113, ptr %116, align 8, !tbaa !9
  %117 = load i32, ptr %2, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %119
  %121 = load double, ptr %120, align 8, !tbaa !9
  %122 = load double, ptr @e8, align 8, !tbaa !9
  %123 = load i32, ptr %2, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %125
  %127 = load double, ptr %126, align 8, !tbaa !9
  %128 = load double, ptr @e7, align 8, !tbaa !9
  %129 = fmul double %127, %128
  %130 = call double @llvm.fmuladd.f64(double %121, double %122, double %129)
  %131 = load i32, ptr %2, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %132
  store double %130, ptr %133, align 8, !tbaa !9
  br label %134

134:                                              ; preds = %99, %64
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %2, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %2, align 4, !tbaa !5
  br label %47, !llvm.loop !11

138:                                              ; preds = %51
  %139 = load i32, ptr @n, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %140
  %142 = load double, ptr %141, align 8, !tbaa !9
  %143 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %142)
  br label %4, !llvm.loop !13

144:                                              ; preds = %4
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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

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

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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@p = external dso_local global double, align 8
@q = external dso_local global double, align 8
@f = external dso_local local_unnamed_addr global [105 x double], align 16
@g = external dso_local local_unnamed_addr global [105 x double], align 16
@e1 = external dso_local local_unnamed_addr global double, align 8
@e2 = external dso_local local_unnamed_addr global double, align 8
@e3 = external dso_local local_unnamed_addr global double, align 8
@e4 = external dso_local local_unnamed_addr global double, align 8
@e5 = external dso_local local_unnamed_addr global double, align 8
@e6 = external dso_local local_unnamed_addr global double, align 8
@e7 = external dso_local local_unnamed_addr global double, align 8
@e8 = external dso_local local_unnamed_addr global double, align 8
@tmp = external dso_local local_unnamed_addr global double, align 8
@.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 [7 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %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
  %.not23 = icmp eq i32 %2, 0
  br i1 %.not23, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %0, %._crit_edge
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @p, ptr noundef nonnull @q)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 100
  br i1 %6, label %7, label %8

7:                                                ; preds = %.lr.ph25
  store i32 100, ptr @n, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %7, %.lr.ph25
  %9 = phi i32 [ 100, %7 ], [ %5, %.lr.ph25 ]
  %10 = load double, ptr @p, align 8, !tbaa !9
  %11 = load double, ptr @q, align 8, !tbaa !9
  %12 = fadd double %10, %11
  %13 = fneg double %10
  %14 = tail call double @llvm.fmuladd.f64(double %13, double %11, double %12)
  %15 = fdiv double %10, %14
  store double %15, ptr @e1, align 8, !tbaa !9
  %16 = fsub double 1.000000e+00, %15
  store double %16, ptr @e2, align 8, !tbaa !9
  %17 = fdiv double %11, %14
  store double %17, ptr @e4, align 8, !tbaa !9
  %18 = fsub double 1.000000e+00, %17
  store double %18, ptr @e3, align 8, !tbaa !9
  %19 = tail call double @llvm.fmuladd.f64(double %13, double %11, double 1.000000e+00)
  store double %19, ptr @tmp, align 8, !tbaa !9
  %20 = fsub double 1.000000e+00, %10
  %21 = fdiv double %20, %19
  store double %21, ptr @e5, align 8, !tbaa !9
  %22 = fsub double 1.000000e+00, %21
  store double %22, ptr @e6, align 8, !tbaa !9
  %23 = fsub double 1.000000e+00, %11
  %24 = fdiv double %23, %19
  store double %24, ptr @e8, align 8, !tbaa !9
  %25 = fsub double 1.000000e+00, %24
  store double %25, ptr @e7, align 8, !tbaa !9
  store double 0.000000e+00, ptr @f, align 16, !tbaa !9
  store double 1.000000e+00, ptr @g, align 16, !tbaa !9
  %.not2021 = icmp slt i32 %9, 1
  br i1 %.not2021, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %8
  %26 = add nuw nsw i32 %9, 1
  %wide.trip.count = zext nneg i32 %26 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %8
  %27 = sext i32 %9 to i64
  %28 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %29)
  %31 = load i32, ptr @t, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %._crit_edge26, label %.lr.ph25, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %33 = phi double [ 1.000000e+00, %.lr.ph.preheader ], [ %39, %.lr.ph ]
  %34 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %37, %.lr.ph ]
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %35 = fcmp olt double %34, %33
  %. = select i1 %35, double %15, double %21
  %.34 = select i1 %35, double %16, double %22
  %.35 = select i1 %35, double %18, double %25
  %.36 = select i1 %35, double %17, double %24
  %36 = fmul double %., %33
  %37 = tail call double @llvm.fmuladd.f64(double %34, double %.34, double %36)
  %38 = fmul double %.35, %33
  %39 = tail call double @llvm.fmuladd.f64(double %34, double %.36, double %38)
  %40 = getelementptr inbounds [105 x double], ptr @f, i64 0, i64 %indvars.iv
  store double %37, ptr %40, align 8
  %41 = getelementptr inbounds [105 x double], ptr @g, i64 0, i64 %indvars.iv
  store double %39, ptr %41, align 8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge26:                                    ; preds = %._crit_edge, %0
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress nofree 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 #1 = { 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 #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,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass