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

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

%union.QMvec3 = type { [3 x float] }
%union.QMmat4 = type { [4 x <4 x float>] }
%struct.DNvoxel = type { i8, %union.QMvec3, %struct.DNcolor }
%struct.DNcolor = type { i8, i8, i8 }
%union.QMquaternion = type { <4 x float> }
%struct.anon = type { float, float, float }

@g_length = external hidden global %union.QMvec3, align 4
@g_radius = external hidden global float, align 4

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @DN_mat4_translate(ptr dead_on_unwind noalias writable sret(%union.QMmat4) align 16, <2 x float>, float) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @DN_mat4_mult(ptr dead_on_unwind noalias writable sret(%union.QMmat4) align 16, ptr noundef byval(%union.QMmat4) align 16, ptr noundef byval(%union.QMmat4) align 16) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @DN_quaternion_to_mat4(ptr dead_on_unwind noalias writable sret(%union.QMmat4) align 16, double, double) #4

; Function Attrs: nounwind uwtable
declare hidden void @_DN_shape(ptr noundef, ptr noundef byval(%struct.DNvoxel) align 8, ptr noundef, ptr noundef, i1 noundef zeroext, <2 x float>, float, <2 x float>, float, ptr noundef byval(%union.QMmat4) align 16, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @DN_shape_rounded_box(ptr noundef %0, ptr noundef byval(%struct.DNvoxel) align 8 %1, i1 noundef zeroext %2, <2 x float> %3, float %4, <2 x float> %5, float %6, float noundef %7, double %8, double %9, ptr noundef %10, ptr noundef %11) #5 {
  %13 = alloca %union.QMvec3, align 4
  %14 = alloca { <2 x float>, float }, align 4
  %15 = alloca %union.QMvec3, align 4
  %16 = alloca { <2 x float>, float }, align 4
  %17 = alloca %union.QMquaternion, align 16
  %18 = alloca ptr, align 8
  %19 = alloca i8, align 1
  %20 = alloca float, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca %union.QMmat4, align 16
  %24 = alloca %union.QMmat4, align 16
  %25 = alloca { <2 x float>, float }, align 4
  %26 = alloca %union.QMmat4, align 16
  %27 = alloca %union.QMmat4, align 16
  %28 = alloca %union.QMvec3, align 4
  %29 = alloca %union.QMvec3, align 4
  %30 = alloca { <2 x float>, float }, align 4
  %31 = alloca { <2 x float>, float }, align 4
  %32 = getelementptr inbounds { <2 x float>, float }, ptr %14, i32 0, i32 0
  store <2 x float> %3, ptr %32, align 4
  %33 = getelementptr inbounds { <2 x float>, float }, ptr %14, i32 0, i32 1
  store float %4, ptr %33, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %14, i64 12, i1 false)
  %34 = getelementptr inbounds { <2 x float>, float }, ptr %16, i32 0, i32 0
  store <2 x float> %5, ptr %34, align 4
  %35 = getelementptr inbounds { <2 x float>, float }, ptr %16, i32 0, i32 1
  store float %6, ptr %35, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %16, i64 12, i1 false)
  %36 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  store double %8, ptr %36, align 16
  %37 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  store double %9, ptr %37, align 8
  store ptr %0, ptr %18, align 8, !tbaa !5
  %38 = zext i1 %2 to i8
  store i8 %38, ptr %19, align 1, !tbaa !9
  store float %7, ptr %20, align 4, !tbaa !11
  store ptr %10, ptr %21, align 8, !tbaa !5
  store ptr %11, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %23) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %24) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %13, i64 12, i1 false)
  %39 = getelementptr inbounds { <2 x float>, float }, ptr %25, i32 0, i32 0
  %40 = load <2 x float>, ptr %39, align 4
  %41 = getelementptr inbounds { <2 x float>, float }, ptr %25, i32 0, i32 1
  %42 = load float, ptr %41, align 4
  call void @DN_mat4_translate(ptr dead_on_unwind writable sret(%union.QMmat4) align 16 %24, <2 x float> %40, float %42)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %23, ptr align 16 %24, i64 64, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 64, ptr %24) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %26) #6
  %43 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %44 = load double, ptr %43, align 16
  %45 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %46 = load double, ptr %45, align 8
  call void @DN_quaternion_to_mat4(ptr dead_on_unwind writable sret(%union.QMmat4) align 16 %27, double %44, double %46)
  call void @DN_mat4_mult(ptr dead_on_unwind writable sret(%union.QMmat4) align 16 %26, ptr noundef byval(%union.QMmat4) align 16 %23, ptr noundef byval(%union.QMmat4) align 16 %27)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %23, ptr align 16 %26, i64 64, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 64, ptr %26) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @g_length, ptr align 4 %15, i64 12, i1 false), !tbaa.struct !15
  %47 = load float, ptr %20, align 4, !tbaa !11
  store float %47, ptr @g_radius, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr %28) #6
  %48 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !14
  %50 = fneg float %49
  %51 = load float, ptr %20, align 4, !tbaa !11
  %52 = fsub float %50, %51
  store float %52, ptr %28, align 4, !tbaa !11
  %53 = getelementptr inbounds float, ptr %28, i64 1
  %54 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 1
  %55 = load float, ptr %54, align 4, !tbaa !14
  %56 = fneg float %55
  %57 = load float, ptr %20, align 4, !tbaa !11
  %58 = fsub float %56, %57
  store float %58, ptr %53, align 4, !tbaa !11
  %59 = getelementptr inbounds float, ptr %28, i64 2
  %60 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 2
  %61 = load float, ptr %60, align 4, !tbaa !14
  %62 = fneg float %61
  %63 = load float, ptr %20, align 4, !tbaa !11
  %64 = fsub float %62, %63
  store float %64, ptr %59, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr %29) #6
  %65 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 0
  %66 = load float, ptr %65, align 4, !tbaa !14
  %67 = load float, ptr %20, align 4, !tbaa !11
  %68 = fadd float %66, %67
  store float %68, ptr %29, align 4, !tbaa !11
  %69 = getelementptr inbounds float, ptr %29, i64 1
  %70 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 0
  %71 = load float, ptr %70, align 4, !tbaa !14
  %72 = load float, ptr %20, align 4, !tbaa !11
  %73 = fadd float %71, %72
  store float %73, ptr %69, align 4, !tbaa !11
  %74 = getelementptr inbounds float, ptr %29, i64 2
  %75 = getelementptr inbounds %struct.anon, ptr %15, i32 0, i32 0
  %76 = load float, ptr %75, align 4, !tbaa !14
  %77 = load float, ptr %20, align 4, !tbaa !11
  %78 = fadd float %76, %77
  store float %78, ptr %74, align 4, !tbaa !11
  %79 = load ptr, ptr %18, align 8, !tbaa !5
  %80 = load ptr, ptr %21, align 8, !tbaa !5
  %81 = load ptr, ptr %22, align 8, !tbaa !5
  %82 = load i8, ptr %19, align 1, !tbaa !9, !range !16, !noundef !17
  %83 = trunc i8 %82 to i1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 4 %28, i64 12, i1 false)
  %84 = getelementptr inbounds { <2 x float>, float }, ptr %30, i32 0, i32 0
  %85 = load <2 x float>, ptr %84, align 4
  %86 = getelementptr inbounds { <2 x float>, float }, ptr %30, i32 0, i32 1
  %87 = load float, ptr %86, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %31, ptr align 4 %29, i64 12, i1 false)
  %88 = getelementptr inbounds { <2 x float>, float }, ptr %31, i32 0, i32 0
  %89 = load <2 x float>, ptr %88, align 4
  %90 = getelementptr inbounds { <2 x float>, float }, ptr %31, i32 0, i32 1
  %91 = load float, ptr %90, align 4
  call void @_DN_shape(ptr noundef %79, ptr noundef byval(%struct.DNvoxel) align 8 %1, ptr noundef %80, ptr noundef %81, i1 noundef zeroext %83, <2 x float> %85, float %87, <2 x float> %89, float %91, ptr noundef byval(%union.QMmat4) align 16 %23, ptr noundef @_DN_sdf_rounded_box)
  call void @llvm.lifetime.end.p0(i64 12, ptr %29) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %28) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %23) #6
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden float @_DN_sdf_rounded_box(<2 x float>, float) #5

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 = { inlinehint 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 #5 = { 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 #6 = { 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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{i64 0, i64 64, !14}
!14 = !{!7, !7, i64 0}
!15 = !{i64 0, i64 12, !14}
!16 = !{i8 0, i8 2}
!17 = !{}


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

%union.QMvec3 = type { [3 x float] }
%union.QMmat4 = type { [4 x <4 x float>] }
%struct.DNvoxel = type { i8, %union.QMvec3, %struct.DNcolor }
%struct.DNcolor = type { i8, i8, i8 }

@g_length = external hidden local_unnamed_addr global %union.QMvec3, align 4
@g_radius = external hidden local_unnamed_addr global float, align 4

; Function Attrs: mustprogress 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @DN_mat4_translate(ptr dead_on_unwind noalias writable sret(%union.QMmat4) align 16, <2 x float>, float) local_unnamed_addr #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @DN_mat4_mult(ptr dead_on_unwind noalias writable sret(%union.QMmat4) align 16, ptr noundef byval(%union.QMmat4) align 16, ptr noundef byval(%union.QMmat4) align 16) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @DN_quaternion_to_mat4(ptr dead_on_unwind noalias writable sret(%union.QMmat4) align 16, double, double) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden void @_DN_shape(ptr noundef, ptr noundef byval(%struct.DNvoxel) align 8, ptr noundef, ptr noundef, i1 noundef zeroext, <2 x float>, float, <2 x float>, float, ptr noundef byval(%union.QMmat4) align 16, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local void @DN_shape_rounded_box(ptr noundef %0, ptr noundef byval(%struct.DNvoxel) align 8 %1, i1 noundef zeroext %2, <2 x float> %3, float %4, <2 x float> %5, float %6, float noundef %7, double %8, double %9, ptr noundef %10, ptr noundef %11) local_unnamed_addr #5 {
  %13 = extractelement <2 x float> %5, i64 0
  %14 = alloca %union.QMmat4, align 16
  %15 = alloca %union.QMmat4, align 16
  %16 = alloca %union.QMmat4, align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %14) #6
  call void @DN_mat4_translate(ptr dead_on_unwind nonnull writable sret(%union.QMmat4) align 16 %14, <2 x float> %3, float %4)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %15) #6
  call void @DN_quaternion_to_mat4(ptr dead_on_unwind nonnull writable sret(%union.QMmat4) align 16 %16, double %8, double %9)
  call void @DN_mat4_mult(ptr dead_on_unwind nonnull writable sret(%union.QMmat4) align 16 %15, ptr noundef nonnull byval(%union.QMmat4) align 16 %14, ptr noundef nonnull byval(%union.QMmat4) align 16 %16)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %14, ptr noundef nonnull align 16 dereferenceable(64) %15, i64 64, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %15) #6
  store <2 x float> %5, ptr @g_length, align 4
  store float %6, ptr getelementptr inbounds (i8, ptr @g_length, i64 8), align 4, !tbaa !6
  store float %7, ptr @g_radius, align 4, !tbaa !9
  %17 = fneg <2 x float> %5
  %18 = insertelement <2 x float> poison, float %7, i64 0
  %19 = shufflevector <2 x float> %18, <2 x float> poison, <2 x i32> zeroinitializer
  %20 = fsub <2 x float> %17, %19
  %21 = fneg float %6
  %22 = fsub float %21, %7
  %23 = fadd float %13, %7
  %.sroa.03.0.vec.insert = insertelement <2 x float> poison, float %23, i64 0
  %.sroa.03.4.vec.insert = shufflevector <2 x float> %.sroa.03.0.vec.insert, <2 x float> poison, <2 x i32> zeroinitializer
  call void @_DN_shape(ptr noundef %0, ptr noundef nonnull byval(%struct.DNvoxel) align 8 %1, ptr noundef %10, ptr noundef %11, i1 noundef zeroext %2, <2 x float> %20, float %22, <2 x float> %.sroa.03.4.vec.insert, float %23, ptr noundef nonnull byval(%union.QMmat4) align 16 %14, ptr noundef nonnull @_DN_sdf_rounded_box)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %14) #6
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden float @_DN_sdf_rounded_box(<2 x float>, float) #5

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 = { inlinehint 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 #5 = { 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 #6 = { 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 = !{i64 0, i64 64, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SLPVectorizerPass,SROAPass