; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/LONG/JULY15/NTHCIR (A)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@t = external dso_local global i32, align 4
@r1 = external dso_local global x86_fp80, align 16
@r2 = external dso_local global x86_fp80, align 16
@r3 = external dso_local global x86_fp80, align 16
@r4 = external dso_local global x86_fp80, align 16
@n0 = external dso_local global i64, align 8
@p = external dso_local global i64, align 8
@m = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@tmp = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@ans = external dso_local global x86_fp80, align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = 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 x86_fp80, align 16
  %3 = alloca x86_fp80, align 16
  %4 = alloca x86_fp80, align 16
  %5 = alloca x86_fp80, align 16
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @t)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n0)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) @p)
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(8) @m)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(8) @b)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 16 dereferenceable(16) @r1)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 16 dereferenceable(16) @r2)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 16 dereferenceable(16) @r3)
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 16 dereferenceable(16) @r4)
  %19 = load i64, ptr @n0, align 8, !tbaa !5
  store i64 %19, ptr @tmp, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #5
  %20 = load x86_fp80, ptr @r1, align 16, !tbaa !9
  %21 = fdiv x86_fp80 0xKBFFF8000000000000000, %20
  store x86_fp80 %21, ptr %3, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #5
  %22 = load x86_fp80, ptr @r2, align 16, !tbaa !9
  %23 = fdiv x86_fp80 0xK3FFF8000000000000000, %22
  store x86_fp80 %23, ptr %4, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #5
  %24 = load x86_fp80, ptr @r3, align 16, !tbaa !9
  %25 = fdiv x86_fp80 0xK3FFF8000000000000000, %24
  store x86_fp80 %25, ptr %5, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  %26 = load x86_fp80, ptr @r4, align 16, !tbaa !9
  %27 = fdiv x86_fp80 0xK3FFF8000000000000000, %26
  store x86_fp80 %27, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %28 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %29 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %30 = fadd x86_fp80 %28, %29
  store x86_fp80 %30, ptr %8, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %67, %0
  %32 = load i32, ptr %9, align 4, !tbaa !11
  %33 = load i32, ptr @t, align 4, !tbaa !11
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %70

36:                                               ; preds = %31
  %37 = load i64, ptr @n0, align 8, !tbaa !5
  %38 = load i64, ptr @p, align 8, !tbaa !5
  %39 = mul nsw i64 %37, %38
  %40 = load i64, ptr @m, align 8, !tbaa !5
  %41 = srem i64 %39, %40
  %42 = load i64, ptr @b, align 8, !tbaa !5
  %43 = add nsw i64 %41, %42
  store i64 %43, ptr @n0, align 8, !tbaa !5
  %44 = load i64, ptr @n0, align 8, !tbaa !5
  %45 = sub nsw i64 %44, 4
  store i64 %45, ptr @n, align 8, !tbaa !5
  %46 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %47 = load i64, ptr @n, align 8, !tbaa !5
  %48 = sitofp i64 %47 to x86_fp80
  %49 = fmul x86_fp80 %46, %48
  %50 = load i64, ptr @n, align 8, !tbaa !5
  %51 = add nsw i64 %50, 1
  %52 = sitofp i64 %51 to x86_fp80
  %53 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %54 = load i64, ptr @n, align 8, !tbaa !5
  %55 = sitofp i64 %54 to x86_fp80
  %56 = fmul x86_fp80 %53, %55
  %57 = fneg x86_fp80 %56
  %58 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %49, x86_fp80 %52, x86_fp80 %57)
  %59 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %60 = load i64, ptr @n, align 8, !tbaa !5
  %61 = add nsw i64 %60, 1
  %62 = sitofp i64 %61 to x86_fp80
  %63 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %59, x86_fp80 %62, x86_fp80 %58)
  %64 = fdiv x86_fp80 0xK3FFF8000000000000000, %63
  %65 = load x86_fp80, ptr @ans, align 16, !tbaa !9
  %66 = fadd x86_fp80 %65, %64
  store x86_fp80 %66, ptr @ans, align 16, !tbaa !9
  br label %67

67:                                               ; preds = %36
  %68 = load i32, ptr %9, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %9, align 4, !tbaa !11
  br label %31, !llvm.loop !13

70:                                               ; preds = %35
  %71 = load x86_fp80, ptr @ans, align 16, !tbaa !9
  %72 = fptrunc x86_fp80 %71 to double
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %72)
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #5
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) #2 align 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 x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #4

; 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 = { 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 = { 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 = !{!"long long", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@t = external dso_local global i32, align 4
@r1 = external dso_local global x86_fp80, align 16
@r2 = external dso_local global x86_fp80, align 16
@r3 = external dso_local global x86_fp80, align 16
@r4 = external dso_local global x86_fp80, align 16
@n0 = external dso_local global i64, align 8
@p = external dso_local global i64, align 8
@m = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@tmp = external dso_local local_unnamed_addr global i64, align 8
@n = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global x86_fp80, align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @t)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n0)
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) @p)
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) @m)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(8) @b)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 16 dereferenceable(16) @r1)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 16 dereferenceable(16) @r2)
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 16 dereferenceable(16) @r3)
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 16 dereferenceable(16) @r4)
  %10 = load i64, ptr @n0, align 8, !tbaa !5
  store i64 %10, ptr @tmp, align 8, !tbaa !5
  %11 = load x86_fp80, ptr @r1, align 16, !tbaa !9
  %12 = fdiv x86_fp80 0xK3FFF8000000000000000, %11
  %13 = load x86_fp80, ptr @r2, align 16, !tbaa !9
  %14 = fdiv x86_fp80 0xK3FFF8000000000000000, %13
  %15 = load x86_fp80, ptr @r4, align 16, !tbaa !9
  %16 = fdiv x86_fp80 0xK3FFF8000000000000000, %15
  %17 = fsub x86_fp80 %14, %12
  %18 = load i32, ptr @t, align 4, !tbaa !11
  %.not10 = icmp slt i32 %18, 1
  %.pre = load x86_fp80, ptr @ans, align 16, !tbaa !9
  br i1 %.not10, label %._crit_edge16, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %19 = load x86_fp80, ptr @r3, align 16, !tbaa !9
  %20 = load i64, ptr @p, align 8, !tbaa !5
  %21 = load i64, ptr @m, align 8, !tbaa !5
  %22 = load i64, ptr @b, align 8, !tbaa !5
  %23 = fdiv x86_fp80 0xKBFFF8000000000000000, %19
  br label %27

._crit_edge:                                      ; preds = %27
  store i64 %32, ptr @n0, align 8, !tbaa !5
  store i64 %33, ptr @n, align 8, !tbaa !5
  store x86_fp80 %42, ptr @ans, align 16, !tbaa !9
  br label %._crit_edge16

._crit_edge16:                                    ; preds = %0, %._crit_edge
  %24 = phi x86_fp80 [ %42, %._crit_edge ], [ %.pre, %0 ]
  %25 = fptrunc x86_fp80 %24 to double
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %25)
  ret i32 0

27:                                               ; preds = %.lr.ph, %27
  %.011 = phi i32 [ 1, %.lr.ph ], [ %43, %27 ]
  %28 = phi i64 [ %10, %.lr.ph ], [ %32, %27 ]
  %29 = phi x86_fp80 [ %.pre, %.lr.ph ], [ %42, %27 ]
  %30 = mul nsw i64 %20, %28
  %31 = srem i64 %30, %21
  %32 = add nsw i64 %22, %31
  %33 = add nsw i64 %32, -4
  %34 = sitofp i64 %33 to x86_fp80
  %35 = fmul x86_fp80 %17, %34
  %36 = add nsw i64 %32, -3
  %37 = sitofp i64 %36 to x86_fp80
  %38 = fmul x86_fp80 %23, %34
  %39 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %35, x86_fp80 %37, x86_fp80 %38)
  %40 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %16, x86_fp80 %37, x86_fp80 %39)
  %41 = fdiv x86_fp80 0xK3FFF8000000000000000, %40
  %42 = fadd x86_fp80 %29, %41
  %43 = add nuw i32 %.011, 1
  %exitcond.not = icmp eq i32 %.011, %18
  br i1 %exitcond.not, label %._crit_edge, label %27, !llvm.loop !13
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #2 align 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 #4

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 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"long long", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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