; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/311 Division 2/Problem A (A)

; 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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@x1 = external dso_local global i32, align 4
@x2 = external dso_local global i32, align 4
@x3 = external dso_local global i32, align 4
@x4 = external dso_local global i32, align 4
@x5 = external dso_local global i32, align 4
@x6 = external dso_local global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x1, ptr noundef @x2)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x3, ptr noundef @x4)
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x5, ptr noundef @x6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %9 = load i32, ptr @x1, align 4, !tbaa !5
  store i32 %9, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %10 = load i32, ptr @x3, align 4, !tbaa !5
  store i32 %10, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %11 = load i32, ptr @x5, align 4, !tbaa !5
  store i32 %11, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr @x1, align 4, !tbaa !5
  %13 = load i32, ptr @x3, align 4, !tbaa !5
  %14 = add nsw i32 %12, %13
  %15 = load i32, ptr @x5, align 4, !tbaa !5
  %16 = add nsw i32 %14, %15
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sub nsw i32 %17, %16
  store i32 %18, ptr @n, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = load i32, ptr @x2, align 4, !tbaa !5
  %21 = load i32, ptr @x1, align 4, !tbaa !5
  %22 = sub nsw i32 %20, %21
  %23 = icmp sge i32 %19, %22
  br i1 %23, label %24, label %31

24:                                               ; preds = %0
  %25 = load i32, ptr @x2, align 4, !tbaa !5
  %26 = load i32, ptr @x1, align 4, !tbaa !5
  %27 = sub nsw i32 %25, %26
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sub nsw i32 %28, %27
  store i32 %29, ptr @n, align 4, !tbaa !5
  %30 = load i32, ptr @x2, align 4, !tbaa !5
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %35

31:                                               ; preds = %0
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, %32
  store i32 %34, ptr %2, align 4, !tbaa !5
  store i32 0, ptr @n, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %31, %24
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = load i32, ptr @x4, align 4, !tbaa !5
  %38 = load i32, ptr @x3, align 4, !tbaa !5
  %39 = sub nsw i32 %37, %38
  %40 = icmp sge i32 %36, %39
  br i1 %40, label %41, label %48

41:                                               ; preds = %35
  %42 = load i32, ptr @x4, align 4, !tbaa !5
  %43 = load i32, ptr @x3, align 4, !tbaa !5
  %44 = sub nsw i32 %42, %43
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = sub nsw i32 %45, %44
  store i32 %46, ptr @n, align 4, !tbaa !5
  %47 = load i32, ptr @x4, align 4, !tbaa !5
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %52

48:                                               ; preds = %35
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = add nsw i32 %50, %49
  store i32 %51, ptr %3, align 4, !tbaa !5
  store i32 0, ptr @n, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %48, %41
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = load i32, ptr @x6, align 4, !tbaa !5
  %55 = load i32, ptr @x5, align 4, !tbaa !5
  %56 = sub nsw i32 %54, %55
  %57 = icmp sge i32 %53, %56
  br i1 %57, label %58, label %65

58:                                               ; preds = %52
  %59 = load i32, ptr @x6, align 4, !tbaa !5
  %60 = load i32, ptr @x5, align 4, !tbaa !5
  %61 = sub nsw i32 %59, %60
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = sub nsw i32 %62, %61
  store i32 %63, ptr @n, align 4, !tbaa !5
  %64 = load i32, ptr @x6, align 4, !tbaa !5
  store i32 %64, ptr %4, align 4, !tbaa !5
  br label %69

65:                                               ; preds = %52
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = add nsw i32 %67, %66
  store i32 %68, ptr %4, align 4, !tbaa !5
  store i32 0, ptr @n, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %65, %58
  %70 = load i32, ptr %2, align 4, !tbaa !5
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %70)
  %72 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %71, ptr noundef @.str.1)
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %72, i32 noundef %73)
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %74, ptr noundef @.str.1)
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %75, i32 noundef %76)
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %77, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(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) #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 = { "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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 = { mustprogress 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@x1 = external dso_local global i32, align 4
@x2 = external dso_local global i32, align 4
@x3 = external dso_local global i32, align 4
@x4 = external dso_local global i32, align 4
@x5 = external dso_local global i32, align 4
@x6 = external dso_local global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x1, ptr noundef nonnull @x2)
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x3, ptr noundef nonnull @x4)
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x5, ptr noundef nonnull @x6)
  %5 = load i32, ptr @x1, align 4, !tbaa !5
  %6 = load i32, ptr @x3, align 4, !tbaa !5
  %7 = load i32, ptr @x5, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = add i32 %6, %5
  %10 = add i32 %9, %7
  %11 = sub i32 %8, %10
  %12 = load i32, ptr @x2, align 4, !tbaa !5
  %13 = sub nsw i32 %12, %5
  %.not = icmp slt i32 %11, %13
  %14 = sub nsw i32 %11, %13
  %15 = add nsw i32 %11, %5
  %storemerge = select i1 %.not, i32 0, i32 %14
  %.07 = select i1 %.not, i32 %15, i32 %12
  %16 = load i32, ptr @x4, align 4, !tbaa !5
  %17 = sub nsw i32 %16, %6
  %.not16 = icmp slt i32 %storemerge, %17
  %18 = sub nsw i32 %storemerge, %17
  %19 = add nsw i32 %storemerge, %6
  %storemerge18 = select i1 %.not16, i32 0, i32 %18
  %.06 = select i1 %.not16, i32 %19, i32 %16
  %20 = load i32, ptr @x6, align 4, !tbaa !5
  %21 = sub nsw i32 %20, %7
  %.not17 = icmp slt i32 %storemerge18, %21
  %22 = sub nsw i32 %storemerge18, %21
  %23 = add nsw i32 %storemerge18, %7
  %storemerge19 = select i1 %.not17, i32 0, i32 %22
  %.0 = select i1 %.not17, i32 %23, i32 %20
  store i32 %storemerge19, ptr @n, align 4, !tbaa !5
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.07)
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull @.str.1)
  %26 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %25, i32 noundef %.06)
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %26, ptr noundef nonnull @.str.1)
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %27, i32 noundef %.0)
  %29 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { "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 #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 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 = { mustprogress 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" }

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass