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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @nus_sampler_build(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.VkSamplerCreateInfo, align 8
  %7 = alloca %struct.NUS_sampler, align 8
  %8 = alloca %struct.VkSamplerCreateInfo, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 80, ptr %6) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.NUS_sampler, ptr %7, i32 0, i32 0
  store ptr null, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.NUS_sampler, ptr %7, i32 0, i32 1
  call void @nus_get_binding(ptr dead_on_unwind writable sret(%struct.NUS_binding) align 8 %12)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %7, i64 40, i1 false), !tbaa.struct !14
  %13 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 0
  store i32 31, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 1
  store ptr null, ptr %14, align 8, !tbaa !18
  %15 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 2
  store i32 0, ptr %15, align 8, !tbaa !19
  %16 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 3
  %17 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %17, ptr %16, align 4, !tbaa !20
  %18 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 4
  %19 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %19, ptr %18, align 8, !tbaa !21
  %20 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 5
  store i32 1, ptr %20, align 4, !tbaa !22
  %21 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 6
  store i32 0, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 7
  store i32 0, ptr %22, align 4, !tbaa !24
  %23 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 8
  store i32 0, ptr %23, align 8, !tbaa !25
  %24 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 9
  store float 0.000000e+00, ptr %24, align 4, !tbaa !26
  %25 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 10
  store i32 1, ptr %25, align 8, !tbaa !27
  %26 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 11
  store float 1.600000e+01, ptr %26, align 4, !tbaa !28
  %27 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 12
  store i32 0, ptr %27, align 8, !tbaa !29
  %28 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 13
  store i32 7, ptr %28, align 4, !tbaa !30
  %29 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 14
  store float 0.000000e+00, ptr %29, align 8, !tbaa !31
  %30 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 15
  store float 0.000000e+00, ptr %30, align 4, !tbaa !32
  %31 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 16
  store i32 3, ptr %31, align 8, !tbaa !33
  %32 = getelementptr inbounds %struct.VkSamplerCreateInfo, ptr %8, i32 0, i32 17
  store i32 0, ptr %32, align 4, !tbaa !34
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %8, i64 80, i1 false), !tbaa.struct !35
  %33 = load ptr, ptr @vkCreateSampler, align 8, !tbaa !5
  %34 = call ptr @nus_get_bound_device()
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.NUS_sampler, ptr %35, i32 0, i32 0
  %37 = call i32 %33(ptr noundef %34, ptr noundef %6, ptr noundef null, ptr noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %2
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %42

41:                                               ; preds = %2
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %42

42:                                               ; preds = %41, %39
  call void @llvm.lifetime.end.p0(i64 80, ptr %6) #4
  %43 = load i32, ptr %3, align 4
  ret i32 %43
}

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

declare void @nus_get_binding(ptr dead_on_unwind writable sret(%struct.NUS_binding) align 8) #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

declare ptr @nus_get_bound_device() #2

declare i32 @printf(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"NUS_sampler", !6, i64 0, !13, i64 8}
!13 = !{!"NUS_binding", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24}
!14 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 4, !9}
!15 = !{!16, !10, i64 0}
!16 = !{!"VkSamplerCreateInfo", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !17, i64 44, !10, i64 48, !17, i64 52, !10, i64 56, !10, i64 60, !17, i64 64, !17, i64 68, !10, i64 72, !10, i64 76}
!17 = !{!"float", !7, i64 0}
!18 = !{!16, !6, i64 8}
!19 = !{!16, !10, i64 16}
!20 = !{!16, !10, i64 20}
!21 = !{!16, !10, i64 24}
!22 = !{!16, !10, i64 28}
!23 = !{!16, !10, i64 32}
!24 = !{!16, !10, i64 36}
!25 = !{!16, !10, i64 40}
!26 = !{!16, !17, i64 44}
!27 = !{!16, !10, i64 48}
!28 = !{!16, !17, i64 52}
!29 = !{!16, !10, i64 56}
!30 = !{!16, !10, i64 60}
!31 = !{!16, !17, i64 64}
!32 = !{!16, !17, i64 68}
!33 = !{!16, !10, i64 72}
!34 = !{!16, !10, i64 76}
!35 = !{i64 0, i64 4, !9, i64 8, i64 8, !5, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 4, !9, i64 36, i64 4, !9, i64 40, i64 4, !9, i64 44, i64 4, !36, i64 48, i64 4, !9, i64 52, i64 4, !36, i64 56, i64 4, !9, i64 60, i64 4, !9, i64 64, i64 4, !36, i64 68, i64 4, !36, i64 72, i64 4, !9, i64 76, i64 4, !9}
!36 = !{!17, !17, 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.VkSamplerCreateInfo = type { i32, ptr, i32, i32, i32, i32, i32, i32, i32, float, i32, float, i32, i32, float, float, i32, i32 }
%struct.NUS_sampler = type { ptr, %struct.NUS_binding }
%struct.NUS_binding = type { ptr, ptr, ptr, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @nus_sampler_build(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.VkSamplerCreateInfo, align 8
  %4 = alloca %struct.NUS_sampler, align 8
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %3) #6
  store ptr null, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  call void @nus_get_binding(ptr dead_on_unwind nonnull writable sret(%struct.NUS_binding) align 8 %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %4, i64 40, i1 false), !tbaa.struct !12
  store i32 31, ptr %3, align 8, !tbaa !14
  %.sroa.21.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  store ptr null, ptr %.sroa.21.0..sroa_idx, align 8, !tbaa !13
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 16
  store i32 0, ptr %.sroa.3.0..sroa_idx, align 8, !tbaa !14
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 20
  store i32 %1, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !14
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %1, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !14
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 28
  store i32 1, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !14
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 32
  %.sroa.11.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 48
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %.sroa.7.0..sroa_idx, i8 0, i64 16, i1 false)
  store i32 1, ptr %.sroa.11.0..sroa_idx, align 8, !tbaa !14
  %.sroa.12.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 52
  store float 1.600000e+01, ptr %.sroa.12.0..sroa_idx, align 4, !tbaa !15
  %.sroa.13.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 56
  store i32 0, ptr %.sroa.13.0..sroa_idx, align 8, !tbaa !14
  %.sroa.14.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 60
  store i32 7, ptr %.sroa.14.0..sroa_idx, align 4, !tbaa !14
  %.sroa.15.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 64
  store <2 x float> zeroinitializer, ptr %.sroa.15.0..sroa_idx, align 8, !tbaa !15
  %.sroa.17.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 72
  store i32 3, ptr %.sroa.17.0..sroa_idx, align 8, !tbaa !14
  %.sroa.18.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 76
  store i32 0, ptr %.sroa.18.0..sroa_idx, align 4, !tbaa !14
  %6 = load ptr, ptr @vkCreateSampler, align 8, !tbaa !13
  %7 = call ptr @nus_get_bound_device() #6
  %8 = call i32 %6(ptr noundef %7, ptr noundef nonnull %3, ptr noundef null, ptr noundef %0) #6
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %11, label %9

9:                                                ; preds = %2
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %11

11:                                               ; preds = %2, %9
  %.0 = phi i32 [ 0, %9 ], [ 1, %2 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #6
  ret i32 %.0
}

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

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

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

declare ptr @nus_get_bound_device() local_unnamed_addr #2

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"NUS_sampler", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"NUS_binding", !7, i64 0, !7, i64 8, !7, i64 16, !11, i64 24}
!11 = !{!"int", !8, i64 0}
!12 = !{i64 0, i64 8, !13, i64 8, i64 8, !13, i64 16, i64 8, !13, i64 24, i64 8, !13, i64 32, i64 4, !14}
!13 = !{!7, !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass