; LLVM IR from ravireddy07/cpp-book :: src/Code-Chef/JAN2021-Long/CURMAT.ll (Z5mergeiii)

; 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<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@par = external dso_local global [200000 x i32], align 16
@sz = external dso_local global [200000 x i32], align 16
@weight = external dso_local global [200000 x i32], align 16
@cnt_of_components = external dso_local global i32, align 4
@cnt_of_bad_edges = external dso_local global i32, align 4
@stk = external dso_local global %"class.std::stack", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7calcInvii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z11mul_to_rooti(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5mergeiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %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
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %30 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %30, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = add nsw i32 %31, %32
  store i32 %33, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = call noundef i32 @_Z4findi(i32 noundef %34)
  store i32 %35, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = call noundef i32 @_Z4findi(i32 noundef %36)
  store i32 %37, ptr %10, align 4, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !5
  %40 = icmp ne i32 %38, %39
  br i1 %40, label %41, label %160

41:                                               ; preds = %3
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp slt i32 %45, %49
  br i1 %50, label %51, label %103

51:                                               ; preds = %41
  %52 = load i32, ptr %9, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %53
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %56
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %59
  %61 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJRiS7_S7_S7_S7_EEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %54, ptr noundef nonnull align 4 dereferenceable(4) %57, ptr noundef nonnull align 4 dereferenceable(4) %60)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %62)
  store i32 %63, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %64)
  store i32 %65, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = load i32, ptr %12, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = mul nsw i64 %67, %69
  %71 = load i32, ptr @p, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = srem i64 %70, %72
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = load i32, ptr @p, align 4, !tbaa !5
  %76 = call noundef i32 @_Z7calcInvii(i32 noundef %74, i32 noundef %75)
  %77 = sext i32 %76 to i64
  %78 = mul nsw i64 %73, %77
  %79 = load i32, ptr @p, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = srem i64 %78, %80
  %82 = trunc i64 %81 to i32
  store i32 %82, ptr %13, align 4, !tbaa !5
  %83 = load i32, ptr %13, align 4, !tbaa !5
  %84 = load i32, ptr %9, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %85
  store i32 %83, ptr %86, align 4, !tbaa !5
  %87 = load i32, ptr %10, align 4, !tbaa !5
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %89
  store i32 %87, ptr %90, align 4, !tbaa !5
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr %10, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = add nsw i32 %98, %94
  store i32 %99, ptr %97, align 4, !tbaa !5
  %100 = load i32, ptr %9, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %101
  store i32 0, ptr %102, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %157

103:                                              ; preds = %41
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %105
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %108
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %111
  %113 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJRiS7_S7_S7_S7_EEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %106, ptr noundef nonnull align 4 dereferenceable(4) %109, ptr noundef nonnull align 4 dereferenceable(4) %112)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %114)
  store i32 %115, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %116)
  store i32 %117, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %118 = load i32, ptr %6, align 4, !tbaa !5
  %119 = load i32, ptr @p, align 4, !tbaa !5
  %120 = call noundef i32 @_Z7calcInvii(i32 noundef %118, i32 noundef %119)
  %121 = sext i32 %120 to i64
  %122 = load i32, ptr %15, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = mul nsw i64 %121, %123
  %125 = load i32, ptr @p, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = srem i64 %124, %126
  %128 = load i32, ptr %14, align 4, !tbaa !5
  %129 = load i32, ptr @p, align 4, !tbaa !5
  %130 = call noundef i32 @_Z7calcInvii(i32 noundef %128, i32 noundef %129)
  %131 = sext i32 %130 to i64
  %132 = mul nsw i64 %127, %131
  %133 = load i32, ptr @p, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = srem i64 %132, %134
  %136 = trunc i64 %135 to i32
  store i32 %136, ptr %16, align 4, !tbaa !5
  %137 = load i32, ptr %16, align 4, !tbaa !5
  %138 = load i32, ptr %10, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %139
  store i32 %137, ptr %140, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = load i32, ptr %10, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %143
  store i32 %141, ptr %144, align 4, !tbaa !5
  %145 = load i32, ptr %10, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = load i32, ptr %9, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = add nsw i32 %152, %148
  store i32 %153, ptr %151, align 4, !tbaa !5
  %154 = load i32, ptr %10, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %155
  store i32 0, ptr %156, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %157

157:                                              ; preds = %103, %51
  %158 = load i32, ptr @cnt_of_components, align 4, !tbaa !5
  %159 = add nsw i32 %158, -1
  store i32 %159, ptr @cnt_of_components, align 4, !tbaa !5
  br label %196

160:                                              ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %161 = load i32, ptr %7, align 4, !tbaa !5
  %162 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %161)
  store i32 %162, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %163 = load i32, ptr %8, align 4, !tbaa !5
  %164 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %163)
  store i32 %164, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %165 = load i32, ptr %17, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = load i32, ptr %18, align 4, !tbaa !5
  %168 = load i32, ptr @p, align 4, !tbaa !5
  %169 = call noundef i32 @_Z7calcInvii(i32 noundef %167, i32 noundef %168)
  %170 = sext i32 %169 to i64
  %171 = mul nsw i64 %166, %170
  %172 = load i32, ptr @p, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = srem i64 %171, %173
  %175 = trunc i64 %174 to i32
  store i32 %175, ptr %19, align 4, !tbaa !5
  %176 = load i32, ptr %19, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = load i32, ptr %6, align 4, !tbaa !5
  %179 = load i32, ptr @p, align 4, !tbaa !5
  %180 = call noundef i32 @_Z7calcInvii(i32 noundef %178, i32 noundef %179)
  %181 = sext i32 %180 to i64
  %182 = mul nsw i64 %177, %181
  %183 = load i32, ptr @p, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = srem i64 %182, %184
  %186 = trunc i64 %185 to i32
  store i32 %186, ptr %19, align 4, !tbaa !5
  %187 = load i32, ptr %19, align 4, !tbaa !5
  %188 = icmp eq i32 %187, 1
  br i1 %188, label %189, label %191

189:                                              ; preds = %160
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store i32 -1, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  store i32 -1, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store i32 -1, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  store i32 -1, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  store i32 -1, ptr %24, align 4, !tbaa !5
  %190 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJiiiiiEEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %20, ptr noundef nonnull align 4 dereferenceable(4) %21, ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %23, ptr noundef nonnull align 4 dereferenceable(4) %24)
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  br label %195

191:                                              ; preds = %160
  %192 = load i32, ptr @cnt_of_bad_edges, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr @cnt_of_bad_edges, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  store i32 -2, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #3
  store i32 -2, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  store i32 -2, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  store i32 -2, ptr %28, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  store i32 -2, ptr %29, align 4, !tbaa !5
  %194 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJiiiiiEEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %26, ptr noundef nonnull align 4 dereferenceable(4) %27, ptr noundef nonnull align 4 dereferenceable(4) %28, ptr noundef nonnull align 4 dereferenceable(4) %29)
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  br label %195

195:                                              ; preds = %191, %189
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %196

196:                                              ; preds = %195, %157
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"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::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::tuple<int, int, int, int, int>, std::allocator<std::tuple<int, int, int, int, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@n = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local local_unnamed_addr global i32, align 4
@par = external dso_local global [200000 x i32], align 16
@sz = external dso_local global [200000 x i32], align 16
@weight = external dso_local global [200000 x i32], align 16
@cnt_of_components = external dso_local local_unnamed_addr global i32, align 4
@cnt_of_bad_edges = external dso_local local_unnamed_addr global i32, align 4
@stk = external dso_local global %"class.std::stack", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7calcInvii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z11mul_to_rooti(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5mergeiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %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 = load i32, ptr @n, align 4, !tbaa !5
  %17 = add nsw i32 %16, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %18 = tail call noundef i32 @_Z4findi(i32 noundef %0)
  store i32 %18, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %19 = tail call noundef i32 @_Z4findi(i32 noundef %17)
  store i32 %19, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %18, %19
  br i1 %.not, label %78, label %20

20:                                               ; preds = %3
  %21 = sext i32 %18 to i64
  %22 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %19 to i64
  %25 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp slt i32 %23, %26
  br i1 %27, label %28, label %46

28:                                               ; preds = %20
  %29 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %21
  %30 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %21
  %31 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJRiS7_S7_S7_S7_EEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %29, ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %30)
  %32 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %0)
  %33 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %17)
  %34 = sext i32 %2 to i64
  %35 = sext i32 %33 to i64
  %36 = mul nsw i64 %35, %34
  %37 = load i32, ptr @p, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = srem i64 %36, %38
  %40 = call noundef i32 @_Z7calcInvii(i32 noundef %32, i32 noundef %37)
  %41 = sext i32 %40 to i64
  %42 = mul nsw i64 %39, %41
  %43 = load i32, ptr @p, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = srem i64 %42, %44
  br label %66

46:                                               ; preds = %20
  %47 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %24
  %48 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %24
  %49 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJRiS7_S7_S7_S7_EEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %48)
  %50 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %17)
  %51 = call noundef i32 @_Z11mul_to_rooti(i32 noundef %0)
  %52 = load i32, ptr @p, align 4, !tbaa !5
  %53 = call noundef i32 @_Z7calcInvii(i32 noundef %2, i32 noundef %52)
  %54 = sext i32 %53 to i64
  %55 = sext i32 %51 to i64
  %56 = mul nsw i64 %54, %55
  %57 = load i32, ptr @p, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = srem i64 %56, %58
  %60 = call noundef i32 @_Z7calcInvii(i32 noundef %50, i32 noundef %57)
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %59, %61
  %63 = load i32, ptr @p, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = srem i64 %62, %64
  br label %66

66:                                               ; preds = %46, %28
  %.sink38.in = phi ptr [ %5, %46 ], [ %4, %28 ]
  %.sink35.in = phi i64 [ %65, %46 ], [ %45, %28 ]
  %.sink.in = phi ptr [ %4, %46 ], [ %5, %28 ]
  %.sink35 = trunc i64 %.sink35.in to i32
  %.sink38 = load i32, ptr %.sink38.in, align 4, !tbaa !5
  %67 = sext i32 %.sink38 to i64
  %68 = getelementptr inbounds [200000 x i32], ptr @weight, i64 0, i64 %67
  store i32 %.sink35, ptr %68, align 4, !tbaa !5
  %.sink = load i32, ptr %.sink.in, align 4, !tbaa !5
  %69 = getelementptr inbounds [200000 x i32], ptr @par, i64 0, i64 %67
  store i32 %.sink, ptr %69, align 4, !tbaa !5
  %70 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %67
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = sext i32 %.sink to i64
  %73 = getelementptr inbounds [200000 x i32], ptr @sz, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, %71
  store i32 %75, ptr %73, align 4, !tbaa !5
  store i32 0, ptr %70, align 4, !tbaa !5
  %76 = load i32, ptr @cnt_of_components, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr @cnt_of_components, align 4, !tbaa !5
  br label %102

78:                                               ; preds = %3
  %79 = tail call noundef i32 @_Z11mul_to_rooti(i32 noundef %0)
  %80 = tail call noundef i32 @_Z11mul_to_rooti(i32 noundef %17)
  %81 = sext i32 %79 to i64
  %82 = load i32, ptr @p, align 4, !tbaa !5
  %83 = tail call noundef i32 @_Z7calcInvii(i32 noundef %80, i32 noundef %82)
  %84 = sext i32 %83 to i64
  %85 = mul nsw i64 %84, %81
  %86 = load i32, ptr @p, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = srem i64 %85, %87
  %89 = tail call noundef i32 @_Z7calcInvii(i32 noundef %2, i32 noundef %86)
  %90 = sext i32 %89 to i64
  %91 = mul nsw i64 %88, %90
  %92 = load i32, ptr @p, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = srem i64 %91, %93
  %95 = icmp eq i64 %94, 1
  br i1 %95, label %96, label %98

96:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  store i32 -1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  store i32 -1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  store i32 -1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  store i32 -1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  store i32 -1, ptr %10, align 4, !tbaa !5
  %97 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJiiiiiEEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  br label %102

98:                                               ; preds = %78
  %99 = load i32, ptr @cnt_of_bad_edges, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr @cnt_of_bad_edges, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  store i32 -2, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  store i32 -2, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #3
  store i32 -2, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #3
  store i32 -2, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #3
  store i32 -2, ptr %15, align 4, !tbaa !5
  %101 = call noundef nonnull align 1 ptr @_ZNSt5stackISt5tupleIJiiiiiEESt5dequeIS1_SaIS1_EEE7emplaceIJiiiiiEEEDcDpOT_(ptr noundef nonnull align 8 dereferenceable(80) @stk, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %15)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  br label %102

102:                                              ; preds = %96, %98, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  ret void
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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