; LLVM IR from frozein/DoonEngine :: src/DoonEngine (voxel)

; 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.DNivec3 = type { i32, i32, i32 }
%struct.DNvolume = type { i32, i32, i32, %struct.DNuvec3, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, %union.QMvec3, %union.QMvec3, float, i32, %union.QMvec3, %union.QMvec3, %union.QMvec3, i32, i32, float, i8, i32, %union.QMvec3, %union.QMvec3, i32, float }
%struct.DNuvec3 = type { i32, i32, i32 }
%union.QMvec3 = type { [3 x float] }
%struct.DNchunk = type { %struct.DNivec3, i8, i32, i32, [8 x [8 x [8 x %struct.DNcompressedVoxel]]] }
%struct.DNcompressedVoxel = type { i32, i32 }
%struct.DNchunkHandle = type { i8, i32 }

@g_DN_message_callback = external dso_local global ptr, align 8
@.str.18 = external hidden unnamed_addr constant [73 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minnum.f64(double, double) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @DN_in_map_bounds(ptr noundef, i64, i32) #3

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @DN_set_max_chunks(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @DN_add_chunk(ptr noundef %0, i64 %1, i32 %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca %struct.DNivec3, align 4
  %6 = alloca { i64, i32 }, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca { i64, i32 }, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.DNivec3, align 4
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca [256 x i8], align 16
  %15 = alloca i32, align 4
  %16 = alloca %struct.DNivec3, align 4
  %17 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  store i64 %1, ptr %17, align 4
  %18 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  store i32 %2, ptr %18, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %6, i64 12, i1 false)
  store ptr %0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DNvolume, ptr %19, i32 0, i32 5
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %8, align 4, !tbaa !16
  br label %23

23:                                               ; preds = %115, %3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DNvolume, ptr %25, i32 0, i32 11
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = load i32, ptr %8, align 4, !tbaa !16
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %struct.DNchunk, ptr %27, i64 %29
  %31 = getelementptr inbounds %struct.DNchunk, ptr %30, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %31, i64 12, i1 false)
  %32 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %33 = load i64, ptr %32, align 4
  %34 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %35 = load i32, ptr %34, align 4
  %36 = call zeroext i1 @DN_in_map_bounds(ptr noundef %24, i64 %33, i32 %35)
  br i1 %36, label %104, label %37

37:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %38 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !18
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.DNvolume, ptr %40, i32 0, i32 3
  %42 = getelementptr inbounds %struct.DNuvec3, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !20
  %44 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !21
  %46 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !22
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.DNvolume, ptr %48, i32 0, i32 3
  %50 = getelementptr inbounds %struct.DNuvec3, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !23
  %52 = mul i32 %47, %51
  %53 = add i32 %45, %52
  %54 = mul i32 %43, %53
  %55 = add i32 %39, %54
  store i32 %55, ptr %10, align 4, !tbaa !16
  %56 = load i32, ptr %8, align 4, !tbaa !16
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.DNvolume, ptr %57, i32 0, i32 10
  %59 = load ptr, ptr %58, align 8, !tbaa !24
  %60 = load i32, ptr %10, align 4, !tbaa !16
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds %struct.DNchunkHandle, ptr %59, i64 %61
  %63 = getelementptr inbounds %struct.DNchunkHandle, ptr %62, i32 0, i32 1
  store i32 %56, ptr %63, align 4, !tbaa !25
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.DNvolume, ptr %64, i32 0, i32 10
  %66 = load ptr, ptr %65, align 8, !tbaa !24
  %67 = load i32, ptr %10, align 4, !tbaa !16
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %struct.DNchunkHandle, ptr %66, i64 %68
  %70 = getelementptr inbounds %struct.DNchunkHandle, ptr %69, i32 0, i32 0
  store i8 1, ptr %70, align 4, !tbaa !27
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.DNvolume, ptr %71, i32 0, i32 11
  %73 = load ptr, ptr %72, align 8, !tbaa !17
  %74 = load i32, ptr %8, align 4, !tbaa !16
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds %struct.DNchunk, ptr %73, i64 %75
  %77 = getelementptr inbounds %struct.DNchunk, ptr %76, i32 0, i32 0
  %78 = getelementptr inbounds %struct.DNivec3, ptr %11, i32 0, i32 0
  %79 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !18
  store i32 %80, ptr %78, align 4, !tbaa !18
  %81 = getelementptr inbounds %struct.DNivec3, ptr %11, i32 0, i32 1
  %82 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !21
  store i32 %83, ptr %81, align 4, !tbaa !21
  %84 = getelementptr inbounds %struct.DNivec3, ptr %11, i32 0, i32 2
  %85 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 2
  %86 = load i32, ptr %85, align 4, !tbaa !22
  store i32 %86, ptr %84, align 4, !tbaa !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %77, ptr align 4 %11, i64 12, i1 false), !tbaa.struct !28
  %87 = load i32, ptr %8, align 4, !tbaa !16
  %88 = sext i32 %87 to i64
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.DNvolume, ptr %89, i32 0, i32 4
  %91 = load i64, ptr %90, align 8, !tbaa !29
  %92 = sub i64 %91, 1
  %93 = icmp eq i64 %88, %92
  br i1 %93, label %94, label %95

94:                                               ; preds = %37
  br label %98

95:                                               ; preds = %37
  %96 = load i32, ptr %8, align 4, !tbaa !16
  %97 = add nsw i32 %96, 1
  br label %98

98:                                               ; preds = %95, %94
  %99 = phi i32 [ 0, %94 ], [ %97, %95 ]
  %100 = sext i32 %99 to i64
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.DNvolume, ptr %101, i32 0, i32 5
  store i64 %100, ptr %102, align 8, !tbaa !9
  %103 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %103, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %228

104:                                              ; preds = %23
  %105 = load i32, ptr %8, align 4, !tbaa !16
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %8, align 4, !tbaa !16
  %107 = load i32, ptr %8, align 4, !tbaa !16
  %108 = sext i32 %107 to i64
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.DNvolume, ptr %109, i32 0, i32 4
  %111 = load i64, ptr %110, align 8, !tbaa !29
  %112 = icmp uge i64 %108, %111
  br i1 %112, label %113, label %114

113:                                              ; preds = %104
  store i32 0, ptr %8, align 4, !tbaa !16
  br label %114

114:                                              ; preds = %113, %104
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %8, align 4, !tbaa !16
  %117 = sext i32 %116 to i64
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.DNvolume, ptr %118, i32 0, i32 5
  %120 = load i64, ptr %119, align 8, !tbaa !9
  %121 = icmp ne i64 %117, %120
  br i1 %121, label %23, label %122, !llvm.loop !30

122:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.DNvolume, ptr %123, i32 0, i32 4
  %125 = load i64, ptr %124, align 8, !tbaa !29
  %126 = mul i64 %125, 2
  %127 = uitofp i64 %126 to double
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.DNvolume, ptr %128, i32 0, i32 3
  %130 = getelementptr inbounds %struct.DNuvec3, ptr %129, i32 0, i32 0
  %131 = load i32, ptr %130, align 4, !tbaa !20
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.DNvolume, ptr %132, i32 0, i32 3
  %134 = getelementptr inbounds %struct.DNuvec3, ptr %133, i32 0, i32 1
  %135 = load i32, ptr %134, align 4, !tbaa !23
  %136 = mul i32 %131, %135
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.DNvolume, ptr %137, i32 0, i32 3
  %139 = getelementptr inbounds %struct.DNuvec3, ptr %138, i32 0, i32 2
  %140 = load i32, ptr %139, align 4, !tbaa !32
  %141 = mul i32 %136, %140
  %142 = uitofp i32 %141 to double
  %143 = call double @llvm.minnum.f64(double %127, double %142)
  %144 = fptoui double %143 to i64
  store i64 %144, ptr %13, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 256, ptr %14) #5
  %145 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  %146 = load i64, ptr %13, align 8, !tbaa !33
  %147 = load i64, ptr %13, align 8, !tbaa !33
  %148 = mul i64 %147, 4120
  %149 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %145, ptr noundef @.str.18, i64 noundef %146, i64 noundef %148) #5
  %150 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  %151 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  call void %150(i32 noundef 0, i32 noundef 0, ptr noundef %151)
  %152 = load ptr, ptr %7, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.DNvolume, ptr %152, i32 0, i32 4
  %154 = load i64, ptr %153, align 8, !tbaa !29
  %155 = trunc i64 %154 to i32
  store i32 %155, ptr %8, align 4, !tbaa !16
  %156 = load ptr, ptr %7, align 8, !tbaa !5
  %157 = load i64, ptr %13, align 8, !tbaa !33
  %158 = call zeroext i1 @DN_set_max_chunks(ptr noundef %156, i64 noundef %157)
  br i1 %158, label %160, label %159

159:                                              ; preds = %122
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %227

160:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %161 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 0
  %162 = load i32, ptr %161, align 4, !tbaa !18
  %163 = load ptr, ptr %7, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.DNvolume, ptr %163, i32 0, i32 3
  %165 = getelementptr inbounds %struct.DNuvec3, ptr %164, i32 0, i32 0
  %166 = load i32, ptr %165, align 4, !tbaa !20
  %167 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 1
  %168 = load i32, ptr %167, align 4, !tbaa !21
  %169 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 2
  %170 = load i32, ptr %169, align 4, !tbaa !22
  %171 = load ptr, ptr %7, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.DNvolume, ptr %171, i32 0, i32 3
  %173 = getelementptr inbounds %struct.DNuvec3, ptr %172, i32 0, i32 1
  %174 = load i32, ptr %173, align 4, !tbaa !23
  %175 = mul i32 %170, %174
  %176 = add i32 %168, %175
  %177 = mul i32 %166, %176
  %178 = add i32 %162, %177
  store i32 %178, ptr %15, align 4, !tbaa !16
  %179 = load i32, ptr %8, align 4, !tbaa !16
  %180 = load ptr, ptr %7, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.DNvolume, ptr %180, i32 0, i32 10
  %182 = load ptr, ptr %181, align 8, !tbaa !24
  %183 = load i32, ptr %15, align 4, !tbaa !16
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds %struct.DNchunkHandle, ptr %182, i64 %184
  %186 = getelementptr inbounds %struct.DNchunkHandle, ptr %185, i32 0, i32 1
  store i32 %179, ptr %186, align 4, !tbaa !25
  %187 = load ptr, ptr %7, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.DNvolume, ptr %187, i32 0, i32 10
  %189 = load ptr, ptr %188, align 8, !tbaa !24
  %190 = load i32, ptr %15, align 4, !tbaa !16
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds %struct.DNchunkHandle, ptr %189, i64 %191
  %193 = getelementptr inbounds %struct.DNchunkHandle, ptr %192, i32 0, i32 0
  store i8 1, ptr %193, align 4, !tbaa !27
  %194 = load ptr, ptr %7, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.DNvolume, ptr %194, i32 0, i32 11
  %196 = load ptr, ptr %195, align 8, !tbaa !17
  %197 = load i32, ptr %8, align 4, !tbaa !16
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds %struct.DNchunk, ptr %196, i64 %198
  %200 = getelementptr inbounds %struct.DNchunk, ptr %199, i32 0, i32 0
  %201 = getelementptr inbounds %struct.DNivec3, ptr %16, i32 0, i32 0
  %202 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 0
  %203 = load i32, ptr %202, align 4, !tbaa !18
  store i32 %203, ptr %201, align 4, !tbaa !18
  %204 = getelementptr inbounds %struct.DNivec3, ptr %16, i32 0, i32 1
  %205 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 1
  %206 = load i32, ptr %205, align 4, !tbaa !21
  store i32 %206, ptr %204, align 4, !tbaa !21
  %207 = getelementptr inbounds %struct.DNivec3, ptr %16, i32 0, i32 2
  %208 = getelementptr inbounds %struct.DNivec3, ptr %5, i32 0, i32 2
  %209 = load i32, ptr %208, align 4, !tbaa !22
  store i32 %209, ptr %207, align 4, !tbaa !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %200, ptr align 4 %16, i64 12, i1 false), !tbaa.struct !28
  %210 = load i32, ptr %8, align 4, !tbaa !16
  %211 = sext i32 %210 to i64
  %212 = load ptr, ptr %7, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct.DNvolume, ptr %212, i32 0, i32 4
  %214 = load i64, ptr %213, align 8, !tbaa !29
  %215 = sub i64 %214, 1
  %216 = icmp eq i64 %211, %215
  br i1 %216, label %217, label %218

217:                                              ; preds = %160
  br label %221

218:                                              ; preds = %160
  %219 = load i32, ptr %8, align 4, !tbaa !16
  %220 = add nsw i32 %219, 1
  br label %221

221:                                              ; preds = %218, %217
  %222 = phi i32 [ 0, %217 ], [ %220, %218 ]
  %223 = sext i32 %222 to i64
  %224 = load ptr, ptr %7, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.DNvolume, ptr %224, i32 0, i32 5
  store i64 %223, ptr %225, align 8, !tbaa !9
  %226 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %226, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %227

227:                                              ; preds = %221, %159
  call void @llvm.lifetime.end.p0(i64 256, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %228

228:                                              ; preds = %227, %98
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %229 = load i32, ptr %4, align 4
  ret i32 %229
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #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/C++ TBAA"}
!9 = !{!10, !13, i64 32}
!10 = !{!"DNvolume", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !7, i64 112, !7, i64 124, !14, i64 136, !11, i64 140, !7, i64 144, !7, i64 156, !7, i64 168, !11, i64 180, !11, i64 184, !14, i64 188, !15, i64 192, !11, i64 196, !7, i64 200, !7, i64 212, !11, i64 224, !14, i64 228}
!11 = !{!"int", !7, i64 0}
!12 = !{!"DNuvec3", !11, i64 0, !11, i64 4, !11, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 80}
!18 = !{!19, !11, i64 0}
!19 = !{!"DNivec3", !11, i64 0, !11, i64 4, !11, i64 8}
!20 = !{!10, !11, i64 12}
!21 = !{!19, !11, i64 4}
!22 = !{!19, !11, i64 8}
!23 = !{!10, !11, i64 16}
!24 = !{!10, !6, i64 72}
!25 = !{!26, !11, i64 4}
!26 = !{!"DNchunkHandle", !7, i64 0, !11, i64 4}
!27 = !{!26, !7, i64 0}
!28 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 4, !16}
!29 = !{!10, !13, i64 24}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!10, !11, i64 20}
!33 = !{!13, !13, i64 0}


; 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.DNchunk = type { %struct.DNivec3, i8, i32, i32, [8 x [8 x [8 x %struct.DNcompressedVoxel]]] }
%struct.DNivec3 = type { i32, i32, i32 }
%struct.DNcompressedVoxel = type { i32, i32 }
%struct.DNchunkHandle = type { i8, i32 }

@g_DN_message_callback = external dso_local local_unnamed_addr global ptr, align 8
@.str.18 = external hidden unnamed_addr constant [73 x i8], align 1

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minnum.f64(double, double) #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @DN_set_max_chunks(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @DN_add_chunk(ptr noundef %0, i64 %1, i32 %2) local_unnamed_addr #2 {
  %4 = alloca [256 x i8], align 16
  %.sroa.052.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.5.0.extract.shift = lshr i64 %1, 32
  %.sroa.5.0.extract.trunc = trunc nuw i64 %.sroa.5.0.extract.shift to i32
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = trunc i64 %6 to i32
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  br label %10

10:                                               ; preds = %37, %3
  %.063 = phi i32 [ %7, %3 ], [ %spec.store.select, %37 ]
  %11 = load ptr, ptr %8, align 8, !tbaa !15
  %12 = sext i32 %.063 to i64
  %13 = getelementptr inbounds %struct.DNchunk, ptr %11, i64 %12
  %.sroa.010.0.copyload = load i64, ptr %13, align 4
  %.sroa.211.0..sroa_idx = getelementptr inbounds i8, ptr %13, i64 8
  %.sroa.211.0.copyload = load i32, ptr %.sroa.211.0..sroa_idx, align 4
  %14 = tail call zeroext i1 @DN_in_map_bounds(ptr noundef nonnull %0, i64 %.sroa.010.0.copyload, i32 %.sroa.211.0.copyload)
  br i1 %14, label %37, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %0, i64 12
  %17 = load i32, ptr %16, align 4, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = mul i32 %19, %2
  %21 = add i32 %20, %.sroa.5.0.extract.trunc
  %22 = mul i32 %21, %17
  %23 = add i32 %22, %.sroa.052.0.extract.trunc
  %24 = getelementptr inbounds i8, ptr %0, i64 72
  %25 = load ptr, ptr %24, align 8, !tbaa !18
  %26 = sext i32 %23 to i64
  %27 = getelementptr inbounds %struct.DNchunkHandle, ptr %25, i64 %26, i32 1
  store i32 %.063, ptr %27, align 4, !tbaa !19
  %28 = getelementptr inbounds %struct.DNchunkHandle, ptr %25, i64 %26
  store i8 1, ptr %28, align 4, !tbaa !21
  %29 = load ptr, ptr %8, align 8, !tbaa !15
  %30 = getelementptr inbounds %struct.DNchunk, ptr %29, i64 %12
  store i32 %.sroa.052.0.extract.trunc, ptr %30, align 4, !tbaa !22
  %.sroa.26.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 4
  store i32 %.sroa.5.0.extract.trunc, ptr %.sroa.26.0..sroa_idx, align 4, !tbaa !22
  %.sroa.37.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 8
  store i32 %2, ptr %.sroa.37.0..sroa_idx, align 4, !tbaa !22
  %31 = load i64, ptr %9, align 8, !tbaa !23
  %32 = add i64 %31, -1
  %33 = icmp eq i64 %32, %12
  %34 = add nsw i32 %.063, 1
  %35 = sext i32 %34 to i64
  %36 = select i1 %33, i64 0, i64 %35
  store i64 %36, ptr %5, align 8, !tbaa !5
  br label %84

37:                                               ; preds = %10
  %38 = add nsw i32 %.063, 1
  %39 = sext i32 %38 to i64
  %40 = load i64, ptr %9, align 8, !tbaa !23
  %.not = icmp ugt i64 %40, %39
  %spec.store.select = select i1 %.not, i32 %38, i32 0
  %41 = sext i32 %spec.store.select to i64
  %42 = load i64, ptr %5, align 8, !tbaa !5
  %.not64 = icmp eq i64 %42, %41
  br i1 %.not64, label %43, label %10, !llvm.loop !24

43:                                               ; preds = %37
  %44 = shl i64 %40, 1
  %45 = uitofp i64 %44 to double
  %46 = getelementptr inbounds i8, ptr %0, i64 12
  %47 = load i32, ptr %46, align 4, !tbaa !16
  %48 = getelementptr inbounds i8, ptr %0, i64 16
  %49 = load i32, ptr %48, align 4, !tbaa !17
  %50 = mul i32 %49, %47
  %51 = getelementptr inbounds i8, ptr %0, i64 20
  %52 = load i32, ptr %51, align 4, !tbaa !26
  %53 = mul i32 %50, %52
  %54 = uitofp i32 %53 to double
  %55 = tail call double @llvm.minnum.f64(double %45, double %54)
  %56 = fptoui double %55 to i64
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %4) #4
  %57 = mul i64 %56, 4120
  %58 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.18, i64 noundef %56, i64 noundef %57) #4
  %59 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !27
  call void %59(i32 noundef 0, i32 noundef 0, ptr noundef nonnull %4) #4
  %60 = load i64, ptr %9, align 8, !tbaa !23
  %61 = call zeroext i1 @DN_set_max_chunks(ptr noundef nonnull %0, i64 noundef %56)
  br i1 %61, label %62, label %83

62:                                               ; preds = %43
  %63 = trunc i64 %60 to i32
  %64 = load i32, ptr %46, align 4, !tbaa !16
  %65 = load i32, ptr %48, align 4, !tbaa !17
  %66 = mul i32 %65, %2
  %67 = add i32 %66, %.sroa.5.0.extract.trunc
  %68 = mul i32 %67, %64
  %69 = add i32 %68, %.sroa.052.0.extract.trunc
  %70 = getelementptr inbounds i8, ptr %0, i64 72
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = sext i32 %69 to i64
  %73 = getelementptr inbounds %struct.DNchunkHandle, ptr %71, i64 %72, i32 1
  store i32 %63, ptr %73, align 4, !tbaa !19
  %74 = getelementptr inbounds %struct.DNchunkHandle, ptr %71, i64 %72
  store i8 1, ptr %74, align 4, !tbaa !21
  %75 = load ptr, ptr %8, align 8, !tbaa !15
  %sext = shl i64 %60, 32
  %76 = ashr exact i64 %sext, 32
  %77 = getelementptr inbounds %struct.DNchunk, ptr %75, i64 %76
  store i32 %.sroa.052.0.extract.trunc, ptr %77, align 4, !tbaa !22
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %77, i64 4
  store i32 %.sroa.5.0.extract.trunc, ptr %.sroa.2.0..sroa_idx, align 4, !tbaa !22
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %77, i64 8
  store i32 %2, ptr %.sroa.3.0..sroa_idx, align 4, !tbaa !22
  %78 = load i64, ptr %9, align 8, !tbaa !23
  %79 = add i64 %78, -1
  %80 = icmp eq i64 %76, %79
  %sext65 = add i64 %sext, 4294967296
  %81 = ashr exact i64 %sext65, 32
  %82 = select i1 %80, i64 0, i64 %81
  store i64 %82, ptr %5, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %43, %62
  %.0 = phi i32 [ %63, %62 ], [ 0, %43 ]
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %4) #4
  br label %84

84:                                               ; preds = %83, %15
  %.1 = phi i32 [ %.0, %83 ], [ %.063, %15 ]
  ret i32 %.1
}

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

!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 32}
!6 = !{!"DNvolume", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !8, i64 112, !8, i64 124, !13, i64 136, !7, i64 140, !8, i64 144, !8, i64 156, !8, i64 168, !7, i64 180, !7, i64 184, !13, i64 188, !14, i64 192, !7, i64 196, !8, i64 200, !8, i64 212, !7, i64 224, !13, i64 228}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"DNuvec3", !7, i64 0, !7, i64 4, !7, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!6, !12, i64 80}
!16 = !{!6, !7, i64 12}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !12, i64 72}
!19 = !{!20, !7, i64 4}
!20 = !{!"DNchunkHandle", !8, i64 0, !7, i64 4}
!21 = !{!20, !8, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!6, !11, i64 24}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!6, !7, i64 20}
!27 = !{!12, !12, i64 0}


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