; LLVM IR from DionysiosB/CodeForces :: 0100-0199 (192A-FunkyNumbers)

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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 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 ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !5
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = mul nsw i64 2, %10
  %12 = sitofp i64 %11 to double
  %13 = call double @sqrt(double noundef %12) #6
  %14 = fptosi double %13 to i64
  store i64 %14, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %15 = load i64, ptr %3, align 8, !tbaa !5
  %16 = add nsw i64 %15, 1
  %17 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %16, i64 8)
  %18 = extractvalue { i64, i1 } %17, 1
  %19 = extractvalue { i64, i1 } %17, 0
  %20 = select i1 %18, i64 -1, i64 %19
  %21 = call noalias noundef nonnull ptr @_Znam(i64 noundef %20) #7
  store ptr %21, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %36, %0
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = icmp sle i64 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %39

27:                                               ; preds = %22
  %28 = load i64, ptr %5, align 8, !tbaa !5
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = add nsw i64 %29, 1
  %31 = mul nsw i64 %28, %30
  %32 = sdiv i64 %31, 2
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = load i64, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds i64, ptr %33, i64 %34
  store i64 %32, ptr %35, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %27
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %5, align 8, !tbaa !5
  br label %22, !llvm.loop !11

39:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #6
  store i8 0, ptr %6, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = trunc i64 %40 to i32
  store i32 %41, ptr %8, align 4, !tbaa !15
  br label %42

42:                                               ; preds = %97, %39
  %43 = load i32, ptr %7, align 4, !tbaa !15
  %44 = load i32, ptr %8, align 4, !tbaa !15
  %45 = icmp sle i32 %43, %44
  br i1 %45, label %46, label %98

46:                                               ; preds = %42
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  %48 = load i32, ptr %7, align 4, !tbaa !15
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i64, ptr %47, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !15
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i64, ptr %52, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !5
  %57 = add nsw i64 %51, %56
  %58 = load i64, ptr %2, align 8, !tbaa !5
  %59 = icmp eq i64 %57, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %46
  store i8 1, ptr %6, align 1, !tbaa !13
  br label %98

61:                                               ; preds = %46
  %62 = load ptr, ptr %4, align 8, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !15
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i64, ptr %62, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = load ptr, ptr %4, align 8, !tbaa !9
  %68 = load i32, ptr %8, align 4, !tbaa !15
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i64, ptr %67, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !5
  %72 = add nsw i64 %66, %71
  %73 = load i64, ptr %2, align 8, !tbaa !5
  %74 = icmp slt i64 %72, %73
  br i1 %74, label %75, label %78

75:                                               ; preds = %61
  %76 = load i32, ptr %7, align 4, !tbaa !15
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %7, align 4, !tbaa !15
  br label %96

78:                                               ; preds = %61
  %79 = load ptr, ptr %4, align 8, !tbaa !9
  %80 = load i32, ptr %7, align 4, !tbaa !15
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i64, ptr %79, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !9
  %85 = load i32, ptr %8, align 4, !tbaa !15
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i64, ptr %84, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !5
  %89 = add nsw i64 %83, %88
  %90 = load i64, ptr %2, align 8, !tbaa !5
  %91 = icmp sgt i64 %89, %90
  br i1 %91, label %92, label %95

92:                                               ; preds = %78
  %93 = load i32, ptr %8, align 4, !tbaa !15
  %94 = add nsw i32 %93, -1
  store i32 %94, ptr %8, align 4, !tbaa !15
  br label %95

95:                                               ; preds = %92, %78
  br label %96

96:                                               ; preds = %95, %75
  br label %97

97:                                               ; preds = %96
  br label %42, !llvm.loop !17

98:                                               ; preds = %60, %42
  %99 = load i8, ptr %6, align 1, !tbaa !13, !range !18, !noundef !19
  %100 = trunc i8 %99 to i1
  br i1 %100, label %101, label %103

101:                                              ; preds = %98
  %102 = call i32 @puts(ptr noundef @.str.1)
  br label %105

103:                                              ; preds = %98
  %104 = call i32 @puts(ptr noundef @.str.2)
  br label %105

105:                                              ; preds = %103, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  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 i32 @__isoc99_scanf(ptr noundef, ...) #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #5

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

declare i32 @puts(ptr noundef) #2

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nobuiltin allocsize(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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !12}
!18 = !{i8 0, i8 2}
!19 = !{}


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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  store i64 0, ptr %1, align 8, !tbaa !5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = shl nsw i64 %3, 1
  %5 = sitofp i64 %4 to double
  %6 = call double @sqrt(double noundef %5) #5
  %7 = fptosi double %6 to i64
  %8 = add i64 %7, 1
  %9 = icmp ugt i64 %8, 2305843009213693951
  %10 = shl i64 %8, 3
  %11 = select i1 %9, i64 -1, i64 %10
  %12 = call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #6
  %.not33 = icmp slt i64 %7, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %13 = add nuw i64 %7, 1
  %min.iters.check = icmp ult i64 %7, 3
  br i1 %min.iters.check, label %.lr.ph.preheader41, label %vector.ph

.lr.ph.preheader41:                               ; preds = %middle.block, %.lr.ph.preheader
  %.02834.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %13, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %14 = add nuw <2 x i64> %vec.ind, <i64 1, i64 1>
  %15 = add <2 x i64> %vec.ind, <i64 3, i64 3>
  %16 = mul nuw nsw <2 x i64> %14, %vec.ind
  %17 = mul nuw nsw <2 x i64> %15, %step.add
  %18 = lshr <2 x i64> %16, <i64 1, i64 1>
  %19 = lshr <2 x i64> %17, <i64 1, i64 1>
  %20 = getelementptr inbounds i64, ptr %12, i64 %index
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x i64> %18, ptr %20, align 8, !tbaa !5
  store <2 x i64> %19, ptr %21, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %13, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader41

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %0
  %23 = trunc i64 %7 to i32
  %.not32.not35 = icmp slt i32 %23, 1
  br i1 %.not32.not35, label %.critedge, label %.lr.ph39

.lr.ph39:                                         ; preds = %._crit_edge
  %24 = load i64, ptr %1, align 8, !tbaa !5
  br label %29

.lr.ph:                                           ; preds = %.lr.ph.preheader41, %.lr.ph
  %.02834 = phi i64 [ %25, %.lr.ph ], [ %.02834.ph, %.lr.ph.preheader41 ]
  %25 = add nuw i64 %.02834, 1
  %26 = mul nuw nsw i64 %25, %.02834
  %27 = lshr i64 %26, 1
  %28 = getelementptr inbounds i64, ptr %12, i64 %.02834
  store i64 %27, ptr %28, align 8, !tbaa !5
  %exitcond.not = icmp eq i64 %.02834, %7
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

29:                                               ; preds = %.lr.ph39, %38
  %.037 = phi i32 [ %23, %.lr.ph39 ], [ %.1, %38 ]
  %.02536 = phi i32 [ 1, %.lr.ph39 ], [ %.126, %38 ]
  %30 = zext nneg i32 %.02536 to i64
  %31 = getelementptr inbounds i64, ptr %12, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = sext i32 %.037 to i64
  %34 = getelementptr inbounds i64, ptr %12, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = add nsw i64 %35, %32
  %37 = icmp eq i64 %36, %24
  br i1 %37, label %.critedge, label %38

38:                                               ; preds = %29
  %39 = icmp slt i64 %36, %24
  %40 = icmp sgt i64 %36, %24
  %41 = zext i1 %39 to i32
  %.126 = add nuw nsw i32 %.02536, %41
  %spec.select = sext i1 %40 to i32
  %.1 = add nsw i32 %.037, %spec.select
  %.not32.not = icmp sgt i32 %.126, %.1
  br i1 %.not32.not, label %.critedge, label %29, !llvm.loop !14

.critedge:                                        ; preds = %38, %29, %._crit_edge
  %.str.2.sink = phi ptr [ @.str.2, %._crit_edge ], [ @.str.1, %29 ], [ @.str.2, %38 ]
  %42 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) 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

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

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 = { 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 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 = { nobuiltin allocsize(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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass