; LLVM IR from DionysiosB/CodeForces :: 0200-0299 (287B-Pipeline)

; 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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = 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 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 i64, align 8
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = icmp eq i64 %11, 1
  br i1 %12, label %13, label %15

13:                                               ; preds = %0
  %14 = call i32 @puts(ptr noundef @.str.1)
  br label %108

15:                                               ; preds = %0
  %16 = load i64, ptr %2, align 8, !tbaa !5
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = icmp sle i64 %16, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = call i32 @puts(ptr noundef @.str.2)
  br label %107

21:                                               ; preds = %15
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = sub nsw i64 %24, 1
  %26 = mul nsw i64 %23, %25
  %27 = sdiv i64 %26, 2
  %28 = add nsw i64 %27, 1
  %29 = icmp sgt i64 %22, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %21
  %31 = call i32 @puts(ptr noundef @.str.3)
  br label %106

32:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %33 = load i64, ptr %3, align 8, !tbaa !5
  %34 = sub nsw i64 %33, 1
  store i64 %34, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 1, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = load i64, ptr %3, align 8, !tbaa !5
  %37 = sub nsw i64 %36, 1
  %38 = mul nsw i64 %35, %37
  %39 = sdiv i64 %38, 2
  %40 = add nsw i64 1, %39
  store i64 %40, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %41 = load i64, ptr %7, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = load i64, ptr %6, align 8, !tbaa !5
  %44 = sub nsw i64 %43, 1
  %45 = mul nsw i64 %42, %44
  %46 = sdiv i64 %45, 2
  %47 = sub nsw i64 %41, %46
  store i64 %47, ptr %8, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %84, %32
  %49 = load i64, ptr %4, align 8, !tbaa !5
  %50 = add nsw i64 %49, 1
  %51 = load i64, ptr %5, align 8, !tbaa !5
  %52 = icmp slt i64 %50, %51
  br i1 %52, label %53, label %85

53:                                               ; preds = %48
  %54 = load i64, ptr %4, align 8, !tbaa !5
  %55 = load i64, ptr %5, align 8, !tbaa !5
  %56 = add nsw i64 %54, %55
  %57 = sdiv i64 %56, 2
  store i64 %57, ptr %6, align 8, !tbaa !5
  %58 = load i64, ptr %7, align 8, !tbaa !5
  %59 = load i64, ptr %6, align 8, !tbaa !5
  %60 = load i64, ptr %6, align 8, !tbaa !5
  %61 = sub nsw i64 %60, 1
  %62 = mul nsw i64 %59, %61
  %63 = sdiv i64 %62, 2
  %64 = sub nsw i64 %58, %63
  store i64 %64, ptr %8, align 8, !tbaa !5
  %65 = load i64, ptr %8, align 8, !tbaa !5
  %66 = load i64, ptr %2, align 8, !tbaa !5
  %67 = icmp eq i64 %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %53
  %69 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %69, ptr %5, align 8, !tbaa !5
  br label %85

70:                                               ; preds = %53
  %71 = load i64, ptr %8, align 8, !tbaa !5
  %72 = load i64, ptr %2, align 8, !tbaa !5
  %73 = icmp sgt i64 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %75, ptr %4, align 8, !tbaa !5
  br label %83

76:                                               ; preds = %70
  %77 = load i64, ptr %8, align 8, !tbaa !5
  %78 = load i64, ptr %2, align 8, !tbaa !5
  %79 = icmp slt i64 %77, %78
  br i1 %79, label %80, label %82

80:                                               ; preds = %76
  %81 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %81, ptr %5, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %80, %76
  br label %83

83:                                               ; preds = %82, %74
  br label %84

84:                                               ; preds = %83
  br label %48, !llvm.loop !9

85:                                               ; preds = %68, %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !5
  %86 = load i64, ptr %8, align 8, !tbaa !5
  %87 = load i64, ptr %2, align 8, !tbaa !5
  %88 = icmp slt i64 %86, %87
  br i1 %88, label %89, label %94

