; 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.DNchunkHandleGPU = 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] }

@g_DN_message_callback = external dso_local global ptr, align 8
@glad_glBindBuffer = external global ptr, align 8
@glad_glMapBuffer = external global ptr, align 8
@glad_glUnmapBuffer = external global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [77 x i8], align 1
@glad_glMemoryBarrier = external global ptr, align 8

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minnum.f64(double, double) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @DN_sync_gpu(ptr noundef %0, i32 noundef %1, i32 noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.DNivec3, align 4
  %15 = alloca i32, align 4
  %16 = alloca %struct.DNchunkHandleGPU, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i8, align 1
  %20 = alloca { i64, i32 }, align 4
  %21 = alloca i32, align 4
  %22 = alloca i64, align 8
  %23 = alloca [256 x i8], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  store i8 0, ptr %7, align 1, !tbaa !11
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.DNvolume, ptr %24, i32 0, i32 29
  %26 = load i32, ptr %25, align 8, !tbaa !13
  %27 = add i32 %26, 1
  store i32 %27, ptr %25, align 8, !tbaa !13
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.DNvolume, ptr %28, i32 0, i32 29
  %30 = load i32, ptr %29, align 8, !tbaa !13
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = icmp uge i32 %30, %31
  br i1 %32, label %33, label %36

33:                                               ; preds = %3
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.DNvolume, ptr %34, i32 0, i32 29
  store i32 0, ptr %35, align 8, !tbaa !13
  br label %36

36:                                               ; preds = %33, %3
  %37 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.DNvolume, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !18
  call void %37(i32 noundef 37074, i32 noundef %40)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %41 = load ptr, ptr @glad_glMapBuffer, align 8, !tbaa !5
  %42 = call ptr %41(i32 noundef 37074, i32 noundef 35002)
  store ptr %42, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.DNvolume, ptr %43, i32 0, i32 10
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  store ptr %45, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.DNvolume, ptr %46, i32 0, i32 8
  store i64 0, ptr %47, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %154, %36
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.DNvolume, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds %struct.DNuvec3, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !21
  %54 = icmp ult i32 %49, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %48
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %157

56:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %150, %56
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.DNvolume, ptr %59, i32 0, i32 3
  %61 = getelementptr inbounds %struct.DNuvec3, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !22
  %63 = icmp ult i32 %58, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %57
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %153

65:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %146, %65
  %67 = load i32, ptr %13, align 4, !tbaa !9
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.DNvolume, ptr %68, i32 0, i32 3
  %70 = getelementptr inbounds %struct.DNuvec3, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 4, !tbaa !23
  %72 = icmp ult i32 %67, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %66
  store i32 8, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %149

74:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #5
  %75 = getelementptr inbounds %struct.DNivec3, ptr %14, i32 0, i32 0
  %76 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %76, ptr %75, align 4, !tbaa !24
  %77 = getelementptr inbounds %struct.DNivec3, ptr %14, i32 0, i32 1
  %78 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %78, ptr %77, align 4, !tbaa !26
  %79 = getelementptr inbounds %struct.DNivec3, ptr %14, i32 0, i32 2
  %80 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %80, ptr %79, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %81 = getelementptr inbounds %struct.DNivec3, ptr %14, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !24
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.DNvolume, ptr %83, i32 0, i32 3
  %85 = getelementptr inbounds %struct.DNuvec3, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !23
  %87 = getelementptr inbounds %struct.DNivec3, ptr %14, i32 0, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !26
  %89 = getelementptr inbounds %struct.DNivec3, ptr %14, i32 0, i32 2
  %90 = load i32, ptr %89, align 4, !tbaa !27
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.DNvolume, ptr %91, i32 0, i32 3
  %93 = getelementptr inbounds %struct.DNuvec3, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !22
  %95 = mul i32 %90, %94
  %96 = add i32 %88, %95
  %97 = mul i32 %86, %96
  %98 = add i32 %82, %97
  store i32 %98, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #5
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = load i32, ptr %15, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %99, i64 %101
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %102, i64 12, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %103 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %16, i32 0, i32 0
  %104 = load i32, ptr %103, align 4, !tbaa !29
  %105 = and i32 %104, 3
  store i32 %105, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %106 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %16, i32 0, i32 0
  %107 = load i32, ptr %106, align 4, !tbaa !29
  %108 = lshr i32 %107, 4
  store i32 %108, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #5
  %109 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %16, i32 0, i32 0
  %110 = load i32, ptr %109, align 4, !tbaa !29
  %111 = and i32 %110, 4
  %112 = icmp ugt i32 %111, 0
  %113 = zext i1 %112 to i8
  store i8 %113, ptr %19, align 1, !tbaa !11
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = load i32, ptr %15, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %114, i64 %116
  %118 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %117, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !31
  %120 = add i32 %119, 1
  store i32 %120, ptr %118, align 4, !tbaa !31
  %121 = load i32, ptr %5, align 4, !tbaa !9
  %122 = icmp ne i32 %121, 1
  br i1 %122, label %123, label %132

123:                                              ; preds = %74
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = load i32, ptr %15, align 4, !tbaa !9
  %127 = load i32, ptr %17, align 4, !tbaa !9
  %128 = load i32, ptr %18, align 4, !tbaa !9
  %129 = load i8, ptr %19, align 1, !tbaa !11, !range !32, !noundef !33
  %130 = trunc i8 %129 to i1
  %131 = load i32, ptr %6, align 4, !tbaa !9
  call void @_DN_request_chunk_lighting(ptr noundef %124, ptr noundef %125, i32 noundef %126, i32 noundef %127, i32 noundef %128, i1 noundef zeroext %130, i32 noundef %131)
  br label %132

132:                                              ; preds = %123, %74
  %133 = load i32, ptr %5, align 4, !tbaa !9
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %145

135:                                              ; preds = %132
  %136 = load ptr, ptr %4, align 8, !tbaa !5
  %137 = load ptr, ptr %9, align 8, !tbaa !5
  %138 = load ptr, ptr %8, align 8, !tbaa !5
  %139 = load i32, ptr %15, align 4, !tbaa !9
  %140 = load i32, ptr %18, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %14, i64 12, i1 false)
  %141 = getelementptr inbounds { i64, i32 }, ptr %20, i32 0, i32 0
  %142 = load i64, ptr %141, align 4
  %143 = getelementptr inbounds { i64, i32 }, ptr %20, i32 0, i32 1
  %144 = load i32, ptr %143, align 4
  call void @_DN_stream_to_gpu(ptr noundef %136, ptr noundef %137, ptr noundef %138, i64 %142, i32 %144, i32 noundef %139, ptr noundef %17, i32 noundef %140, ptr noundef %7)
  br label %145

145:                                              ; preds = %135, %132
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #5
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %13, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %13, align 4, !tbaa !9
  br label %66, !llvm.loop !34

149:                                              ; preds = %73
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %12, align 4, !tbaa !9
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %12, align 4, !tbaa !9
  br label %57, !llvm.loop !36

153:                                              ; preds = %64
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %10, align 4, !tbaa !9
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %10, align 4, !tbaa !9
  br label %48, !llvm.loop !37

157:                                              ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 10, ptr %21, align 4, !tbaa !9
  %158 = load ptr, ptr %4, align 8, !tbaa !5
  %159 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_DN_sort_gpu_voxel_buffer(ptr noundef %158, ptr noundef %159, i32 noundef 10)
  %160 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.DNvolume, ptr %161, i32 0, i32 0
  %163 = load i32, ptr %162, align 8, !tbaa !18
  call void %160(i32 noundef 37074, i32 noundef %163)
  %164 = load ptr, ptr @glad_glUnmapBuffer, align 8, !tbaa !5
  %165 = call zeroext i8 %164(i32 noundef 37074)
  %166 = load i8, ptr %7, align 1, !tbaa !11, !range !32, !noundef !33
  %167 = trunc i8 %166 to i1
  br i1 %167, label %168, label %191

168:                                              ; preds = %157
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %169 = load ptr, ptr %4, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.DNvolume, ptr %169, i32 0, i32 6
  %171 = load i64, ptr %170, align 8, !tbaa !38
  %172 = mul i64 %171, 2
  %173 = uitofp i64 %172 to double
  %174 = load ptr, ptr %4, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.DNvolume, ptr %174, i32 0, i32 4
  %176 = load i64, ptr %175, align 8, !tbaa !39
  %177 = mul i64 %176, 512
  %178 = uitofp i64 %177 to double
  %179 = call double @llvm.minnum.f64(double %173, double %178)
  %180 = fptoui double %179 to i64
  store i64 %180, ptr %22, align 8, !tbaa !40
  call void @llvm.lifetime.start.p0(i64 256, ptr %23) #5
  %181 = getelementptr inbounds [256 x i8], ptr %23, i64 0, i64 0
  %182 = load i64, ptr %22, align 8, !tbaa !40
  %183 = load i64, ptr %22, align 8, !tbaa !40
  %184 = mul i64 %183, 16
  %185 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %181, ptr noundef @.str.19, i64 noundef %182, i64 noundef %184) #5
  %186 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  %187 = getelementptr inbounds [256 x i8], ptr %23, i64 0, i64 0
  call void %186(i32 noundef 1, i32 noundef 0, ptr noundef %187)
  %188 = load ptr, ptr %4, align 8, !tbaa !5
  %189 = load i64, ptr %22, align 8, !tbaa !40
  %190 = call zeroext i1 @DN_set_max_voxels_gpu(ptr noundef %188, i64 noundef %189)
  call void @llvm.lifetime.end.p0(i64 256, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  br label %191

191:                                              ; preds = %168, %157
  %192 = load ptr, ptr @glad_glMemoryBarrier, align 8, !tbaa !5
  call void %192(i32 noundef 512)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @_DN_request_chunk_lighting(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext, i32 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @_DN_stream_to_gpu(ptr noundef, ptr noundef, ptr noundef, i64, i32, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @_DN_sort_gpu_voxel_buffer(ptr noundef, ptr noundef, i32 noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 }

!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 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !10, i64 224}
!14 = !{!"DNvolume", !10, i64 0, !10, i64 4, !10, i64 8, !15, i64 12, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !7, i64 112, !7, i64 124, !17, i64 136, !10, i64 140, !7, i64 144, !7, i64 156, !7, i64 168, !10, i64 180, !10, i64 184, !17, i64 188, !12, i64 192, !10, i64 196, !7, i64 200, !7, i64 212, !10, i64 224, !17, i64 228}
!15 = !{!"DNuvec3", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!14, !10, i64 0}
!19 = !{!14, !6, i64 72}
!20 = !{!14, !16, i64 56}
!21 = !{!14, !10, i64 20}
!22 = !{!14, !10, i64 16}
!23 = !{!14, !10, i64 12}
!24 = !{!25, !10, i64 0}
!25 = !{!"DNivec3", !10, i64 0, !10, i64 4, !10, i64 8}
!26 = !{!25, !10, i64 4}
!27 = !{!25, !10, i64 8}
!28 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9}
!29 = !{!30, !10, i64 0}
!30 = !{!"DNchunkHandleGPU", !10, i64 0, !10, i64 4, !10, i64 8}
!31 = !{!30, !10, i64 4}
!32 = !{i8 0, i8 2}
!33 = !{}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = distinct !{!36, !35}
!37 = distinct !{!37, !35}
!38 = !{!14, !16, i64 40}
!39 = !{!14, !16, i64 24}
!40 = !{!16, !16, i64 0}


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

@g_DN_message_callback = external dso_local local_unnamed_addr global ptr, align 8
@glad_glBindBuffer = external local_unnamed_addr global ptr, align 8
@glad_glMapBuffer = external local_unnamed_addr global ptr, align 8
@glad_glUnmapBuffer = external local_unnamed_addr global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [77 x i8], align 1
@glad_glMemoryBarrier = external local_unnamed_addr global ptr, align 8

; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minnum.f64(double, double) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @DN_sync_gpu(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #3 {
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  store i8 0, ptr %4, align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 224
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = add i32 %8, 1
  %.not = icmp ult i32 %9, %2
  %spec.select = select i1 %.not, i32 %9, i32 0
  store i32 %spec.select, ptr %7, align 8, !tbaa !9
  %10 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !16
  %11 = load i32, ptr %0, align 8, !tbaa !17
  tail call void %10(i32 noundef 37074, i32 noundef %11) #4
  %12 = load ptr, ptr @glad_glMapBuffer, align 8, !tbaa !16
  %13 = tail call ptr %12(i32 noundef 37074, i32 noundef 35002) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  store i64 0, ptr %16, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  %19 = load i32, ptr %18, align 4, !tbaa !20
  %.not69 = icmp eq i32 %19, 0
  br i1 %.not69, label %._crit_edge68, label %.preheader57.lr.ph

.preheader57.lr.ph:                               ; preds = %3
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %cond = icmp eq i32 %1, 1
  %.not56 = icmp eq i32 %1, 0
  %21 = load i32, ptr %20, align 4, !tbaa !21
  %.not70 = icmp eq i32 %21, 0
  br i1 %.not70, label %._crit_edge68, label %.preheader57

.preheader57:                                     ; preds = %.preheader57.lr.ph, %._crit_edge62
  %22 = phi i32 [ %49, %._crit_edge62 ], [ %19, %.preheader57.lr.ph ]
  %23 = phi i32 [ %50, %._crit_edge62 ], [ %21, %.preheader57.lr.ph ]
  %.066 = phi i32 [ %51, %._crit_edge62 ], [ 0, %.preheader57.lr.ph ]
  %.not71 = icmp eq i32 %23, 0
  br i1 %.not71, label %._crit_edge62, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader57
  %24 = load i32, ptr %17, align 4, !tbaa !22
  %.not72 = icmp eq i32 %24, 0
  br i1 %.not72, label %._crit_edge62, label %.preheader

._crit_edge68:                                    ; preds = %._crit_edge62, %.preheader57.lr.ph, %3
  call void @_DN_sort_gpu_voxel_buffer(ptr noundef nonnull %0, ptr noundef %13, i32 noundef 10)
  %25 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !16
  %26 = load i32, ptr %0, align 8, !tbaa !17
  call void %25(i32 noundef 37074, i32 noundef %26) #4
  %27 = load ptr, ptr @glad_glUnmapBuffer, align 8, !tbaa !16
  %28 = call zeroext i8 %27(i32 noundef 37074) #4
  %29 = load i8, ptr %4, align 1, !tbaa !5, !range !23, !noundef !24
  %30 = trunc nuw i8 %29 to i1
  br i1 %30, label %77, label %92

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %31 = phi i32 [ %53, %._crit_edge ], [ %24, %.preheader.lr.ph ]
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not73 = icmp eq i32 %31, 0
  br i1 %.not73, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %.sroa.013.4.insert.shift = shl nuw nsw i64 %indvars.iv81, 32
  %32 = trunc nuw nsw i64 %indvars.iv81 to i32
  br i1 %cond, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %33 = phi i32 [ %46, %.lr.ph.split.us ], [ %31, %.lr.ph ]
  %.sroa.013.4.insert.insert.us = or disjoint i64 %.sroa.013.4.insert.shift, %indvars.iv78
  %34 = load i32, ptr %20, align 4, !tbaa !21
  %35 = mul i32 %34, %.066
  %36 = add i32 %35, %32
  %37 = mul i32 %36, %33
  %38 = trunc nuw nsw i64 %indvars.iv78 to i32
  %39 = add i32 %37, %38
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %13, i64 %40
  %.sroa.06.0.copyload.us = load i32, ptr %41, align 4, !tbaa !25
  %.sroa.6.0..sroa_idx.us = getelementptr inbounds i8, ptr %41, i64 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %42 = and i32 %.sroa.06.0.copyload.us, 3
  store i32 %42, ptr %5, align 4, !tbaa !25
  %43 = lshr i32 %.sroa.06.0.copyload.us, 4
  %44 = load i32, ptr %.sroa.6.0..sroa_idx.us, align 4, !tbaa !26
  %45 = add i32 %44, 1
  store i32 %45, ptr %.sroa.6.0..sroa_idx.us, align 4, !tbaa !26
  call void @_DN_stream_to_gpu(ptr noundef nonnull %0, ptr noundef %15, ptr noundef nonnull %13, i64 %.sroa.013.4.insert.insert.us, i32 %.066, i32 noundef %39, ptr noundef nonnull %5, i32 noundef %43, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %46 = load i32, ptr %17, align 4, !tbaa !22
  %47 = zext i32 %46 to i64
  %48 = icmp ult i64 %indvars.iv.next79, %47
  br i1 %48, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !28

._crit_edge62.loopexit75:                         ; preds = %._crit_edge
  %.pre = load i32, ptr %18, align 4, !tbaa !20
  br label %._crit_edge62

._crit_edge62:                                    ; preds = %.preheader.lr.ph, %._crit_edge62.loopexit75, %.preheader57
  %49 = phi i32 [ %22, %.preheader57 ], [ %.pre, %._crit_edge62.loopexit75 ], [ %22, %.preheader.lr.ph ]
  %50 = phi i32 [ 0, %.preheader57 ], [ %54, %._crit_edge62.loopexit75 ], [ %23, %.preheader.lr.ph ]
  %51 = add nuw nsw i32 %.066, 1
  %52 = icmp ult i32 %51, %49
  br i1 %52, label %.preheader57, label %._crit_edge68, !llvm.loop !30

._crit_edge:                                      ; preds = %73, %.lr.ph.split.us, %.preheader
  %53 = phi i32 [ 0, %.preheader ], [ %46, %.lr.ph.split.us ], [ %74, %73 ]
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %54 = load i32, ptr %20, align 4, !tbaa !21
  %55 = zext i32 %54 to i64
  %56 = icmp ult i64 %indvars.iv.next82, %55
  br i1 %56, label %.preheader, label %._crit_edge62.loopexit75, !llvm.loop !32

.lr.ph.split:                                     ; preds = %.lr.ph, %73
  %indvars.iv = phi i64 [ %indvars.iv.next, %73 ], [ 0, %.lr.ph ]
  %57 = phi i32 [ %74, %73 ], [ %31, %.lr.ph ]
  %58 = load i32, ptr %20, align 4, !tbaa !21
  %59 = mul i32 %58, %.066
  %60 = add i32 %59, %32
  %61 = mul i32 %60, %57
  %62 = trunc nuw nsw i64 %indvars.iv to i32
  %63 = add i32 %61, %62
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.DNchunkHandleGPU, ptr %13, i64 %64
  %.sroa.06.0.copyload = load i32, ptr %65, align 4, !tbaa !25
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %65, i64 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %66 = and i32 %.sroa.06.0.copyload, 3
  store i32 %66, ptr %5, align 4, !tbaa !25
  %67 = lshr i32 %.sroa.06.0.copyload, 4
  %68 = load i32, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !26
  %69 = add i32 %68, 1
  store i32 %69, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !26
  %70 = and i32 %.sroa.06.0.copyload, 4
  %71 = icmp ne i32 %70, 0
  call void @_DN_request_chunk_lighting(ptr noundef nonnull %0, ptr noundef %15, i32 noundef %63, i32 noundef %66, i32 noundef %67, i1 noundef zeroext %71, i32 noundef %2)
  br i1 %.not56, label %73, label %72

72:                                               ; preds = %.lr.ph.split
  %.sroa.013.4.insert.insert = or disjoint i64 %.sroa.013.4.insert.shift, %indvars.iv
  call void @_DN_stream_to_gpu(ptr noundef nonnull %0, ptr noundef %15, ptr noundef nonnull %13, i64 %.sroa.013.4.insert.insert, i32 %.066, i32 noundef %63, ptr noundef nonnull %5, i32 noundef %67, ptr noundef nonnull %4)
  br label %73

73:                                               ; preds = %72, %.lr.ph.split
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %74 = load i32, ptr %17, align 4, !tbaa !22
  %75 = zext i32 %74 to i64
  %76 = icmp ult i64 %indvars.iv.next, %75
  br i1 %76, label %.lr.ph.split, label %._crit_edge, !llvm.loop !28

77:                                               ; preds = %._crit_edge68
  %78 = getelementptr inbounds i8, ptr %0, i64 40
  %79 = load i64, ptr %78, align 8, !tbaa !33
  %80 = shl i64 %79, 1
  %81 = uitofp i64 %80 to double
  %82 = getelementptr inbounds i8, ptr %0, i64 24
  %83 = load i64, ptr %82, align 8, !tbaa !34
  %84 = shl i64 %83, 9
  %85 = uitofp i64 %84 to double
  %86 = call double @llvm.minnum.f64(double %81, double %85)
  %87 = fptoui double %86 to i64
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %6) #4
  %88 = shl i64 %87, 4
  %89 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.19, i64 noundef %87, i64 noundef %88) #4
  %90 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !16
  call void %90(i32 noundef 1, i32 noundef 0, ptr noundef nonnull %6) #4
  %91 = call zeroext i1 @DN_set_max_voxels_gpu(ptr noundef nonnull %0, i64 noundef %87)
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %6) #4
  br label %92

92:                                               ; preds = %77, %._crit_edge68
  %93 = load ptr, ptr @glad_glMemoryBarrier, align 8, !tbaa !16
  call void %93(i32 noundef 512) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @_DN_request_chunk_lighting(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @_DN_stream_to_gpu(ptr noundef, ptr noundef, ptr noundef, i64, i32, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @_DN_sort_gpu_voxel_buffer(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 224}
!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, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !7, i64 112, !7, i64 124, !15, i64 136, !11, i64 140, !7, i64 144, !7, i64 156, !7, i64 168, !11, i64 180, !11, i64 184, !15, i64 188, !6, i64 192, !11, i64 196, !7, i64 200, !7, i64 212, !11, i64 224, !15, i64 228}
!11 = !{!"int", !7, i64 0}
!12 = !{!"DNuvec3", !11, i64 0, !11, i64 4, !11, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!10, !11, i64 0}
!18 = !{!10, !14, i64 72}
!19 = !{!10, !13, i64 56}
!20 = !{!10, !11, i64 20}
!21 = !{!10, !11, i64 16}
!22 = !{!10, !11, i64 12}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!11, !11, i64 0}
!26 = !{!27, !11, i64 4}
!27 = !{!"DNchunkHandleGPU", !11, i64 0, !11, i64 4, !11, i64 8}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29, !31}
!31 = !{!"llvm.loop.unswitch.partial.disable"}
!32 = distinct !{!32, !29, !31}
!33 = !{!10, !13, i64 40}
!34 = !{!10, !13, i64 24}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass