; LLVM IR from DionysiosB/CodeForces :: 0200-0299 (298B-Sail)

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

22:                                               ; preds = %0
  %23 = load i64, ptr %8, align 8, !tbaa !8
  %24 = sub nsw i64 0, %23
  store i64 %24, ptr %8, align 8, !tbaa !8
  store i8 87, ptr %7, align 1, !tbaa !5
  br label %25

25:                                               ; preds = %22, %0
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  store i8 78, ptr %9, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %26 = load i64, ptr %6, align 8, !tbaa !8
  %27 = load i64, ptr %4, align 8, !tbaa !8
  %28 = sub nsw i64 %26, %27
  store i64 %28, ptr %10, align 8, !tbaa !8
  %29 = load i64, ptr %10, align 8, !tbaa !8
  %30 = icmp slt i64 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %25
  %32 = load i64, ptr %10, align 8, !tbaa !8
  %33 = sub nsw i64 0, %32
  store i64 %33, ptr %10, align 8, !tbaa !8
  store i8 83, ptr %9, align 1, !tbaa !5
  br label %34

34:                                               ; preds = %31, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store i64 0, ptr %11, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 0, ptr %12, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store i64 0, ptr %13, align 8, !tbaa !8
  store i64 1, ptr %13, align 8, !tbaa !8
  br label %35

35:                                               ; preds = %72, %34
  %36 = load i64, ptr %13, align 8, !tbaa !8
  %37 = load i64, ptr %2, align 8, !tbaa !8
  %38 = icmp sle i64 %36, %37
  br i1 %38, label %39, label %75

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #3
  %40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %14)
  %41 = load i8, ptr %14, align 1, !tbaa !5
  %42 = sext i8 %41 to i32
  %43 = load i8, ptr %7, align 1, !tbaa !5
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %42, %44
  br i1 %45, label %46, label %49

46:                                               ; preds = %39
  %47 = load i64, ptr %11, align 8, !tbaa !8
  %48 = add nsw i64 %47, 1
  store i64 %48, ptr %11, align 8, !tbaa !8
  br label %59

49:                                               ; preds = %39
  %50 = load i8, ptr %14, align 1, !tbaa !5
  %51 = sext i8 %50 to i32
  %52 = load i8, ptr %9, align 1, !tbaa !5
  %53 = sext i8 %52 to i32
  %54 = icmp eq i32 %51, %53
  br i1 %54, label %55, label %58

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

58:                                               ; preds = %55, %49
  br label %59

59:                                               ; preds = %58, %46
  %60 = load i64, ptr %11, align 8, !tbaa !8
  %61 = load i64, ptr %8, align 8, !tbaa !8
  %62 = icmp sge i64 %60, %61
  br i1 %62, label %63, label %68

63:                                               ; preds = %59
  %64 = load i64, ptr %12, align 8, !tbaa !8
  %65 = load i64, ptr %10, align 8, !tbaa !8
  %66 = icmp sge i64 %64, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %63
  store i32 2, ptr %15, align 4
  br label %69

68:                                               ; preds = %63, %59
  store i32 0, ptr %15, align 4
  br label %69

69:                                               ; preds = %68, %67
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  %70 = load i32, ptr %15, align 4
  switch i32 %70, label %90 [
    i32 0, label %71
    i32 2, label %75
  ]

71:                                               ; preds = %69
  br label %72

72:                                               ; preds = %71
  %73 = load i64, ptr %13, align 8, !tbaa !8
  %74 = add nsw i64 %73, 1
  store i64 %74, ptr %13, align 8, !tbaa !8
  br label %35, !llvm.loop !10

75:                                               ; preds = %69, %35
  %76 = load i64, ptr %11, align 8, !tbaa !8
  %77 = load i64, ptr %8, align 8, !tbaa !8
  %78 = icmp sge i64 %76, %77
  br i1 %78, label %79, label %86

79:                                               ; preds = %75
  %80 = load i64, ptr %12, align 8, !tbaa !8
  %81 = load i64, ptr %10, align 8, !tbaa !8
  %82 = icmp sge i64 %80, %81
  br i1 %82, label %83, label %86

83:                                               ; preds = %79
  %84 = load i64, ptr %13, align 8, !tbaa !8
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %84)
  br label %88

86:                                               ; preds = %79, %75
  %87 = call i32 @puts(ptr noundef @.str.3)
  br label %88

88:                                               ; preds = %86, %83
  store i32 0, ptr %1, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %89 = load i32, ptr %1, align 4
  ret i32 %89

90:                                               ; preds = %69
  unreachable
}

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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 [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = 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
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %8 = load i64, ptr %4, align 8, !tbaa !5
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = sub nsw i64 %8, %9
  %11 = icmp slt i64 %10, 0
  %spec.select = select i1 %11, i32 87, i32 69
  %spec.select39 = call i64 @llvm.abs.i64(i64 %10, i1 true)
  %12 = load i64, ptr %5, align 8, !tbaa !5
  %13 = load i64, ptr %3, align 8, !tbaa !5
  %14 = sub nsw i64 %12, %13
  %15 = icmp slt i64 %14, 0
  %.027 = select i1 %15, i32 83, i32 78
  %.026 = call i64 @llvm.abs.i64(i64 %14, i1 true)
  %16 = load i64, ptr %1, align 8, !tbaa !5
  %.not42 = icmp slt i64 %16, 1
  br i1 %.not42, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %23
  %.02145 = phi i64 [ %24, %23 ], [ 1, %0 ]
  %.02244 = phi i64 [ %.1, %23 ], [ 0, %0 ]
  %.02343 = phi i64 [ %.124, %23 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %6)
  %18 = load i8, ptr %6, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %spec.select, %19
  %21 = icmp eq i32 %.027, %19
  %22 = zext i1 %20 to i64
  %.124 = add nuw nsw i64 %.02343, %22
  %not. = xor i1 %20, true
  %narrow = select i1 %not., i1 %21, i1 false
  %spec.select40 = zext i1 %narrow to i64
  %.1 = add nuw nsw i64 %.02244, %spec.select40
  %.not35 = icmp ult i64 %.124, %spec.select39
  %.not36 = icmp ult i64 %.1, %.026
  %or.cond = select i1 %.not35, i1 true, i1 %.not36
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #4
  br i1 %or.cond, label %23, label %._crit_edge

23:                                               ; preds = %.lr.ph
  %24 = add nuw nsw i64 %.02145, 1
  %25 = load i64, ptr %1, align 8, !tbaa !5
  %.not.not = icmp slt i64 %.02145, %25
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %23, %.lr.ph, %0
  %.021.lcssa = phi i64 [ 1, %0 ], [ %.02145, %.lr.ph ], [ %24, %23 ]
  %.225 = phi i64 [ 0, %0 ], [ %.124, %.lr.ph ], [ %.124, %23 ]
  %.2 = phi i64 [ 0, %0 ], [ %.1, %.lr.ph ], [ %.1, %23 ]
  %.not37 = icmp slt i64 %.225, %spec.select39
  %.not38 = icmp slt i64 %.2, %.026
  %or.cond41 = select i1 %.not37, i1 true, i1 %.not38
  br i1 %or.cond41, label %28, label %26

26:                                               ; preds = %._crit_edge
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.021.lcssa)
  br label %30

28:                                               ; preds = %._crit_edge
  %29 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %30

30:                                               ; preds = %28, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  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 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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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