89:                                               ; preds = %85
  %90 = load i64, ptr %3, align 8, !tbaa !5
  %91 = load i64, ptr %6, align 8, !tbaa !5
  %92 = sub nsw i64 %90, %91
  %93 = add nsw i64 %92, 1
  store i64 %93, ptr %9, align 8, !tbaa !5
  br label %103

94:                                               ; preds = %85
  %95 = load i64, ptr %8, align 8, !tbaa !5
  %96 = load i64, ptr %2, align 8, !tbaa !5
  %97 = icmp sge i64 %95, %96
  br i1 %97, label %98, label %102

98:                                               ; preds = %94
  %99 = load i64, ptr %3, align 8, !tbaa !5
  %100 = load i64, ptr %6, align 8, !tbaa !5
  %101 = sub nsw i64 %99, %100
  store i64 %101, ptr %9, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %98, %94
  br label %103

103:                                              ; preds = %102, %89
  %104 = load i64, ptr %9, align 8, !tbaa !5
  %105 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %104)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %106

106:                                              ; preds = %103, %30
  br label %107

107:                                              ; preds = %106, %19
  br label %108

108:                                              ; preds = %107, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  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

declare i32 @puts(ptr noundef) #2

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 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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"

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind 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) #3
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store i64 0, ptr %2, align 8, !tbaa !5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = icmp eq i64 %4, 1
  br i1 %5, label %6, label %8

6:                                                ; preds = %0
  %7 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %36

8:                                                ; preds = %0
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp sgt i64 %4, %9
  br i1 %.not, label %12, label %10

10:                                               ; preds = %8
  %11 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %36

12:                                               ; preds = %8
  %13 = add nsw i64 %9, -1
  %14 = mul nsw i64 %13, %9
  %15 = sdiv i64 %14, 2
  %16 = add nsw i64 %15, 1
  %17 = icmp sgt i64 %4, %16
  br i1 %17, label %19, label %.preheader

.preheader:                                       ; preds = %12
  %18 = icmp sgt i64 %9, 3
  br i1 %18, label %.lr.ph, label %._crit_edge

19:                                               ; preds = %12
  %20 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %36

.lr.ph:                                           ; preds = %.preheader, %28
  %.02235 = phi i64 [ %.123, %28 ], [ 1, %.preheader ]
  %.02634 = phi i64 [ %.127, %28 ], [ %13, %.preheader ]
  %21 = add nuw nsw i64 %.02235, %.02634
  %22 = lshr i64 %21, 1
  %23 = add nsw i64 %22, -1
  %24 = mul nsw i64 %23, %22
  %25 = lshr i64 %24, 1
  %26 = sub nsw i64 %16, %25
  %27 = icmp eq i64 %26, %4
  br i1 %27, label %._crit_edge, label %28

28:                                               ; preds = %.lr.ph
  %29 = icmp sgt i64 %26, %4
  %30 = icmp slt i64 %26, %4
  %spec.select = select i1 %30, i64 %22, i64 %.02634
  %.127 = select i1 %29, i64 %.02634, i64 %spec.select
  %.123 = select i1 %29, i64 %22, i64 %.02235
  %31 = add nuw nsw i64 %.123, 1
  %32 = icmp slt i64 %31, %.127
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %28, %.lr.ph, %.preheader
  %.125 = phi i64 [ 1, %.preheader ], [ %22, %.lr.ph ], [ %22, %28 ]
  %.1 = phi i64 [ %16, %.preheader ], [ %26, %28 ], [ %4, %.lr.ph ]
  %33 = icmp slt i64 %.1, %4
  %34 = zext i1 %33 to i64
  %.0.v = add i64 %9, %34
  %.0 = sub i64 %.0.v, %.125
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %.0)
  br label %36

36:                                               ; preds = %10, %._crit_edge, %19, %6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  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: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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

; 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 nofree norecurse nounwind 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 = { 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 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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass