; LLVM IR from DionysiosB/CodeForces :: 1100-1199 (1196C-RobotBreakout)

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

16:                                               ; preds = %104, %0
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr %2, align 8, !tbaa !5
  %19 = icmp ne i64 %17, 0
  br i1 %19, label %20, label %105

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 -100000, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 100000, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 -100000, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 100000, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %81, %20
  %23 = load i64, ptr %8, align 8, !tbaa !5
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = icmp slt i64 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %84

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef %14)
  %29 = load i64, ptr %11, align 8, !tbaa !5
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %41, label %31

31:                                               ; preds = %27
  %32 = load i64, ptr %4, align 8, !tbaa !5
  %33 = load i64, ptr %9, align 8, !tbaa !5
  %34 = icmp sgt i64 %32, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  %36 = load i64, ptr %4, align 8, !tbaa !5
  br label %39

37:                                               ; preds = %31
  %38 = load i64, ptr %9, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %37, %35
  %40 = phi i64 [ %36, %35 ], [ %38, %37 ]
  store i64 %40, ptr %4, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %39, %27
  %42 = load i64, ptr %13, align 8, !tbaa !5
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %54, label %44

44:                                               ; preds = %41
  %45 = load i64, ptr %5, align 8, !tbaa !5
  %46 = load i64, ptr %9, align 8, !tbaa !5
  %47 = icmp slt i64 %45, %46
  br i1 %47, label %48, label %50

48:                                               ; preds = %44
  %49 = load i64, ptr %5, align 8, !tbaa !5
  br label %52

50:                                               ; preds = %44
  %51 = load i64, ptr %9, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %50, %48
  %53 = phi i64 [ %49, %48 ], [ %51, %50 ]
  store i64 %53, ptr %5, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %52, %41
  %55 = load i64, ptr %14, align 8, !tbaa !5
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %67, label %57

57:                                               ; preds = %54
  %58 = load i64, ptr %6, align 8, !tbaa !5
  %59 = load i64, ptr %10, align 8, !tbaa !5
  %60 = icmp sgt i64 %58, %59
  br i1 %60, label %61, label %63

61:                                               ; preds = %57
  %62 = load i64, ptr %6, align 8, !tbaa !5
  br label %65

63:                                               ; preds = %57
  %64 = load i64, ptr %10, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %63, %61
  %66 = phi i64 [ %62, %61 ], [ %64, %63 ]
  store i64 %66, ptr %6, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %65, %54
  %68 = load i64, ptr %12, align 8, !tbaa !5
  %69 = icmp ne i64 %68, 0
  br i1 %69, label %80, label %70

70:                                               ; preds = %67
  %71 = load i64, ptr %7, align 8, !tbaa !5
  %72 = load i64, ptr %10, align 8, !tbaa !5
  %73 = icmp slt i64 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = load i64, ptr %7, align 8, !tbaa !5
  br label %78

76:                                               ; preds = %70
  %77 = load i64, ptr %10, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %76, %74
  %79 = phi i64 [ %75, %74 ], [ %77, %76 ]
  store i64 %79, ptr %7, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %78, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  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 8, ptr %9) #3
  br label %81

81:                                               ; preds = %80
  %82 = load i64, ptr %8, align 8, !tbaa !5
  %83 = add nsw i64 %82, 1
  store i64 %83, ptr %8, align 8, !tbaa !5
  br label %22, !llvm.loop !9

84:                                               ; preds = %26
  %85 = load i64, ptr %5, align 8, !tbaa !5
  %86 = load i64, ptr %4, align 8, !tbaa !5
  %87 = icmp slt i64 %85, %86
  br i1 %87, label %92, label %88

88:                                               ; preds = %84
  %89 = load i64, ptr %7, align 8, !tbaa !5
  %90 = load i64, ptr %6, align 8, !tbaa !5
  %91 = icmp slt i64 %89, %90
  br i1 %91, label %92, label %94

92:                                               ; preds = %88, %84
  %93 = call i32 @puts(ptr noundef @.str.2)
  br label %104

94:                                               ; preds = %88
  %95 = load i64, ptr %4, align 8, !tbaa !5
  %96 = load i64, ptr %5, align 8, !tbaa !5
  %97 = add nsw i64 %95, %96
  %98 = sdiv i64 %97, 2
  %99 = load i64, ptr %6, align 8, !tbaa !5
  %100 = load i64, ptr %7, align 8, !tbaa !5
  %101 = add nsw i64 %99, %100
  %102 = sdiv i64 %101, 2
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %98, i64 noundef %102)
  br label %104

104:                                              ; preds = %94, %92
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %16, !llvm.loop !11

105:                                              ; preds = %16
  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

; 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

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 = { 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}


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

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

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph39
  %.023.lcssa = phi i64 [ -100000, %.lr.ph39 ], [ %.124, %.lr.ph ]
  %.021.lcssa = phi i64 [ 100000, %.lr.ph39 ], [ %.122, %.lr.ph ]
  %.019.lcssa = phi i64 [ -100000, %.lr.ph39 ], [ %.120, %.lr.ph ]
  %.018.lcssa = phi i64 [ 100000, %.lr.ph39 ], [ %.1, %.lr.ph ]
  %15 = icmp slt i64 %.021.lcssa, %.023.lcssa
  %16 = icmp slt i64 %.018.lcssa, %.019.lcssa
  %or.cond = select i1 %15, i1 true, i1 %16
  br i1 %or.cond, label %31, label %33

.lr.ph:                                           ; preds = %.lr.ph39, %.lr.ph
  %.033 = phi i64 [ %28, %.lr.ph ], [ 0, %.lr.ph39 ]
  %.01832 = phi i64 [ %.1, %.lr.ph ], [ 100000, %.lr.ph39 ]
  %.01931 = phi i64 [ %.120, %.lr.ph ], [ -100000, %.lr.ph39 ]
  %.02130 = phi i64 [ %.122, %.lr.ph ], [ 100000, %.lr.ph39 ]
  %.02329 = phi i64 [ %.124, %.lr.ph ], [ -100000, %.lr.ph39 ]
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %18 = load i64, ptr %5, align 8, !tbaa !5
  %.not25 = icmp eq i64 %18, 0
  %19 = load i64, ptr %3, align 8
  %20 = call i64 @llvm.smax.i64(i64 %.02329, i64 %19)
  %.124 = select i1 %.not25, i64 %20, i64 %.02329
  %21 = load i64, ptr %7, align 8, !tbaa !5
  %.not26 = icmp eq i64 %21, 0
  %22 = call i64 @llvm.smin.i64(i64 %.02130, i64 %19)
  %.122 = select i1 %.not26, i64 %22, i64 %.02130
  %23 = load i64, ptr %8, align 8, !tbaa !5
  %.not27 = icmp eq i64 %23, 0
  %24 = load i64, ptr %4, align 8
  %25 = call i64 @llvm.smax.i64(i64 %.01931, i64 %24)
  %.120 = select i1 %.not27, i64 %25, i64 %.01931
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %.not28 = icmp eq i64 %26, 0
  %27 = call i64 @llvm.smin.i64(i64 %.01832, i64 %24)
  %.1 = select i1 %.not28, i64 %27, i64 %.01832
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  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
  %28 = add nuw nsw i64 %.033, 1
  %29 = load i64, ptr %2, align 8, !tbaa !5
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !9

31:                                               ; preds = %._crit_edge
  %32 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %39

33:                                               ; preds = %._crit_edge
  %34 = add nsw i64 %.021.lcssa, %.023.lcssa
  %35 = sdiv i64 %34, 2
  %36 = add nsw i64 %.018.lcssa, %.019.lcssa
  %37 = sdiv i64 %36, 2
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %35, i64 noundef %37)
  br label %39

39:                                               ; preds = %33, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  %40 = load i64, ptr %1, align 8, !tbaa !5
  %41 = add nsw i64 %40, -1
  store i64 %41, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %40, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39, !llvm.loop !11

._crit_edge40:                                    ; preds = %39, %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: 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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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