; LLVM IR from phisko/kengine :: kengine/render/polyvox/libs/polyvox/examples/OpenGL (Shapes)

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

%"class.PolyVox::MaterialDensityPair" = type { i16 }

; 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: mustprogress uwtable
declare dso_local void @_ZN7PolyVox9RawVolumeINS_19MaterialDensityPairItLh8ELh8EEEE8setVoxelEiiiS2_(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef, i16) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMaxDensityEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMinDensityEv() #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EEC2Ett(ptr noundef nonnull align 2 dereferenceable(2), i16 noundef zeroext, i16 noundef zeroext) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18createCubeInVolumeRN7PolyVox9RawVolumeINS_19MaterialDensityPairItLh8ELh8EEEEENS_6VectorILj3EiiEES6_h(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"class.PolyVox::MaterialDensityPair", align 2
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i8 %3, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %16 = call noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMaxDensityEv()
  %17 = trunc i16 %16 to i8
  store i8 %17, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %18 = call noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMinDensityEv()
  %19 = trunc i16 %18 to i8
  store i8 %19, ptr %10, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %20 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12) %1)
  store i32 %20, ptr %11, align 4, !tbaa !10
  br label %21

21:                                               ; preds = %67, %4
  %22 = load i32, ptr %11, align 4, !tbaa !10
  %23 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %70

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %27 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12) %1)
  store i32 %27, ptr %13, align 4, !tbaa !10
  br label %28

28:                                               ; preds = %63, %26
  %29 = load i32, ptr %13, align 4, !tbaa !10
  %30 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %34 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12) %1)
  store i32 %34, ptr %14, align 4, !tbaa !10
  br label %35

35:                                               ; preds = %59, %33
  %36 = load i32, ptr %14, align 4, !tbaa !10
  %37 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %62

40:                                               ; preds = %35
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %14, align 4, !tbaa !10
  %43 = load i32, ptr %13, align 4, !tbaa !10
  %44 = load i32, ptr %11, align 4, !tbaa !10
  %45 = load i8, ptr %8, align 1, !tbaa !9
  %46 = zext i8 %45 to i16
  %47 = load i8, ptr %8, align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %40
  %51 = load i8, ptr %9, align 1, !tbaa !9
  br label %54

52:                                               ; preds = %40
  %53 = load i8, ptr %10, align 1, !tbaa !9
  br label %54

54:                                               ; preds = %52, %50
  %55 = phi i8 [ %51, %50 ], [ %53, %52 ]
  %56 = zext i8 %55 to i16
  call void @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EEC2Ett(ptr noundef nonnull align 2 dereferenceable(2) %15, i16 noundef zeroext %46, i16 noundef zeroext %56)
  %57 = getelementptr inbounds %"class.PolyVox::MaterialDensityPair", ptr %15, i32 0, i32 0
  %58 = load i16, ptr %57, align 2
  call void @_ZN7PolyVox9RawVolumeINS_19MaterialDensityPairItLh8ELh8EEEE8setVoxelEiiiS2_(ptr noundef nonnull align 8 dereferenceable(40) %41, i32 noundef %42, i32 noundef %43, i32 noundef %44, i16 %58)
  br label %59

59:                                               ; preds = %54
  %60 = load i32, ptr %14, align 4, !tbaa !10
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %14, align 4, !tbaa !10
  br label %35, !llvm.loop !12

62:                                               ; preds = %39
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %13, align 4, !tbaa !10
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %13, align 4, !tbaa !10
  br label %28, !llvm.loop !14

66:                                               ; preds = %32
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %11, align 4, !tbaa !10
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %11, align 4, !tbaa !10
  br label %21, !llvm.loop !15

70:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { mustprogress 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 #3 = { inlinehint mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


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

%"class.PolyVox::MaterialDensityPair" = type { i16 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7PolyVox9RawVolumeINS_19MaterialDensityPairItLh8ELh8EEEE8setVoxelEiiiS2_(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef, i16) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMaxDensityEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMinDensityEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EEC2Ett(ptr noundef nonnull align 2 dereferenceable(2), i16 noundef zeroext, i16 noundef zeroext) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18createCubeInVolumeRN7PolyVox9RawVolumeINS_19MaterialDensityPairItLh8ELh8EEEEENS_6VectorILj3EiiEES6_h(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = alloca %"class.PolyVox::MaterialDensityPair", align 2
  %6 = tail call noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMaxDensityEv()
  %7 = tail call noundef zeroext i16 @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EE13getMinDensityEv()
  %8 = tail call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12) %1)
  %9 = tail call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %.not25 = icmp sgt i32 %8, %9
  br i1 %.not25, label %._crit_edge29, label %.lr.ph28

.lr.ph28:                                         ; preds = %4
  %10 = zext i8 %3 to i16
  %.not17 = icmp eq i8 %3, 0
  %.v = select i1 %.not17, i16 %7, i16 %6
  %11 = and i16 %.v, 255
  br label %12

._crit_edge29:                                    ; preds = %._crit_edge24, %4
  ret void

12:                                               ; preds = %.lr.ph28, %._crit_edge24
  %.01426 = phi i32 [ %8, %.lr.ph28 ], [ %15, %._crit_edge24 ]
  %13 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12) %1)
  %14 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %.not1520 = icmp sgt i32 %13, %14
  br i1 %.not1520, label %._crit_edge24, label %.lr.ph23

._crit_edge24:                                    ; preds = %._crit_edge, %12
  %15 = add nsw i32 %.01426, 1
  %16 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %.not.not = icmp slt i32 %.01426, %16
  br i1 %.not.not, label %12, label %._crit_edge29, !llvm.loop !5

.lr.ph23:                                         ; preds = %12, %._crit_edge
  %.01321 = phi i32 [ %19, %._crit_edge ], [ %13, %12 ]
  %17 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12) %1)
  %18 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %.not1618 = icmp sgt i32 %17, %18
  br i1 %.not1618, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph23
  %19 = add nsw i32 %.01321, 1
  %20 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %.not15.not = icmp slt i32 %.01321, %20
  br i1 %.not15.not, label %.lr.ph23, label %._crit_edge24, !llvm.loop !7

.lr.ph:                                           ; preds = %.lr.ph23, %.lr.ph
  %.019 = phi i32 [ %22, %.lr.ph ], [ %17, %.lr.ph23 ]
  call void @_ZN7PolyVox19MaterialDensityPairItLh8ELh8EEC2Ett(ptr noundef nonnull align 2 dereferenceable(2) %5, i16 noundef zeroext %10, i16 noundef zeroext %11)
  %21 = load i16, ptr %5, align 2
  call void @_ZN7PolyVox9RawVolumeINS_19MaterialDensityPairItLh8ELh8EEEE8setVoxelEiiiS2_(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %.019, i32 noundef %.01321, i32 noundef %.01426, i16 %21)
  %22 = add nsw i32 %.019, 1
  %23 = call noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %.not16.not = icmp slt i32 %.019, %23
  br i1 %.not16.not, label %.lr.ph, label %._crit_edge, !llvm.loop !8
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getZEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getYEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7PolyVox6VectorILj3EiiE4getXEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { mustprogress 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 #2 = { inlinehint mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass