; LLVM IR from AnneLivia/Competitive-Programming :: Online Judges/URI/1985 (main)

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = 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 float, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store float 0.000000e+00, ptr %5, align 4, !tbaa !5
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %7

7:                                                ; preds = %50, %0
  %8 = load i32, ptr %2, align 4, !tbaa !9
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr %2, align 4, !tbaa !9
  %10 = icmp ne i32 %8, 0
  br i1 %10, label %11, label %51

11:                                               ; preds = %7
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %14 = load i32, ptr %3, align 4, !tbaa !9
  switch i32 %14, label %50 [
    i32 1001, label %15
    i32 1002, label %22
    i32 1003, label %29
    i32 1004, label %36
    i32 1005, label %43
  ]

15:                                               ; preds = %11
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sitofp i32 %16 to double
  %18 = load float, ptr %5, align 4, !tbaa !5
  %19 = fpext float %18 to double
  %20 = call double @llvm.fmuladd.f64(double 1.500000e+00, double %17, double %19)
  %21 = fptrunc double %20 to float
  store float %21, ptr %5, align 4, !tbaa !5
  br label %50

22:                                               ; preds = %11
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = sitofp i32 %23 to double
  %25 = load float, ptr %5, align 4, !tbaa !5
  %26 = fpext float %25 to double
  %27 = call double @llvm.fmuladd.f64(double 2.500000e+00, double %24, double %26)
  %28 = fptrunc double %27 to float
  store float %28, ptr %5, align 4, !tbaa !5
  br label %50

29:                                               ; preds = %11
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = sitofp i32 %30 to double
  %32 = load float, ptr %5, align 4, !tbaa !5
  %33 = fpext float %32 to double
  %34 = call double @llvm.fmuladd.f64(double 3.500000e+00, double %31, double %33)
  %35 = fptrunc double %34 to float
  store float %35, ptr %5, align 4, !tbaa !5
  br label %50

36:                                               ; preds = %11
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = sitofp i32 %37 to double
  %39 = load float, ptr %5, align 4, !tbaa !5
  %40 = fpext float %39 to double
  %41 = call double @llvm.fmuladd.f64(double 4.500000e+00, double %38, double %40)
  %42 = fptrunc double %41 to float
  store float %42, ptr %5, align 4, !tbaa !5
  br label %50

43:                                               ; preds = %11
  %44 = load i32, ptr %4, align 4, !tbaa !9
  %45 = sitofp i32 %44 to double
  %46 = load float, ptr %5, align 4, !tbaa !5
  %47 = fpext float %46 to double
  %48 = call double @llvm.fmuladd.f64(double 5.500000e+00, double %45, double %47)
  %49 = fptrunc double %48 to float
  store float %49, ptr %5, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %43, %36, %29, %22, %15, %11
  br label %7, !llvm.loop !11

51:                                               ; preds = %7
  %52 = load float, ptr %5, align 4, !tbaa !5
  %53 = fpext float %52 to double
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %53)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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) }
attributes #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr %1, align 4, !tbaa !5
  %.not6 = icmp eq i32 %5, 0
  br i1 %.not6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %40
  %.07 = phi float [ %.1, %40 ], [ 0.000000e+00, %0 ]
  %7 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %9 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %9, label %40 [
    i32 1001, label %10
    i32 1002, label %16
    i32 1003, label %22
    i32 1004, label %28
    i32 1005, label %34
  ]

10:                                               ; preds = %.lr.ph
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = sitofp i32 %11 to double
  %13 = fpext float %.07 to double
  %14 = call double @llvm.fmuladd.f64(double %12, double 1.500000e+00, double %13)
  %15 = fptrunc double %14 to float
  br label %40

16:                                               ; preds = %.lr.ph
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sitofp i32 %17 to double
  %19 = fpext float %.07 to double
  %20 = call double @llvm.fmuladd.f64(double %18, double 2.500000e+00, double %19)
  %21 = fptrunc double %20 to float
  br label %40

22:                                               ; preds = %.lr.ph
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = fpext float %.07 to double
  %26 = call double @llvm.fmuladd.f64(double %24, double 3.500000e+00, double %25)
  %27 = fptrunc double %26 to float
  br label %40

28:                                               ; preds = %.lr.ph
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sitofp i32 %29 to double
  %31 = fpext float %.07 to double
  %32 = call double @llvm.fmuladd.f64(double %30, double 4.500000e+00, double %31)
  %33 = fptrunc double %32 to float
  br label %40

34:                                               ; preds = %.lr.ph
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sitofp i32 %35 to double
  %37 = fpext float %.07 to double
  %38 = call double @llvm.fmuladd.f64(double %36, double 5.500000e+00, double %37)
  %39 = fptrunc double %38 to float
  br label %40

40:                                               ; preds = %34, %28, %22, %16, %10, %.lr.ph
  %.1 = phi float [ %.07, %.lr.ph ], [ %39, %34 ], [ %33, %28 ], [ %27, %22 ], [ %21, %16 ], [ %15, %10 ]
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = add nsw i32 %41, -1
  store i32 %42, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %41, 0
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %40
  %43 = fpext float %.1 to double
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.0.lcssa = phi double [ 0.000000e+00, %0 ], [ %43, %._crit_edge.loopexit ]
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %.0.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

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 #2

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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" }
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"}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass