; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (407A-Triangle)

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  store i8 0, ptr %8, align 1, !tbaa !5
  store i64 1, ptr %4, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %67, %0
  %12 = load i64, ptr %4, align 8, !tbaa !9
  %13 = load i64, ptr %2, align 8, !tbaa !9
  %14 = icmp slt i64 %12, %13
  br i1 %14, label %15, label %70

15:                                               ; preds = %11
  %16 = load i64, ptr %2, align 8, !tbaa !9
  %17 = load i64, ptr %2, align 8, !tbaa !9
  %18 = mul nsw i64 %16, %17
  %19 = load i64, ptr %4, align 8, !tbaa !9
  %20 = load i64, ptr %4, align 8, !tbaa !9
  %21 = mul nsw i64 %19, %20
  %22 = sub nsw i64 %18, %21
  %23 = sitofp i64 %22 to double
  %24 = call double @sqrt(double noundef %23) #5
  %25 = fptosi double %24 to i64
  store i64 %25, ptr %5, align 8, !tbaa !9
  %26 = load i64, ptr %4, align 8, !tbaa !9
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = mul nsw i64 %26, %27
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = mul nsw i64 %29, %30
  %32 = add nsw i64 %28, %31
  %33 = load i64, ptr %2, align 8, !tbaa !9
  %34 = load i64, ptr %2, align 8, !tbaa !9
  %35 = mul nsw i64 %33, %34
  %36 = icmp ne i64 %32, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %15
  br label %67

38:                                               ; preds = %15
  %39 = load i64, ptr %3, align 8, !tbaa !9
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = mul nsw i64 %39, %40
  %42 = load i64, ptr %2, align 8, !tbaa !9
  %43 = sdiv i64 %41, %42
  store i64 %43, ptr %6, align 8, !tbaa !9
  %44 = load i64, ptr %3, align 8, !tbaa !9
  %45 = load i64, ptr %4, align 8, !tbaa !9
  %46 = mul nsw i64 %44, %45
  %47 = load i64, ptr %2, align 8, !tbaa !9
  %48 = sdiv i64 %46, %47
  store i64 %48, ptr %7, align 8, !tbaa !9
  %49 = load i64, ptr %6, align 8, !tbaa !9
  %50 = load i64, ptr %6, align 8, !tbaa !9
  %51 = mul nsw i64 %49, %50
  %52 = load i64, ptr %7, align 8, !tbaa !9
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = mul nsw i64 %52, %53
  %55 = add nsw i64 %51, %54
  %56 = load i64, ptr %3, align 8, !tbaa !9
  %57 = load i64, ptr %3, align 8, !tbaa !9
  %58 = mul nsw i64 %56, %57
  %59 = icmp ne i64 %55, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %38
  br label %67

61:                                               ; preds = %38
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = icmp eq i64 %62, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  br label %67

66:                                               ; preds = %61
  store i8 1, ptr %8, align 1, !tbaa !5
  br label %70

67:                                               ; preds = %65, %60, %37
  %68 = load i64, ptr %4, align 8, !tbaa !9
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %4, align 8, !tbaa !9
  br label %11, !llvm.loop !11

70:                                               ; preds = %66, %11
  %71 = load i8, ptr %8, align 1, !tbaa !5, !range !13, !noundef !14
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %81

73:                                               ; preds = %70
  %74 = call i32 @puts(ptr noundef @.str)
  %75 = load i64, ptr %4, align 8, !tbaa !9
  %76 = load i64, ptr %5, align 8, !tbaa !9
  %77 = load i64, ptr %6, align 8, !tbaa !9
  %78 = sub nsw i64 0, %77
  %79 = load i64, ptr %7, align 8, !tbaa !9
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %75, i64 noundef %76, i64 noundef %78, i64 noundef %79)
  br label %83

81:                                               ; preds = %70
  %82 = call i32 @puts(ptr noundef @.str.2)
  br label %83

83:                                               ; preds = %81, %73
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret i32 0
}

; 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 @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

declare i32 @puts(ptr noundef) #4

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

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


; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(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 @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = icmp sgt i64 %5, 1
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %29
  %7 = phi i64 [ %16, %29 ], [ %5, %0 ]
  %.02742 = phi i64 [ %30, %29 ], [ 1, %0 ]
  %8 = mul nsw i64 %7, %7
  %9 = mul nuw nsw i64 %.02742, %.02742
  %10 = sub nsw i64 %8, %9
  %11 = sitofp i64 %10 to double
  %12 = call double @sqrt(double noundef %11) #5
  %13 = fptosi double %12 to i64
  %14 = mul nsw i64 %13, %13
  %15 = add nuw nsw i64 %14, %9
  %16 = load i64, ptr %1, align 8, !tbaa !5
  %17 = mul nsw i64 %16, %16
  %.not = icmp eq i64 %15, %17
  br i1 %.not, label %18, label %29

18:                                               ; preds = %.lr.ph
  %19 = load i64, ptr %2, align 8, !tbaa !5
  %20 = mul nsw i64 %19, %13
  %21 = sdiv i64 %20, %16
  %22 = mul nsw i64 %19, %.02742
  %23 = sdiv i64 %22, %16
  %24 = mul nsw i64 %21, %21
  %25 = mul nsw i64 %23, %23
  %26 = add nuw nsw i64 %25, %24
  %27 = mul nsw i64 %19, %19
  %.not32 = icmp ne i64 %26, %27
  %28 = icmp eq i64 %23, %13
  %or.cond = or i1 %28, %.not32
  br i1 %or.cond, label %29, label %32

29:                                               ; preds = %18, %.lr.ph
  %30 = add nuw nsw i64 %.02742, 1
  %31 = icmp slt i64 %30, %16
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !9

32:                                               ; preds = %18
  %33 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str)
  %34 = sub nsw i64 0, %21
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.02742, i64 noundef %13, i64 noundef %34, i64 noundef %23)
  br label %37

._crit_edge:                                      ; preds = %29, %0
  %36 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %37

37:                                               ; preds = %._crit_edge, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, 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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3

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

; 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 = { 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 nofree nounwind willreturn memory(write) "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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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