; LLVM IR from tangjz/acm-icpc :: self_training/2015-02-11 (K)

; 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::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@valid1 = external dso_local global i32, align 4
@valid2 = external dso_local global i32, align 4
@valid3 = external dso_local global i32, align 4
@A = external dso_local global %"class.std::stack", align 8
@B = external dso_local global %"class.std::queue", align 8
@C = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = 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 i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %4

4:                                                ; preds = %114, %0
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %6 = icmp ne i32 %5, -1
  br i1 %6, label %7, label %115

7:                                                ; preds = %4
  br label %8

8:                                                ; preds = %11, %7
  %9 = call noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  %10 = xor i1 %9, true
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  call void @_ZNSt5stackIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br label %8, !llvm.loop !5

12:                                               ; preds = %8
  store i32 1, ptr @valid1, align 4, !tbaa !7
  br label %13

13:                                               ; preds = %16, %12
  %14 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  %15 = xor i1 %14, true
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br label %13, !llvm.loop !11

17:                                               ; preds = %13
  store i32 1, ptr @valid2, align 4, !tbaa !7
  br label %18

18:                                               ; preds = %21, %17
  %19 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  %20 = xor i1 %19, true
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br label %18, !llvm.loop !12

22:                                               ; preds = %18
  store i32 1, ptr @valid3, align 4, !tbaa !7
  br label %23

23:                                               ; preds = %84, %22
  %24 = load i32, ptr @n, align 4, !tbaa !7
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr @n, align 4, !tbaa !7
  %26 = icmp ne i32 %24, 0
  br i1 %26, label %27, label %85

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %2, ptr noundef %3)
  %29 = load i32, ptr %2, align 4, !tbaa !7
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %44

31:                                               ; preds = %27
  %32 = load i32, ptr @valid1, align 4, !tbaa !7
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  call void @_ZNSt5stackIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) @A, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %35

35:                                               ; preds = %34, %31
  %36 = load i32, ptr @valid2, align 4, !tbaa !7
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) @B, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %39

39:                                               ; preds = %38, %35
  %40 = load i32, ptr @valid3, align 4, !tbaa !7
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) @C, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %43

43:                                               ; preds = %42, %39
  br label %84

44:                                               ; preds = %27
  %45 = load i32, ptr @valid1, align 4, !tbaa !7
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %57

47:                                               ; preds = %44
  %48 = call noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br i1 %48, label %54, label %49

49:                                               ; preds = %47
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5stackIiSt5dequeIiSaIiEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  %51 = load i32, ptr %50, align 4, !tbaa !7
  %52 = load i32, ptr %3, align 4, !tbaa !7
  %53 = icmp ne i32 %51, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %49, %47
  store i32 0, ptr @valid1, align 4, !tbaa !7
  br label %56

55:                                               ; preds = %49
  call void @_ZNSt5stackIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br label %56

56:                                               ; preds = %55, %54
  br label %57

57:                                               ; preds = %56, %44
  %58 = load i32, ptr @valid2, align 4, !tbaa !7
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %70

60:                                               ; preds = %57
  %61 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br i1 %61, label %67, label %62

62:                                               ; preds = %60
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  %64 = load i32, ptr %63, align 4, !tbaa !7
  %65 = load i32, ptr %3, align 4, !tbaa !7
  %66 = icmp ne i32 %64, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %62, %60
  store i32 0, ptr @valid2, align 4, !tbaa !7
  br label %69

68:                                               ; preds = %62
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br label %69

69:                                               ; preds = %68, %67
  br label %70

70:                                               ; preds = %69, %57
  %71 = load i32, ptr @valid3, align 4, !tbaa !7
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %83

73:                                               ; preds = %70
  %74 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br i1 %74, label %80, label %75

75:                                               ; preds = %73
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  %77 = load i32, ptr %76, align 4, !tbaa !7
  %78 = load i32, ptr %3, align 4, !tbaa !7
  %79 = icmp ne i32 %77, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %75, %73
  store i32 0, ptr @valid3, align 4, !tbaa !7
  br label %82

81:                                               ; preds = %75
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br label %82

82:                                               ; preds = %81, %80
  br label %83

83:                                               ; preds = %82, %70
  br label %84

84:                                               ; preds = %83, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %23, !llvm.loop !13

85:                                               ; preds = %23
  %86 = load i32, ptr @valid1, align 4, !tbaa !7
  %87 = load i32, ptr @valid2, align 4, !tbaa !7
  %88 = add nsw i32 %86, %87
  %89 = load i32, ptr @valid3, align 4, !tbaa !7
  %90 = add nsw i32 %88, %89
  %91 = icmp sgt i32 %90, 1
  br i1 %91, label %92, label %94

92:                                               ; preds = %85
  %93 = call i32 @puts(ptr noundef @.str.4)
  br label %114

94:                                               ; preds = %85
  %95 = load i32, ptr @valid1, align 4, !tbaa !7
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %94
  %98 = call i32 @puts(ptr noundef @.str.5)
  br label %113

99:                                               ; preds = %94
  %100 = load i32, ptr @valid2, align 4, !tbaa !7
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %104

102:                                              ; preds = %99
  %103 = call i32 @puts(ptr noundef @.str.6)
  br label %112

104:                                              ; preds = %99
  %105 = load i32, ptr @valid3, align 4, !tbaa !7
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %109

107:                                              ; preds = %104
  %108 = call i32 @puts(ptr noundef @.str.7)
  br label %111

109:                                              ; preds = %104
  %110 = call i32 @puts(ptr noundef @.str.8)
  br label %111

111:                                              ; preds = %109, %107
  br label %112

112:                                              ; preds = %111, %102
  br label %113

113:                                              ; preds = %112, %97
  br label %114

114:                                              ; preds = %113, %92
  br label %4, !llvm.loop !14

115:                                              ; preds = %4
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5stackIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5stackIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5stackIiSt5dequeIiSaIiEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #2 align 2

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

declare i32 @puts(ptr noundef) #1

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 = { 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 #3 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}


; 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::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@valid1 = external dso_local local_unnamed_addr global i32, align 4
@valid2 = external dso_local local_unnamed_addr global i32, align 4
@valid3 = external dso_local local_unnamed_addr global i32, align 4
@A = external dso_local global %"class.std::stack", align 8
@B = external dso_local global %"class.std::queue", align 8
@C = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not24 = icmp eq i32 %3, -1
  br i1 %.not24, label %._crit_edge25, label %.preheader

.preheader:                                       ; preds = %0, %65
  %4 = call noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br i1 %4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  call void @_ZNSt5stackIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  %5 = call noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br i1 %5, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  store i32 1, ptr @valid1, align 4, !tbaa !7
  %6 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br i1 %6, label %._crit_edge16, label %.lr.ph15

.lr.ph15:                                         ; preds = %._crit_edge, %.lr.ph15
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  %7 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br i1 %7, label %._crit_edge16, label %.lr.ph15, !llvm.loop !11

._crit_edge16:                                    ; preds = %.lr.ph15, %._crit_edge
  store i32 1, ptr @valid2, align 4, !tbaa !7
  %8 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br i1 %8, label %._crit_edge19, label %.lr.ph18

.lr.ph18:                                         ; preds = %._crit_edge16, %.lr.ph18
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  %9 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br i1 %9, label %._crit_edge19, label %.lr.ph18, !llvm.loop !12

._crit_edge19:                                    ; preds = %.lr.ph18, %._crit_edge16
  store i32 1, ptr @valid3, align 4, !tbaa !7
  %10 = load i32, ptr @n, align 4, !tbaa !7
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @n, align 4, !tbaa !7
  %.not120 = icmp eq i32 %10, 0
  br i1 %.not120, label %._crit_edge23, label %.lr.ph22

.lr.ph22:                                         ; preds = %._crit_edge19, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %13 = load i32, ptr %1, align 4, !tbaa !7
  %14 = icmp eq i32 %13, 1
  %15 = load i32, ptr @valid1, align 4, !tbaa !7
  %.not11 = icmp eq i32 %15, 0
  br i1 %14, label %16, label %24

16:                                               ; preds = %.lr.ph22
  br i1 %.not11, label %18, label %17

17:                                               ; preds = %16
  call void @_ZNSt5stackIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) @A, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %18

18:                                               ; preds = %17, %16
  %19 = load i32, ptr @valid2, align 4, !tbaa !7
  %.not12 = icmp eq i32 %19, 0
  br i1 %.not12, label %21, label %20

20:                                               ; preds = %18
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) @B, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %21

21:                                               ; preds = %20, %18
  %22 = load i32, ptr @valid3, align 4, !tbaa !7
  %.not13 = icmp eq i32 %22, 0
  br i1 %.not13, label %53, label %23

23:                                               ; preds = %21
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) @C, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %53

24:                                               ; preds = %.lr.ph22
  br i1 %.not11, label %33, label %25

25:                                               ; preds = %24
  %26 = call noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br i1 %26, label %31, label %27

27:                                               ; preds = %25
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5stackIiSt5dequeIiSaIiEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  %29 = load i32, ptr %28, align 4, !tbaa !7
  %30 = load i32, ptr %2, align 4, !tbaa !7
  %.not6 = icmp eq i32 %29, %30
  br i1 %.not6, label %32, label %31

31:                                               ; preds = %27, %25
  store i32 0, ptr @valid1, align 4, !tbaa !7
  br label %33

32:                                               ; preds = %27
  call void @_ZNSt5stackIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @A)
  br label %33

33:                                               ; preds = %31, %32, %24
  %34 = load i32, ptr @valid2, align 4, !tbaa !7
  %.not7 = icmp eq i32 %34, 0
  br i1 %.not7, label %43, label %35

35:                                               ; preds = %33
  %36 = call noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br i1 %36, label %41, label %37

37:                                               ; preds = %35
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  %39 = load i32, ptr %38, align 4, !tbaa !7
  %40 = load i32, ptr %2, align 4, !tbaa !7
  %.not8 = icmp eq i32 %39, %40
  br i1 %.not8, label %42, label %41

41:                                               ; preds = %37, %35
  store i32 0, ptr @valid2, align 4, !tbaa !7
  br label %43

42:                                               ; preds = %37
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @B)
  br label %43

43:                                               ; preds = %41, %42, %33
  %44 = load i32, ptr @valid3, align 4, !tbaa !7
  %.not9 = icmp eq i32 %44, 0
  br i1 %.not9, label %53, label %45

45:                                               ; preds = %43
  %46 = call noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br i1 %46, label %51, label %47

47:                                               ; preds = %45
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  %49 = load i32, ptr %48, align 4, !tbaa !7
  %50 = load i32, ptr %2, align 4, !tbaa !7
  %.not10 = icmp eq i32 %49, %50
  br i1 %.not10, label %52, label %51

51:                                               ; preds = %47, %45
  store i32 0, ptr @valid3, align 4, !tbaa !7
  br label %53

52:                                               ; preds = %47
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @C)
  br label %53

53:                                               ; preds = %43, %52, %51, %21, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %54 = load i32, ptr @n, align 4, !tbaa !7
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr @n, align 4, !tbaa !7
  %.not1 = icmp eq i32 %54, 0
  br i1 %.not1, label %._crit_edge23.loopexit, label %.lr.ph22, !llvm.loop !13

._crit_edge23.loopexit:                           ; preds = %53
  %.pre = load i32, ptr @valid3, align 4, !tbaa !7
  br label %._crit_edge23

._crit_edge23:                                    ; preds = %._crit_edge23.loopexit, %._crit_edge19
  %56 = phi i32 [ %.pre, %._crit_edge23.loopexit ], [ 1, %._crit_edge19 ]
  %57 = load i32, ptr @valid1, align 4, !tbaa !7
  %58 = load i32, ptr @valid2, align 4, !tbaa !7
  %59 = add nsw i32 %58, %57
  %60 = add nsw i32 %59, %56
  %61 = icmp sgt i32 %60, 1
  br i1 %61, label %65, label %62

62:                                               ; preds = %._crit_edge23
  %.not2 = icmp eq i32 %57, 0
  br i1 %.not2, label %63, label %65

63:                                               ; preds = %62
  %.not3 = icmp eq i32 %58, 0
  br i1 %.not3, label %64, label %65

64:                                               ; preds = %63
  %.not4 = icmp eq i32 %56, 0
  %.str.8..str.7 = select i1 %.not4, ptr @.str.8, ptr @.str.7
  br label %65

65:                                               ; preds = %64, %63, %62, %._crit_edge23
  %.str.5.sink = phi ptr [ @.str.4, %._crit_edge23 ], [ @.str.5, %62 ], [ @.str.6, %63 ], [ %.str.8..str.7, %64 ]
  %66 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.5.sink)
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not = icmp eq i32 %67, -1
  br i1 %.not, label %._crit_edge25, label %.preheader, !llvm.loop !14

._crit_edge25:                                    ; preds = %65, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5stackIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5stackIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueIiSt5dequeIiSaIiEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5stackIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5stackIiSt5dequeIiSaIiEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #2 align 2

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

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

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 = { 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 #2 = { 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 #3 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}


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