; LLVM IR from onnx/onnx-mlir :: src/Runtime (OMSort)

; 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"

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [46 x i8], align 1
@__PRETTY_FUNCTION__.omTensorSort = external hidden unnamed_addr constant [68 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [69 x i8], align 1
@OM_DATA_TYPE_SIZE = external constant [0 x i32], align 4

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @getCompareFunction(i64 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @omTensorSort(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca [6 x i64], align 16
  %22 = alloca [6 x i64], align 16
  %23 = alloca i64, align 8
  %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 i64, align 8
  %30 = alloca ptr, align 8
  %31 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call i32 @omTensorGetDataType(ptr noundef %32)
  store i32 %33, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call i64 @omTensorGetRank(ptr noundef %34)
  store i64 %35, ptr %10, align 8, !tbaa !9
  %36 = load i64, ptr %10, align 8, !tbaa !9
  %37 = icmp ule i64 %36, 6
  br i1 %37, label %38, label %40

38:                                               ; preds = %4
  br i1 true, label %39, label %40

39:                                               ; preds = %38
  br label %41

40:                                               ; preds = %38, %4
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 337, ptr noundef @__PRETTY_FUNCTION__.omTensorSort) #6
  unreachable

41:                                               ; preds = %39
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = sub i64 %43, 1
  %45 = icmp eq i64 %42, %44
  br i1 %45, label %46, label %48

46:                                               ; preds = %41
  br i1 true, label %47, label %48

47:                                               ; preds = %46
  br label %49

48:                                               ; preds = %46, %41
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 338, ptr noundef @__PRETTY_FUNCTION__.omTensorSort) #6
  unreachable

49:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call ptr @omTensorGetShape(ptr noundef %50)
  store ptr %51, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = call ptr @omTensorGetStrides(ptr noundef %52)
  store ptr %53, ptr %12, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = load i64, ptr %7, align 8, !tbaa !9
  %56 = getelementptr inbounds i64, ptr %54, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = icmp eq i64 %57, 1
  br i1 %58, label %59, label %61

59:                                               ; preds = %49
  br i1 true, label %60, label %61

60:                                               ; preds = %59
  br label %62

61:                                               ; preds = %59, %49
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 341, ptr noundef @__PRETTY_FUNCTION__.omTensorSort) #6
  unreachable

62:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = call ptr @omTensorGetDataPtr(ptr noundef %63)
  store ptr %64, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %65, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = call ptr @omTensorGetDataPtr(ptr noundef %66)
  store ptr %67, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i64, ptr %7, align 8, !tbaa !9
  %70 = getelementptr inbounds i64, ptr %68, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !9
  store i64 %71, ptr %16, align 8, !tbaa !9
  %72 = load i64, ptr %16, align 8, !tbaa !9
  %73 = icmp eq i64 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %62
  store i32 1, ptr %17, align 4
  br label %220

75:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %76 = load i64, ptr %8, align 8, !tbaa !9
  %77 = load i32, ptr %9, align 4, !tbaa !11
  %78 = call ptr @getCompareFunction(i64 noundef %76, i32 noundef %77)
  store ptr %78, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %79 = load i32, ptr %9, align 4, !tbaa !11
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds [0 x i32], ptr @OM_DATA_TYPE_SIZE, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !11
  %83 = sext i32 %82 to i64
  store i64 %83, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  store ptr @qsort_r, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %21) #5
  call void @llvm.memset.p0.i64(ptr align 16 %21, i8 0, i64 48, i1 false)
  %84 = getelementptr inbounds [6 x i64], ptr %21, i32 0, i32 0
  store i64 1, ptr %84, align 16
  %85 = getelementptr inbounds [6 x i64], ptr %21, i32 0, i32 1
  store i64 1, ptr %85, align 8
  %86 = getelementptr inbounds [6 x i64], ptr %21, i32 0, i32 2
  store i64 1, ptr %86, align 16
  %87 = getelementptr inbounds [6 x i64], ptr %21, i32 0, i32 3
  store i64 1, ptr %87, align 8
  %88 = getelementptr inbounds [6 x i64], ptr %21, i32 0, i32 4
  store i64 1, ptr %88, align 16
  %89 = getelementptr inbounds [6 x i64], ptr %21, i32 0, i32 5
  store i64 1, ptr %89, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %22) #5
  call void @llvm.memset.p0.i64(ptr align 16 %22, i8 0, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %114, %75
  %91 = load i64, ptr %23, align 8, !tbaa !9
  %92 = load i64, ptr %10, align 8, !tbaa !9
  %93 = icmp ult i64 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  br label %117

95:                                               ; preds = %90
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = load i64, ptr %23, align 8, !tbaa !9
  %98 = getelementptr inbounds i64, ptr %96, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !9
  %100 = load i64, ptr %23, align 8, !tbaa !9
  %101 = load i64, ptr %10, align 8, !tbaa !9
  %102 = sub i64 6, %101
  %103 = add i64 %100, %102
  %104 = getelementptr inbounds [6 x i64], ptr %21, i64 0, i64 %103
  store i64 %99, ptr %104, align 8, !tbaa !9
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  %106 = load i64, ptr %23, align 8, !tbaa !9
  %107 = getelementptr inbounds i64, ptr %105, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !9
  %109 = load i64, ptr %23, align 8, !tbaa !9
  %110 = load i64, ptr %10, align 8, !tbaa !9
  %111 = sub i64 6, %110
  %112 = add i64 %109, %111
  %113 = getelementptr inbounds [6 x i64], ptr %22, i64 0, i64 %112
  store i64 %108, ptr %113, align 8, !tbaa !9
  br label %114

114:                                              ; preds = %95
  %115 = load i64, ptr %23, align 8, !tbaa !9
  %116 = add i64 %115, 1
  store i64 %116, ptr %23, align 8, !tbaa !9
  br label %90, !llvm.loop !13

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

118:                                              ; preds = %216, %117
  %119 = load i32, ptr %24, align 4, !tbaa !11
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [6 x i64], ptr %21, i64 0, i64 0
  %122 = load i64, ptr %121, align 16, !tbaa !9
  %123 = icmp slt i64 %120, %122
  br i1 %123, label %125, label %124

124:                                              ; preds = %118
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #5
  br label %219

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

126:                                              ; preds = %212, %125
  %127 = load i32, ptr %25, align 4, !tbaa !11
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [6 x i64], ptr %21, i64 0, i64 1
  %130 = load i64, ptr %129, align 8, !tbaa !9
  %131 = icmp slt i64 %128, %130
  br i1 %131, label %133, label %132

132:                                              ; preds = %126
  store i32 8, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #5
  br label %215

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

134:                                              ; preds = %208, %133
  %135 = load i32, ptr %26, align 4, !tbaa !11
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [6 x i64], ptr %21, i64 0, i64 2
  %138 = load i64, ptr %137, align 16, !tbaa !9
  %139 = icmp slt i64 %136, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %134
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #5
  br label %211

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

142:                                              ; preds = %204, %141
  %143 = load i32, ptr %27, align 4, !tbaa !11
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [6 x i64], ptr %21, i64 0, i64 3
  %146 = load i64, ptr %145, align 8, !tbaa !9
  %147 = icmp slt i64 %144, %146
  br i1 %147, label %149, label %148

148:                                              ; preds = %142
  store i32 14, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #5
  br label %207

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

150:                                              ; preds = %200, %149
  %151 = load i32, ptr %28, align 4, !tbaa !11
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [6 x i64], ptr %21, i64 0, i64 4
  %154 = load i64, ptr %153, align 16, !tbaa !9
  %155 = icmp slt i64 %152, %154
  br i1 %155, label %157, label %156

156:                                              ; preds = %150
  store i32 17, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #5
  br label %203

157:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #5
  %158 = load i32, ptr %24, align 4, !tbaa !11
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [6 x i64], ptr %22, i64 0, i64 0
  %161 = load i64, ptr %160, align 16, !tbaa !9
  %162 = mul nsw i64 %159, %161
  %163 = load i32, ptr %25, align 4, !tbaa !11
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [6 x i64], ptr %22, i64 0, i64 1
  %166 = load i64, ptr %165, align 8, !tbaa !9
  %167 = mul nsw i64 %164, %166
  %168 = add nsw i64 %162, %167
  %169 = load i32, ptr %26, align 4, !tbaa !11
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [6 x i64], ptr %22, i64 0, i64 2
  %172 = load i64, ptr %171, align 16, !tbaa !9
  %173 = mul nsw i64 %170, %172
  %174 = add nsw i64 %168, %173
  %175 = load i32, ptr %27, align 4, !tbaa !11
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [6 x i64], ptr %22, i64 0, i64 3
  %178 = load i64, ptr %177, align 8, !tbaa !9
  %179 = mul nsw i64 %176, %178
  %180 = add nsw i64 %174, %179
  %181 = load i32, ptr %28, align 4, !tbaa !11
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [6 x i64], ptr %22, i64 0, i64 4
  %184 = load i64, ptr %183, align 16, !tbaa !9
  %185 = mul nsw i64 %182, %184
  %186 = add nsw i64 %180, %185
  store i64 %186, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #5
  %187 = load ptr, ptr %15, align 8, !tbaa !5
  %188 = load i64, ptr %19, align 8, !tbaa !9
  %189 = load i64, ptr %29, align 8, !tbaa !9
  %190 = mul i64 %188, %189
  %191 = getelementptr inbounds i8, ptr %187, i64 %190
  store ptr %191, ptr %30, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #5
  %192 = load ptr, ptr %14, align 8, !tbaa !5
  %193 = load i64, ptr %29, align 8, !tbaa !9
  %194 = getelementptr inbounds i64, ptr %192, i64 %193
  store ptr %194, ptr %31, align 8, !tbaa !5
  %195 = load ptr, ptr %20, align 8, !tbaa !5
  %196 = load ptr, ptr %31, align 8, !tbaa !5
  %197 = load i64, ptr %16, align 8, !tbaa !9
  %198 = load ptr, ptr %18, align 8, !tbaa !5
  %199 = load ptr, ptr %30, align 8, !tbaa !5
  call void %195(ptr noundef %196, i64 noundef %197, i64 noundef 8, ptr noundef %198, ptr noundef %199)
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #5
  br label %200

200:                                              ; preds = %157
  %201 = load i32, ptr %28, align 4, !tbaa !11
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %28, align 4, !tbaa !11
  br label %150, !llvm.loop !15

203:                                              ; preds = %156
  br label %204

204:                                              ; preds = %203
  %205 = load i32, ptr %27, align 4, !tbaa !11
  %206 = add nsw i32 %205, 1
  store i32 %206, ptr %27, align 4, !tbaa !11
  br label %142, !llvm.loop !16

207:                                              ; preds = %148
  br label %208

208:                                              ; preds = %207
  %209 = load i32, ptr %26, align 4, !tbaa !11
  %210 = add nsw i32 %209, 1
  store i32 %210, ptr %26, align 4, !tbaa !11
  br label %134, !llvm.loop !17

211:                                              ; preds = %140
  br label %212

212:                                              ; preds = %211
  %213 = load i32, ptr %25, align 4, !tbaa !11
  %214 = add nsw i32 %213, 1
  store i32 %214, ptr %25, align 4, !tbaa !11
  br label %126, !llvm.loop !18

215:                                              ; preds = %132
  br label %216

216:                                              ; preds = %215
  %217 = load i32, ptr %24, align 4, !tbaa !11
  %218 = add nsw i32 %217, 1
  store i32 %218, ptr %24, align 4, !tbaa !11
  br label %118, !llvm.loop !19

219:                                              ; preds = %124
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 48, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %220

220:                                              ; preds = %219, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void
}

declare i32 @omTensorGetDataType(ptr noundef) #3

declare i64 @omTensorGetRank(ptr noundef) #3

declare ptr @omTensorGetShape(ptr noundef) #3

declare ptr @omTensorGetStrides(ptr noundef) #3

declare ptr @omTensorGetDataPtr(ptr noundef) #3

declare void @qsort_r(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


; 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"

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [46 x i8], align 1
@__PRETTY_FUNCTION__.omTensorSort = external hidden unnamed_addr constant [68 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [69 x i8], align 1
@OM_DATA_TYPE_SIZE = external local_unnamed_addr constant [0 x i32], align 4

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @getCompareFunction(i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @omTensorSort(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #2 {
  %5 = alloca [6 x i64], align 16
  %6 = alloca [6 x i64], align 16
  %7 = tail call i32 @omTensorGetDataType(ptr noundef %1) #6
  %8 = tail call i64 @omTensorGetRank(ptr noundef %1) #6
  %9 = icmp ult i64 %8, 7
  br i1 %9, label %11, label %10

10:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 337, ptr noundef nonnull @__PRETTY_FUNCTION__.omTensorSort) #7
  unreachable

11:                                               ; preds = %4
  %12 = add nsw i64 %8, -1
  %13 = icmp eq i64 %12, %2
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 338, ptr noundef nonnull @__PRETTY_FUNCTION__.omTensorSort) #7
  unreachable

15:                                               ; preds = %11
  %16 = tail call ptr @omTensorGetShape(ptr noundef %1) #6
  %17 = tail call ptr @omTensorGetStrides(ptr noundef %1) #6
  %18 = getelementptr inbounds i64, ptr %17, i64 %2
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = icmp eq i64 %19, 1
  br i1 %20, label %22, label %21

21:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 341, ptr noundef nonnull @__PRETTY_FUNCTION__.omTensorSort) #7
  unreachable

22:                                               ; preds = %15
  %23 = tail call ptr @omTensorGetDataPtr(ptr noundef %0) #6
  %24 = tail call ptr @omTensorGetDataPtr(ptr noundef %1) #6
  %25 = getelementptr inbounds i64, ptr %16, i64 %2
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %73, label %28

28:                                               ; preds = %22
  %29 = tail call ptr @getCompareFunction(i64 noundef %3, i32 noundef %7)
  %30 = zext i32 %7 to i64
  %31 = getelementptr inbounds [0 x i32], ptr @OM_DATA_TYPE_SIZE, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #6
  %34 = getelementptr inbounds i8, ptr %5, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(48) %34, i8 0, i64 16, i1 false)
  store i64 1, ptr %5, align 16
  %35 = getelementptr inbounds i8, ptr %5, i64 8
  store i64 1, ptr %35, align 8
  %36 = getelementptr inbounds i8, ptr %5, i64 16
  store i64 1, ptr %36, align 16
  %37 = getelementptr inbounds i8, ptr %5, i64 24
  store i64 1, ptr %37, align 8
  %38 = getelementptr inbounds i8, ptr %5, i64 32
  store i64 1, ptr %38, align 16
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(48) %6, i8 0, i64 48, i1 false)
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %.preheader68.lr.ph, label %.preheader69

.preheader69:                                     ; preds = %28
  %39 = shl nuw nsw i64 %8, 3
  %40 = sub nuw nsw i64 48, %39
  %scevgep = getelementptr i8, ptr %5, i64 %40
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %scevgep, ptr nonnull align 8 %16, i64 %39, i1 false), !tbaa !5
  %scevgep107 = getelementptr i8, ptr %6, i64 %40
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %scevgep107, ptr nonnull align 8 %17, i64 %39, i1 false), !tbaa !5
  %.pre = load i64, ptr %5, align 16, !tbaa !5
  %41 = icmp sgt i64 %.pre, 0
  br i1 %41, label %.preheader68.lr.ph, label %._crit_edge

.preheader68.lr.ph:                               ; preds = %28, %.preheader69
  %42 = phi i64 [ %.pre, %.preheader69 ], [ 1, %28 ]
  %43 = load i64, ptr %35, align 8, !tbaa !5
  %44 = icmp slt i64 %43, 1
  %45 = load i64, ptr %36, align 16
  %46 = load i64, ptr %37, align 8
  %47 = icmp slt i64 %46, 1
  %48 = load i64, ptr %38, align 16
  %49 = icmp slt i64 %48, 1
  %50 = load i64, ptr %6, align 16
  %51 = getelementptr inbounds i8, ptr %6, i64 8
  %52 = load i64, ptr %51, align 8
  %53 = getelementptr inbounds i8, ptr %6, i64 16
  %54 = load i64, ptr %53, align 16
  %55 = getelementptr inbounds i8, ptr %6, i64 24
  %56 = load i64, ptr %55, align 8
  %57 = getelementptr inbounds i8, ptr %6, i64 32
  %58 = load i64, ptr %57, align 16
  %59 = icmp slt i64 %45, 1
  %or.cond.not140 = select i1 %44, i1 true, i1 %59
  %brmerge = select i1 %or.cond.not140, i1 true, i1 %47
  %brmerge137 = select i1 %brmerge, i1 true, i1 %49
  br i1 %brmerge137, label %._crit_edge, label %.preheader68.us.us.us.us

.preheader68.us.us.us.us:                         ; preds = %.preheader68.lr.ph, %._crit_edge81.split.us.split.us.split.us.us.us.us.us
  %indvars.iv131 = phi i64 [ %indvars.iv.next132, %._crit_edge81.split.us.split.us.split.us.us.us.us.us ], [ 0, %.preheader68.lr.ph ]
  %60 = mul nsw i64 %50, %indvars.iv131
  br label %.preheader67.us.us.us.us.us.us.us

.preheader67.us.us.us.us.us.us.us:                ; preds = %._crit_edge.split.us.split.us.us.us.us.us.us.us.us, %.preheader68.us.us.us.us
  %indvars.iv127 = phi i64 [ %indvars.iv.next128, %._crit_edge.split.us.split.us.us.us.us.us.us.us.us ], [ 0, %.preheader68.us.us.us.us ]
  %61 = mul nsw i64 %52, %indvars.iv127
  %62 = add nsw i64 %61, %60
  br label %.preheader66.us.us.us.us.us.us.us.us.us

.preheader66.us.us.us.us.us.us.us.us.us:          ; preds = %._crit_edge74.split.us.us.us.us.us.us.us.us.us.us, %.preheader67.us.us.us.us.us.us.us
  %indvars.iv123 = phi i64 [ %indvars.iv.next124, %._crit_edge74.split.us.us.us.us.us.us.us.us.us.us ], [ 0, %.preheader67.us.us.us.us.us.us.us ]
  %63 = mul nsw i64 %54, %indvars.iv123
  %64 = add nsw i64 %62, %63
  br label %.preheader.us.us.us.us.us.us.us.us.us.us

.preheader.us.us.us.us.us.us.us.us.us.us:         ; preds = %._crit_edge.us.us.us.us.us.us.us.us.us.us, %.preheader66.us.us.us.us.us.us.us.us.us
  %indvars.iv119 = phi i64 [ %indvars.iv.next120, %._crit_edge.us.us.us.us.us.us.us.us.us.us ], [ 0, %.preheader66.us.us.us.us.us.us.us.us.us ]
  %65 = mul nsw i64 %56, %indvars.iv119
  %66 = add nsw i64 %64, %65
  br label %67

67:                                               ; preds = %67, %.preheader.us.us.us.us.us.us.us.us.us.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %67 ], [ 0, %.preheader.us.us.us.us.us.us.us.us.us.us ]
  %68 = mul nsw i64 %58, %indvars.iv
  %69 = add nsw i64 %66, %68
  %70 = mul i64 %69, %33
  %71 = getelementptr inbounds i8, ptr %24, i64 %70
  %72 = getelementptr inbounds i64, ptr %23, i64 %69
  tail call void @qsort_r(ptr noundef %72, i64 noundef %26, i64 noundef 8, ptr noundef %29, ptr noundef %71) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %48
  br i1 %exitcond.not, label %._crit_edge.us.us.us.us.us.us.us.us.us.us, label %67, !llvm.loop !11

._crit_edge.us.us.us.us.us.us.us.us.us.us:        ; preds = %67
  %indvars.iv.next120 = add nuw nsw i64 %indvars.iv119, 1
  %exitcond122.not = icmp eq i64 %indvars.iv.next120, %46
  br i1 %exitcond122.not, label %._crit_edge74.split.us.us.us.us.us.us.us.us.us.us, label %.preheader.us.us.us.us.us.us.us.us.us.us, !llvm.loop !13

._crit_edge74.split.us.us.us.us.us.us.us.us.us.us: ; preds = %._crit_edge.us.us.us.us.us.us.us.us.us.us
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %exitcond126.not = icmp eq i64 %indvars.iv.next124, %45
  br i1 %exitcond126.not, label %._crit_edge.split.us.split.us.us.us.us.us.us.us.us, label %.preheader66.us.us.us.us.us.us.us.us.us, !llvm.loop !14

._crit_edge.split.us.split.us.us.us.us.us.us.us.us: ; preds = %._crit_edge74.split.us.us.us.us.us.us.us.us.us.us
  %indvars.iv.next128 = add nuw nsw i64 %indvars.iv127, 1
  %exitcond130.not = icmp eq i64 %indvars.iv.next128, %43
  br i1 %exitcond130.not, label %._crit_edge81.split.us.split.us.split.us.us.us.us.us, label %.preheader67.us.us.us.us.us.us.us, !llvm.loop !15

._crit_edge81.split.us.split.us.split.us.us.us.us.us: ; preds = %._crit_edge.split.us.split.us.us.us.us.us.us.us.us
  %indvars.iv.next132 = add nuw nsw i64 %indvars.iv131, 1
  %exitcond134.not = icmp eq i64 %indvars.iv.next132, %42
  br i1 %exitcond134.not, label %._crit_edge, label %.preheader68.us.us.us.us, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge81.split.us.split.us.split.us.us.us.us.us, %.preheader68.lr.ph, %.preheader69
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  br label %73

73:                                               ; preds = %22, %._crit_edge
  ret void
}

declare i32 @omTensorGetDataType(ptr noundef) local_unnamed_addr #3

declare i64 @omTensorGetRank(ptr noundef) local_unnamed_addr #3

declare ptr @omTensorGetShape(ptr noundef) local_unnamed_addr #3

declare ptr @omTensorGetStrides(ptr noundef) local_unnamed_addr #3

declare ptr @omTensorGetDataPtr(ptr noundef) local_unnamed_addr #3

declare void @qsort_r(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass