; LLVM IR from Thre4dripper/DSA-Programs :: 06. Circular Doubly Linked Lists/Insertion.ll (Z13insertAtIndexiiPP4NodePi)

; 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 }
%struct.Node = type { i32, ptr, ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13insertAtIndexiiPP4NodePi(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = icmp sge i32 %13, 0
  br i1 %14, label %15, label %226

15:                                               ; preds = %4
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !9
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = icmp sle i32 %16, %18
  br i1 %19, label %20, label %226

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %21 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #5
  store ptr %21, ptr %9, align 8, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.Node, ptr %23, i32 0, i32 0
  store i32 %22, ptr %24, align 8, !tbaa !11
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %32, label %27

27:                                               ; preds = %20
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp eq i32 %28, %30
  br i1 %31, label %32, label %147

32:                                               ; preds = %27, %20
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.Node, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = icmp eq ptr %36, %38
  br i1 %39, label %40, label %55

40:                                               ; preds = %32
  %41 = load ptr, ptr %9, align 8, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.Node, ptr %43, i32 0, i32 1
  store ptr %41, ptr %44, align 8, !tbaa !13
  %45 = load ptr, ptr %9, align 8, !tbaa !9
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 2
  store ptr %45, ptr %48, align 8, !tbaa !14
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.Node, ptr %50, i32 0, i32 1
  store ptr %49, ptr %51, align 8, !tbaa !13
  %52 = load ptr, ptr %9, align 8, !tbaa !9
  %53 = load ptr, ptr %9, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.Node, ptr %53, i32 0, i32 2
  store ptr %52, ptr %54, align 8, !tbaa !14
  br label %146

55:                                               ; preds = %32
  %56 = load ptr, ptr %7, align 8, !tbaa !9
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.Node, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !13
  %60 = getelementptr inbounds %struct.Node, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = load ptr, ptr %7, align 8, !tbaa !9
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.Node, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = icmp eq ptr %61, %65
  br i1 %66, label %67, label %104

67:                                               ; preds = %55
  %68 = load ptr, ptr %7, align 8, !tbaa !9
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.Node, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = load ptr, ptr %9, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.Node, ptr %72, i32 0, i32 1
  store ptr %71, ptr %73, align 8, !tbaa !13
  %74 = load ptr, ptr %7, align 8, !tbaa !9
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.Node, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !13
  %78 = load ptr, ptr %9, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.Node, ptr %78, i32 0, i32 2
  store ptr %77, ptr %79, align 8, !tbaa !14
  %80 = load ptr, ptr %9, align 8, !tbaa !9
  %81 = load ptr, ptr %7, align 8, !tbaa !9
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.Node, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = getelementptr inbounds %struct.Node, ptr %84, i32 0, i32 1
  store ptr %80, ptr %85, align 8, !tbaa !13
  %86 = load ptr, ptr %9, align 8, !tbaa !9
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  %88 = load ptr, ptr %87, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.Node, ptr %88, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !13
  %91 = getelementptr inbounds %struct.Node, ptr %90, i32 0, i32 2
  store ptr %86, ptr %91, align 8, !tbaa !14
  %92 = load i32, ptr %6, align 4, !tbaa !5
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %103

94:                                               ; preds = %67
  %95 = load ptr, ptr %9, align 8, !tbaa !9
  %96 = load ptr, ptr %7, align 8, !tbaa !9
  %97 = load ptr, ptr %96, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.Node, ptr %97, i32 0, i32 1
  store ptr %95, ptr %98, align 8, !tbaa !13
  %99 = load ptr, ptr %9, align 8, !tbaa !9
  %100 = load ptr, ptr %7, align 8, !tbaa !9
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.Node, ptr %101, i32 0, i32 2
  store ptr %99, ptr %102, align 8, !tbaa !14
  br label %103

103:                                              ; preds = %94, %67
  br label %145

104:                                              ; preds = %55
  %105 = load ptr, ptr %7, align 8, !tbaa !9
  %106 = load ptr, ptr %105, align 8, !tbaa !9
  %107 = getelementptr inbounds %struct.Node, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !13
  %109 = load ptr, ptr %9, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.Node, ptr %109, i32 0, i32 1
  store ptr %108, ptr %110, align 8, !tbaa !13
  %111 = load ptr, ptr %7, align 8, !tbaa !9
  %112 = load ptr, ptr %111, align 8, !tbaa !9
  %113 = getelementptr inbounds %struct.Node, ptr %112, i32 0, i32 1
  %114 = load ptr, ptr %113, align 8, !tbaa !13
  %115 = getelementptr inbounds %struct.Node, ptr %114, i32 0, i32 2
  %116 = load ptr, ptr %115, align 8, !tbaa !14
  %117 = load ptr, ptr %9, align 8, !tbaa !9
  %118 = getelementptr inbounds %struct.Node, ptr %117, i32 0, i32 2
  store ptr %116, ptr %118, align 8, !tbaa !14
  %119 = load ptr, ptr %9, align 8, !tbaa !9
  %120 = load ptr, ptr %7, align 8, !tbaa !9
  %121 = load ptr, ptr %120, align 8, !tbaa !9
  %122 = getelementptr inbounds %struct.Node, ptr %121, i32 0, i32 1
  %123 = load ptr, ptr %122, align 8, !tbaa !13
  %124 = getelementptr inbounds %struct.Node, ptr %123, i32 0, i32 2
  %125 = load ptr, ptr %124, align 8, !tbaa !14
  %126 = getelementptr inbounds %struct.Node, ptr %125, i32 0, i32 1
  store ptr %119, ptr %126, align 8, !tbaa !13
  %127 = load ptr, ptr %9, align 8, !tbaa !9
  %128 = load ptr, ptr %7, align 8, !tbaa !9
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = getelementptr inbounds %struct.Node, ptr %129, i32 0, i32 1
  %131 = load ptr, ptr %130, align 8, !tbaa !13
  %132 = getelementptr inbounds %struct.Node, ptr %131, i32 0, i32 2
  store ptr %127, ptr %132, align 8, !tbaa !14
  %133 = load i32, ptr %6, align 4, !tbaa !5
  %134 = icmp eq i32 %133, 0
  br i1 %134, label %135, label %144

135:                                              ; preds = %104
  %136 = load ptr, ptr %9, align 8, !tbaa !9
  %137 = load ptr, ptr %7, align 8, !tbaa !9
  %138 = load ptr, ptr %137, align 8, !tbaa !9
  %139 = getelementptr inbounds %struct.Node, ptr %138, i32 0, i32 1
  store ptr %136, ptr %139, align 8, !tbaa !13
  %140 = load ptr, ptr %9, align 8, !tbaa !9
  %141 = load ptr, ptr %7, align 8, !tbaa !9
  %142 = load ptr, ptr %141, align 8, !tbaa !9
  %143 = getelementptr inbounds %struct.Node, ptr %142, i32 0, i32 2
  store ptr %140, ptr %143, align 8, !tbaa !14
  br label %144

144:                                              ; preds = %135, %104
  br label %145

145:                                              ; preds = %144, %103
  br label %146

146:                                              ; preds = %145, %40
  br label %222

147:                                              ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %148 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #5
  store ptr %148, ptr %10, align 8, !tbaa !9
  %149 = load ptr, ptr %7, align 8, !tbaa !9
  %150 = load ptr, ptr %149, align 8, !tbaa !9
  %151 = getelementptr inbounds %struct.Node, ptr %150, i32 0, i32 1
  %152 = load ptr, ptr %151, align 8, !tbaa !13
  store ptr %152, ptr %10, align 8, !tbaa !9
  %153 = load i32, ptr %6, align 4, !tbaa !5
  %154 = load ptr, ptr %8, align 8, !tbaa !9
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = sdiv i32 %155, 2
  %157 = icmp sle i32 %153, %156
  br i1 %157, label %158, label %189

158:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %169, %158
  %160 = load i32, ptr %11, align 4, !tbaa !5
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = sub nsw i32 %161, 1
  %163 = icmp slt i32 %160, %162
  br i1 %163, label %165, label %164

164:                                              ; preds = %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %172

165:                                              ; preds = %159
  %166 = load ptr, ptr %10, align 8, !tbaa !9
  %167 = getelementptr inbounds %struct.Node, ptr %166, i32 0, i32 1
  %168 = load ptr, ptr %167, align 8, !tbaa !13
  store ptr %168, ptr %10, align 8, !tbaa !9
  br label %169

169:                                              ; preds = %165
  %170 = load i32, ptr %11, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %11, align 4, !tbaa !5
  br label %159, !llvm.loop !15

172:                                              ; preds = %164
  %173 = load ptr, ptr %10, align 8, !tbaa !9
  %174 = getelementptr inbounds %struct.Node, ptr %173, i32 0, i32 1
  %175 = load ptr, ptr %174, align 8, !tbaa !13
  %176 = load ptr, ptr %9, align 8, !tbaa !9
  %177 = getelementptr inbounds %struct.Node, ptr %176, i32 0, i32 1
  store ptr %175, ptr %177, align 8, !tbaa !13
  %178 = load ptr, ptr %10, align 8, !tbaa !9
  %179 = load ptr, ptr %9, align 8, !tbaa !9
  %180 = getelementptr inbounds %struct.Node, ptr %179, i32 0, i32 2
  store ptr %178, ptr %180, align 8, !tbaa !14
  %181 = load ptr, ptr %9, align 8, !tbaa !9
  %182 = load ptr, ptr %10, align 8, !tbaa !9
  %183 = getelementptr inbounds %struct.Node, ptr %182, i32 0, i32 1
  %184 = load ptr, ptr %183, align 8, !tbaa !13
  %185 = getelementptr inbounds %struct.Node, ptr %184, i32 0, i32 2
  store ptr %181, ptr %185, align 8, !tbaa !14
  %186 = load ptr, ptr %9, align 8, !tbaa !9
  %187 = load ptr, ptr %10, align 8, !tbaa !9
  %188 = getelementptr inbounds %struct.Node, ptr %187, i32 0, i32 1
  store ptr %186, ptr %188, align 8, !tbaa !13
  br label %221

189:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %190 = load ptr, ptr %8, align 8, !tbaa !9
  %191 = load i32, ptr %190, align 4, !tbaa !5
  store i32 %191, ptr %12, align 4, !tbaa !5
  br label %192

192:                                              ; preds = %201, %189
  %193 = load i32, ptr %12, align 4, !tbaa !5
  %194 = load i32, ptr %6, align 4, !tbaa !5
  %195 = icmp sgt i32 %193, %194
  br i1 %195, label %197, label %196

196:                                              ; preds = %192
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %204

197:                                              ; preds = %192
  %198 = load ptr, ptr %10, align 8, !tbaa !9
  %199 = getelementptr inbounds %struct.Node, ptr %198, i32 0, i32 2
  %200 = load ptr, ptr %199, align 8, !tbaa !14
  store ptr %200, ptr %10, align 8, !tbaa !9
  br label %201

201:                                              ; preds = %197
  %202 = load i32, ptr %12, align 4, !tbaa !5
  %203 = add nsw i32 %202, -1
  store i32 %203, ptr %12, align 4, !tbaa !5
  br label %192, !llvm.loop !17

204:                                              ; preds = %196
  %205 = load ptr, ptr %10, align 8, !tbaa !9
  %206 = getelementptr inbounds %struct.Node, ptr %205, i32 0, i32 2
  %207 = load ptr, ptr %206, align 8, !tbaa !14
  %208 = load ptr, ptr %9, align 8, !tbaa !9
  %209 = getelementptr inbounds %struct.Node, ptr %208, i32 0, i32 2
  store ptr %207, ptr %209, align 8, !tbaa !14
  %210 = load ptr, ptr %10, align 8, !tbaa !9
  %211 = load ptr, ptr %9, align 8, !tbaa !9
  %212 = getelementptr inbounds %struct.Node, ptr %211, i32 0, i32 1
  store ptr %210, ptr %212, align 8, !tbaa !13
  %213 = load ptr, ptr %9, align 8, !tbaa !9
  %214 = load ptr, ptr %10, align 8, !tbaa !9
  %215 = getelementptr inbounds %struct.Node, ptr %214, i32 0, i32 2
  %216 = load ptr, ptr %215, align 8, !tbaa !14
  %217 = getelementptr inbounds %struct.Node, ptr %216, i32 0, i32 1
  store ptr %213, ptr %217, align 8, !tbaa !13
  %218 = load ptr, ptr %9, align 8, !tbaa !9
  %219 = load ptr, ptr %10, align 8, !tbaa !9
  %220 = getelementptr inbounds %struct.Node, ptr %219, i32 0, i32 2
  store ptr %218, ptr %220, align 8, !tbaa !14
  br label %221

221:                                              ; preds = %204, %172
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %222

222:                                              ; preds = %221, %146
  %223 = load ptr, ptr %8, align 8, !tbaa !9
  %224 = load i32, ptr %223, align 4, !tbaa !5
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr %223, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %229

226:                                              ; preds = %15, %4
  %227 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.3)
  %228 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %227, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %229

229:                                              ; preds = %226, %222
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(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 = { 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 #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 = { nounwind }
attributes #5 = { builtin allocsize(0) }

!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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Node", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !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 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13insertAtIndexiiPP4NodePi(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef %3) local_unnamed_addr #2 {
  %5 = icmp sgt i32 %1, -1
  br i1 %5, label %6, label %115

6:                                                ; preds = %4
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp slt i32 %7, %1
  br i1 %.not, label %115, label %8

8:                                                ; preds = %6
  %9 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  store i32 %0, ptr %9, align 8, !tbaa !9
  %10 = icmp eq i32 %1, 0
  %11 = icmp eq i32 %7, %1
  %or.cond = or i1 %10, %11
  %12 = load ptr, ptr %2, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  br i1 %or.cond, label %15, label %54

15:                                               ; preds = %8
  %16 = icmp eq ptr %14, %12
  br i1 %16, label %17, label %22

17:                                               ; preds = %15
  store ptr %9, ptr %13, align 8, !tbaa !13
  %18 = load ptr, ptr %2, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  store ptr %9, ptr %19, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %9, ptr %20, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %9, i64 16
  br label %.sink.split

22:                                               ; preds = %15
  %23 = getelementptr inbounds i8, ptr %14, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = icmp eq ptr %24, %14
  %26 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %14, ptr %26, align 8, !tbaa !13
  %27 = load ptr, ptr %13, align 8, !tbaa !13
  br i1 %25, label %28, label %40

28:                                               ; preds = %22
  %29 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %27, ptr %29, align 8, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %27, i64 8
  store ptr %9, ptr %30, align 8, !tbaa !13
  %31 = load ptr, ptr %2, align 8, !tbaa !12
  %32 = getelementptr inbounds i8, ptr %31, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  store ptr %9, ptr %34, align 8, !tbaa !14
  br i1 %10, label %35, label %113

35:                                               ; preds = %28
  %36 = load ptr, ptr %2, align 8, !tbaa !12
  %37 = getelementptr inbounds i8, ptr %36, i64 8
  store ptr %9, ptr %37, align 8, !tbaa !13
  %38 = load ptr, ptr %2, align 8, !tbaa !12
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  br label %.sink.split

40:                                               ; preds = %22
  %41 = getelementptr inbounds i8, ptr %27, i64 16
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %42, ptr %43, align 8, !tbaa !14
  %44 = getelementptr inbounds i8, ptr %42, i64 8
  store ptr %9, ptr %44, align 8, !tbaa !13
  %45 = load ptr, ptr %2, align 8, !tbaa !12
  %46 = getelementptr inbounds i8, ptr %45, i64 8
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %47, i64 16
  store ptr %9, ptr %48, align 8, !tbaa !14
  br i1 %10, label %49, label %113

49:                                               ; preds = %40
  %50 = load ptr, ptr %2, align 8, !tbaa !12
  %51 = getelementptr inbounds i8, ptr %50, i64 8
  store ptr %9, ptr %51, align 8, !tbaa !13
  %52 = load ptr, ptr %2, align 8, !tbaa !12
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  br label %.sink.split

54:                                               ; preds = %8
  %55 = lshr i32 %7, 1
  %.not79 = icmp ult i32 %55, %1
  br i1 %.not79, label %.preheader, label %.preheader80

.preheader80:                                     ; preds = %54
  %56 = icmp ugt i32 %1, 1
  br i1 %56, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader80
  %57 = add nsw i32 %1, -2
  %58 = add nsw i32 %1, -1
  %xtraiter = and i32 %58, 7
  %59 = icmp ult i32 %57, 7
  br i1 %59, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %58, -8
  br label %.lr.ph

.preheader:                                       ; preds = %54
  %60 = icmp ugt i32 %7, %1
  br i1 %60, label %.lr.ph85.preheader, label %._crit_edge86

.lr.ph85.preheader:                               ; preds = %.preheader
  %61 = sub i32 %7, %1
  %xtraiter93 = and i32 %61, 7
  %lcmp.mod94.not = icmp eq i32 %xtraiter93, 0
  br i1 %lcmp.mod94.not, label %.lr.ph85.prol.loopexit, label %.lr.ph85.prol

.lr.ph85.prol:                                    ; preds = %.lr.ph85.preheader, %.lr.ph85.prol
  %.084.prol = phi i32 [ %64, %.lr.ph85.prol ], [ %7, %.lr.ph85.preheader ]
  %.183.prol = phi ptr [ %63, %.lr.ph85.prol ], [ %14, %.lr.ph85.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph85.prol ], [ 0, %.lr.ph85.preheader ]
  %62 = getelementptr inbounds i8, ptr %.183.prol, i64 16
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  %64 = add nsw i32 %.084.prol, -1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter93
  br i1 %prol.iter.cmp.not, label %.lr.ph85.prol.loopexit, label %.lr.ph85.prol, !llvm.loop !15

.lr.ph85.prol.loopexit:                           ; preds = %.lr.ph85.prol, %.lr.ph85.preheader
  %.084.unr = phi i32 [ %7, %.lr.ph85.preheader ], [ %64, %.lr.ph85.prol ]
  %.183.unr = phi ptr [ %14, %.lr.ph85.preheader ], [ %63, %.lr.ph85.prol ]
  %.lcssa.unr = phi ptr [ poison, %.lr.ph85.preheader ], [ %63, %.lr.ph85.prol ]
  %65 = sub i32 %1, %7
  %66 = icmp ugt i32 %65, -8
  br i1 %66, label %._crit_edge86, label %.lr.ph85

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa91.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %89, %.lr.ph ]
  %.07581.unr = phi ptr [ %14, %.lr.ph.preheader ], [ %89, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.07581.epil = phi ptr [ %68, %.lr.ph.epil ], [ %.07581.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %67 = getelementptr inbounds i8, ptr %.07581.epil, i64 8
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader80
  %.075.lcssa = phi ptr [ %14, %.preheader80 ], [ %.lcssa91.ph, %._crit_edge.loopexit.unr-lcssa ], [ %68, %.lr.ph.epil ]
  %69 = getelementptr inbounds i8, ptr %.075.lcssa, i64 8
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  %71 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %70, ptr %71, align 8, !tbaa !13
  %72 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %.075.lcssa, ptr %72, align 8, !tbaa !14
  %73 = getelementptr inbounds i8, ptr %70, i64 16
  store ptr %9, ptr %73, align 8, !tbaa !14
  br label %.sink.split

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.07581 = phi ptr [ %14, %.lr.ph.preheader.new ], [ %89, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %74 = getelementptr inbounds i8, ptr %.07581, i64 8
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  %76 = getelementptr inbounds i8, ptr %75, i64 8
  %77 = load ptr, ptr %76, align 8, !tbaa !13
  %78 = getelementptr inbounds i8, ptr %77, i64 8
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = getelementptr inbounds i8, ptr %79, i64 8
  %81 = load ptr, ptr %80, align 8, !tbaa !13
  %82 = getelementptr inbounds i8, ptr %81, i64 8
  %83 = load ptr, ptr %82, align 8, !tbaa !13
  %84 = getelementptr inbounds i8, ptr %83, i64 8
  %85 = load ptr, ptr %84, align 8, !tbaa !13
  %86 = getelementptr inbounds i8, ptr %85, i64 8
  %87 = load ptr, ptr %86, align 8, !tbaa !13
  %88 = getelementptr inbounds i8, ptr %87, i64 8
  %89 = load ptr, ptr %88, align 8, !tbaa !13
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7 = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !18

._crit_edge86:                                    ; preds = %.lr.ph85.prol.loopexit, %.lr.ph85, %.preheader
  %.1.lcssa = phi ptr [ %14, %.preheader ], [ %.lcssa.unr, %.lr.ph85.prol.loopexit ], [ %110, %.lr.ph85 ]
  %90 = getelementptr inbounds i8, ptr %.1.lcssa, i64 16
  %91 = load ptr, ptr %90, align 8, !tbaa !14
  %92 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %91, ptr %92, align 8, !tbaa !14
  %93 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %.1.lcssa, ptr %93, align 8, !tbaa !13
  %94 = getelementptr inbounds i8, ptr %91, i64 8
  store ptr %9, ptr %94, align 8, !tbaa !13
  br label %.sink.split

.lr.ph85:                                         ; preds = %.lr.ph85.prol.loopexit, %.lr.ph85
  %.084 = phi i32 [ %111, %.lr.ph85 ], [ %.084.unr, %.lr.ph85.prol.loopexit ]
  %.183 = phi ptr [ %110, %.lr.ph85 ], [ %.183.unr, %.lr.ph85.prol.loopexit ]
  %95 = getelementptr inbounds i8, ptr %.183, i64 16
  %96 = load ptr, ptr %95, align 8, !tbaa !14
  %97 = getelementptr inbounds i8, ptr %96, i64 16
  %98 = load ptr, ptr %97, align 8, !tbaa !14
  %99 = getelementptr inbounds i8, ptr %98, i64 16
  %100 = load ptr, ptr %99, align 8, !tbaa !14
  %101 = getelementptr inbounds i8, ptr %100, i64 16
  %102 = load ptr, ptr %101, align 8, !tbaa !14
  %103 = getelementptr inbounds i8, ptr %102, i64 16
  %104 = load ptr, ptr %103, align 8, !tbaa !14
  %105 = getelementptr inbounds i8, ptr %104, i64 16
  %106 = load ptr, ptr %105, align 8, !tbaa !14
  %107 = getelementptr inbounds i8, ptr %106, i64 16
  %108 = load ptr, ptr %107, align 8, !tbaa !14
  %109 = getelementptr inbounds i8, ptr %108, i64 16
  %110 = load ptr, ptr %109, align 8, !tbaa !14
  %111 = add nsw i32 %.084, -8
  %112 = icmp sgt i32 %111, %1
  br i1 %112, label %.lr.ph85, label %._crit_edge86, !llvm.loop !20

.sink.split:                                      ; preds = %35, %49, %17, %._crit_edge86, %._crit_edge
  %.sink = phi ptr [ %69, %._crit_edge ], [ %90, %._crit_edge86 ], [ %21, %17 ], [ %53, %49 ], [ %39, %35 ]
  store ptr %9, ptr %.sink, align 8, !tbaa !12
  br label %113

113:                                              ; preds = %.sink.split, %40, %28
  %114 = add nsw i32 %7, 1
  store i32 %114, ptr %3, align 4, !tbaa !5
  br label %118

115:                                              ; preds = %6, %4
  %116 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.3)
  %117 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %116, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %118

118:                                              ; preds = %115, %113
  ret void
}

attributes #0 = { nobuiltin allocsize(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 = { 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 #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 = { builtin allocsize(0) }

!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"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Node", !6, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !11, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass