; LLVM IR from PyCee/NUS_library :: src/gpu (NUS_queue_family)

; 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.VkQueueFamilyProperties = type { i32, i32, i32, %struct.VkExtent3D }
%struct.VkExtent3D = type { i32, i32, i32 }
%struct.NUS_queue_family = type { ptr, ptr, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @nus_queue_family_build(ptr noundef byval(%struct.VkQueueFamilyProperties) align 8 %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  %7 = load i32, ptr %5, align 4, !tbaa !5
  %8 = load ptr, ptr %6, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.NUS_queue_family, ptr %8, i32 0, i32 3
  store i32 %7, ptr %9, align 4, !tbaa !11
  %10 = getelementptr inbounds %struct.VkQueueFamilyProperties, ptr %0, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = icmp eq i32 0, %11
  br i1 %12, label %13, label %15

13:                                               ; preds = %3
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 0, ptr %4, align 4
  br label %62

15:                                               ; preds = %3
  %16 = getelementptr inbounds %struct.VkQueueFamilyProperties, ptr %0, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = load ptr, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.NUS_queue_family, ptr %18, i32 0, i32 2
  store i32 %17, ptr %19, align 8, !tbaa !16
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.NUS_queue_family, ptr %20, i32 0, i32 4
  store i32 0, ptr %21, align 8, !tbaa !17
  %22 = getelementptr inbounds %struct.VkQueueFamilyProperties, ptr %0, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !18
  %24 = and i32 %23, 1
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %15
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.NUS_queue_family, ptr %27, i32 0, i32 4
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = or i32 %29, 1
  store i32 %30, ptr %28, align 8, !tbaa !17
  br label %31

31:                                               ; preds = %26, %15
  %32 = getelementptr inbounds %struct.VkQueueFamilyProperties, ptr %0, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !18
  %34 = and i32 %33, 2
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %41

36:                                               ; preds = %31
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.NUS_queue_family, ptr %37, i32 0, i32 4
  %39 = load i32, ptr %38, align 8, !tbaa !17
  %40 = or i32 %39, 2
  store i32 %40, ptr %38, align 8, !tbaa !17
  br label %41

41:                                               ; preds = %36, %31
  %42 = getelementptr inbounds %struct.VkQueueFamilyProperties, ptr %0, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !18
  %44 = and i32 %43, 4
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %51

46:                                               ; preds = %41
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.NUS_queue_family, ptr %47, i32 0, i32 4
  %49 = load i32, ptr %48, align 8, !tbaa !17
  %50 = or i32 %49, 4
  store i32 %50, ptr %48, align 8, !tbaa !17
  br label %51

51:                                               ; preds = %46, %41
  %52 = getelementptr inbounds %struct.VkQueueFamilyProperties, ptr %0, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !18
  %54 = and i32 %53, 8
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %61

56:                                               ; preds = %51
  %57 = load ptr, ptr %6, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.NUS_queue_family, ptr %57, i32 0, i32 4
  %59 = load i32, ptr %58, align 8, !tbaa !17
  %60 = or i32 %59, 8
  store i32 %60, ptr %58, align 8, !tbaa !17
  br label %61

61:                                               ; preds = %56, %51
  store i32 1, ptr %4, align 4
  br label %62

62:                                               ; preds = %61, %13
  %63 = load i32, ptr %4, align 4
  ret i32 %63
}

declare i32 @printf(ptr noundef, ...) #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" }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 20}
!12 = !{!"NUS_queue_family", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28}
!13 = !{!14, !6, i64 4}
!14 = !{!"VkQueueFamilyProperties", !6, i64 0, !6, i64 4, !6, i64 8, !15, i64 12}
!15 = !{!"VkExtent3D", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !6, i64 24}
!18 = !{!14, !6, 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.VkQueueFamilyProperties = type { i32, i32, i32, %struct.VkExtent3D }
%struct.VkExtent3D = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @nus_queue_family_build(ptr nocapture noundef readonly byval(%struct.VkQueueFamilyProperties) align 8 %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 20
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %3
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %17

10:                                               ; preds = %3
  %11 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %6, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %2, i64 24
  %13 = load i32, ptr %0, align 8, !tbaa !15
  %spec.select12 = and i32 %13, 7
  store i32 %spec.select12, ptr %12, align 8
  %14 = and i32 %13, 8
  %.not11 = icmp eq i32 %14, 0
  br i1 %.not11, label %17, label %15

15:                                               ; preds = %10
  %16 = or disjoint i32 %spec.select12, 8
  store i32 %16, ptr %12, align 8, !tbaa !16
  br label %17

17:                                               ; preds = %10, %15, %8
  %.0 = phi i32 [ 0, %8 ], [ 1, %15 ], [ 1, %10 ]
  ret i32 %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

!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, !10, i64 20}
!6 = !{!"NUS_queue_family", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"VkQueueFamilyProperties", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12}
!13 = !{!"VkExtent3D", !10, i64 0, !10, i64 4, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!12, !10, i64 0}
!16 = !{!6, !10, i64 24}


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