; LLVM IR from tangjz/acm-icpc :: uvalive (6135)

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

@K = external dso_local global i32, align 4
@W = external dso_local global double, align 8
@D = external dso_local global double, align 8
@A = external dso_local global double, align 8
@p = external dso_local global [10 x [2 x double]], align 16
@q = external dso_local global [10 x [2 x double]], align 16
@L = external dso_local global double, align 8
@R = external dso_local global double, align 8
@M = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z7simpsondd(double noundef, double noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z3asrdddd(double noundef, double noundef, double noundef, double noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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
  store i32 0, ptr %1, align 4
  br label %6

6:                                                ; preds = %95, %0
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @W, ptr noundef @D, ptr noundef @A, ptr noundef @K)
  %8 = icmp eq i32 %7, 4
  br i1 %8, label %9, label %99

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

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

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %24

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [10 x [2 x double]], ptr @p, i64 0, i64 %17
  %19 = getelementptr inbounds [2 x double], ptr %18, i64 0, i64 0
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %19)
  br label %21

21:                                               ; preds = %15
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !9

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

25:                                               ; preds = %36, %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr @K, align 4, !tbaa !5
  %28 = icmp sle i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %39

30:                                               ; preds = %25
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10 x [2 x double]], ptr @p, i64 0, i64 %32
  %34 = getelementptr inbounds [2 x double], ptr %33, i64 0, i64 1
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %34)
  br label %36

36:                                               ; preds = %30
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %25, !llvm.loop !11

39:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %51, %39
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = load i32, ptr @K, align 4, !tbaa !5
  %43 = icmp sle i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %54

45:                                               ; preds = %40
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10 x [2 x double]], ptr @q, i64 0, i64 %47
  %49 = getelementptr inbounds [2 x double], ptr %48, i64 0, i64 0
  %50 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %49)
  br label %51

51:                                               ; preds = %45
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %4, align 4, !tbaa !5
  br label %40, !llvm.loop !12

54:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %66, %54
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = load i32, ptr @K, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %69

60:                                               ; preds = %55
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [10 x [2 x double]], ptr @q, i64 0, i64 %62
  %64 = getelementptr inbounds [2 x double], ptr %63, i64 0, i64 1
  %65 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %64)
  br label %66

66:                                               ; preds = %60
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %5, align 4, !tbaa !5
  br label %55, !llvm.loop !13

69:                                               ; preds = %59
  %70 = load double, ptr @D, align 8, !tbaa !14
  %71 = fneg double %70
  store double %71, ptr @L, align 8, !tbaa !14
  store double 0.000000e+00, ptr @R, align 8, !tbaa !14
  br label %72

72:                                               ; preds = %94, %69
  %73 = load double, ptr @R, align 8, !tbaa !14
  %74 = load double, ptr @L, align 8, !tbaa !14
  %75 = fsub double %73, %74
  %76 = fcmp oge double %75, 1.000000e-08
  br i1 %76, label %77, label %95

77:                                               ; preds = %72
  %78 = load double, ptr @L, align 8, !tbaa !14
  %79 = load double, ptr @R, align 8, !tbaa !14
  %80 = load double, ptr @L, align 8, !tbaa !14
  %81 = fsub double %79, %80
  %82 = fdiv double %81, 2.000000e+00
  %83 = fadd double %78, %82
  store double %83, ptr @M, align 8, !tbaa !14
  %84 = load double, ptr @W, align 8, !tbaa !14
  %85 = load double, ptr @W, align 8, !tbaa !14
  %86 = call noundef double @_Z7simpsondd(double noundef 0.000000e+00, double noundef %85)
  %87 = call noundef double @_Z3asrdddd(double noundef 0.000000e+00, double noundef %84, double noundef 1.000000e-05, double noundef %86)
  %88 = load double, ptr @A, align 8, !tbaa !14
  %89 = fcmp olt double %87, %88
  br i1 %89, label %90, label %92

90:                                               ; preds = %77
  %91 = load double, ptr @M, align 8, !tbaa !14
  store double %91, ptr @R, align 8, !tbaa !14
  br label %94

92:                                               ; preds = %77
  %93 = load double, ptr @M, align 8, !tbaa !14
  store double %93, ptr @L, align 8, !tbaa !14
  br label %94

94:                                               ; preds = %92, %90
  br label %72, !llvm.loop !16

95:                                               ; preds = %72
  %96 = load double, ptr @L, align 8, !tbaa !14
  %97 = fneg double %96
  %98 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %97)
  br label %6, !llvm.loop !17

99:                                               ; preds = %6
  ret i32 0
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { "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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !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"

@K = external dso_local global i32, align 4
@W = external dso_local global double, align 8
@D = external dso_local global double, align 8
@A = external dso_local global double, align 8
@p = external dso_local global [10 x [2 x double]], align 16
@q = external dso_local global [10 x [2 x double]], align 16
@L = external dso_local local_unnamed_addr global double, align 8
@R = external dso_local local_unnamed_addr global double, align 8
@M = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z7simpsondd(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z3asrdddd(double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @W, ptr noundef nonnull @D, ptr noundef nonnull @A, ptr noundef nonnull @K)
  %2 = icmp eq i32 %1, 4
  br i1 %2, label %.preheader21, label %._crit_edge36

.preheader21:                                     ; preds = %0, %._crit_edge35
  %3 = load i32, ptr @K, align 4, !tbaa !5
  %.not22 = icmp slt i32 %3, 0
  br i1 %.not22, label %._crit_edge, label %.lr.ph

.preheader20:                                     ; preds = %.lr.ph
  %.not1624 = icmp slt i32 %6, 0
  br i1 %.not1624, label %._crit_edge, label %.lr.ph26

.lr.ph:                                           ; preds = %.preheader21, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader21 ]
  %4 = getelementptr inbounds [10 x [2 x double]], ptr @p, i64 0, i64 %indvars.iv
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %4)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %6 = load i32, ptr @K, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %.not.not = icmp slt i64 %indvars.iv, %7
  br i1 %.not.not, label %.lr.ph, label %.preheader20, !llvm.loop !9

.preheader19:                                     ; preds = %.lr.ph26
  %.not1727 = icmp slt i32 %10, 0
  br i1 %.not1727, label %._crit_edge, label %.lr.ph29

.lr.ph26:                                         ; preds = %.preheader20, %.lr.ph26
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph26 ], [ 0, %.preheader20 ]
  %8 = getelementptr inbounds [10 x [2 x double]], ptr @p, i64 0, i64 %indvars.iv39, i64 1
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %8)
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %10 = load i32, ptr @K, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %.not16.not = icmp slt i64 %indvars.iv39, %11
  br i1 %.not16.not, label %.lr.ph26, label %.preheader19, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph29
  %.not1830 = icmp slt i32 %14, 0
  br i1 %.not1830, label %._crit_edge, label %.lr.ph32

.lr.ph29:                                         ; preds = %.preheader19, %.lr.ph29
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %.lr.ph29 ], [ 0, %.preheader19 ]
  %12 = getelementptr inbounds [10 x [2 x double]], ptr @q, i64 0, i64 %indvars.iv42
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %12)
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %14 = load i32, ptr @K, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %.not17.not = icmp slt i64 %indvars.iv42, %15
  br i1 %.not17.not, label %.lr.ph29, label %.preheader, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph32, %.preheader21, %.preheader20, %.preheader19, %.preheader
  %16 = load double, ptr @D, align 8, !tbaa !13
  %17 = fneg double %16
  store double %17, ptr @L, align 8, !tbaa !13
  store double 0.000000e+00, ptr @R, align 8, !tbaa !13
  %18 = fcmp ult double %16, 1.000000e-08
  br i1 %18, label %._crit_edge35, label %.lr.ph34

.lr.ph32:                                         ; preds = %.preheader, %.lr.ph32
  %indvars.iv45 = phi i64 [ %indvars.iv.next46, %.lr.ph32 ], [ 0, %.preheader ]
  %19 = getelementptr inbounds [10 x [2 x double]], ptr @q, i64 0, i64 %indvars.iv45, i64 1
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19)
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %21 = load i32, ptr @K, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %.not18.not = icmp slt i64 %indvars.iv45, %22
  br i1 %.not18.not, label %.lr.ph32, label %._crit_edge, !llvm.loop !15

.lr.ph34:                                         ; preds = %._crit_edge, %35
  %23 = phi double [ %38, %35 ], [ %16, %._crit_edge ]
  %24 = phi double [ %36, %35 ], [ %17, %._crit_edge ]
  %25 = fmul double %23, 5.000000e-01
  %26 = fadd double %24, %25
  store double %26, ptr @M, align 8, !tbaa !13
  %27 = load double, ptr @W, align 8, !tbaa !13
  %28 = tail call noundef double @_Z7simpsondd(double noundef 0.000000e+00, double noundef %27)
  %29 = tail call noundef double @_Z3asrdddd(double noundef 0.000000e+00, double noundef %27, double noundef 1.000000e-05, double noundef %28)
  %30 = load double, ptr @A, align 8, !tbaa !13
  %31 = fcmp olt double %29, %30
  %32 = load double, ptr @M, align 8, !tbaa !13
  br i1 %31, label %33, label %34

33:                                               ; preds = %.lr.ph34
  store double %32, ptr @R, align 8, !tbaa !13
  %.pre48 = load double, ptr @L, align 8, !tbaa !13
  br label %35

34:                                               ; preds = %.lr.ph34
  store double %32, ptr @L, align 8, !tbaa !13
  %.pre = load double, ptr @R, align 8, !tbaa !13
  br label %35

35:                                               ; preds = %34, %33
  %36 = phi double [ %32, %34 ], [ %.pre48, %33 ]
  %37 = phi double [ %.pre, %34 ], [ %32, %33 ]
  %38 = fsub double %37, %36
  %39 = fcmp ult double %38, 1.000000e-08
  br i1 %39, label %._crit_edge35, label %.lr.ph34, !llvm.loop !16

._crit_edge35:                                    ; preds = %35, %._crit_edge
  %.lcssa = phi double [ %17, %._crit_edge ], [ %36, %35 ]
  %40 = fneg double %.lcssa
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %40)
  %42 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @W, ptr noundef nonnull @D, ptr noundef nonnull @A, ptr noundef nonnull @K)
  %43 = icmp eq i32 %42, 4
  br i1 %43, label %.preheader21, label %._crit_edge36, !llvm.loop !17

._crit_edge36:                                    ; preds = %._crit_edge35, %0
  ret i32 0
}

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

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

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 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 = { 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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