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

; 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
@p = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@f1 = external dso_local global i32, align 4
@f2 = external dso_local global i32, align 4
@E1 = external dso_local global x86_fp80, align 16
@E2 = external dso_local global x86_fp80, align 16
@E3 = external dso_local global x86_fp80, align 16
@E4 = external dso_local global x86_fp80, align 16
@x = external dso_local global x86_fp80, align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_Z3powei(x86_fp80 noundef, i32 noundef) #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 = %76, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @p, ptr noundef @k, ptr noundef @f1, ptr noundef @f2)
  %4 = icmp eq i32 %3, 5
  br i1 %4, label %5, label %80

5:                                                ; preds = %2
  %6 = load i32, ptr @p, align 4, !tbaa !5
  %7 = load i32, ptr @f1, align 4, !tbaa !5
  %8 = icmp sge i32 %6, %7
  br i1 %8, label %9, label %18

9:                                                ; preds = %5
  %10 = load i32, ptr @p, align 4, !tbaa !5
  %11 = load i32, ptr @f1, align 4, !tbaa !5
  %12 = sub nsw i32 %10, %11
  %13 = sitofp i32 %12 to double
  %14 = fadd double %13, 1.000000e+00
  %15 = load i32, ptr @p, align 4, !tbaa !5
  %16 = sitofp i32 %15 to double
  %17 = fdiv double %14, %16
  br label %19

18:                                               ; preds = %5
  br label %19

19:                                               ; preds = %18, %9
  %20 = phi double [ %17, %9 ], [ 0.000000e+00, %18 ]
  %21 = fpext double %20 to x86_fp80
  store x86_fp80 %21, ptr @E1, align 16, !tbaa !9
  %22 = load i32, ptr @p, align 4, !tbaa !5
  %23 = load i32, ptr @f2, align 4, !tbaa !5
  %24 = icmp sge i32 %22, %23
  br i1 %24, label %25, label %34

25:                                               ; preds = %19
  %26 = load i32, ptr @p, align 4, !tbaa !5
  %27 = load i32, ptr @f2, align 4, !tbaa !5
  %28 = sub nsw i32 %26, %27
  %29 = sitofp i32 %28 to double
  %30 = fadd double %29, 1.000000e+00
  %31 = load i32, ptr @p, align 4, !tbaa !5
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %30, %32
  br label %35

34:                                               ; preds = %19
  br label %35

35:                                               ; preds = %34, %25
  %36 = phi double [ %33, %25 ], [ 0.000000e+00, %34 ]
  %37 = fpext double %36 to x86_fp80
  store x86_fp80 %37, ptr @E2, align 16, !tbaa !9
  %38 = load x86_fp80, ptr @E1, align 16, !tbaa !9
  %39 = load x86_fp80, ptr @E2, align 16, !tbaa !9
  %40 = fsub x86_fp80 %38, %39
  store x86_fp80 %40, ptr @E3, align 16, !tbaa !9
  %41 = load x86_fp80, ptr @E2, align 16, !tbaa !9
  %42 = fsub x86_fp80 0xK3FFF8000000000000000, %41
  store x86_fp80 %42, ptr @E4, align 16, !tbaa !9
  %43 = load x86_fp80, ptr @E1, align 16, !tbaa !9
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = call noundef x86_fp80 @_Z3powei(x86_fp80 noundef %43, i32 noundef %44)
  store x86_fp80 %45, ptr @x, align 16, !tbaa !9
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = load i32, ptr @k, align 4, !tbaa !5
  %48 = icmp sgt i32 %46, %47
  br i1 %48, label %49, label %76

49:                                               ; preds = %35
  %50 = load x86_fp80, ptr @E2, align 16, !tbaa !9
  %51 = load i32, ptr @k, align 4, !tbaa !5
  %52 = call noundef x86_fp80 @_Z3powei(x86_fp80 noundef %50, i32 noundef %51)
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = load i32, ptr @k, align 4, !tbaa !5
  %55 = sub nsw i32 %53, %54
  %56 = sitofp i32 %55 to x86_fp80
  %57 = load x86_fp80, ptr @E4, align 16, !tbaa !9
  %58 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %56, x86_fp80 %57, x86_fp80 0xK3FFF8000000000000000)
  %59 = load x86_fp80, ptr @E1, align 16, !tbaa !9
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = load i32, ptr @k, align 4, !tbaa !5
  %62 = sub nsw i32 %60, %61
  %63 = sub nsw i32 %62, 1
  %64 = call noundef x86_fp80 @_Z3powei(x86_fp80 noundef %59, i32 noundef %63)
  %65 = load i32, ptr @n, align 4, !tbaa !5
  %66 = load i32, ptr @k, align 4, !tbaa !5
  %67 = sub nsw i32 %65, %66
  %68 = sitofp i32 %67 to x86_fp80
  %69 = load x86_fp80, ptr @E3, align 16, !tbaa !9
  %70 = load x86_fp80, ptr @E1, align 16, !tbaa !9
  %71 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %68, x86_fp80 %69, x86_fp80 %70)
  %72 = fneg x86_fp80 %64
  %73 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %72, x86_fp80 %71, x86_fp80 %58)
  %74 = load x86_fp80, ptr @x, align 16, !tbaa !9
  %75 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %52, x86_fp80 %73, x86_fp80 %74)
  store x86_fp80 %75, ptr @x, align 16, !tbaa !9
  br label %76

76:                                               ; preds = %49, %35
  %77 = load x86_fp80, ptr @x, align 16, !tbaa !9
  %78 = fptrunc x86_fp80 %77 to double
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %78)
  br label %2, !llvm.loop !11

80:                                               ; preds = %2
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

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 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 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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
@p = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@f1 = external dso_local global i32, align 4
@f2 = external dso_local global i32, align 4
@E1 = external dso_local local_unnamed_addr global x86_fp80, align 16
@E2 = external dso_local local_unnamed_addr global x86_fp80, align 16
@E3 = external dso_local local_unnamed_addr global x86_fp80, align 16
@E4 = external dso_local local_unnamed_addr global x86_fp80, align 16
@x = external dso_local local_unnamed_addr global x86_fp80, align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_Z3powei(x86_fp80 noundef, i32 noundef) 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 @n, ptr noundef nonnull @p, ptr noundef nonnull @k, ptr noundef nonnull @f1, ptr noundef nonnull @f2)
  %2 = icmp eq i32 %1, 5
  br i1 %2, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %54
  %3 = load i32, ptr @p, align 4, !tbaa !5
  %4 = load i32, ptr @f1, align 4, !tbaa !5
  %.not = icmp slt i32 %3, %4
  br i1 %.not, label %11, label %5

5:                                                ; preds = %.lr.ph
  %6 = sub nsw i32 %3, %4
  %7 = sitofp i32 %6 to double
  %8 = fadd double %7, 1.000000e+00
  %9 = sitofp i32 %3 to double
  %10 = fdiv double %8, %9
  br label %11

11:                                               ; preds = %.lr.ph, %5
  %12 = phi double [ %10, %5 ], [ 0.000000e+00, %.lr.ph ]
  %13 = fpext double %12 to x86_fp80
  store x86_fp80 %13, ptr @E1, align 16, !tbaa !9
  %14 = load i32, ptr @f2, align 4, !tbaa !5
  %.not5 = icmp slt i32 %3, %14
  br i1 %.not5, label %21, label %15

15:                                               ; preds = %11
  %16 = sub nsw i32 %3, %14
  %17 = sitofp i32 %16 to double
  %18 = fadd double %17, 1.000000e+00
  %19 = sitofp i32 %3 to double
  %20 = fdiv double %18, %19
  br label %21

21:                                               ; preds = %11, %15
  %22 = phi double [ %20, %15 ], [ 0.000000e+00, %11 ]
  %23 = fpext double %22 to x86_fp80
  store x86_fp80 %23, ptr @E2, align 16, !tbaa !9
  %24 = fsub x86_fp80 %13, %23
  store x86_fp80 %24, ptr @E3, align 16, !tbaa !9
  %25 = fsub x86_fp80 0xK3FFF8000000000000000, %23
  store x86_fp80 %25, ptr @E4, align 16, !tbaa !9
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = tail call noundef x86_fp80 @_Z3powei(x86_fp80 noundef %13, i32 noundef %26)
  store x86_fp80 %27, ptr @x, align 16, !tbaa !9
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = load i32, ptr @k, align 4, !tbaa !5
  %30 = icmp sgt i32 %28, %29
  br i1 %30, label %31, label %54

31:                                               ; preds = %21
  %32 = load x86_fp80, ptr @E2, align 16, !tbaa !9
  %33 = tail call noundef x86_fp80 @_Z3powei(x86_fp80 noundef %32, i32 noundef %29)
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = load i32, ptr @k, align 4, !tbaa !5
  %36 = sub nsw i32 %34, %35
  %37 = sitofp i32 %36 to x86_fp80
  %38 = load x86_fp80, ptr @E4, align 16, !tbaa !9
  %39 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %37, x86_fp80 %38, x86_fp80 0xK3FFF8000000000000000)
  %40 = load x86_fp80, ptr @E1, align 16, !tbaa !9
  %41 = add nsw i32 %36, -1
  %42 = tail call noundef x86_fp80 @_Z3powei(x86_fp80 noundef %40, i32 noundef %41)
  %43 = load i32, ptr @n, align 4, !tbaa !5
  %44 = load i32, ptr @k, align 4, !tbaa !5
  %45 = sub nsw i32 %43, %44
  %46 = sitofp i32 %45 to x86_fp80
  %47 = load x86_fp80, ptr @E3, align 16, !tbaa !9
  %48 = load x86_fp80, ptr @E1, align 16, !tbaa !9
  %49 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %46, x86_fp80 %47, x86_fp80 %48)
  %50 = fneg x86_fp80 %42
  %51 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %50, x86_fp80 %49, x86_fp80 %39)
  %52 = load x86_fp80, ptr @x, align 16, !tbaa !9
  %53 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %33, x86_fp80 %51, x86_fp80 %52)
  store x86_fp80 %53, ptr @x, align 16, !tbaa !9
  br label %54

54:                                               ; preds = %31, %21
  %55 = phi x86_fp80 [ %53, %31 ], [ %27, %21 ]
  %56 = fptrunc x86_fp80 %55 to double
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %56)
  %58 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @p, ptr noundef nonnull @k, ptr noundef nonnull @f1, ptr noundef nonnull @f2)
  %59 = icmp eq i32 %58, 5
  br i1 %59, label %.lr.ph, label %._crit_edge, !llvm.loop !11

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

; 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 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 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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