; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (401C-Team)

; 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 [9 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 [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = 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 i32, align 4
  %5 = alloca i64, align 8
  %6 = 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
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  %8 = load i64, ptr %3, align 8, !tbaa !5
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = sub nsw i64 %9, 1
  %11 = icmp eq i64 %8, %10
  br i1 %11, label %16, label %12

12:                                               ; preds = %0
  %13 = load i64, ptr %3, align 8, !tbaa !5
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = icmp eq i64 %13, %14
  br i1 %15, label %16, label %38

16:                                               ; preds = %12, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %34, %16
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = add nsw i64 %20, %21
  %23 = icmp slt i64 %19, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %37

25:                                               ; preds = %17
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = srem i32 %26, 2
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %33

31:                                               ; preds = %25
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %33

33:                                               ; preds = %31, %29
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %4, align 4, !tbaa !9
  br label %17, !llvm.loop !11

37:                                               ; preds = %24
  br label %97

38:                                               ; preds = %12
  %39 = load i64, ptr %3, align 8, !tbaa !5
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = add nsw i64 %40, 1
  %42 = icmp sge i64 %39, %41
  br i1 %42, label %43, label %94

43:                                               ; preds = %38
  %44 = load i64, ptr %3, align 8, !tbaa !5
  %45 = load i64, ptr %2, align 8, !tbaa !5
  %46 = add nsw i64 %45, 1
  %47 = mul nsw i64 2, %46
  %48 = icmp sle i64 %44, %47
  br i1 %48, label %49, label %94

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !5
  %50 = load i64, ptr %3, align 8, !tbaa !5
  %51 = load i64, ptr %2, align 8, !tbaa !5
  %52 = add nsw i64 %51, 1
  %53 = mul nsw i64 2, %52
  %54 = icmp eq i64 %50, %53
  br i1 %54, label %55, label %58

55:                                               ; preds = %49
  %56 = load i64, ptr %2, align 8, !tbaa !5
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %5, align 8, !tbaa !5
  br label %63

58:                                               ; preds = %49
  %59 = load i64, ptr %3, align 8, !tbaa !5
  %60 = load i64, ptr %2, align 8, !tbaa !5
  %61 = add nsw i64 %60, 1
  %62 = srem i64 %59, %61
  store i64 %62, ptr %5, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %58, %55
  %64 = load i64, ptr %3, align 8, !tbaa !5
  %65 = load i64, ptr %2, align 8, !tbaa !5
  %66 = add nsw i64 %65, 1
  %67 = icmp eq i64 %64, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %63
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %74

70:                                               ; preds = %63
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %72 = load i64, ptr %5, align 8, !tbaa !5
  %73 = add nsw i64 %72, -1
  store i64 %73, ptr %5, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %70, %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %75

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

79:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %93

80:                                               ; preds = %75
  %81 = load i64, ptr %5, align 8, !tbaa !5
  %82 = icmp sgt i64 %81, 0
  br i1 %82, label %83, label %85

83:                                               ; preds = %80
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %87

85:                                               ; preds = %80
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %87

87:                                               ; preds = %85, %83
  %88 = load i64, ptr %5, align 8, !tbaa !5
  %89 = add nsw i64 %88, -1
  store i64 %89, ptr %5, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %87
  %91 = load i64, ptr %6, align 8, !tbaa !5
  %92 = add nsw i64 %91, 1
  store i64 %92, ptr %6, align 8, !tbaa !5
  br label %75, !llvm.loop !13

93:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %96

94:                                               ; preds = %43, %38
  %95 = call i32 @puts(ptr noundef @.str.6)
  br label %96

96:                                               ; preds = %94, %93
  br label %97

97:                                               ; preds = %96, %37
  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 @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

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 }

!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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 [9 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 [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 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 %2, align 8, !tbaa !5
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  %7 = icmp eq i64 %4, %6
  %8 = icmp eq i64 %4, %5
  %or.cond = or i1 %8, %7
  br i1 %or.cond, label %.preheader, label %18

.preheader:                                       ; preds = %0
  %9 = add nsw i64 %5, %4
  %10 = icmp sgt i64 %9, 0
  br i1 %10, label %.lr.ph18, label %.loopexit

.lr.ph18:                                         ; preds = %.preheader, %.lr.ph18
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph18 ], [ 0, %.preheader ]
  %11 = and i64 %indvars.iv, 1
  %12 = icmp eq i64 %11, 0
  %.str.1..str.2 = select i1 %12, ptr @.str.1, ptr @.str.2
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = load i64, ptr %1, align 8, !tbaa !5
  %16 = add nsw i64 %15, %14
  %17 = icmp sgt i64 %16, %indvars.iv.next
  br i1 %17, label %.lr.ph18, label %.loopexit, !llvm.loop !9

18:                                               ; preds = %0
  %19 = add nsw i64 %5, 1
  %.not.not = icmp sgt i64 %4, %5
  br i1 %.not.not, label %20, label %42

20:                                               ; preds = %18
  %21 = shl nsw i64 %19, 1
  %.not = icmp sgt i64 %4, %21
  br i1 %.not, label %42, label %22

22:                                               ; preds = %20
  %23 = icmp eq i64 %4, %21
  br i1 %23, label %26, label %24

24:                                               ; preds = %22
  %25 = srem i64 %4, %19
  br label %26

26:                                               ; preds = %22, %24
  %.08 = phi i64 [ %25, %24 ], [ %19, %22 ]
  %27 = icmp eq i64 %4, %19
  br i1 %27, label %28, label %30

28:                                               ; preds = %26
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %33

30:                                               ; preds = %26
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %32 = add nsw i64 %.08, -1
  br label %33

33:                                               ; preds = %30, %28
  %.1 = phi i64 [ %.08, %28 ], [ %32, %30 ]
  %34 = load i64, ptr %1, align 8, !tbaa !5
  %35 = icmp sgt i64 %34, 0
  br i1 %35, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %33, %.lr.ph
  %.016 = phi i64 [ %39, %.lr.ph ], [ 0, %33 ]
  %.215 = phi i64 [ %38, %.lr.ph ], [ %.1, %33 ]
  %36 = icmp sgt i64 %.215, 0
  %.str.4..str.5 = select i1 %36, ptr @.str.4, ptr @.str.5
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.4..str.5)
  %38 = add nsw i64 %.215, -1
  %39 = add nuw nsw i64 %.016, 1
  %40 = load i64, ptr %1, align 8, !tbaa !5
  %41 = icmp slt i64 %39, %40
  br i1 %41, label %.lr.ph, label %.loopexit, !llvm.loop !11

42:                                               ; preds = %20, %18
  %43 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.6)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph18, %33, %.preheader, %42
  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 @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

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

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", !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: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass