; LLVM IR from Try/Tempest :: Engine/thirdparty/spirv_cross (spirv_cross)

; 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.spirv_cross::Compiler::PhysicalBlockMeta" = type { i32 }

; 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 noundef ptr @_ZNK11spirv_cross8Compiler35PhysicalStorageBufferPointerHandler15find_block_metaEj(ptr noundef nonnull align 8 dereferenceable(184), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11spirv_cross8Compiler35PhysicalStorageBufferPointerHandler19mark_aligned_accessEjPKjj(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %14, ptr %9, align 4, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds i32, ptr %15, i32 1
  store ptr %16, ptr %7, align 8, !tbaa !5
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = add i32 %17, -1
  store i32 %18, ptr %8, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %30

21:                                               ; preds = %4
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = and i32 %22, 1
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %21
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i32 1
  store ptr %27, ptr %7, align 8, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = add i32 %28, -1
  store i32 %29, ptr %8, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %25, %21, %4
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %55

33:                                               ; preds = %30
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = and i32 %34, 2
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %55

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr %38, align 4, !tbaa !9
  store i32 %39, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = call noundef ptr @_ZNK11spirv_cross8Compiler35PhysicalStorageBufferPointerHandler15find_block_metaEj(ptr noundef nonnull align 8 dereferenceable(184) %12, i32 noundef %40)
  store ptr %41, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %54

44:                                               ; preds = %37
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.spirv_cross::Compiler::PhysicalBlockMeta", ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = icmp ugt i32 %45, %48
  br i1 %49, label %50, label %54

50:                                               ; preds = %44
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.spirv_cross::Compiler::PhysicalBlockMeta", ptr %52, i32 0, i32 0
  store i32 %51, ptr %53, align 4, !tbaa !11
  br label %54

54:                                               ; preds = %50, %44, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %55

55:                                               ; preds = %54, %33, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret void
}

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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN11spirv_cross8Compiler17PhysicalBlockMetaE", !10, 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK11spirv_cross8Compiler35PhysicalStorageBufferPointerHandler15find_block_metaEj(ptr noundef nonnull align 8 dereferenceable(184), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11spirv_cross8Compiler35PhysicalStorageBufferPointerHandler19mark_aligned_accessEjPKjj(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %.not = icmp eq i32 %3, 1
  br i1 %.not, label %.thread, label %5

5:                                                ; preds = %4
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = and i32 %6, 1
  %.not20 = icmp ne i32 %7, 0
  %8 = icmp eq i32 %3, 2
  %.016 = and i1 %8, %.not20
  %9 = and i32 %6, 2
  %.not22 = icmp eq i32 %9, 0
  %or.cond = or i1 %.not22, %.016
  br i1 %or.cond, label %.thread, label %10

10:                                               ; preds = %5
  %.0.v = select i1 %.not20, i64 8, i64 4
  %.0 = getelementptr inbounds i8, ptr %2, i64 %.0.v
  %11 = load i32, ptr %.0, align 4, !tbaa !5
  %12 = tail call noundef ptr @_ZNK11spirv_cross8Compiler35PhysicalStorageBufferPointerHandler15find_block_metaEj(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %1)
  %.not23 = icmp eq ptr %12, null
  br i1 %.not23, label %.thread, label %13

13:                                               ; preds = %10
  %14 = load i32, ptr %12, align 4, !tbaa !9
  %15 = icmp ugt i32 %11, %14
  br i1 %15, label %16, label %.thread

16:                                               ; preds = %13
  store i32 %11, ptr %12, align 4, !tbaa !9
  br label %.thread

.thread:                                          ; preds = %4, %10, %13, %16, %5
  ret void
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN11spirv_cross8Compiler17PhysicalBlockMetaE", !6, i64 0}


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