; LLVM IR from PyCee/NUS_library :: src/render (NUS_graphics_pipeline)

; 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.VkGraphicsPipelineCreateInfo = type { i32, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32 }
%struct.VkViewport = type { float, float, float, float, float, float }
%struct.VkRect2D = type { %struct.VkOffset2D, %struct.VkExtent2D }
%struct.VkOffset2D = type { i32, i32 }
%struct.VkExtent2D = type { i32, i32 }
%struct.NUS_binding = type { ptr, ptr, ptr, i32 }
%struct.NUS_graphics_pipeline = type { ptr, %struct.VkViewport, %struct.VkRect2D, %struct.NUS_binding }

@vkCreateGraphicsPipelines = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @nus_graphics_pipeline_build(ptr noundef byval(%struct.VkGraphicsPipelineCreateInfo) align 8 %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %struct.VkViewport, align 4
  %6 = alloca %struct.VkRect2D, align 4
  %7 = alloca %struct.NUS_binding, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr @vkCreateGraphicsPipelines, align 8, !tbaa !5
  %9 = call ptr @nus_get_bound_device()
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.NUS_graphics_pipeline, ptr %10, i32 0, i32 0
  %12 = call i32 %8(ptr noundef %9, ptr noundef null, i32 noundef 1, ptr noundef %0, ptr noundef null, ptr noundef %11)
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %16

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

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.NUS_graphics_pipeline, ptr %17, i32 0, i32 1
  call void @llvm.memset.p0.i64(ptr align 4 %5, i8 0, i64 24, i1 false)
  %19 = getelementptr inbounds %struct.VkViewport, ptr %5, i32 0, i32 0
  %20 = getelementptr inbounds %struct.VkViewport, ptr %5, i32 0, i32 1
  %21 = getelementptr inbounds %struct.VkViewport, ptr %5, i32 0, i32 2
  %22 = getelementptr inbounds %struct.VkViewport, ptr %5, i32 0, i32 3
  %23 = getelementptr inbounds %struct.VkViewport, ptr %5, i32 0, i32 4
  %24 = getelementptr inbounds %struct.VkViewport, ptr %5, i32 0, i32 5
  store float 1.000000e+00, ptr %24, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 4 %5, i64 24, i1 false), !tbaa.struct !12
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.NUS_graphics_pipeline, ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds %struct.VkRect2D, ptr %6, i32 0, i32 0
  %28 = getelementptr inbounds %struct.VkOffset2D, ptr %27, i32 0, i32 0
  store i32 0, ptr %28, align 4, !tbaa !14
  %29 = getelementptr inbounds %struct.VkOffset2D, ptr %27, i32 0, i32 1
  store i32 0, ptr %29, align 4, !tbaa !17
  %30 = getelementptr inbounds %struct.VkRect2D, ptr %6, i32 0, i32 1
  %31 = getelementptr inbounds %struct.VkExtent2D, ptr %30, i32 0, i32 0
  store i32 0, ptr %31, align 4, !tbaa !18
  %32 = getelementptr inbounds %struct.VkExtent2D, ptr %30, i32 0, i32 1
  store i32 0, ptr %32, align 4, !tbaa !20
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 4 %6, i64 16, i1 false), !tbaa.struct !21
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.NUS_graphics_pipeline, ptr %33, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  call void @nus_get_binding(ptr dead_on_unwind writable sret(%struct.NUS_binding) align 8 %7)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 8 %7, i64 32, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  store i32 1, ptr %3, align 4
  br label %35

35:                                               ; preds = %16, %14
  %36 = load i32, ptr %3, align 4
  ret i32 %36
}

declare ptr @nus_get_bound_device() #1

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; 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) #3

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

declare void @nus_get_binding(ptr dead_on_unwind writable sret(%struct.NUS_binding) align 8) #1

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 20}
!10 = !{!"VkViewport", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"float", !7, i64 0}
!12 = !{i64 0, i64 4, !13, i64 4, i64 4, !13, i64 8, i64 4, !13, i64 12, i64 4, !13, i64 16, i64 4, !13, i64 20, i64 4, !13}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"VkOffset2D", !16, i64 0, !16, i64 4}
!16 = !{!"int", !7, i64 0}
!17 = !{!15, !16, i64 4}
!18 = !{!19, !16, i64 0}
!19 = !{!"VkExtent2D", !16, i64 0, !16, i64 4}
!20 = !{!19, !16, i64 4}
!21 = !{i64 0, i64 4, !22, i64 4, i64 4, !22, i64 8, i64 4, !22, i64 12, i64 4, !22}
!22 = !{!16, !16, i64 0}
!23 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 4, !22}


; 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.VkGraphicsPipelineCreateInfo = type { i32, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32 }
%struct.NUS_binding = type { ptr, ptr, ptr, i32 }

@vkCreateGraphicsPipelines = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @nus_graphics_pipeline_build(ptr noundef byval(%struct.VkGraphicsPipelineCreateInfo) align 8 %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.NUS_binding, align 8
  %4 = load ptr, ptr @vkCreateGraphicsPipelines, align 8, !tbaa !5
  %5 = tail call ptr @nus_get_bound_device() #6
  %6 = call i32 %4(ptr noundef %5, ptr noundef null, i32 noundef 1, ptr noundef nonnull %0, ptr noundef null, ptr noundef %1) #6
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %9, label %7

7:                                                ; preds = %2
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %13

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %10, i8 0, i64 20, i1 false)
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 28
  store float 1.000000e+00, ptr %.sroa.22.0..sroa_idx, align 4, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %1, i64 32
  %12 = getelementptr inbounds i8, ptr %1, i64 48
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  call void @nus_get_binding(ptr dead_on_unwind nonnull writable sret(%struct.NUS_binding) align 8 %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %3, i64 32, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  br label %13

13:                                               ; preds = %9, %7
  %.0 = phi i32 [ 0, %7 ], [ 1, %9 ]
  ret i32 %.0
}

declare ptr @nus_get_bound_device() local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress 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) #4

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

declare void @nus_get_binding(ptr dead_on_unwind writable sret(%struct.NUS_binding) align 8) local_unnamed_addr #1

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

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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{!"float", !7, i64 0}
!11 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass