; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (1006（模拟）)

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

@D = external dso_local global double, align 8
@H = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@S = external dso_local global double, align 8
@Total = external dso_local global double, align 8
@signal = external dso_local global i32, align 4
@maximum = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [4 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
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8get_nextv() #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %2

2:                                                ; preds = %33, %18, %13, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @D)
  %4 = icmp ne i32 %3, 0
  br i1 %4, label %5, label %8

5:                                                ; preds = %2
  %6 = load double, ptr @D, align 8, !tbaa !5
  %7 = fcmp une double %6, -1.000000e+00
  br label %8

8:                                                ; preds = %5, %2
  %9 = phi i1 [ false, %2 ], [ %7, %5 ]
  br i1 %9, label %10, label %37

10:                                               ; preds = %8
  %11 = load double, ptr @D, align 8, !tbaa !5
  %12 = fcmp oeq double %11, 0.000000e+00
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %2, !llvm.loop !9

15:                                               ; preds = %10
  %16 = load double, ptr @D, align 8, !tbaa !5
  %17 = fcmp oge double %16, 1.200000e+02
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %2, !llvm.loop !9

20:                                               ; preds = %15
  store i32 0, ptr @M, align 4, !tbaa !11
  store i32 0, ptr @H, align 4, !tbaa !11
  store double 0.000000e+00, ptr @S, align 8, !tbaa !5
  store double 0.000000e+00, ptr @Total, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %32, %20
  call void @_Z8get_nextv()
  %22 = load i32, ptr @H, align 4, !tbaa !11
  %23 = icmp sge i32 %22, 12
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %33

25:                                               ; preds = %21
  %26 = load i32, ptr @signal, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = load double, ptr @maximum, align 8, !tbaa !5
  %30 = load double, ptr @Total, align 8, !tbaa !5
  %31 = fadd double %30, %29
  store double %31, ptr @Total, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %28, %25
  br label %21, !llvm.loop !13

33:                                               ; preds = %24
  %34 = load double, ptr @Total, align 8, !tbaa !5
  %35 = fdiv double %34, 4.320000e+02
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %35)
  br label %2, !llvm.loop !9

37:                                               ; preds = %8
  %38 = load i32, ptr %1, align 4
  ret i32 %38
}

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

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

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}


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

@D = external dso_local global double, align 8
@H = external dso_local local_unnamed_addr global i32, align 4
@M = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local local_unnamed_addr global double, align 8
@Total = external dso_local local_unnamed_addr global double, align 8
@signal = external dso_local local_unnamed_addr global i32, align 4
@maximum = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [4 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
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8get_nextv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind 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 @D)
  %2 = icmp ne i32 %1, 0
  %3 = load double, ptr @D, align 8
  %4 = fcmp une double %3, -1.000000e+00
  %5 = select i1 %2, i1 %4, i1 false
  br i1 %5, label %.lr.ph2, label %._crit_edge3

.lr.ph2:                                          ; preds = %0, %.backedge
  %6 = phi double [ %12, %.backedge ], [ %3, %0 ]
  %7 = fcmp oeq double %6, 0.000000e+00
  br i1 %7, label %8, label %15

8:                                                ; preds = %.lr.ph2
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.backedge

.backedge:                                        ; preds = %8, %17, %._crit_edge
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @D)
  %11 = icmp ne i32 %10, 0
  %12 = load double, ptr @D, align 8
  %13 = fcmp une double %12, -1.000000e+00
  %14 = select i1 %11, i1 %13, i1 false
  br i1 %14, label %.lr.ph2, label %._crit_edge3, !llvm.loop !5

15:                                               ; preds = %.lr.ph2
  %16 = fcmp ult double %6, 1.200000e+02
  br i1 %16, label %19, label %17

17:                                               ; preds = %15
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.backedge

19:                                               ; preds = %15
  store i32 0, ptr @M, align 4, !tbaa !7
  store i32 0, ptr @H, align 4, !tbaa !7
  store double 0.000000e+00, ptr @S, align 8, !tbaa !11
  store double 0.000000e+00, ptr @Total, align 8, !tbaa !11
  tail call void @_Z8get_nextv()
  %20 = load i32, ptr @H, align 4, !tbaa !7
  %21 = icmp sgt i32 %20, 11
  br i1 %21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %19, %27
  %22 = load i32, ptr @signal, align 4, !tbaa !7
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %27, label %23

23:                                               ; preds = %.lr.ph
  %24 = load double, ptr @maximum, align 8, !tbaa !11
  %25 = load double, ptr @Total, align 8, !tbaa !11
  %26 = fadd double %24, %25
  store double %26, ptr @Total, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %23, %.lr.ph
  tail call void @_Z8get_nextv()
  %28 = load i32, ptr @H, align 4, !tbaa !7
  %29 = icmp sgt i32 %28, 11
  br i1 %29, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %27, %19
  %30 = load double, ptr @Total, align 8, !tbaa !11
  %31 = fdiv double %30, 4.320000e+02
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %31)
  br label %.backedge

._crit_edge3:                                     ; preds = %.backedge, %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 @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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = distinct !{!13, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass