; 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.DNuvec3 = 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 }
%union.QMvec3 = type { [3 x float] }
%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 global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [37 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: nounwind uwtable
declare dso_local ptr @DN_create_volume(i64, i32, i32 noundef) #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) #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @DN_load_volume(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca [256 x i8], align 16
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.DNuvec3, align 4
  %11 = alloca { i64, i32 }, align 4
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i16, align 2
  %16 = alloca { i64, i32 }, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str.14)
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %28, label %22

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 256, ptr %7) #6
  %23 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %23, ptr noundef @.str.15, ptr noundef %24) #6
  %26 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  %27 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  call void %26(i32 noundef 3, i32 noundef 1, ptr noundef %27)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 256, ptr %7) #6
  br label %191

28:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #6
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i64 @fread(ptr noundef %10, i64 noundef 12, i64 noundef 1, ptr noundef %29)
  %31 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %10, i64 12, i1 false)
  %32 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %33 = load i64, ptr %32, align 4
  %34 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %35 = load i32, ptr %34, align 4
  %36 = call ptr @DN_create_volume(i64 %33, i32 %35, i32 noundef %31)
  store ptr %36, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call i64 @fread(ptr noundef %12, i64 noundef 8, i64 noundef 1, ptr noundef %37)
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i64, ptr %12, align 8, !tbaa !11
  %41 = call zeroext i1 @DN_set_max_chunks(ptr noundef %39, i64 noundef %40)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %42 = call noalias ptr @malloc(i64 noundef 8240) #7
  store ptr %42, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %130, %28
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = load i64, ptr %12, align 8, !tbaa !11
  %47 = icmp ult i64 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %43
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %133

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #6
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call i64 @fread(ptr noundef %15, i64 noundef 2, i64 noundef 1, ptr noundef %50)
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = load i16, ptr %15, align 2, !tbaa !13
  %54 = zext i16 %53 to i64
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = call i64 @fread(ptr noundef %52, i64 noundef %54, i64 noundef 1, ptr noundef %55)
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.DNvolume, ptr %59, i32 0, i32 11
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %14, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.DNchunk, ptr %61, i64 %63
  call void @_DN_decompress_chunk(ptr noundef %57, ptr noundef %58, ptr noundef %64)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.DNvolume, ptr %66, i32 0, i32 11
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds %struct.DNchunk, ptr %68, i64 %70
  %72 = getelementptr inbounds %struct.DNchunk, ptr %71, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %72, i64 12, i1 false)
  %73 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %74 = load i64, ptr %73, align 4
  %75 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %76 = load i32, ptr %75, align 4
  %77 = call zeroext i1 @DN_in_map_bounds(ptr noundef %65, i64 %74, i32 %76)
  br i1 %77, label %78, label %129

78:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.DNvolume, ptr %79, i32 0, i32 11
  %81 = load ptr, ptr %80, align 8, !tbaa !15
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %struct.DNchunk, ptr %81, i64 %83
  %85 = getelementptr inbounds %struct.DNchunk, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds %struct.DNivec3, ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 4, !tbaa !20
  %88 = getelementptr inbounds %struct.DNuvec3, ptr %10, i32 0, i32 0
  %89 = load i32, ptr %88, align 4, !tbaa !23
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.DNvolume, ptr %90, i32 0, i32 11
  %92 = load ptr, ptr %91, align 8, !tbaa !15
  %93 = load i32, ptr %14, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %struct.DNchunk, ptr %92, i64 %94
  %96 = getelementptr inbounds %struct.DNchunk, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds %struct.DNivec3, ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !24
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.DNvolume, ptr %99, i32 0, i32 11
  %101 = load ptr, ptr %100, align 8, !tbaa !15
  %102 = load i32, ptr %14, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds %struct.DNchunk, ptr %101, i64 %103
  %105 = getelementptr inbounds %struct.DNchunk, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds %struct.DNivec3, ptr %105, i32 0, i32 2
  %107 = load i32, ptr %106, align 4, !tbaa !25
  %108 = getelementptr inbounds %struct.DNuvec3, ptr %10, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !26
  %110 = mul i32 %107, %109
  %111 = add i32 %98, %110
  %112 = mul i32 %89, %111
  %113 = add i32 %87, %112
  store i32 %113, ptr %17, align 4, !tbaa !9
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.DNvolume, ptr %114, i32 0, i32 10
  %116 = load ptr, ptr %115, align 8, !tbaa !27
  %117 = load i32, ptr %17, align 4, !tbaa !9
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds %struct.DNchunkHandle, ptr %116, i64 %118
  %120 = getelementptr inbounds %struct.DNchunkHandle, ptr %119, i32 0, i32 0
  store i8 1, ptr %120, align 4, !tbaa !28
  %121 = load i32, ptr %14, align 4, !tbaa !9
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.DNvolume, ptr %122, i32 0, i32 10
  %124 = load ptr, ptr %123, align 8, !tbaa !27
  %125 = load i32, ptr %17, align 4, !tbaa !9
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds %struct.DNchunkHandle, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.DNchunkHandle, ptr %127, i32 0, i32 1
  store i32 %121, ptr %128, align 4, !tbaa !30
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %129

129:                                              ; preds = %78, %49
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #6
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %14, align 4, !tbaa !9
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %14, align 4, !tbaa !9
  br label %43, !llvm.loop !31

133:                                              ; preds = %48
  %134 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %134) #6
  %135 = load ptr, ptr %9, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.DNvolume, ptr %135, i32 0, i32 12
  %137 = load ptr, ptr %136, align 8, !tbaa !33
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = call i64 @fread(ptr noundef %137, i64 noundef 32, i64 noundef 256, ptr noundef %138)
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.DNvolume, ptr %140, i32 0, i32 15
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = call i64 @fread(ptr noundef %141, i64 noundef 12, i64 noundef 1, ptr noundef %142)
  %144 = load ptr, ptr %9, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.DNvolume, ptr %144, i32 0, i32 16
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = call i64 @fread(ptr noundef %145, i64 noundef 12, i64 noundef 1, ptr noundef %146)
  %148 = load ptr, ptr %9, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.DNvolume, ptr %148, i32 0, i32 17
  %150 = load ptr, ptr %6, align 8, !tbaa !5
  %151 = call i64 @fread(ptr noundef %149, i64 noundef 4, i64 noundef 1, ptr noundef %150)
  %152 = load ptr, ptr %9, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.DNvolume, ptr %152, i32 0, i32 18
  %154 = load ptr, ptr %6, align 8, !tbaa !5
  %155 = call i64 @fread(ptr noundef %153, i64 noundef 4, i64 noundef 1, ptr noundef %154)
  %156 = load ptr, ptr %9, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.DNvolume, ptr %156, i32 0, i32 19
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  %159 = call i64 @fread(ptr noundef %157, i64 noundef 12, i64 noundef 1, ptr noundef %158)
  %160 = load ptr, ptr %9, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.DNvolume, ptr %160, i32 0, i32 20
  %162 = load ptr, ptr %6, align 8, !tbaa !5
  %163 = call i64 @fread(ptr noundef %161, i64 noundef 12, i64 noundef 1, ptr noundef %162)
  %164 = load ptr, ptr %9, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.DNvolume, ptr %164, i32 0, i32 21
  %166 = load ptr, ptr %6, align 8, !tbaa !5
  %167 = call i64 @fread(ptr noundef %165, i64 noundef 12, i64 noundef 1, ptr noundef %166)
  %168 = load ptr, ptr %9, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.DNvolume, ptr %168, i32 0, i32 22
  %170 = load ptr, ptr %6, align 8, !tbaa !5
  %171 = call i64 @fread(ptr noundef %169, i64 noundef 4, i64 noundef 1, ptr noundef %170)
  %172 = load ptr, ptr %9, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.DNvolume, ptr %172, i32 0, i32 23
  %174 = load ptr, ptr %6, align 8, !tbaa !5
  %175 = call i64 @fread(ptr noundef %173, i64 noundef 4, i64 noundef 1, ptr noundef %174)
  %176 = load ptr, ptr %9, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.DNvolume, ptr %176, i32 0, i32 24
  %178 = load ptr, ptr %6, align 8, !tbaa !5
  %179 = call i64 @fread(ptr noundef %177, i64 noundef 4, i64 noundef 1, ptr noundef %178)
  %180 = load ptr, ptr %9, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.DNvolume, ptr %180, i32 0, i32 27
  %182 = load ptr, ptr %6, align 8, !tbaa !5
  %183 = call i64 @fread(ptr noundef %181, i64 noundef 12, i64 noundef 1, ptr noundef %182)
  %184 = load ptr, ptr %9, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.DNvolume, ptr %184, i32 0, i32 28
  %186 = load ptr, ptr %6, align 8, !tbaa !5
  %187 = call i64 @fread(ptr noundef %185, i64 noundef 12, i64 noundef 1, ptr noundef %186)
  %188 = load ptr, ptr %6, align 8, !tbaa !5
  %189 = call i32 @fclose(ptr noundef %188)
  %190 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %190, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %191

191:                                              ; preds = %133, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %192 = load ptr, ptr %3, align 8
  ret ptr %192
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #5

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

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

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

declare i32 @fclose(ptr noundef) #5

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


; 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.DNuvec3 = type { i32, i32, i32 }
%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.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [37 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: nounwind uwtable
declare dso_local ptr @DN_create_volume(i64, i32, i32 noundef) local_unnamed_addr #1

; 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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @DN_load_volume(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca [256 x i8], align 16
  %4 = alloca %struct.DNuvec3, align 8
  %5 = alloca i64, align 8
  %6 = alloca i16, align 2
  %7 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.14)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %11

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #5
  %9 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef %0) #5
  %10 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  call void %10(i32 noundef 3, i32 noundef 1, ptr noundef nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #5
  br label %79

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #5
  %12 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %.sroa.012.0.copyload = load i64, ptr %4, align 8
  %.sroa.213.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  %.sroa.213.0.copyload = load i32, ptr %.sroa.213.0..sroa_idx, align 8
  %13 = tail call ptr @DN_create_volume(i64 %.sroa.012.0.copyload, i32 %.sroa.213.0.copyload, i32 noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %14 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef nonnull %7)
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = tail call zeroext i1 @DN_set_max_chunks(ptr noundef %13, i64 noundef %15)
  %17 = tail call noalias dereferenceable_or_null(8240) ptr @malloc(i64 noundef 8240) #6
  %.not65 = icmp eq i64 %15, 0
  %18 = trunc i64 %.sroa.012.0.copyload to i32
  %19 = lshr i64 %.sroa.012.0.copyload, 32
  %20 = trunc nuw i64 %19 to i32
  br i1 %.not65, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11
  %21 = getelementptr inbounds i8, ptr %13, i64 80
  %22 = getelementptr inbounds i8, ptr %13, i64 72
  br label %51

._crit_edge:                                      ; preds = %78, %11
  tail call void @free(ptr noundef %17) #5
  %23 = getelementptr inbounds i8, ptr %13, i64 88
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = tail call i64 @fread(ptr noundef %24, i64 noundef 32, i64 noundef 256, ptr noundef nonnull %7)
  %26 = getelementptr inbounds i8, ptr %13, i64 112
  %27 = tail call i64 @fread(ptr noundef nonnull %26, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %28 = getelementptr inbounds i8, ptr %13, i64 124
  %29 = tail call i64 @fread(ptr noundef nonnull %28, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %30 = getelementptr inbounds i8, ptr %13, i64 136
  %31 = tail call i64 @fread(ptr noundef nonnull %30, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %7)
  %32 = getelementptr inbounds i8, ptr %13, i64 140
  %33 = tail call i64 @fread(ptr noundef nonnull %32, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %7)
  %34 = getelementptr inbounds i8, ptr %13, i64 144
  %35 = tail call i64 @fread(ptr noundef nonnull %34, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %36 = getelementptr inbounds i8, ptr %13, i64 156
  %37 = tail call i64 @fread(ptr noundef nonnull %36, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %38 = getelementptr inbounds i8, ptr %13, i64 168
  %39 = tail call i64 @fread(ptr noundef nonnull %38, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %40 = getelementptr inbounds i8, ptr %13, i64 180
  %41 = tail call i64 @fread(ptr noundef nonnull %40, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %7)
  %42 = getelementptr inbounds i8, ptr %13, i64 184
  %43 = tail call i64 @fread(ptr noundef nonnull %42, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %7)
  %44 = getelementptr inbounds i8, ptr %13, i64 188
  %45 = tail call i64 @fread(ptr noundef nonnull %44, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %7)
  %46 = getelementptr inbounds i8, ptr %13, i64 200
  %47 = tail call i64 @fread(ptr noundef nonnull %46, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %48 = getelementptr inbounds i8, ptr %13, i64 212
  %49 = tail call i64 @fread(ptr noundef nonnull %48, i64 noundef 12, i64 noundef 1, ptr noundef nonnull %7)
  %50 = tail call i32 @fclose(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #5
  br label %79

51:                                               ; preds = %.lr.ph, %78
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %78 ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %6) #5
  %52 = call i64 @fread(ptr noundef nonnull %6, i64 noundef 2, i64 noundef 1, ptr noundef nonnull %7)
  %53 = load i16, ptr %6, align 2, !tbaa !17
  %54 = zext i16 %53 to i64
  %55 = tail call i64 @fread(ptr noundef %17, i64 noundef %54, i64 noundef 1, ptr noundef nonnull %7)
  %56 = load ptr, ptr %21, align 8, !tbaa !19
  %57 = getelementptr inbounds %struct.DNchunk, ptr %56, i64 %indvars.iv
  tail call void @_DN_decompress_chunk(ptr noundef %17, ptr noundef %13, ptr noundef %57)
  %58 = load ptr, ptr %21, align 8, !tbaa !19
  %59 = getelementptr inbounds %struct.DNchunk, ptr %58, i64 %indvars.iv
  %.sroa.0.0.copyload = load i64, ptr %59, align 4
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %59, i64 8
  %.sroa.2.0.copyload = load i32, ptr %.sroa.2.0..sroa_idx, align 4
  %60 = tail call zeroext i1 @DN_in_map_bounds(ptr noundef %13, i64 %.sroa.0.0.copyload, i32 %.sroa.2.0.copyload)
  br i1 %60, label %61, label %78

61:                                               ; preds = %51
  %62 = load ptr, ptr %21, align 8, !tbaa !19
  %63 = getelementptr inbounds %struct.DNchunk, ptr %62, i64 %indvars.iv
  %64 = load i32, ptr %63, align 4, !tbaa !20
  %65 = getelementptr inbounds i8, ptr %63, i64 4
  %66 = load i32, ptr %65, align 4, !tbaa !23
  %67 = getelementptr inbounds i8, ptr %63, i64 8
  %68 = load i32, ptr %67, align 4, !tbaa !24
  %69 = mul i32 %68, %20
  %70 = add i32 %69, %66
  %71 = mul i32 %70, %18
  %72 = add i32 %71, %64
  %73 = load ptr, ptr %22, align 8, !tbaa !25
  %74 = zext i32 %72 to i64
  %75 = getelementptr inbounds %struct.DNchunkHandle, ptr %73, i64 %74
  store i8 1, ptr %75, align 4, !tbaa !26
  %76 = getelementptr inbounds %struct.DNchunkHandle, ptr %73, i64 %74, i32 1
  %77 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %77, ptr %76, align 4, !tbaa !28
  br label %78

78:                                               ; preds = %61, %51
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #5
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %15
  br i1 %exitcond.not, label %._crit_edge, label %51, !llvm.loop !29

79:                                               ; preds = %._crit_edge, %8
  %.0 = phi ptr [ %13, %._crit_edge ], [ null, %8 ]
  ret ptr %.0
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync 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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 88}
!12 = !{!"DNvolume", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 12, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !7, i64 112, !7, i64 124, !15, i64 136, !13, i64 140, !7, i64 144, !7, i64 156, !7, i64 168, !13, i64 180, !13, i64 184, !15, i64 188, !16, i64 192, !13, i64 196, !7, i64 200, !7, i64 212, !13, i64 224, !15, i64 228}
!13 = !{!"int", !7, i64 0}
!14 = !{!"DNuvec3", !13, i64 0, !13, i64 4, !13, i64 8}
!15 = !{!"float", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!12, !6, i64 80}
!20 = !{!21, !13, i64 0}
!21 = !{!"DNchunk", !22, i64 0, !16, i64 12, !13, i64 16, !13, i64 20, !7, i64 24}
!22 = !{!"DNivec3", !13, i64 0, !13, i64 4, !13, i64 8}
!23 = !{!21, !13, i64 4}
!24 = !{!21, !13, i64 8}
!25 = !{!12, !6, i64 72}
!26 = !{!27, !7, i64 0}
!27 = !{!"DNchunkHandle", !7, i64 0, !13, i64 4}
!28 = !{!27, !13, i64 4}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass