; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1136)

; 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
@cnt = external dso_local global i32, align 4
@f = external dso_local global [11 x [27 x double]], align 16
@p1 = external dso_local global double, align 8
@p2 = 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 [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %7

7:                                                ; preds = %124, %0
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %9 = icmp ne i32 %8, -1
  br i1 %9, label %10, label %125

10:                                               ; preds = %7
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store double 0.000000e+00, ptr @p2, align 8, !tbaa !9
  store double 0.000000e+00, ptr @p1, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 16 @f, i8 0, i64 2376, i1 false)
  store double 1.000000e+00, ptr @f, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %111, %10
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4, ptr noundef %5)
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %24

20:                                               ; preds = %16
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr @cnt, align 4, !tbaa !5
  %23 = add nsw i32 %22, %21
  store i32 %23, ptr @cnt, align 4, !tbaa !5
  br label %24

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

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

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

29:                                               ; preds = %25
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %30, %31
  %33 = icmp sge i32 %32, 27
  br i1 %33, label %34, label %64

34:                                               ; preds = %29
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = sitofp i32 %35 to double
  %37 = fdiv double %36, 1.000000e+02
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sub nsw i32 %38, 1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %40
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [27 x double], ptr %41, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = fmul double %37, %45
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sitofp i32 %47 to double
  %49 = load double, ptr @p1, align 8, !tbaa !9
  %50 = call double @llvm.fmuladd.f64(double %46, double %48, double %49)
  store double %50, ptr @p1, align 8, !tbaa !9
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = sitofp i32 %51 to double
  %53 = fdiv double %52, 1.000000e+02
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = sub nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %56
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [27 x double], ptr %57, i64 0, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load double, ptr @p2, align 8, !tbaa !9
  %63 = call double @llvm.fmuladd.f64(double %53, double %61, double %62)
  store double %63, ptr @p2, align 8, !tbaa !9
  br label %86

64:                                               ; preds = %29
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sitofp i32 %65 to double
  %67 = fdiv double %66, 1.000000e+02
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %70
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [27 x double], ptr %71, i64 0, i64 %73
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %77
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = add nsw i32 %79, %80
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [27 x double], ptr %78, i64 0, i64 %82
  %84 = load double, ptr %83, align 8, !tbaa !9
  %85 = call double @llvm.fmuladd.f64(double %67, double %75, double %84)
  store double %85, ptr %83, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %64, %34
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = sub nsw i32 100, %87
  %89 = sitofp i32 %88 to double
  %90 = fdiv double %89, 1.000000e+02
  %91 = load i32, ptr %2, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %93
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [27 x double], ptr %94, i64 0, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !9
  %99 = load i32, ptr %2, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %100
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [27 x double], ptr %101, i64 0, i64 %103
  %105 = load double, ptr %104, align 8, !tbaa !9
  %106 = call double @llvm.fmuladd.f64(double %90, double %98, double %105)
  store double %106, ptr %104, align 8, !tbaa !9
  br label %107

107:                                              ; preds = %86
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %6, align 4, !tbaa !5
  br label %25, !llvm.loop !11

110:                                              ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %2, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !13

114:                                              ; preds = %15
  %115 = load i32, ptr @cnt, align 4, !tbaa !5
  %116 = icmp slt i32 %115, 27
  br i1 %116, label %117, label %119

117:                                              ; preds = %114
  %118 = call i32 @puts(ptr noundef @.str.2)
  br label %124

119:                                              ; preds = %114
  %120 = load double, ptr @p1, align 8, !tbaa !9
  %121 = load double, ptr @p2, align 8, !tbaa !9
  %122 = fdiv double %120, %121
  %123 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %122)
  br label %124

124:                                              ; preds = %119, %117
  br label %7, !llvm.loop !14

125:                                              ; preds = %7
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

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

declare i32 @puts(ptr noundef) #1

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 nounwind willreturn memory(argmem: write) }
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"

@n = external dso_local global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local local_unnamed_addr global [11 x [27 x double]], align 16
@p1 = external dso_local local_unnamed_addr global double, align 8
@p2 = 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 [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not25 = icmp eq i32 %3, -1
  br i1 %.not25, label %._crit_edge28, label %.lr.ph27

.lr.ph27:                                         ; preds = %0, %50
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store double 0.000000e+00, ptr @p2, align 8, !tbaa !9
  store double 0.000000e+00, ptr @p1, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2376) @f, i8 0, i64 2376, i1 false)
  store double 1.000000e+00, ptr @f, align 16, !tbaa !9
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not2023 = icmp slt i32 %4, 1
  br i1 %.not2023, label %._crit_edge.thread, label %.lr.ph

._crit_edge:                                      ; preds = %21
  %.pre34 = load i32, ptr @cnt, align 4, !tbaa !5
  %5 = icmp slt i32 %.pre34, 27
  br i1 %5, label %._crit_edge.thread, label %47

.lr.ph:                                           ; preds = %.lr.ph27, %21
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %21 ], [ 1, %.lr.ph27 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %.not21 = icmp eq i32 %7, 0
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br i1 %.not21, label %11, label %8

8:                                                ; preds = %.lr.ph
  %9 = load i32, ptr @cnt, align 4, !tbaa !5
  %10 = add nsw i32 %9, %.pre
  store i32 %10, ptr @cnt, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %8, %.lr.ph
  %12 = sub nsw i32 100, %7
  %13 = sitofp i32 %12 to double
  %14 = fdiv double %13, 1.000000e+02
  %15 = add nsw i64 %indvars.iv30, -1
  %p1.promoted = load double, ptr @p1, align 8, !tbaa !9
  %p2.promoted = load double, ptr @p2, align 8, !tbaa !9
  %16 = sitofp i32 %7 to double
  %17 = fdiv double %16, 1.000000e+02
  %18 = trunc nuw nsw i64 %indvars.iv30 to i32
  %19 = uitofp nneg i32 %18 to double
  %20 = sext i32 %.pre to i64
  br label %24

21:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %.not20.not = icmp slt i64 %indvars.iv30, %23
  br i1 %.not20.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

24:                                               ; preds = %11, %39
  %indvars.iv = phi i64 [ 0, %11 ], [ %indvars.iv.next, %39 ]
  %25 = phi double [ %p1.promoted, %11 ], [ %42, %39 ]
  %26 = phi double [ %p2.promoted, %11 ], [ %41, %39 ]
  %27 = add nsw i64 %indvars.iv, %20
  %28 = icmp sgt i64 %27, 26
  %29 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %15, i64 %indvars.iv
  %30 = load double, ptr %29, align 8, !tbaa !9
  br i1 %28, label %31, label %35

31:                                               ; preds = %24
  %32 = fmul double %17, %30
  %33 = call double @llvm.fmuladd.f64(double %32, double %19, double %25)
  store double %33, ptr @p1, align 8, !tbaa !9
  %34 = call double @llvm.fmuladd.f64(double %17, double %30, double %26)
  store double %34, ptr @p2, align 8, !tbaa !9
  br label %39

35:                                               ; preds = %24
  %36 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %indvars.iv30, i64 %27
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = call double @llvm.fmuladd.f64(double %17, double %30, double %37)
  store double %38, ptr %36, align 8, !tbaa !9
  %.pre33 = load double, ptr %29, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %35, %31
  %40 = phi double [ %.pre33, %35 ], [ %30, %31 ]
  %41 = phi double [ %26, %35 ], [ %34, %31 ]
  %42 = phi double [ %25, %35 ], [ %33, %31 ]
  %43 = getelementptr inbounds [11 x [27 x double]], ptr @f, i64 0, i64 %indvars.iv30, i64 %indvars.iv
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = call double @llvm.fmuladd.f64(double %14, double %40, double %44)
  store double %45, ptr %43, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 27
  br i1 %exitcond.not, label %21, label %24, !llvm.loop !13

._crit_edge.thread:                               ; preds = %.lr.ph27, %._crit_edge
  %46 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %50

47:                                               ; preds = %._crit_edge
  %48 = fdiv double %42, %41
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %48)
  br label %50

50:                                               ; preds = %47, %._crit_edge.thread
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not = icmp eq i32 %51, -1
  br i1 %.not, label %._crit_edge28, label %.lr.ph27, !llvm.loop !14

._crit_edge28:                                    ; preds = %50, %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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

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

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

; 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 nounwind willreturn memory(argmem: write) }
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.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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