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

@g_lightingRequestBuffer = external dso_local global i32, align 4
@g_materialBuffer = external dso_local global i32, align 4
@g_lightingProgram = external dso_local global i32, align 4
@g_drawProgram = external dso_local global i32, align 4
@g_maxLightingRequests = external dso_local global i32, align 4
@g_DN_message_callback = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [35 x i8], align 1
@glad_glBindBufferBase = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @DN_init() #0 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = call zeroext i1 @_DN_gen_shader_storage_buffer(ptr noundef @g_materialBuffer, i64 noundef 8192)
  br i1 %5, label %8, label %6

6:                                                ; preds = %0
  %7 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  call void %7(i32 noundef 1, i32 noundef 2, ptr noundef @.str)
  store i1 false, ptr %1, align 1
  br label %33

8:                                                ; preds = %0
  %9 = load ptr, ptr @glad_glBindBufferBase, align 8, !tbaa !5
  %10 = load i32, ptr @g_materialBuffer, align 4, !tbaa !9
  call void %9(i32 noundef 37074, i32 noundef 2, i32 noundef %10)
  %11 = load i32, ptr @g_maxLightingRequests, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = mul i64 4, %12
  %14 = call zeroext i1 @_DN_gen_shader_storage_buffer(ptr noundef @g_lightingRequestBuffer, i64 noundef %13)
  br i1 %14, label %17, label %15

15:                                               ; preds = %8
  %16 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  call void %16(i32 noundef 1, i32 noundef 2, ptr noundef @.str.1)
  store i1 false, ptr %1, align 1
  br label %33

17:                                               ; preds = %8
  %18 = load ptr, ptr @glad_glBindBufferBase, align 8, !tbaa !5
  %19 = load i32, ptr @g_lightingRequestBuffer, align 4, !tbaa !9
  call void %18(i32 noundef 37074, i32 noundef 3, i32 noundef %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %20 = call i32 @DN_compute_program_load(ptr noundef @.str.2, ptr noundef @.str.3)
  store i32 %20, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %21 = call i32 @DN_compute_program_load(ptr noundef @.str.4, ptr noundef @.str.3)
  store i32 %21, ptr %3, align 4, !tbaa !9
  %22 = load i32, ptr %2, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %27, label %24

24:                                               ; preds = %17
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %24, %17
  %28 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  call void %28(i32 noundef 2, i32 noundef 2, ptr noundef @.str.5)
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %32

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !9
  store i32 %30, ptr @g_lightingProgram, align 4, !tbaa !9
  %31 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %31, ptr @g_drawProgram, align 4, !tbaa !9
  store i1 true, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %32

32:                                               ; preds = %29, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %33

33:                                               ; preds = %32, %15, %6
  %34 = load i1, ptr %1, align 1
  ret i1 %34
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @_DN_gen_shader_storage_buffer(ptr noundef, i64 noundef) #0

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

declare i32 @DN_compute_program_load(ptr noundef, ptr noundef) #2

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

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

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


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

@g_lightingRequestBuffer = external dso_local global i32, align 4
@g_materialBuffer = external dso_local global i32, align 4
@g_lightingProgram = external dso_local local_unnamed_addr global i32, align 4
@g_drawProgram = external dso_local local_unnamed_addr global i32, align 4
@g_maxLightingRequests = external dso_local local_unnamed_addr global i32, align 4
@g_DN_message_callback = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [35 x i8], align 1
@glad_glBindBufferBase = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @DN_init() local_unnamed_addr #0 {
  %1 = tail call zeroext i1 @_DN_gen_shader_storage_buffer(ptr noundef nonnull @g_materialBuffer, i64 noundef 8192)
  br i1 %1, label %4, label %2

2:                                                ; preds = %0
  %3 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  tail call void %3(i32 noundef 1, i32 noundef 2, ptr noundef nonnull @.str) #2
  br label %23

4:                                                ; preds = %0
  %5 = load ptr, ptr @glad_glBindBufferBase, align 8, !tbaa !5
  %6 = load i32, ptr @g_materialBuffer, align 4, !tbaa !9
  tail call void %5(i32 noundef 37074, i32 noundef 2, i32 noundef %6) #2
  %7 = load i32, ptr @g_maxLightingRequests, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = shl nsw i64 %8, 2
  %10 = tail call zeroext i1 @_DN_gen_shader_storage_buffer(ptr noundef nonnull @g_lightingRequestBuffer, i64 noundef %9)
  br i1 %10, label %13, label %11

11:                                               ; preds = %4
  %12 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  tail call void %12(i32 noundef 1, i32 noundef 2, ptr noundef nonnull @.str.1) #2
  br label %23

13:                                               ; preds = %4
  %14 = load ptr, ptr @glad_glBindBufferBase, align 8, !tbaa !5
  %15 = load i32, ptr @g_lightingRequestBuffer, align 4, !tbaa !9
  tail call void %14(i32 noundef 37074, i32 noundef 3, i32 noundef %15) #2
  %16 = tail call i32 @DN_compute_program_load(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3) #2
  %17 = tail call i32 @DN_compute_program_load(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.3) #2
  %18 = icmp sgt i32 %16, -1
  %19 = icmp sgt i32 %17, -1
  %or.cond.not = select i1 %18, i1 %19, i1 false
  br i1 %or.cond.not, label %22, label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr @g_DN_message_callback, align 8, !tbaa !5
  tail call void %21(i32 noundef 2, i32 noundef 2, ptr noundef nonnull @.str.5) #2
  br label %23

22:                                               ; preds = %13
  store i32 %16, ptr @g_lightingProgram, align 4, !tbaa !9
  store i32 %17, ptr @g_drawProgram, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %20, %22, %11, %2
  %.1 = phi i1 [ false, %11 ], [ false, %2 ], [ true, %22 ], [ false, %20 ]
  ret i1 %.1
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @_DN_gen_shader_storage_buffer(ptr noundef, i64 noundef) local_unnamed_addr #0

declare i32 @DN_compute_program_load(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 #2 = { 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}


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