; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 2/1139. City Blocks (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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %13 = load double, ptr %2, align 8, !tbaa !5
  %14 = fadd double %13, -1.000000e+00
  store double %14, ptr %2, align 8, !tbaa !5
  %15 = load double, ptr %3, align 8, !tbaa !5
  %16 = fadd double %15, -1.000000e+00
  store double %16, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %17 = load double, ptr %3, align 8, !tbaa !5
  %18 = load double, ptr %2, align 8, !tbaa !5
  %19 = fdiv double %17, %18
  store double %19, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %69, %0
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = sitofp i32 %21 to double
  %23 = load double, ptr %2, align 8, !tbaa !5
  %24 = fcmp olt double %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %72

26:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  store i8 0, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %27 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %27, ptr %10, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %64, %26
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sitofp i32 %29 to double
  %31 = load double, ptr %3, align 8, !tbaa !5
  %32 = fcmp olt double %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  store i32 5, ptr %8, align 4
  br label %67

34:                                               ; preds = %28
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  %37 = sitofp i32 %36 to double
  %38 = load double, ptr %4, align 8, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = sitofp i32 %39 to double
  %41 = fmul double %38, %40
  %42 = fcmp ogt double %37, %41
  br i1 %42, label %43, label %55

43:                                               ; preds = %34
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = sitofp i32 %44 to double
  %46 = load double, ptr %4, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  %49 = sitofp i32 %48 to double
  %50 = fmul double %46, %49
  %51 = fcmp olt double %45, %50
  br i1 %51, label %52, label %55

52:                                               ; preds = %43
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !9
  store i8 1, ptr %9, align 1, !tbaa !11
  br label %63

55:                                               ; preds = %43, %34
  %56 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %57 = trunc i8 %56 to i1
  br i1 %57, label %61, label %58

58:                                               ; preds = %55
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %6, align 4, !tbaa !9
  br label %62

61:                                               ; preds = %55
  store i32 5, ptr %8, align 4
  br label %67

62:                                               ; preds = %58
  br label %63

63:                                               ; preds = %62, %52
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %10, align 4, !tbaa !9
  br label %28, !llvm.loop !15

67:                                               ; preds = %61, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %68

68:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !9
  br label %20, !llvm.loop !17

72:                                               ; preds = %25
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %73)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %75 = load i32, ptr %1, align 4
  ret i32 %75
}

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

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


; 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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %5 = load double, ptr %1, align 8, !tbaa !5
  %6 = fadd double %5, -1.000000e+00
  store double %6, ptr %1, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = fadd double %7, -1.000000e+00
  store double %8, ptr %2, align 8, !tbaa !5
  %9 = fdiv double %8, %6
  %10 = fcmp ogt double %6, 0.000000e+00
  br i1 %10, label %.preheader, label %._crit_edge35

.preheader:                                       ; preds = %0, %._crit_edge
  %11 = phi double [ %.pre-phi38, %._crit_edge ], [ 0.000000e+00, %0 ]
  %.01634 = phi i32 [ %.pre-phi, %._crit_edge ], [ 0, %0 ]
  %.01733 = phi i32 [ %.118.lcssa, %._crit_edge ], [ 0, %0 ]
  %.01932 = phi i32 [ %.120.lcssa, %._crit_edge ], [ 0, %0 ]
  %12 = sitofp i32 %.01733 to double
  %13 = fcmp ogt double %8, %12
  br i1 %13, label %.lr.ph, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre = add nuw nsw i32 %.01634, 1
  %.pre37 = uitofp nneg i32 %.pre to double
  br label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %14 = fmul double %9, %11
  %15 = add nuw nsw i32 %.01634, 1
  %16 = uitofp nneg i32 %15 to double
  %17 = fmul double %9, %16
  br label %19

._crit_edge35:                                    ; preds = %._crit_edge, %0
  %.019.lcssa = phi i32 [ 0, %0 ], [ %.120.lcssa, %._crit_edge ]
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.019.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0

19:                                               ; preds = %.lr.ph, %30
  %20 = phi double [ %12, %.lr.ph ], [ %22, %30 ]
  %.027 = phi i32 [ %.01733, %.lr.ph ], [ %21, %30 ]
  %.01526 = phi i1 [ false, %.lr.ph ], [ %or.cond, %30 ]
  %.11825 = phi i32 [ %.01733, %.lr.ph ], [ %.2, %30 ]
  %.12024 = phi i32 [ %.01932, %.lr.ph ], [ %.221, %30 ]
  %21 = add nsw i32 %.027, 1
  %22 = sitofp i32 %21 to double
  %23 = fcmp olt double %14, %22
  %24 = fcmp ogt double %17, %20
  %or.cond = select i1 %23, i1 %24, i1 false
  br i1 %or.cond, label %25, label %27

25:                                               ; preds = %19
  %26 = add nsw i32 %.12024, 1
  br label %30

27:                                               ; preds = %19
  br i1 %.01526, label %._crit_edge, label %28

28:                                               ; preds = %27
  %29 = add nsw i32 %.11825, 1
  br label %30

30:                                               ; preds = %25, %28
  %.221 = phi i32 [ %26, %25 ], [ %.12024, %28 ]
  %.2 = phi i32 [ %.11825, %25 ], [ %29, %28 ]
  %31 = fcmp ogt double %8, %22
  br i1 %31, label %19, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %30, %27, %.preheader.._crit_edge_crit_edge
  %.pre-phi38 = phi double [ %.pre37, %.preheader.._crit_edge_crit_edge ], [ %16, %27 ], [ %16, %30 ]
  %.pre-phi = phi i32 [ %.pre, %.preheader.._crit_edge_crit_edge ], [ %15, %27 ], [ %15, %30 ]
  %.120.lcssa = phi i32 [ %.01932, %.preheader.._crit_edge_crit_edge ], [ %.221, %30 ], [ %.12024, %27 ]
  %.118.lcssa = phi i32 [ %.01733, %.preheader.._crit_edge_crit_edge ], [ %.2, %30 ], [ %.11825, %27 ]
  %32 = fcmp ogt double %6, %.pre-phi38
  br i1 %32, label %.preheader, label %._crit_edge35, !llvm.loop !11
}

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

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 = { 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 = { "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 = { 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 = !{!"double", !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}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass