; 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.DNvoxel = type { i8, %union.QMvec3, %struct.DNcolor }
%union.QMvec3 = type { [3 x float] }
%struct.DNcolor = type { i8, i8, i8 }
%struct.DNcompressedVoxel = type { i32, i32 }
%struct.DNuvec3 = type { i32, i32, i32 }
%struct.anon = type { float, float, float }

; 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: nounwind uwtable
define dso_local i64 @DN_compress_voxel(ptr noundef byval(%struct.DNvoxel) align 8 %0) #2 {
  %2 = alloca %struct.DNcompressedVoxel, align 4
  %3 = alloca %union.QMvec3, align 4
  %4 = alloca %union.QMvec3, align 4
  %5 = alloca { <2 x float>, float }, align 4
  %6 = alloca { <2 x float>, float }, align 4
  %7 = alloca { <2 x float>, float }, align 8
  %8 = alloca %union.QMvec3, align 4
  %9 = alloca %union.QMvec3, align 4
  %10 = alloca { <2 x float>, float }, align 4
  %11 = alloca { <2 x float>, float }, align 4
  %12 = alloca { <2 x float>, float }, align 8
  %13 = alloca %struct.DNuvec3, align 4
  %14 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #4
  %15 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  store float 1.000000e+00, ptr %4, align 4, !tbaa !5
  %16 = getelementptr inbounds float, ptr %4, i64 1
  store float 1.000000e+00, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds float, ptr %4, i64 2
  store float 1.000000e+00, ptr %17, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %15, i64 12, i1 false)
  %18 = getelementptr inbounds { <2 x float>, float }, ptr %5, i32 0, i32 0
  %19 = load <2 x float>, ptr %18, align 4
  %20 = getelementptr inbounds { <2 x float>, float }, ptr %5, i32 0, i32 1
  %21 = load float, ptr %20, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %4, i64 12, i1 false)
  %22 = getelementptr inbounds { <2 x float>, float }, ptr %6, i32 0, i32 0
  %23 = load <2 x float>, ptr %22, align 4
  %24 = getelementptr inbounds { <2 x float>, float }, ptr %6, i32 0, i32 1
  %25 = load float, ptr %24, align 4
  %26 = call { <2 x float>, float } @DN_vec3_min(<2 x float> %19, float %21, <2 x float> %23, float %25)
  %27 = getelementptr inbounds %union.QMvec3, ptr %3, i32 0, i32 0
  store { <2 x float>, float } %26, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 8 %7, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %3, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %3) #4
  %28 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #4
  %29 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  store float -1.000000e+00, ptr %9, align 4, !tbaa !5
  %30 = getelementptr inbounds float, ptr %9, i64 1
  store float -1.000000e+00, ptr %30, align 4, !tbaa !5
  %31 = getelementptr inbounds float, ptr %9, i64 2
  store float -1.000000e+00, ptr %31, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %29, i64 12, i1 false)
  %32 = getelementptr inbounds { <2 x float>, float }, ptr %10, i32 0, i32 0
  %33 = load <2 x float>, ptr %32, align 4
  %34 = getelementptr inbounds { <2 x float>, float }, ptr %10, i32 0, i32 1
  %35 = load float, ptr %34, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %9, i64 12, i1 false)
  %36 = getelementptr inbounds { <2 x float>, float }, ptr %11, i32 0, i32 0
  %37 = load <2 x float>, ptr %36, align 4
  %38 = getelementptr inbounds { <2 x float>, float }, ptr %11, i32 0, i32 1
  %39 = load float, ptr %38, align 4
  %40 = call { <2 x float>, float } @DN_vec3_max(<2 x float> %33, float %35, <2 x float> %37, float %39)
  %41 = getelementptr inbounds %union.QMvec3, ptr %8, i32 0, i32 0
  store { <2 x float>, float } %40, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %41, ptr align 8 %12, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %8, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #4
  %42 = getelementptr inbounds %struct.DNuvec3, ptr %13, i32 0, i32 0
  %43 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  %44 = getelementptr inbounds %struct.anon, ptr %43, i32 0, i32 0
  %45 = load float, ptr %44, align 4, !tbaa !10
  %46 = fmul float %45, 2.550000e+02
  %47 = fptosi float %46 to i32
  %48 = add nsw i32 %47, 255
  %49 = sdiv i32 %48, 2
  store i32 %49, ptr %42, align 4, !tbaa !11
  %50 = getelementptr inbounds %struct.DNuvec3, ptr %13, i32 0, i32 1
  %51 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !10
  %54 = fmul float %53, 2.550000e+02
  %55 = fptosi float %54 to i32
  %56 = add nsw i32 %55, 255
  %57 = sdiv i32 %56, 2
  store i32 %57, ptr %50, align 4, !tbaa !14
  %58 = getelementptr inbounds %struct.DNuvec3, ptr %13, i32 0, i32 2
  %59 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 1
  %60 = getelementptr inbounds %struct.anon, ptr %59, i32 0, i32 2
  %61 = load float, ptr %60, align 4, !tbaa !10
  %62 = fmul float %61, 2.550000e+02
  %63 = fptosi float %62 to i32
  %64 = add nsw i32 %63, 255
  %65 = sdiv i32 %64, 2
  store i32 %65, ptr %58, align 4, !tbaa !15
  %66 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 0
  %67 = load i8, ptr %66, align 8, !tbaa !16
  %68 = zext i8 %67 to i32
  %69 = shl i32 %68, 24
  %70 = getelementptr inbounds %struct.DNuvec3, ptr %13, i32 0, i32 0
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = shl i32 %71, 16
  %73 = or i32 %69, %72
  %74 = getelementptr inbounds %struct.DNuvec3, ptr %13, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !14
  %76 = shl i32 %75, 8
  %77 = or i32 %73, %76
  %78 = getelementptr inbounds %struct.DNuvec3, ptr %13, i32 0, i32 2
  %79 = load i32, ptr %78, align 4, !tbaa !15
  %80 = or i32 %77, %79
  %81 = getelementptr inbounds %struct.DNcompressedVoxel, ptr %2, i32 0, i32 0
  store i32 %80, ptr %81, align 4, !tbaa !19
  %82 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 2
  %83 = getelementptr inbounds %struct.DNcolor, ptr %82, i32 0, i32 0
  %84 = load i8, ptr %83, align 8, !tbaa !21
  %85 = zext i8 %84 to i32
  %86 = shl i32 %85, 24
  %87 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 2
  %88 = getelementptr inbounds %struct.DNcolor, ptr %87, i32 0, i32 1
  %89 = load i8, ptr %88, align 1, !tbaa !22
  %90 = zext i8 %89 to i32
  %91 = shl i32 %90, 16
  %92 = or i32 %86, %91
  %93 = getelementptr inbounds %struct.DNvoxel, ptr %0, i32 0, i32 2
  %94 = getelementptr inbounds %struct.DNcolor, ptr %93, i32 0, i32 2
  %95 = load i8, ptr %94, align 2, !tbaa !23
  %96 = zext i8 %95 to i32
  %97 = shl i32 %96, 8
  %98 = or i32 %92, %97
  %99 = getelementptr inbounds %struct.DNcompressedVoxel, ptr %2, i32 0, i32 1
  store i32 %98, ptr %99, align 4, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #4
  %100 = load i64, ptr %2, align 4
  ret i64 %100
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden { <2 x float>, float } @DN_vec3_min(<2 x float>, float, <2 x float>, float) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden { <2 x float>, float } @DN_vec3_max(<2 x float>, float, <2 x float>, float) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 12, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"DNuvec3", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!12, !13, i64 8}
!16 = !{!17, !7, i64 0}
!17 = !{!"DNvoxel", !7, i64 0, !7, i64 4, !18, i64 16}
!18 = !{!"DNcolor", !7, i64 0, !7, i64 1, !7, i64 2}
!19 = !{!20, !13, i64 0}
!20 = !{!"DNcompressedVoxel", !13, i64 0, !13, i64 4}
!21 = !{!17, !7, i64 16}
!22 = !{!17, !7, i64 17}
!23 = !{!17, !7, i64 18}
!24 = !{!20, !13, 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.DNvoxel = type { i8, %union.QMvec3, %struct.DNcolor }
%union.QMvec3 = type { [3 x float] }
%struct.DNcolor = type { i8, i8, i8 }

; Function Attrs: nounwind uwtable
define dso_local i64 @DN_compress_voxel(ptr nocapture noundef readonly byval(%struct.DNvoxel) align 8 %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %.sroa.016.0.copyload = load <2 x float>, ptr %2, align 4
  %.sroa.217.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 12
  %.sroa.217.0.copyload = load float, ptr %.sroa.217.0..sroa_idx, align 4
  %3 = tail call { <2 x float>, float } @DN_vec3_min(<2 x float> %.sroa.016.0.copyload, float %.sroa.217.0.copyload, <2 x float> <float 1.000000e+00, float 1.000000e+00>, float 1.000000e+00)
  %.fca.0.extract10 = extractvalue { <2 x float>, float } %3, 0
  %.fca.1.extract11 = extractvalue { <2 x float>, float } %3, 1
  %4 = tail call { <2 x float>, float } @DN_vec3_max(<2 x float> %.fca.0.extract10, float %.fca.1.extract11, <2 x float> <float -1.000000e+00, float -1.000000e+00>, float -1.000000e+00)
  %.fca.0.extract = extractvalue { <2 x float>, float } %4, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %4, 1
  %5 = fmul float %.fca.1.extract, 2.550000e+02
  %6 = fptosi float %5 to i32
  %7 = add nsw i32 %6, 255
  %8 = sdiv i32 %7, 2
  %9 = load i8, ptr %0, align 8, !tbaa !5
  %10 = zext i8 %9 to i32
  %11 = shl nuw i32 %10, 24
  %12 = fmul <2 x float> %.fca.0.extract, <float 2.550000e+02, float 2.550000e+02>
  %13 = fptosi <2 x float> %12 to <2 x i32>
  %14 = add nsw <2 x i32> %13, <i32 255, i32 255>
  %15 = sdiv <2 x i32> %14, <i32 2, i32 2>
  %16 = shl <2 x i32> %15, <i32 16, i32 8>
  %17 = or i32 %11, %8
  %18 = extractelement <2 x i32> %16, i64 0
  %19 = or i32 %17, %18
  %20 = extractelement <2 x i32> %16, i64 1
  %21 = or i32 %19, %20
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load i8, ptr %22, align 8, !tbaa !10
  %24 = zext i8 %23 to i64
  %25 = shl nuw i64 %24, 56
  %26 = getelementptr inbounds i8, ptr %0, i64 17
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = zext i8 %27 to i64
  %29 = shl nuw nsw i64 %28, 48
  %30 = or disjoint i64 %29, %25
  %31 = getelementptr inbounds i8, ptr %0, i64 18
  %32 = load i8, ptr %31, align 2, !tbaa !12
  %33 = zext i8 %32 to i64
  %34 = shl nuw nsw i64 %33, 40
  %.sroa.224.0.insert.ext = or disjoint i64 %30, %34
  %.sroa.023.0.insert.ext = zext i32 %21 to i64
  %.sroa.023.0.insert.insert = or disjoint i64 %.sroa.224.0.insert.ext, %.sroa.023.0.insert.ext
  ret i64 %.sroa.023.0.insert.insert
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden { <2 x float>, float } @DN_vec3_min(<2 x float>, float, <2 x float>, float) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden { <2 x float>, float } @DN_vec3_max(<2 x float>, float, <2 x float>, float) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 #1 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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 0}
!6 = !{!"DNvoxel", !7, i64 0, !7, i64 4, !9, i64 16}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"DNcolor", !7, i64 0, !7, i64 1, !7, i64 2}
!10 = !{!6, !7, i64 16}
!11 = !{!6, !7, i64 17}
!12 = !{!6, !7, i64 18}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,TailCallElimPass