; LLVM IR from DionysiosB/CodeForces :: 1400-1499 (1469C-BuildingAFence)

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

14:                                               ; preds = %66, %0
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = add nsw i64 %15, -1
  store i64 %16, ptr %2, align 8, !tbaa !5
  %17 = icmp ne i64 %15, 0
  br i1 %17, label %18, label %72

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %21 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %21, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %22 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %22, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  store i8 1, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 1, ptr %9, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %58, %18
  %24 = load i64, ptr %9, align 8, !tbaa !5
  %25 = load i64, ptr %3, align 8, !tbaa !9
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %61

28:                                               ; preds = %23
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = load i64, ptr %4, align 8, !tbaa !9
  %32 = sub nsw i64 %30, %31
  %33 = add nsw i64 %32, 1
  store i64 %33, ptr %10, align 8, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %35 = load i64, ptr %34, align 8, !tbaa !9
  store i64 %35, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %36 = load i64, ptr %7, align 8, !tbaa !9
  %37 = load i64, ptr %4, align 8, !tbaa !9
  %38 = add nsw i64 %36, %37
  %39 = sub nsw i64 %38, 1
  store i64 %39, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = load i64, ptr %4, align 8, !tbaa !9
  %42 = add nsw i64 %40, %41
  %43 = sub nsw i64 %42, 1
  store i64 %43, ptr %12, align 8, !tbaa !9
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %45 = load i64, ptr %44, align 8, !tbaa !9
  store i64 %45, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = load i64, ptr %5, align 8, !tbaa !9
  %48 = icmp slt i64 %46, %47
  br i1 %48, label %56, label %49

49:                                               ; preds = %28
  %50 = load i64, ptr %6, align 8, !tbaa !9
  %51 = load i64, ptr %5, align 8, !tbaa !9
  %52 = load i64, ptr %4, align 8, !tbaa !9
  %53 = add nsw i64 %51, %52
  %54 = sub nsw i64 %53, 1
  %55 = icmp sgt i64 %50, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %49, %28
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %57

57:                                               ; preds = %56, %49
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %9, align 8, !tbaa !5
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %9, align 8, !tbaa !5
  br label %23, !llvm.loop !13

61:                                               ; preds = %27
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = icmp ne i64 %62, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %66

66:                                               ; preds = %65, %61
  %67 = load i8, ptr %8, align 1, !tbaa !11, !range !15, !noundef !16
  %68 = trunc i8 %67 to i1
  %69 = zext i1 %68 to i64
  %70 = select i1 %68, ptr @.str.3, ptr @.str.4
  %71 = call i32 @puts(ptr noundef %70)
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %14, !llvm.loop !17

72:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %73 = load i32, ptr %1, align 4
  ret i32 %73
}

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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


; 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 [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress 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 i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %9 = load i64, ptr %1, align 8, !tbaa !5
  %10 = add nsw i64 %9, -1
  store i64 %10, ptr %1, align 8, !tbaa !5
  %.not20 = icmp eq i64 %9, 0
  br i1 %.not20, label %._crit_edge23, label %.lr.ph22

.lr.ph22:                                         ; preds = %0, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %4)
  %13 = load i64, ptr %4, align 8, !tbaa !9
  %14 = load i64, ptr %2, align 8, !tbaa !9
  %15 = icmp sgt i64 %14, 1
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %42, %.lr.ph22
  %16 = phi i64 [ %13, %.lr.ph22 ], [ %36, %42 ]
  %.011.lcssa = phi i64 [ %13, %.lr.ph22 ], [ %27, %42 ]
  %.09.lcssa = phi i1 [ true, %.lr.ph22 ], [ %.1, %42 ]
  %.not13 = icmp eq i64 %.011.lcssa, %16
  %17 = select i1 %.not13, i1 %.09.lcssa, i1 false
  %18 = select i1 %17, ptr @.str.3, ptr @.str.4
  %19 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %18)
  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
  %20 = load i64, ptr %1, align 8, !tbaa !5
  %21 = add nsw i64 %20, -1
  store i64 %21, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %20, 0
  br i1 %.not, label %._crit_edge23, label %.lr.ph22, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph22, %42
  %.018 = phi i64 [ %43, %42 ], [ 1, %.lr.ph22 ]
  %.0917 = phi i1 [ %.1, %42 ], [ true, %.lr.ph22 ]
  %.01016 = phi i64 [ %35, %42 ], [ %13, %.lr.ph22 ]
  %.01115 = phi i64 [ %27, %42 ], [ %13, %.lr.ph22 ]
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %23 = load i64, ptr %3, align 8, !tbaa !9
  %24 = add i64 %.01115, 1
  %25 = sub i64 %24, %23
  store i64 %25, ptr %5, align 8, !tbaa !9
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %27 = load i64, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %28 = load i64, ptr %3, align 8, !tbaa !9
  %29 = add i64 %.01016, -1
  %30 = add i64 %29, %28
  store i64 %30, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %31 = load i64, ptr %4, align 8, !tbaa !9
  %32 = add i64 %28, -1
  %33 = add i64 %32, %31
  store i64 %33, ptr %7, align 8, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %35 = load i64, ptr %34, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %36 = load i64, ptr %4, align 8, !tbaa !9
  %37 = icmp slt i64 %35, %36
  br i1 %37, label %41, label %38

38:                                               ; preds = %.lr.ph
  %39 = load i64, ptr %3, align 8, !tbaa !9
  %40 = add nsw i64 %39, %36
  %.not14 = icmp slt i64 %27, %40
  br i1 %.not14, label %42, label %41

41:                                               ; preds = %38, %.lr.ph
  br label %42

42:                                               ; preds = %38, %41
  %.1 = phi i1 [ false, %41 ], [ %.0917, %38 ]
  %43 = add nuw nsw i64 %.018, 1
  %44 = load i64, ptr %2, align 8, !tbaa !9
  %45 = icmp slt i64 %43, %44
  br i1 %45, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge23:                                    ; preds = %._crit_edge, %0
  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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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


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