; 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] }

; 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_in_map_bounds(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 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.DNvolume, ptr %11, i32 0, i32 3
  %13 = getelementptr inbounds %struct.DNuvec3, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = icmp ult i32 %10, %14
  br i1 %15, label %16, label %44

16:                                               ; preds = %3
  %17 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !18
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DNvolume, ptr %19, i32 0, i32 3
  %21 = getelementptr inbounds %struct.DNuvec3, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !19
  %23 = icmp ult i32 %18, %22
  br i1 %23, label %24, label %44

24:                                               ; preds = %16
  %25 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !20
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DNvolume, ptr %27, i32 0, i32 3
  %29 = getelementptr inbounds %struct.DNuvec3, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !21
  %31 = icmp ult i32 %26, %30
  br i1 %31, label %32, label %44

32:                                               ; preds = %24
  %33 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = icmp sge i32 %34, 0
  br i1 %35, label %36, label %44

36:                                               ; preds = %32
  %37 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !18
  %39 = icmp sge i32 %38, 0
  br i1 %39, label %40, label %44

40:                                               ; preds = %36
  %41 = getelementptr inbounds %struct.DNivec3, ptr %4, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !20
  %43 = icmp sge i32 %42, 0
  br label %44

44:                                               ; preds = %40, %36, %32, %24, %16, %3
  %45 = phi i1 [ false, %36 ], [ false, %32 ], [ false, %24 ], [ false, %16 ], [ false, %3 ], [ %43, %40 ]
  ret i1 %45
}

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, !11, i64 0}
!10 = !{!"DNivec3", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 12}
!13 = !{!"DNvolume", !11, i64 0, !11, i64 4, !11, i64 8, !14, i64 12, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !7, i64 112, !7, i64 124, !16, i64 136, !11, i64 140, !7, i64 144, !7, i64 156, !7, i64 168, !11, i64 180, !11, i64 184, !16, i64 188, !17, i64 192, !11, i64 196, !7, i64 200, !7, i64 212, !11, i64 224, !16, i64 228}
!14 = !{!"DNuvec3", !11, i64 0, !11, i64 4, !11, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!10, !11, i64 4}
!19 = !{!13, !11, i64 16}
!20 = !{!10, !11, i64 8}
!21 = !{!13, !11, i64 20}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local zeroext i1 @DN_in_map_bounds(ptr nocapture noundef readonly %0, i64 %1, i32 %2) local_unnamed_addr #0 {
  %.sroa.08.0.extract.trunc = trunc i64 %1 to i32
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp ugt i32 %5, %.sroa.08.0.extract.trunc
  br i1 %6, label %7, label %18

7:                                                ; preds = %3
  %.sroa.3.0.extract.shift = lshr i64 %1, 32
  %.sroa.3.0.extract.trunc = trunc nuw i64 %.sroa.3.0.extract.shift to i32
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i32, ptr %8, align 4, !tbaa !15
  %10 = icmp ugt i32 %9, %.sroa.3.0.extract.trunc
  br i1 %10, label %11, label %18

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 20
  %13 = load i32, ptr %12, align 4, !tbaa !16
  %14 = icmp ugt i32 %13, %2
  %15 = and i64 %1, -9223372034707292160
  %16 = icmp eq i64 %15, 0
  %or.cond5 = and i1 %16, %14
  %17 = icmp sgt i32 %2, -1
  %spec.select = and i1 %17, %or.cond5
  br label %18

18:                                               ; preds = %11, %7, %3
  %19 = phi i1 [ false, %7 ], [ false, %3 ], [ %spec.select, %11 ]
  ret i1 %19
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !7, i64 12}
!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 16}
!16 = !{!6, !7, i64 20}


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