; 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.DNchunkHandle = type { i8, i32 }

; 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 zeroext i1 @DN_does_chunk_exist(ptr noundef %0, i64 %1, i32 %2) #1 {
  %4 = alloca %struct.DNivec3, align 4
  %5 = alloca { i64, i32 }, align 4
  %6 = alloca ptr, align 8
  %7 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  store i64 %1, ptr %7, align 4
  %8 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  store i32 %2, ptr %8, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %5, i64 12, i1 false)
  store ptr %0, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.DNvolume, ptr %9, i32 0, i32 10
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !16
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DNvolume, ptr %14, i32 0, i32 3
  %16 = getelementptr inbounds %struct.DNuvec3, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 4, !tbaa !18
  %18 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !19
  %20 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 2
  %21 = load i32, ptr %20, align 4, !tbaa !20
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.DNvolume, ptr %22, i32 0, i32 3
  %24 = getelementptr inbounds %struct.DNuvec3, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !21
  %26 = mul i32 %21, %25
  %27 = add i32 %19, %26
  %28 = mul i32 %17, %27
  %29 = add i32 %13, %28
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %struct.DNchunkHandle, ptr %11, i64 %30
  %32 = getelementptr inbounds %struct.DNchunkHandle, ptr %31, i32 0, i32 0
  %33 = load i8, ptr %32, align 4, !tbaa !22
  %34 = zext i8 %33 to i32
  %35 = icmp sge i32 %34, 1
  ret i1 %35
}

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

!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, !6, i64 72}
!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 = !{!17, !11, i64 0}
!17 = !{!"DNivec3", !11, i64 0, !11, i64 4, !11, i64 8}
!18 = !{!10, !11, i64 12}
!19 = !{!17, !11, i64 4}
!20 = !{!17, !11, i64 8}
!21 = !{!10, !11, i64 16}
!22 = !{!23, !7, i64 0}
!23 = !{!"DNchunkHandle", !7, i64 0, !11, i64 4}


; 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.DNchunkHandle = type { i8, i32 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local zeroext i1 @DN_does_chunk_exist(ptr nocapture noundef readonly %0, i64 %1, i32 %2) local_unnamed_addr #0 {
  %.sroa.03.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.24.0.extract.shift = lshr i64 %1, 32
  %.sroa.24.0.extract.trunc = trunc nuw i64 %.sroa.24.0.extract.shift to i32
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i32, ptr %8, align 4, !tbaa !16
  %10 = mul i32 %9, %2
  %11 = add i32 %10, %.sroa.24.0.extract.trunc
  %12 = mul i32 %11, %7
  %13 = add i32 %12, %.sroa.03.0.extract.trunc
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds %struct.DNchunkHandle, ptr %5, i64 %14
  %16 = load i8, ptr %15, align 4, !tbaa !17
  %17 = icmp ne i8 %16, 0
  ret i1 %17
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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" }

!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, !12, i64 72}
!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, !7, i64 12}
!16 = !{!6, !7, i64 16}
!17 = !{!18, !8, i64 0}
!18 = !{!"DNchunkHandle", !8, i64 0, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass