; LLVM IR from ritikbanger/Hacktoberfest2022-DSA :: 06. Sorting (kasai_algorithm)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.suffix = type { i32, [2 x i32] }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3cmp6suffixS_(i64, i32, i64, i32) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16buildSuffixArrayNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, ptr noundef %1, i32 noundef %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %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 i1, align 1
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = call ptr @llvm.stacksave.p0()
  store ptr %24, ptr %7, align 8
  %25 = alloca %struct.suffix, i64 %23, align 16
  store i64 %23, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %68, %3
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %71

31:                                               ; preds = %26
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.suffix, ptr %25, i64 %34
  %36 = getelementptr inbounds %struct.suffix, ptr %35, i32 0, i32 0
  store i32 %32, ptr %36, align 4, !tbaa !11
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %38)
  %40 = load i8, ptr %39, align 1, !tbaa !13
  %41 = sext i8 %40 to i32
  %42 = sub nsw i32 %41, 97
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.suffix, ptr %25, i64 %44
  %46 = getelementptr inbounds %struct.suffix, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds [2 x i32], ptr %46, i64 0, i64 0
  store i32 %42, ptr %47, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %60

52:                                               ; preds = %31
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %55)
  %57 = load i8, ptr %56, align 1, !tbaa !13
  %58 = sext i8 %57 to i32
  %59 = sub nsw i32 %58, 97
  br label %61

60:                                               ; preds = %31
  br label %61

61:                                               ; preds = %60, %52
  %62 = phi i32 [ %59, %52 ], [ -1, %60 ]
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.suffix, ptr %25, i64 %64
  %66 = getelementptr inbounds %struct.suffix, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds [2 x i32], ptr %66, i64 0, i64 1
  store i32 %62, ptr %67, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %61
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %9, align 4, !tbaa !9
  br label %26, !llvm.loop !14

71:                                               ; preds = %30
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %struct.suffix, ptr %25, i64 %73
  call void @_ZSt4sortIP6suffixPFiS0_S0_EEvT_S4_T0_(ptr noundef %25, ptr noundef %74, ptr noundef @_Z3cmp6suffixS_)
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = alloca i32, i64 %76, align 16
  store i64 %76, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 4, ptr %11, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %209, %71
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = mul nsw i32 2, %80
  %82 = icmp slt i32 %79, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %78
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %212

84:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %85 = getelementptr inbounds %struct.suffix, ptr %25, i64 0
  %86 = getelementptr inbounds %struct.suffix, ptr %85, i32 0, i32 1
  %87 = getelementptr inbounds [2 x i32], ptr %86, i64 0, i64 0
  %88 = load i32, ptr %87, align 4, !tbaa !9
  store i32 %88, ptr %14, align 4, !tbaa !9
  %89 = load i32, ptr %13, align 4, !tbaa !9
  %90 = getelementptr inbounds %struct.suffix, ptr %25, i64 0
  %91 = getelementptr inbounds %struct.suffix, ptr %90, i32 0, i32 1
  %92 = getelementptr inbounds [2 x i32], ptr %91, i64 0, i64 0
  store i32 %89, ptr %92, align 4, !tbaa !9
  %93 = getelementptr inbounds %struct.suffix, ptr %25, i64 0
  %94 = getelementptr inbounds %struct.suffix, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 16, !tbaa !11
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds i32, ptr %77, i64 %96
  store i32 0, ptr %97, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %98

98:                                               ; preds = %163, %84
  %99 = load i32, ptr %15, align 4, !tbaa !9
  %100 = load i32, ptr %6, align 4, !tbaa !9
  %101 = icmp slt i32 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %166

103:                                              ; preds = %98
  %104 = load i32, ptr %15, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.suffix, ptr %25, i64 %105
  %107 = getelementptr inbounds %struct.suffix, ptr %106, i32 0, i32 1
  %108 = getelementptr inbounds [2 x i32], ptr %107, i64 0, i64 0
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = load i32, ptr %14, align 4, !tbaa !9
  %111 = icmp eq i32 %109, %110
  br i1 %111, label %112, label %140

112:                                              ; preds = %103
  %113 = load i32, ptr %15, align 4, !tbaa !9
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds %struct.suffix, ptr %25, i64 %114
  %116 = getelementptr inbounds %struct.suffix, ptr %115, i32 0, i32 1
  %117 = getelementptr inbounds [2 x i32], ptr %116, i64 0, i64 1
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = load i32, ptr %15, align 4, !tbaa !9
  %120 = sub nsw i32 %119, 1
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds %struct.suffix, ptr %25, i64 %121
  %123 = getelementptr inbounds %struct.suffix, ptr %122, i32 0, i32 1
  %124 = getelementptr inbounds [2 x i32], ptr %123, i64 0, i64 1
  %125 = load i32, ptr %124, align 4, !tbaa !9
  %126 = icmp eq i32 %118, %125
  br i1 %126, label %127, label %140

127:                                              ; preds = %112
  %128 = load i32, ptr %15, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds %struct.suffix, ptr %25, i64 %129
  %131 = getelementptr inbounds %struct.suffix, ptr %130, i32 0, i32 1
  %132 = getelementptr inbounds [2 x i32], ptr %131, i64 0, i64 0
  %133 = load i32, ptr %132, align 4, !tbaa !9
  store i32 %133, ptr %14, align 4, !tbaa !9
  %134 = load i32, ptr %13, align 4, !tbaa !9
  %135 = load i32, ptr %15, align 4, !tbaa !9
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds %struct.suffix, ptr %25, i64 %136
  %138 = getelementptr inbounds %struct.suffix, ptr %137, i32 0, i32 1
  %139 = getelementptr inbounds [2 x i32], ptr %138, i64 0, i64 0
  store i32 %134, ptr %139, align 4, !tbaa !9
  br label %154

140:                                              ; preds = %112, %103
  %141 = load i32, ptr %15, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds %struct.suffix, ptr %25, i64 %142
  %144 = getelementptr inbounds %struct.suffix, ptr %143, i32 0, i32 1
  %145 = getelementptr inbounds [2 x i32], ptr %144, i64 0, i64 0
  %146 = load i32, ptr %145, align 4, !tbaa !9
  store i32 %146, ptr %14, align 4, !tbaa !9
  %147 = load i32, ptr %13, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %13, align 4, !tbaa !9
  %149 = load i32, ptr %15, align 4, !tbaa !9
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds %struct.suffix, ptr %25, i64 %150
  %152 = getelementptr inbounds %struct.suffix, ptr %151, i32 0, i32 1
  %153 = getelementptr inbounds [2 x i32], ptr %152, i64 0, i64 0
  store i32 %148, ptr %153, align 4, !tbaa !9
  br label %154

154:                                              ; preds = %140, %127
  %155 = load i32, ptr %15, align 4, !tbaa !9
  %156 = load i32, ptr %15, align 4, !tbaa !9
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds %struct.suffix, ptr %25, i64 %157
  %159 = getelementptr inbounds %struct.suffix, ptr %158, i32 0, i32 0
  %160 = load i32, ptr %159, align 4, !tbaa !11
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds i32, ptr %77, i64 %161
  store i32 %155, ptr %162, align 4, !tbaa !9
  br label %163

163:                                              ; preds = %154
  %164 = load i32, ptr %15, align 4, !tbaa !9
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %15, align 4, !tbaa !9
  br label %98, !llvm.loop !16

166:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %167

167:                                              ; preds = %202, %166
  %168 = load i32, ptr %16, align 4, !tbaa !9
  %169 = load i32, ptr %6, align 4, !tbaa !9
  %170 = icmp slt i32 %168, %169
  br i1 %170, label %172, label %171

171:                                              ; preds = %167
  store i32 11, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %205

172:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %173 = load i32, ptr %16, align 4, !tbaa !9
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds %struct.suffix, ptr %25, i64 %174
  %176 = getelementptr inbounds %struct.suffix, ptr %175, i32 0, i32 0
  %177 = load i32, ptr %176, align 4, !tbaa !11
  %178 = load i32, ptr %11, align 4, !tbaa !9
  %179 = sdiv i32 %178, 2
  %180 = add nsw i32 %177, %179
  store i32 %180, ptr %17, align 4, !tbaa !9
  %181 = load i32, ptr %17, align 4, !tbaa !9
  %182 = load i32, ptr %6, align 4, !tbaa !9
  %183 = icmp slt i32 %181, %182
  br i1 %183, label %184, label %194

184:                                              ; preds = %172
  %185 = load i32, ptr %17, align 4, !tbaa !9
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds i32, ptr %77, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !9
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds %struct.suffix, ptr %25, i64 %189
  %191 = getelementptr inbounds %struct.suffix, ptr %190, i32 0, i32 1
  %192 = getelementptr inbounds [2 x i32], ptr %191, i64 0, i64 0
  %193 = load i32, ptr %192, align 4, !tbaa !9
  br label %195

194:                                              ; preds = %172
  br label %195

195:                                              ; preds = %194, %184
  %196 = phi i32 [ %193, %184 ], [ -1, %194 ]
  %197 = load i32, ptr %16, align 4, !tbaa !9
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds %struct.suffix, ptr %25, i64 %198
  %200 = getelementptr inbounds %struct.suffix, ptr %199, i32 0, i32 1
  %201 = getelementptr inbounds [2 x i32], ptr %200, i64 0, i64 1
  store i32 %196, ptr %201, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %202

202:                                              ; preds = %195
  %203 = load i32, ptr %16, align 4, !tbaa !9
  %204 = add nsw i32 %203, 1
  store i32 %204, ptr %16, align 4, !tbaa !9
  br label %167, !llvm.loop !17

205:                                              ; preds = %171
  %206 = load i32, ptr %6, align 4, !tbaa !9
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds %struct.suffix, ptr %25, i64 %207
  call void @_ZSt4sortIP6suffixPFiS0_S0_EEvT_S4_T0_(ptr noundef %25, ptr noundef %208, ptr noundef @_Z3cmp6suffixS_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %209

209:                                              ; preds = %205
  %210 = load i32, ptr %11, align 4, !tbaa !9
  %211 = mul nsw i32 %210, 2
  store i32 %211, ptr %11, align 4, !tbaa !9
  br label %78, !llvm.loop !18

212:                                              ; preds = %83
  store i1 false, ptr %18, align 1
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %213

213:                                              ; preds = %224, %212
  %214 = load i32, ptr %19, align 4, !tbaa !9
  %215 = load i32, ptr %6, align 4, !tbaa !9
  %216 = icmp slt i32 %214, %215
  br i1 %216, label %218, label %217

217:                                              ; preds = %213
  store i32 14, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %231

218:                                              ; preds = %213
  %219 = load i32, ptr %19, align 4, !tbaa !9
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds %struct.suffix, ptr %25, i64 %220
  %222 = getelementptr inbounds %struct.suffix, ptr %221, i32 0, i32 0
  invoke void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %222)
          to label %223 unwind label %227

223:                                              ; preds = %218
  br label %224

224:                                              ; preds = %223
  %225 = load i32, ptr %19, align 4, !tbaa !9
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %19, align 4, !tbaa !9
  br label %213, !llvm.loop !19

227:                                              ; preds = %218
  %228 = landingpad { ptr, i32 }
          cleanup
  %229 = extractvalue { ptr, i32 } %228, 0
  store ptr %229, ptr %20, align 8
  %230 = extractvalue { ptr, i32 } %228, 1
  store i32 %230, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  br label %236

231:                                              ; preds = %217
  store i1 true, ptr %18, align 1
  store i32 1, ptr %12, align 4
  %232 = load i1, ptr %18, align 1
  br i1 %232, label %234, label %233

233:                                              ; preds = %231
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  br label %234

234:                                              ; preds = %233, %231
  %235 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %235)
  ret void

236:                                              ; preds = %227
  %237 = load ptr, ptr %20, align 8
  %238 = load i32, ptr %21, align 4
  %239 = insertvalue { ptr, i32 } poison, ptr %237, 0
  %240 = insertvalue { ptr, i32 } %239, i32 %238, 1
  resume { ptr, i32 } %240
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP6suffixPFiS0_S0_EEvT_S4_T0_(ptr noundef, ptr noundef, ptr noundef) #4

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 0}
!12 = !{!"_ZTS6suffix", !10, i64 0, !7, i64 4}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}


; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.suffix = type { i32, [2 x i32] }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3cmp6suffixS_(i64, i32, i64, i32) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16buildSuffixArrayNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %4 = zext i32 %2 to i64
  %5 = alloca %struct.suffix, i64 %4, align 16
  %6 = icmp sgt i32 %2, 0
  br i1 %6, label %.lr.ph.preheader, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %3
  %.pre = sext i32 %2 to i64
  br label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %7 = zext nneg i32 %2 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %92, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %7, %92 ]
  %8 = getelementptr inbounds %struct.suffix, ptr %5, i64 %.pre-phi
  call void @_ZSt4sortIP6suffixPFiS0_S0_EEvT_S4_T0_(ptr noundef nonnull %5, ptr noundef nonnull %8, ptr noundef nonnull @_Z3cmp6suffixS_)
  %9 = alloca i32, i64 %4, align 16
  %10 = icmp sgt i32 %2, 2
  br i1 %10, label %.lr.ph67.us.preheader, label %._crit_edge74

.lr.ph67.us.preheader:                            ; preds = %._crit_edge
  %11 = getelementptr inbounds i8, ptr %5, i64 4
  %xtraiter = and i64 %4, 1
  %unroll_iter = and i64 %4, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph67.us

.lr.ph67.us:                                      ; preds = %.lr.ph67.us.preheader, %._crit_edge70.us
  %.05071.us = phi i32 [ %29, %._crit_edge70.us ], [ 4, %.lr.ph67.us.preheader ]
  %12 = load i32, ptr %11, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  %13 = load i32, ptr %5, align 16, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr %9, i64 %14
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %60

._crit_edge70.us.unr-lcssa:                       ; preds = %57
  br i1 %lcmp.mod.not, label %._crit_edge70.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge70.us.unr-lcssa
  %16 = getelementptr inbounds %struct.suffix, ptr %5, i64 %indvars.iv.next93.1
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = add nsw i32 %17, %78
  %19 = icmp slt i32 %18, %2
  br i1 %19, label %20, label %._crit_edge70.us.epilog-lcssa

20:                                               ; preds = %.epil.preheader
  %21 = sext i32 %18 to i64
  %22 = getelementptr inbounds i32, ptr %9, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %struct.suffix, ptr %5, i64 %24, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !5
  br label %._crit_edge70.us.epilog-lcssa

._crit_edge70.us.epilog-lcssa:                    ; preds = %20, %.epil.preheader
  %27 = phi i32 [ %26, %20 ], [ -1, %.epil.preheader ]
  %28 = getelementptr inbounds i8, ptr %16, i64 8
  store i32 %27, ptr %28, align 4, !tbaa !5
  br label %._crit_edge70.us

._crit_edge70.us:                                 ; preds = %._crit_edge70.us.unr-lcssa, %._crit_edge70.us.epilog-lcssa
  call void @_ZSt4sortIP6suffixPFiS0_S0_EEvT_S4_T0_(ptr noundef nonnull %5, ptr noundef nonnull %8, ptr noundef nonnull @_Z3cmp6suffixS_)
  %29 = shl nsw i32 %.05071.us, 1
  %30 = icmp slt i32 %.05071.us, %2
  br i1 %30, label %.lr.ph67.us, label %._crit_edge74, !llvm.loop !11

31:                                               ; preds = %57, %.lr.ph69.us
  %indvars.iv92 = phi i64 [ 0, %.lr.ph69.us ], [ %indvars.iv.next93.1, %57 ]
  %niter = phi i64 [ 0, %.lr.ph69.us ], [ %niter.next.1, %57 ]
  %32 = getelementptr inbounds %struct.suffix, ptr %5, i64 %indvars.iv92
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = add nsw i32 %33, %78
  %35 = icmp slt i32 %34, %2
  br i1 %35, label %36, label %43

36:                                               ; preds = %31
  %37 = sext i32 %34 to i64
  %38 = getelementptr inbounds i32, ptr %9, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct.suffix, ptr %5, i64 %40, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %36, %31
  %44 = phi i32 [ %42, %36 ], [ -1, %31 ]
  %45 = getelementptr inbounds i8, ptr %32, i64 8
  store i32 %44, ptr %45, align 8, !tbaa !5
  %indvars.iv.next93 = or disjoint i64 %indvars.iv92, 1
  %46 = getelementptr inbounds %struct.suffix, ptr %5, i64 %indvars.iv.next93
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = add nsw i32 %47, %78
  %49 = icmp slt i32 %48, %2
  br i1 %49, label %50, label %57

50:                                               ; preds = %43
  %51 = sext i32 %48 to i64
  %52 = getelementptr inbounds i32, ptr %9, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.suffix, ptr %5, i64 %54, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %50, %43
  %58 = phi i32 [ %56, %50 ], [ -1, %43 ]
  %59 = getelementptr inbounds i8, ptr %46, i64 8
  store i32 %58, ptr %59, align 4, !tbaa !5
  %indvars.iv.next93.1 = add nuw nsw i64 %indvars.iv92, 2
  %niter.next.1 = add nuw nsw i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge70.us.unr-lcssa, label %31, !llvm.loop !13

60:                                               ; preds = %.lr.ph67.us, %73
  %indvars.iv87 = phi i64 [ 1, %.lr.ph67.us ], [ %indvars.iv.next88, %73 ]
  %.05464.us = phi i32 [ %12, %.lr.ph67.us ], [ %63, %73 ]
  %.05563.us = phi i32 [ 0, %.lr.ph67.us ], [ %storemerge.us, %73 ]
  %61 = getelementptr inbounds %struct.suffix, ptr %5, i64 %indvars.iv87
  %62 = getelementptr inbounds i8, ptr %61, i64 4
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp eq i32 %63, %.05464.us
  br i1 %64, label %65, label %71

65:                                               ; preds = %60
  %66 = getelementptr inbounds i8, ptr %61, i64 8
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = getelementptr i8, ptr %61, i64 -4
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp eq i32 %67, %69
  br i1 %70, label %73, label %71

71:                                               ; preds = %65, %60
  %72 = add nsw i32 %.05563.us, 1
  br label %73

73:                                               ; preds = %71, %65
  %storemerge.us = phi i32 [ %72, %71 ], [ %.05563.us, %65 ]
  store i32 %storemerge.us, ptr %62, align 4, !tbaa !5
  %74 = load i32, ptr %61, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %9, i64 %75
  %77 = trunc nuw nsw i64 %indvars.iv87 to i32
  store i32 %77, ptr %76, align 4, !tbaa !5
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %exitcond91.not = icmp eq i64 %indvars.iv.next88, %4
  br i1 %exitcond91.not, label %.lr.ph69.us, label %60, !llvm.loop !14

.lr.ph69.us:                                      ; preds = %73
  %78 = ashr exact i32 %.05071.us, 1
  br label %31

.lr.ph:                                           ; preds = %.lr.ph.preheader, %92
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %92 ]
  %79 = getelementptr inbounds %struct.suffix, ptr %5, i64 %indvars.iv
  %80 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %80, ptr %79, align 4, !tbaa !9
  %81 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %indvars.iv)
  %82 = load i8, ptr %81, align 1, !tbaa !15
  %83 = sext i8 %82 to i32
  %84 = add nsw i32 %83, -97
  %85 = getelementptr inbounds i8, ptr %79, i64 4
  store i32 %84, ptr %85, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %86 = icmp ult i64 %indvars.iv.next, %7
  br i1 %86, label %87, label %92

87:                                               ; preds = %.lr.ph
  %88 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %indvars.iv.next)
  %89 = load i8, ptr %88, align 1, !tbaa !15
  %90 = sext i8 %89 to i32
  %91 = add nsw i32 %90, -97
  br label %92

92:                                               ; preds = %.lr.ph, %87
  %93 = phi i32 [ %91, %87 ], [ -1, %.lr.ph ]
  %94 = getelementptr inbounds i8, ptr %79, i64 8
  store i32 %93, ptr %94, align 4, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv.next, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge74:                                    ; preds = %._crit_edge70.us, %._crit_edge
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br i1 %6, label %.lr.ph82, label %._crit_edge83

.lr.ph82:                                         ; preds = %._crit_edge74, %96
  %indvars.iv97 = phi i64 [ %indvars.iv.next98, %96 ], [ 0, %._crit_edge74 ]
  %95 = getelementptr inbounds %struct.suffix, ptr %5, i64 %indvars.iv97
  invoke void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %95)
          to label %96 unwind label %97

96:                                               ; preds = %.lr.ph82
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %exitcond101.not = icmp eq i64 %indvars.iv.next98, %4
  br i1 %exitcond101.not, label %._crit_edge83, label %.lr.ph82, !llvm.loop !17

97:                                               ; preds = %.lr.ph82
  %98 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  resume { ptr, i32 } %98

._crit_edge83:                                    ; preds = %96, %._crit_edge74
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP6suffixPFiS0_S0_EEvT_S4_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

declare i32 @__gxx_personality_v0(...)

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

attributes #0 = { 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 #1 = { 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 = { 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 = { 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"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS6suffix", !6, i64 0, !7, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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