; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (347B-FixedPoints)

; 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 [5 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 ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store i64 0, ptr %2, align 8, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %9, i64 8)
  %11 = extractvalue { i64, i1 } %10, 1
  %12 = extractvalue { i64, i1 } %10, 0
  %13 = select i1 %11, i64 -1, i64 %12
  %14 = call noalias noundef nonnull ptr @_Znam(i64 noundef %13) #6
  store ptr %14, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %27, %0
  %16 = load i32, ptr %4, align 4, !tbaa !11
  %17 = sext i32 %16 to i64
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %30

21:                                               ; preds = %15
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = load i32, ptr %4, align 4, !tbaa !11
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i64, ptr %22, i64 %24
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %25)
  br label %27

27:                                               ; preds = %21
  %28 = load i32, ptr %4, align 4, !tbaa !11
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %4, align 4, !tbaa !11
  br label %15, !llvm.loop !13

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  store i8 0, ptr %6, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %64, %30
  %32 = load i32, ptr %7, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr %2, align 8, !tbaa !5
  %35 = icmp slt i64 %33, %34
  br i1 %35, label %37, label %36

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

37:                                               ; preds = %31
  %38 = load ptr, ptr %3, align 8, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i64, ptr %38, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = icmp eq i64 %42, %44
  br i1 %45, label %46, label %49

46:                                               ; preds = %37
  %47 = load i64, ptr %5, align 8, !tbaa !5
  %48 = add nsw i64 %47, 1
  store i64 %48, ptr %5, align 8, !tbaa !5
  br label %63

49:                                               ; preds = %37
  %50 = load ptr, ptr %3, align 8, !tbaa !9
  %51 = load ptr, ptr %3, align 8, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i64, ptr %51, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds i64, ptr %50, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = icmp eq i64 %57, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %49
  store i8 1, ptr %6, align 1, !tbaa !15
  br label %62

62:                                               ; preds = %61, %49
  br label %63

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

64:                                               ; preds = %63
  %65 = load i32, ptr %7, align 4, !tbaa !11
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %7, align 4, !tbaa !11
  br label %31, !llvm.loop !17

67:                                               ; preds = %36
  %68 = load i8, ptr %6, align 1, !tbaa !15, !range !18, !noundef !19
  %69 = trunc i8 %68 to i1
  br i1 %69, label %70, label %73

70:                                               ; preds = %67
  %71 = load i64, ptr %5, align 8, !tbaa !5
  %72 = add nsw i64 %71, 2
  store i64 %72, ptr %5, align 8, !tbaa !5
  br label %81

73:                                               ; preds = %67
  %74 = load i64, ptr %5, align 8, !tbaa !5
  %75 = load i64, ptr %2, align 8, !tbaa !5
  %76 = icmp slt i64 %74, %75
  br i1 %76, label %77, label %80

77:                                               ; preds = %73
  %78 = load i64, ptr %5, align 8, !tbaa !5
  %79 = add nsw i64 %78, 1
  store i64 %79, ptr %5, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %77, %73
  br label %81

81:                                               ; preds = %80, %70
  %82 = load i64, ptr %5, align 8, !tbaa !5
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %82)
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #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

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

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

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

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

declare i32 @printf(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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = distinct !{!17, !14}
!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 [5 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) #4
  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 = icmp ugt i64 %3, 2305843009213693951
  %5 = shl i64 %3, 3
  %6 = select i1 %4, i64 -1, i64 %5
  %7 = call noalias noundef nonnull ptr @_Znam(i64 noundef %6) #5
  %8 = icmp sgt i64 %3, 0
  br i1 %8, label %.lr.ph, label %._crit_edge.thread

.preheader:                                       ; preds = %.lr.ph
  %9 = icmp sgt i64 %13, 0
  br i1 %9, label %.lr.ph31.preheader, label %._crit_edge.thread

.lr.ph31.preheader:                               ; preds = %.preheader
  %xtraiter = and i64 %13, 1
  %10 = icmp eq i64 %13, 1
  br i1 %10, label %._crit_edge.unr-lcssa, label %.lr.ph31.preheader.new

.lr.ph31.preheader.new:                           ; preds = %.lr.ph31.preheader
  %unroll_iter = and i64 %13, 9223372036854775806
  br label %.lr.ph31

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %11 = getelementptr inbounds i64, ptr %7, i64 %indvars.iv
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %11)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = icmp sgt i64 %13, %indvars.iv.next
  br i1 %14, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.unr-lcssa:                            ; preds = %46, %.lr.ph31.preheader
  %.120.lcssa.ph = phi i64 [ poison, %.lr.ph31.preheader ], [ %.120.1, %46 ]
  %cond.fr.lcssa.ph = phi i1 [ poison, %.lr.ph31.preheader ], [ %cond.fr.1, %46 ]
  %indvars.iv36.unr = phi i64 [ 0, %.lr.ph31.preheader ], [ %indvars.iv.next37.1, %46 ]
  %.01829.unr = phi i1 [ false, %.lr.ph31.preheader ], [ %cond.fr.1, %46 ]
  %.01928.unr = phi i64 [ 0, %.lr.ph31.preheader ], [ %.120.1, %46 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph31.epil

.lr.ph31.epil:                                    ; preds = %._crit_edge.unr-lcssa
  %15 = getelementptr inbounds i64, ptr %7, i64 %indvars.iv36.unr
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = icmp eq i64 %16, %indvars.iv36.unr
  br i1 %17, label %22, label %18

18:                                               ; preds = %.lr.ph31.epil
  %19 = getelementptr inbounds i64, ptr %7, i64 %16
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = icmp eq i64 %20, %indvars.iv36.unr
  %.fr = freeze i1 %21
  %spec.select.epil = or i1 %.fr, %.01829.unr
  br label %._crit_edge

22:                                               ; preds = %.lr.ph31.epil
  %23 = add nsw i64 %.01928.unr, 1
  br label %._crit_edge

._crit_edge:                                      ; preds = %18, %22, %._crit_edge.unr-lcssa
  %.120.lcssa = phi i64 [ %.120.lcssa.ph, %._crit_edge.unr-lcssa ], [ %23, %22 ], [ %.01928.unr, %18 ]
  %cond.fr.lcssa = phi i1 [ %cond.fr.lcssa.ph, %._crit_edge.unr-lcssa ], [ %.01829.unr, %22 ], [ %spec.select.epil, %18 ]
  %24 = icmp slt i64 %.120.lcssa, %13
  %25 = zext i1 %24 to i64
  %spec.select45 = select i1 %cond.fr.lcssa, i64 2, i64 %25
  %26 = add nsw i64 %spec.select45, %.120.lcssa
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0, %.preheader, %._crit_edge
  %.2 = phi i64 [ %26, %._crit_edge ], [ 0, %.preheader ], [ 0, %0 ]
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0

.lr.ph31:                                         ; preds = %46, %.lr.ph31.preheader.new
  %indvars.iv36 = phi i64 [ 0, %.lr.ph31.preheader.new ], [ %indvars.iv.next37.1, %46 ]
  %.01829 = phi i1 [ false, %.lr.ph31.preheader.new ], [ %cond.fr.1, %46 ]
  %.01928 = phi i64 [ 0, %.lr.ph31.preheader.new ], [ %.120.1, %46 ]
  %niter = phi i64 [ 0, %.lr.ph31.preheader.new ], [ %niter.next.1, %46 ]
  %28 = getelementptr inbounds i64, ptr %7, i64 %indvars.iv36
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = icmp eq i64 %29, %indvars.iv36
  br i1 %30, label %31, label %33

31:                                               ; preds = %.lr.ph31
  %32 = add nsw i64 %.01928, 1
  br label %.lr.ph31.1

33:                                               ; preds = %.lr.ph31
  %34 = getelementptr inbounds i64, ptr %7, i64 %29
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = icmp eq i64 %35, %indvars.iv36
  %spec.select = or i1 %36, %.01829
  br label %.lr.ph31.1

.lr.ph31.1:                                       ; preds = %33, %31
  %.120 = phi i64 [ %32, %31 ], [ %.01928, %33 ]
  %.1 = phi i1 [ %.01829, %31 ], [ %spec.select, %33 ]
  %cond.fr = freeze i1 %.1
  %indvars.iv.next37 = or disjoint i64 %indvars.iv36, 1
  %37 = getelementptr inbounds i64, ptr %7, i64 %indvars.iv.next37
  %38 = load i64, ptr %37, align 8, !tbaa !5
  %39 = icmp eq i64 %38, %indvars.iv.next37
  br i1 %39, label %44, label %40

40:                                               ; preds = %.lr.ph31.1
  %41 = getelementptr inbounds i64, ptr %7, i64 %38
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = icmp eq i64 %42, %indvars.iv.next37
  %spec.select.1 = or i1 %43, %cond.fr
  br label %46

44:                                               ; preds = %.lr.ph31.1
  %45 = add nsw i64 %.120, 1
  br label %46

46:                                               ; preds = %44, %40
  %.120.1 = phi i64 [ %45, %44 ], [ %.120, %40 ]
  %.1.1 = phi i1 [ %cond.fr, %44 ], [ %spec.select.1, %40 ]
  %cond.fr.1 = freeze i1 %.1.1
  %indvars.iv.next37.1 = add nuw nsw i64 %indvars.iv36, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.unr-lcssa, label %.lr.ph31, !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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; 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 @printf(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 = { 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 #4 = { nounwind }
attributes #5 = { 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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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