; LLVM IR from tessarin/dither :: src (MCQuantization)

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

%struct.MCTriplet = type { [3 x i8] }
%struct.MCCube = type { %struct.MCTriplet, %struct.MCTriplet, i32, ptr }

@dim = external hidden global i8, align 1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @MCQuantizeData(ptr noundef %0, i32 noundef %1, i8 noundef zeroext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct.MCTriplet, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i8 %2, ptr %6, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %18 = load i8, ptr %6, align 1, !tbaa !11
  %19 = uitofp i8 %18 to double
  %20 = call double @pow(double noundef 2.000000e+00, double noundef %19) #6
  %21 = fptosi double %20 to i32
  store i32 %21, ptr %7, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = mul i64 24, %23
  %25 = call noalias ptr @malloc(i64 noundef %24) #7
  store ptr %25, ptr %8, align 8, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = mul i64 3, %27
  %29 = call noalias ptr @malloc(i64 noundef %28) #7
  store ptr %29, ptr %9, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.MCCube, ptr %31, i64 0
  %33 = getelementptr inbounds %struct.MCCube, ptr %32, i32 0, i32 3
  store ptr %30, ptr %33, align 8, !tbaa !12
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.MCCube, ptr %35, i64 0
  %37 = getelementptr inbounds %struct.MCCube, ptr %36, i32 0, i32 2
  store i32 %34, ptr %37, align 8, !tbaa !15
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  call void @MCShrinkCube(ptr noundef %38)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  br label %39

39:                                               ; preds = %181, %3
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = load i8, ptr %6, align 1, !tbaa !11
  %42 = zext i8 %41 to i32
  %43 = icmp sle i32 %40, %42
  br i1 %43, label %44, label %182

44:                                               ; preds = %39
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds %struct.MCCube, ptr %45, i64 %47
  store ptr %48, ptr %14, align 8, !tbaa !5
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  call void @MCCalculateBiggestDimension(ptr noundef %49)
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MCCube, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.MCCube, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !15
  %56 = zext i32 %55 to i64
  call void @qsort(ptr noundef %52, i64 noundef %56, i64 noundef 3, ptr noundef @MCCompareTriplet)
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MCCube, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !12
  %60 = load ptr, ptr %14, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.MCCube, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !15
  %63 = udiv i32 %62, 2
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds %struct.MCTriplet, ptr %59, i64 %64
  %66 = getelementptr inbounds %struct.MCTriplet, ptr %65, i32 0, i32 0
  %67 = load i8, ptr @dim, align 1, !tbaa !11
  %68 = zext i8 %67 to i64
  %69 = getelementptr inbounds [3 x i8], ptr %66, i64 0, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !11
  %71 = zext i8 %70 to i32
  store i32 %71, ptr %13, align 4, !tbaa !9
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = sitofp i32 %72 to double
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = sitofp i32 %74 to double
  %76 = call double @pow(double noundef 2.000000e+00, double noundef %75) #6
  %77 = fdiv double %73, %76
  %78 = fptosi double %77 to i32
  store i32 %78, ptr %12, align 4, !tbaa !9
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = load i32, ptr %12, align 4, !tbaa !9
  %82 = add nsw i32 %80, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %struct.MCCube, ptr %79, i64 %83
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %84, ptr align 8 %85, i64 24, i1 false), !tbaa.struct !16
  %86 = load i32, ptr %13, align 4, !tbaa !9
  %87 = trunc i32 %86 to i8
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds %struct.MCCube, ptr %88, i64 %90
  %92 = getelementptr inbounds %struct.MCCube, ptr %91, i32 0, i32 1
  %93 = getelementptr inbounds %struct.MCTriplet, ptr %92, i32 0, i32 0
  %94 = load i8, ptr @dim, align 1, !tbaa !11
  %95 = zext i8 %94 to i64
  %96 = getelementptr inbounds [3 x i8], ptr %93, i64 0, i64 %95
  store i8 %87, ptr %96, align 1, !tbaa !11
  %97 = load i32, ptr %13, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  %99 = trunc i32 %98 to i8
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = load i32, ptr %10, align 4, !tbaa !9
  %102 = load i32, ptr %12, align 4, !tbaa !9
  %103 = add nsw i32 %101, %102
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds %struct.MCCube, ptr %100, i64 %104
  %106 = getelementptr inbounds %struct.MCCube, ptr %105, i32 0, i32 0
  %107 = getelementptr inbounds %struct.MCTriplet, ptr %106, i32 0, i32 0
  %108 = load i8, ptr @dim, align 1, !tbaa !11
  %109 = zext i8 %108 to i64
  %110 = getelementptr inbounds [3 x i8], ptr %107, i64 0, i64 %109
  store i8 %99, ptr %110, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %126, %44
  %112 = load ptr, ptr %14, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MCCube, ptr %112, i32 0, i32 3
  %114 = load ptr, ptr %113, align 8, !tbaa !12
  %115 = load i32, ptr %15, align 4, !tbaa !9
  %116 = zext i32 %115 to i64
  %117 = getelementptr inbounds %struct.MCTriplet, ptr %114, i64 %116
  %118 = getelementptr inbounds %struct.MCTriplet, ptr %117, i32 0, i32 0
  %119 = load i8, ptr @dim, align 1, !tbaa !11
  %120 = zext i8 %119 to i64
  %121 = getelementptr inbounds [3 x i8], ptr %118, i64 0, i64 %120
  %122 = load i8, ptr %121, align 1, !tbaa !11
  %123 = zext i8 %122 to i32
  %124 = load i32, ptr %13, align 4, !tbaa !9
  %125 = icmp sle i32 %123, %124
  br i1 %125, label %126, label %129

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

129:                                              ; preds = %111
  %130 = load i32, ptr %15, align 4, !tbaa !9
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = load i32, ptr %10, align 4, !tbaa !9
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds %struct.MCCube, ptr %131, i64 %133
  %135 = getelementptr inbounds %struct.MCCube, ptr %134, i32 0, i32 2
  store i32 %130, ptr %135, align 8, !tbaa !15
  %136 = load i32, ptr %15, align 4, !tbaa !9
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  %138 = load i32, ptr %10, align 4, !tbaa !9
  %139 = load i32, ptr %12, align 4, !tbaa !9
  %140 = add nsw i32 %138, %139
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds %struct.MCCube, ptr %137, i64 %141
  %143 = getelementptr inbounds %struct.MCCube, ptr %142, i32 0, i32 3
  %144 = load ptr, ptr %143, align 8, !tbaa !12
  %145 = zext i32 %136 to i64
  %146 = getelementptr inbounds %struct.MCTriplet, ptr %144, i64 %145
  store ptr %146, ptr %143, align 8, !tbaa !12
  %147 = load i32, ptr %15, align 4, !tbaa !9
  %148 = load ptr, ptr %8, align 8, !tbaa !5
  %149 = load i32, ptr %10, align 4, !tbaa !9
  %150 = load i32, ptr %12, align 4, !tbaa !9
  %151 = add nsw i32 %149, %150
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds %struct.MCCube, ptr %148, i64 %152
  %154 = getelementptr inbounds %struct.MCCube, ptr %153, i32 0, i32 2
  %155 = load i32, ptr %154, align 8, !tbaa !15
  %156 = sub i32 %155, %147
  store i32 %156, ptr %154, align 8, !tbaa !15
  %157 = load ptr, ptr %8, align 8, !tbaa !5
  %158 = load i32, ptr %10, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds %struct.MCCube, ptr %157, i64 %159
  call void @MCShrinkCube(ptr noundef %160)
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  %162 = load i32, ptr %10, align 4, !tbaa !9
  %163 = load i32, ptr %12, align 4, !tbaa !9
  %164 = add nsw i32 %162, %163
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds %struct.MCCube, ptr %161, i64 %165
  call void @MCShrinkCube(ptr noundef %166)
  %167 = load i32, ptr %10, align 4, !tbaa !9
  %168 = load i32, ptr %12, align 4, !tbaa !9
  %169 = mul nsw i32 %168, 2
  %170 = add nsw i32 %167, %169
  %171 = load i32, ptr %7, align 4, !tbaa !9
  %172 = icmp slt i32 %170, %171
  br i1 %172, label %173, label %178

173:                                              ; preds = %129
  %174 = load i32, ptr %10, align 4, !tbaa !9
  %175 = load i32, ptr %12, align 4, !tbaa !9
  %176 = mul nsw i32 %175, 2
  %177 = add nsw i32 %174, %176
  store i32 %177, ptr %10, align 4, !tbaa !9
  br label %181

178:                                              ; preds = %129
  store i32 0, ptr %10, align 4, !tbaa !9
  %179 = load i32, ptr %11, align 4, !tbaa !9
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %11, align 4, !tbaa !9
  br label %181

181:                                              ; preds = %178, %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %39, !llvm.loop !19

182:                                              ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %183

183:                                              ; preds = %199, %182
  %184 = load i32, ptr %16, align 4, !tbaa !9
  %185 = load i32, ptr %7, align 4, !tbaa !9
  %186 = icmp slt i32 %184, %185
  br i1 %186, label %188, label %187

187:                                              ; preds = %183
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %202

188:                                              ; preds = %183
  %189 = load ptr, ptr %9, align 8, !tbaa !5
  %190 = load i32, ptr %16, align 4, !tbaa !9
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds %struct.MCTriplet, ptr %189, i64 %191
  call void @llvm.lifetime.start.p0(i64 3, ptr %17) #6
  %193 = load ptr, ptr %8, align 8, !tbaa !5
  %194 = load i32, ptr %16, align 4, !tbaa !9
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds %struct.MCCube, ptr %193, i64 %195
  %197 = call i24 @MCCubeAverage(ptr noundef %196)
  %198 = getelementptr inbounds %struct.MCTriplet, ptr %17, i32 0, i32 0
  store i24 %197, ptr %198, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %192, ptr align 1 %17, i64 3, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 3, ptr %17) #6
  br label %199

199:                                              ; preds = %188
  %200 = load i32, ptr %16, align 4, !tbaa !9
  %201 = add nsw i32 %200, 1
  store i32 %201, ptr %16, align 4, !tbaa !9
  br label %183, !llvm.loop !21

202:                                              ; preds = %187
  %203 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %203) #6
  %204 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret ptr %204
}

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

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MCShrinkCube(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @MCCalculateBiggestDimension(ptr noundef) #1

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

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

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

; Function Attrs: nounwind uwtable
declare dso_local i24 @MCCubeAverage(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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


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

%struct.MCCube = type { %struct.MCTriplet, %struct.MCTriplet, i32, ptr }
%struct.MCTriplet = type { [3 x i8] }

@dim = external hidden local_unnamed_addr global i8, align 1

; Function Attrs: mustprogress 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) #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @MCQuantizeData(ptr noundef %0, i32 noundef %1, i8 noundef zeroext %2) local_unnamed_addr #1 {
  %4 = zext i8 %2 to i32
  %ldexp = tail call double @ldexp(double 1.000000e+00, i32 %4) #6
  %5 = fptosi double %ldexp to i32
  %6 = sext i32 %5 to i64
  %7 = mul nsw i64 %6, 24
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #7
  %9 = mul nsw i64 %6, 3
  %10 = tail call noalias ptr @malloc(i64 noundef %9) #7
  %11 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %0, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %1, ptr %12, align 8, !tbaa !12
  tail call void @MCShrinkCube(ptr noundef %8)
  %.not71 = icmp eq i8 %2, 0
  br i1 %.not71, label %.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %13 = sitofp i32 %5 to double
  br label %15

.preheader:                                       ; preds = %48, %3
  %14 = icmp sgt i32 %5, 0
  br i1 %14, label %.lr.ph75.preheader, label %._crit_edge

.lr.ph75.preheader:                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %.lr.ph75

15:                                               ; preds = %.lr.ph, %48
  %.073 = phi i32 [ 0, %.lr.ph ], [ %.1, %48 ]
  %.06672 = phi i32 [ 1, %.lr.ph ], [ %.167, %48 ]
  %16 = sext i32 %.073 to i64
  %17 = getelementptr inbounds %struct.MCCube, ptr %8, i64 %16
  tail call void @MCCalculateBiggestDimension(ptr noundef %17)
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %17, i64 8
  %21 = load i32, ptr %20, align 8, !tbaa !12
  %22 = zext i32 %21 to i64
  tail call void @qsort(ptr noundef %19, i64 noundef %22, i64 noundef 3, ptr noundef nonnull @MCCompareTriplet) #6
  %23 = load ptr, ptr %18, align 8, !tbaa !5
  %24 = load i32, ptr %20, align 8, !tbaa !12
  %25 = lshr i32 %24, 1
  %26 = zext nneg i32 %25 to i64
  %27 = getelementptr inbounds %struct.MCTriplet, ptr %23, i64 %26
  %28 = load i8, ptr @dim, align 1, !tbaa !13
  %29 = zext i8 %28 to i64
  %30 = getelementptr inbounds [3 x i8], ptr %27, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %ldexp69 = tail call double @ldexp(double 1.000000e+00, i32 %.06672) #6
  %32 = fdiv double %13, %ldexp69
  %33 = fptosi double %32 to i32
  %34 = add nsw i32 %.073, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %struct.MCCube, ptr %8, i64 %35
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %36, ptr noundef nonnull align 8 dereferenceable(24) %17, i64 24, i1 false), !tbaa.struct !14
  %37 = getelementptr inbounds i8, ptr %17, i64 3
  %38 = load i8, ptr @dim, align 1, !tbaa !13
  %39 = zext i8 %38 to i64
  %40 = getelementptr inbounds [3 x i8], ptr %37, i64 0, i64 %39
  store i8 %31, ptr %40, align 1, !tbaa !13
  %41 = add i8 %31, 1
  %42 = getelementptr inbounds [3 x i8], ptr %36, i64 0, i64 %39
  store i8 %41, ptr %42, align 1, !tbaa !13
  %43 = load ptr, ptr %18, align 8, !tbaa !5
  %invariant.gep = getelementptr inbounds [3 x i8], ptr %43, i64 0, i64 %39
  br label %44

44:                                               ; preds = %44, %15
  %.065 = phi i32 [ 0, %15 ], [ %47, %44 ]
  %45 = zext i32 %.065 to i64
  %gep = getelementptr inbounds %struct.MCTriplet, ptr %invariant.gep, i64 %45
  %46 = load i8, ptr %gep, align 1, !tbaa !13
  %.not70 = icmp ugt i8 %46, %31
  %47 = add i32 %.065, 1
  br i1 %.not70, label %48, label %44, !llvm.loop !17

48:                                               ; preds = %44
  store i32 %.065, ptr %20, align 8, !tbaa !12
  %49 = getelementptr inbounds i8, ptr %36, i64 16
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MCTriplet, ptr %50, i64 %45
  store ptr %51, ptr %49, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %36, i64 8
  %53 = load i32, ptr %52, align 8, !tbaa !12
  %54 = sub i32 %53, %.065
  store i32 %54, ptr %52, align 8, !tbaa !12
  tail call void @MCShrinkCube(ptr noundef nonnull %17)
  tail call void @MCShrinkCube(ptr noundef nonnull %36)
  %55 = shl nsw i32 %33, 1
  %56 = add nsw i32 %55, %.073
  %57 = icmp sge i32 %56, %5
  %58 = zext i1 %57 to i32
  %.167 = add nuw nsw i32 %.06672, %58
  %.1 = select i1 %57, i32 0, i32 %56
  %.not = icmp ugt i32 %.167, %4
  br i1 %.not, label %.preheader, label %15, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph75, %.preheader
  tail call void @free(ptr noundef %8) #6
  ret ptr %10

.lr.ph75:                                         ; preds = %.lr.ph75.preheader, %.lr.ph75
  %indvars.iv = phi i64 [ 0, %.lr.ph75.preheader ], [ %indvars.iv.next, %.lr.ph75 ]
  %59 = getelementptr inbounds %struct.MCTriplet, ptr %10, i64 %indvars.iv
  %60 = getelementptr inbounds %struct.MCCube, ptr %8, i64 %indvars.iv
  %61 = tail call i24 @MCCubeAverage(ptr noundef %60)
  store i24 %61, ptr %59, align 1, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph75, !llvm.loop !20
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @MCShrinkCube(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @MCCalculateBiggestDimension(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare dso_local i24 @MCCubeAverage(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree willreturn
declare double @ldexp(double, i32) local_unnamed_addr #5

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


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