; LLVM IR from TLE-MEC/Hack-CP-DSA :: Hackerrank/Swap Nodes (solution)

; 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_ostream" = type { ptr, %"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_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl" }
%"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl" = type { %"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.node = type { i32, i32, ptr, ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z10createNodeii(i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9swapNodesP4nodei(ptr noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7inOrderP4node(ptr noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::queue", align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 80, ptr %4) #7
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %19 = invoke noundef ptr @_Z10createNodeii(i32 noundef 1, i32 noundef 1)
          to label %20 unwind label %28

20:                                               ; preds = %0
  store ptr %19, ptr %6, align 8, !tbaa !5
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(80) %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %21 unwind label %28

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %22, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %92, %21
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %32, label %27

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

28:                                               ; preds = %20, %0
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %7, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %8, align 4
  br label %147

32:                                               ; preds = %23
  %33 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %34 unwind label %80

34:                                               ; preds = %32
  %35 = load ptr, ptr %33, align 8, !tbaa !5
  store ptr %35, ptr %6, align 8, !tbaa !5
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %36 unwind label %80

36:                                               ; preds = %34
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %88

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %40 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %12)
          to label %41 unwind label %84

41:                                               ; preds = %39
  %42 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef nonnull align 4 dereferenceable(4) %13)
          to label %43 unwind label %84

43:                                               ; preds = %41
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.node, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %10, align 4, !tbaa !9
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = icmp ne i32 %48, -1
  br i1 %49, label %50, label %55

50:                                               ; preds = %43
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = invoke noundef ptr @_Z10createNodeii(i32 noundef %51, i32 noundef %52)
          to label %54 unwind label %84

54:                                               ; preds = %50
  br label %57

55:                                               ; preds = %43
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %55, %54
  %58 = phi ptr [ %53, %54 ], [ %56, %55 ]
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.node, ptr %59, i32 0, i32 2
  store ptr %58, ptr %60, align 8, !tbaa !13
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = icmp ne i32 %61, -1
  br i1 %62, label %63, label %68

63:                                               ; preds = %57
  %64 = load i32, ptr %13, align 4, !tbaa !9
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = invoke noundef ptr @_Z10createNodeii(i32 noundef %64, i32 noundef %65)
          to label %67 unwind label %84

67:                                               ; preds = %63
  br label %70

68:                                               ; preds = %57
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %68, %67
  %71 = phi ptr [ %66, %67 ], [ %69, %68 ]
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.node, ptr %72, i32 0, i32 3
  store ptr %71, ptr %73, align 8, !tbaa !14
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.node, ptr %74, i32 0, i32 2
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(80) %4, ptr noundef nonnull align 8 dereferenceable(8) %75)
          to label %76 unwind label %84

76:                                               ; preds = %70
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.node, ptr %77, i32 0, i32 3
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(80) %4, ptr noundef nonnull align 8 dereferenceable(8) %78)
          to label %79 unwind label %84

79:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %91

80:                                               ; preds = %34, %32
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %7, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %8, align 4
  br label %95

84:                                               ; preds = %76, %70, %63, %50, %41, %39
  %85 = landingpad { ptr, i32 }
          cleanup
  %86 = extractvalue { ptr, i32 } %85, 0
  store ptr %86, ptr %7, align 8
  %87 = extractvalue { ptr, i32 } %85, 1
  store i32 %87, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %95

88:                                               ; preds = %36
  %89 = load i32, ptr %11, align 4, !tbaa !9
  %90 = add nsw i32 %89, -1
  store i32 %90, ptr %11, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %88, %79
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %11, align 4, !tbaa !9
  br label %23, !llvm.loop !15

95:                                               ; preds = %84, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %146

96:                                               ; preds = %27
  %97 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %98 unwind label %104

98:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %99

99:                                               ; preds = %140, %98
  %100 = load i32, ptr %14, align 4, !tbaa !9
  %101 = load i32, ptr %3, align 4, !tbaa !9
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %108, label %103

103:                                              ; preds = %99
  store i32 5, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %144

104:                                              ; preds = %96
  %105 = landingpad { ptr, i32 }
          cleanup
  %106 = extractvalue { ptr, i32 } %105, 0
  store ptr %106, ptr %7, align 8
  %107 = extractvalue { ptr, i32 } %105, 1
  store i32 %107, ptr %8, align 4
  br label %146

108:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %109 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %16)
          to label %110 unwind label %118

110:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %128, %110
  %112 = load i32, ptr %17, align 4, !tbaa !9
  %113 = load i32, ptr %16, align 4, !tbaa !9
  %114 = mul nsw i32 %112, %113
  %115 = load i32, ptr %10, align 4, !tbaa !9
  %116 = icmp slt i32 %114, %115
  br i1 %116, label %122, label %117

117:                                              ; preds = %111
  store i32 8, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %135

118:                                              ; preds = %137, %135, %108
  %119 = landingpad { ptr, i32 }
          cleanup
  %120 = extractvalue { ptr, i32 } %119, 0
  store ptr %120, ptr %7, align 8
  %121 = extractvalue { ptr, i32 } %119, 1
  store i32 %121, ptr %8, align 4
  br label %143

122:                                              ; preds = %111
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = load i32, ptr %17, align 4, !tbaa !9
  %125 = load i32, ptr %16, align 4, !tbaa !9
  %126 = mul nsw i32 %124, %125
  invoke void @_Z9swapNodesP4nodei(ptr noundef %123, i32 noundef %126)
          to label %127 unwind label %131

127:                                              ; preds = %122
  br label %128

128:                                              ; preds = %127
  %129 = load i32, ptr %17, align 4, !tbaa !9
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %17, align 4, !tbaa !9
  br label %111, !llvm.loop !17

131:                                              ; preds = %122
  %132 = landingpad { ptr, i32 }
          cleanup
  %133 = extractvalue { ptr, i32 } %132, 0
  store ptr %133, ptr %7, align 8
  %134 = extractvalue { ptr, i32 } %132, 1
  store i32 %134, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %143

135:                                              ; preds = %117
  %136 = load ptr, ptr %9, align 8, !tbaa !5
  invoke void @_Z7inOrderP4node(ptr noundef %136)
          to label %137 unwind label %118

137:                                              ; preds = %135
  %138 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %139 unwind label %118

139:                                              ; preds = %137
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %14, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %14, align 4, !tbaa !9
  br label %99, !llvm.loop !18

143:                                              ; preds = %131, %118
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %146

144:                                              ; preds = %103
  store i32 0, ptr %1, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %4) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %145 = load i32, ptr %1, align 4
  ret i32 %145

146:                                              ; preds = %143, %104, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %147

147:                                              ; preds = %146, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %4) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %148

148:                                              ; preds = %147
  %149 = load ptr, ptr %7, align 8
  %150 = load i32, ptr %8, align 4
  %151 = insertvalue { ptr, i32 } poison, ptr %149, 0
  %152 = insertvalue { ptr, i32 } %151, i32 %150, 1
  resume { ptr, i32 } %152
}

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 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)) #5

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

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


; 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_ostream" = type { ptr, %"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_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl" }
%"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl" = type { %"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<node *, std::allocator<node *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z10createNodeii(i32 noundef, i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9swapNodesP4nodei(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7inOrderP4node(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::queue", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %3) #7
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %9 = invoke noundef ptr @_Z10createNodeii(i32 noundef 1, i32 noundef 1)
          to label %10 unwind label %34

10:                                               ; preds = %0
  store ptr %9, ptr %4, align 8, !tbaa !5
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %11 unwind label %34

11:                                               ; preds = %10
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %71, %11
  %.019.lcssa = phi i32 [ undef, %11 ], [ %.120, %71 ]
  %.019.lcssa.fr = freeze i32 %.019.lcssa
  %15 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %.preheader35 unwind label %75

.preheader35:                                     ; preds = %._crit_edge
  %16 = load i32, ptr %2, align 4, !tbaa !9
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph43, label %._crit_edge44

.lr.ph43:                                         ; preds = %.preheader35
  %18 = icmp sgt i32 %.019.lcssa.fr, 0
  br i1 %18, label %.lr.ph43.split.us, label %.lr.ph43.split

.lr.ph43.split.us:                                ; preds = %.lr.ph43, %22
  %.01742.us = phi i32 [ %23, %22 ], [ 0, %.lr.ph43 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %19 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %.preheader.us unwind label %.split.us

20:                                               ; preds = %._crit_edge41.us
  %21 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %22 unwind label %.split.us

22:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  %23 = add nuw nsw i32 %.01742.us, 1
  %24 = load i32, ptr %2, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %.lr.ph43.split.us, label %._crit_edge44, !llvm.loop !11

.preheader.us:                                    ; preds = %.lr.ph43.split.us, %27
  %26 = phi i32 [ %30, %27 ], [ 0, %.lr.ph43.split.us ]
  %.039.us = phi i32 [ %28, %27 ], [ 0, %.lr.ph43.split.us ]
  invoke void @_Z9swapNodesP4nodei(ptr noundef %12, i32 noundef %26)
          to label %27 unwind label %.split46.us

27:                                               ; preds = %.preheader.us
  %28 = add nuw nsw i32 %.039.us, 1
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = mul nsw i32 %29, %28
  %31 = icmp slt i32 %30, %.019.lcssa.fr
  br i1 %31, label %.preheader.us, label %._crit_edge41.us, !llvm.loop !13

._crit_edge41.us:                                 ; preds = %27
  invoke void @_Z7inOrderP4node(ptr noundef %12)
          to label %20 unwind label %.split.us

.split.us:                                        ; preds = %20, %._crit_edge41.us, %.lr.ph43.split.us
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %85

.split46.us:                                      ; preds = %.preheader.us
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %85

34:                                               ; preds = %10, %0
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %86

.lr.ph:                                           ; preds = %11, %71
  %.01838 = phi i32 [ %72, %71 ], [ 0, %11 ]
  %.01937 = phi i32 [ %.120, %71 ], [ undef, %11 ]
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  store ptr %37, ptr %4, align 8, !tbaa !5
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %38, null
  br i1 %.not, label %69, label %39

39:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  %40 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %41 unwind label %67

41:                                               ; preds = %39
  %42 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef nonnull align 4 dereferenceable(4) %6)
          to label %43 unwind label %67

43:                                               ; preds = %41
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 4
  %46 = load i32, ptr %45, align 4, !tbaa !14
  %47 = add nsw i32 %46, 1
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %.not30 = icmp eq i32 %48, -1
  br i1 %.not30, label %51, label %49

49:                                               ; preds = %43
  %50 = invoke noundef ptr @_Z10createNodeii(i32 noundef %48, i32 noundef %47)
          to label %._crit_edge49 unwind label %67

._crit_edge49:                                    ; preds = %49
  %.pre = load ptr, ptr %4, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %._crit_edge49, %43
  %52 = phi ptr [ %.pre, %._crit_edge49 ], [ %44, %43 ]
  %53 = phi ptr [ %50, %._crit_edge49 ], [ null, %43 ]
  %54 = getelementptr inbounds i8, ptr %52, i64 8
  store ptr %53, ptr %54, align 8, !tbaa !16
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %.not31 = icmp eq i32 %55, -1
  br i1 %.not31, label %58, label %56

56:                                               ; preds = %51
  %57 = invoke noundef ptr @_Z10createNodeii(i32 noundef %55, i32 noundef %47)
          to label %._crit_edge50 unwind label %67

._crit_edge50:                                    ; preds = %56
  %.pre51 = load ptr, ptr %4, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %._crit_edge50, %51
  %59 = phi ptr [ %.pre51, %._crit_edge50 ], [ %52, %51 ]
  %60 = phi ptr [ %57, %._crit_edge50 ], [ null, %51 ]
  %61 = getelementptr inbounds i8, ptr %59, i64 16
  store ptr %60, ptr %61, align 8, !tbaa !17
  %62 = getelementptr inbounds i8, ptr %59, i64 8
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %62)
          to label %63 unwind label %67

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 16
  invoke void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %65)
          to label %66 unwind label %67

66:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  br label %71

67:                                               ; preds = %63, %58, %56, %49, %41, %39
  %68 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  br label %86

69:                                               ; preds = %.lr.ph
  %70 = add nsw i32 %.01838, -1
  br label %71

71:                                               ; preds = %66, %69
  %.120 = phi i32 [ %47, %66 ], [ %.01937, %69 ]
  %.1 = phi i32 [ %.01838, %66 ], [ %70, %69 ]
  %72 = add nsw i32 %.1, 1
  %73 = load i32, ptr %1, align 4, !tbaa !9
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge44:                                    ; preds = %81, %22, %.preheader35
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

75:                                               ; preds = %._crit_edge
  %76 = landingpad { ptr, i32 }
          cleanup
  br label %86

.lr.ph43.split:                                   ; preds = %.lr.ph43, %81
  %.01742 = phi i32 [ %82, %81 ], [ 0, %.lr.ph43 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %77 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %.preheader unwind label %.split

.preheader:                                       ; preds = %.lr.ph43.split
  invoke void @_Z7inOrderP4node(ptr noundef %12)
          to label %79 unwind label %.split

.split:                                           ; preds = %79, %.preheader, %.lr.ph43.split
  %78 = landingpad { ptr, i32 }
          cleanup
  br label %85

79:                                               ; preds = %.preheader
  %80 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %81 unwind label %.split

81:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  %82 = add nuw nsw i32 %.01742, 1
  %83 = load i32, ptr %2, align 4, !tbaa !9
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %.lr.ph43.split, label %._crit_edge44, !llvm.loop !11

85:                                               ; preds = %.split, %.split.us, %.split46.us
  %.pn = phi { ptr, i32 } [ %33, %.split46.us ], [ %78, %.split ], [ %32, %.split.us ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  br label %86

86:                                               ; preds = %67, %75, %85, %34
  %.pn32.pn = phi { ptr, i32 } [ %35, %34 ], [ %68, %67 ], [ %.pn, %85 ], [ %76, %75 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @_ZNSt5queueIP4nodeSt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  resume { ptr, i32 } %.pn32.pn
}

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 #3

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; 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 #0 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)) #5

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

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


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