; LLVM IR from l1mey112/yr11-physics-applied :: sokol (sokol)

; 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.sg_context_desc = type { i32, i32, i32, %struct.sg_gl_context_desc, %struct.sg_metal_context_desc, %struct.sg_d3d11_context_desc, %struct.sg_wgpu_context_desc }
%struct.sg_gl_context_desc = type { i8 }
%struct.sg_metal_context_desc = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.sg_d3d11_context_desc = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.sg_wgpu_context_desc = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local i32 @sapp_color_format() #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @sapp_depth_format() #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @sapp_sample_count() #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @sapp_gles2() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_metal_get_device() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_metal_get_renderpass_descriptor() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_metal_get_drawable() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_device() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_device_context() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_render_target_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_depth_stencil_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_device() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_render_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_resolve_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_depth_stencil_view() #0

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

; Function Attrs: nounwind uwtable
define dso_local void @sapp_sgcontext(ptr dead_on_unwind noalias writable sret(%struct.sg_context_desc) align 8 %0) #0 {
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 184, i1 false)
  %2 = call i32 @sapp_color_format()
  %3 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 0
  store i32 %2, ptr %3, align 8, !tbaa !5
  %4 = call i32 @sapp_depth_format()
  %5 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 1
  store i32 %4, ptr %5, align 4, !tbaa !16
  %6 = call i32 @sapp_sample_count()
  %7 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 2
  store i32 %6, ptr %7, align 8, !tbaa !17
  %8 = call zeroext i1 @sapp_gles2()
  %9 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 3
  %10 = getelementptr inbounds %struct.sg_gl_context_desc, ptr %9, i32 0, i32 0
  %11 = zext i1 %8 to i8
  store i8 %11, ptr %10, align 4, !tbaa !18
  %12 = call ptr @sapp_metal_get_device()
  %13 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 4
  %14 = getelementptr inbounds %struct.sg_metal_context_desc, ptr %13, i32 0, i32 0
  store ptr %12, ptr %14, align 8, !tbaa !19
  %15 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 4
  %16 = getelementptr inbounds %struct.sg_metal_context_desc, ptr %15, i32 0, i32 1
  store ptr @sapp_metal_get_renderpass_descriptor, ptr %16, align 8, !tbaa !20
  %17 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 4
  %18 = getelementptr inbounds %struct.sg_metal_context_desc, ptr %17, i32 0, i32 3
  store ptr @sapp_metal_get_drawable, ptr %18, align 8, !tbaa !21
  %19 = call ptr @sapp_d3d11_get_device()
  %20 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 5
  %21 = getelementptr inbounds %struct.sg_d3d11_context_desc, ptr %20, i32 0, i32 0
  store ptr %19, ptr %21, align 8, !tbaa !22
  %22 = call ptr @sapp_d3d11_get_device_context()
  %23 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 5
  %24 = getelementptr inbounds %struct.sg_d3d11_context_desc, ptr %23, i32 0, i32 1
  store ptr %22, ptr %24, align 8, !tbaa !23
  %25 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 5
  %26 = getelementptr inbounds %struct.sg_d3d11_context_desc, ptr %25, i32 0, i32 2
  store ptr @sapp_d3d11_get_render_target_view, ptr %26, align 8, !tbaa !24
  %27 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 5
  %28 = getelementptr inbounds %struct.sg_d3d11_context_desc, ptr %27, i32 0, i32 4
  store ptr @sapp_d3d11_get_depth_stencil_view, ptr %28, align 8, !tbaa !25
  %29 = call ptr @sapp_wgpu_get_device()
  %30 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 6
  %31 = getelementptr inbounds %struct.sg_wgpu_context_desc, ptr %30, i32 0, i32 0
  store ptr %29, ptr %31, align 8, !tbaa !26
  %32 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 6
  %33 = getelementptr inbounds %struct.sg_wgpu_context_desc, ptr %32, i32 0, i32 1
  store ptr @sapp_wgpu_get_render_view, ptr %33, align 8, !tbaa !27
  %34 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 6
  %35 = getelementptr inbounds %struct.sg_wgpu_context_desc, ptr %34, i32 0, i32 3
  store ptr @sapp_wgpu_get_resolve_view, ptr %35, align 8, !tbaa !28
  %36 = getelementptr inbounds %struct.sg_context_desc, ptr %0, i32 0, i32 6
  %37 = getelementptr inbounds %struct.sg_wgpu_context_desc, ptr %36, i32 0, i32 5
  store ptr @sapp_wgpu_get_depth_stencil_view, ptr %37, align 8, !tbaa !29
  ret void
}

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 nounwind willreturn memory(argmem: write) }

!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 = !{!"sg_context_desc", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !12, i64 16, !14, i64 64, !15, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"sg_gl_context_desc", !11, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"sg_metal_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"sg_d3d11_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48}
!15 = !{!"sg_wgpu_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!16 = !{!6, !7, i64 4}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !11, i64 12}
!19 = !{!6, !13, i64 16}
!20 = !{!6, !13, i64 24}
!21 = !{!6, !13, i64 40}
!22 = !{!6, !13, i64 64}
!23 = !{!6, !13, i64 72}
!24 = !{!6, !13, i64 80}
!25 = !{!6, !13, i64 96}
!26 = !{!6, !13, i64 120}
!27 = !{!6, !13, i64 128}
!28 = !{!6, !13, i64 144}
!29 = !{!6, !13, i64 160}


; 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.sg_context_desc = type { i32, i32, i32, %struct.sg_gl_context_desc, %struct.sg_metal_context_desc, %struct.sg_d3d11_context_desc, %struct.sg_wgpu_context_desc }
%struct.sg_gl_context_desc = type { i8 }
%struct.sg_metal_context_desc = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.sg_d3d11_context_desc = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.sg_wgpu_context_desc = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local i32 @sapp_color_format() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @sapp_depth_format() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @sapp_sample_count() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @sapp_gles2() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_metal_get_device() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_metal_get_renderpass_descriptor() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_metal_get_drawable() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_device() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_device_context() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_render_target_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_d3d11_get_depth_stencil_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_device() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_render_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_resolve_view() #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sapp_wgpu_get_depth_stencil_view() #0

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

; Function Attrs: nounwind uwtable
define dso_local void @sapp_sgcontext(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.sg_context_desc) align 8 %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(184) %2, i8 0, i64 176, i1 false)
  %3 = tail call i32 @sapp_color_format()
  store i32 %3, ptr %0, align 8, !tbaa !5
  %4 = tail call i32 @sapp_depth_format()
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %4, ptr %5, align 4, !tbaa !16
  %6 = tail call i32 @sapp_sample_count()
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %6, ptr %7, align 8, !tbaa !17
  %8 = tail call zeroext i1 @sapp_gles2()
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = zext i1 %8 to i8
  store i8 %10, ptr %9, align 4, !tbaa !18
  %11 = tail call ptr @sapp_metal_get_device()
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %11, ptr %12, align 8, !tbaa !19
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr @sapp_metal_get_renderpass_descriptor, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr @sapp_metal_get_drawable, ptr %14, align 8, !tbaa !21
  %15 = tail call ptr @sapp_d3d11_get_device()
  %16 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %15, ptr %16, align 8, !tbaa !22
  %17 = tail call ptr @sapp_d3d11_get_device_context()
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %17, ptr %18, align 8, !tbaa !23
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr @sapp_d3d11_get_render_target_view, ptr %19, align 8, !tbaa !24
  %20 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr @sapp_d3d11_get_depth_stencil_view, ptr %20, align 8, !tbaa !25
  %21 = tail call ptr @sapp_wgpu_get_device()
  %22 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %21, ptr %22, align 8, !tbaa !26
  %23 = getelementptr inbounds i8, ptr %0, i64 128
  store ptr @sapp_wgpu_get_render_view, ptr %23, align 8, !tbaa !27
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  store ptr @sapp_wgpu_get_resolve_view, ptr %24, align 8, !tbaa !28
  %25 = getelementptr inbounds i8, ptr %0, i64 160
  store ptr @sapp_wgpu_get_depth_stencil_view, ptr %25, align 8, !tbaa !29
  ret void
}

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 nounwind willreturn memory(argmem: write) }

!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 = !{!"sg_context_desc", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !12, i64 16, !14, i64 64, !15, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"sg_gl_context_desc", !11, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"sg_metal_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"sg_d3d11_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48}
!15 = !{!"sg_wgpu_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!16 = !{!6, !7, i64 4}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !11, i64 12}
!19 = !{!6, !13, i64 16}
!20 = !{!6, !13, i64 24}
!21 = !{!6, !13, i64 40}
!22 = !{!6, !13, i64 64}
!23 = !{!6, !13, i64 72}
!24 = !{!6, !13, i64 80}
!25 = !{!6, !13, i64 96}
!26 = !{!6, !13, i64 120}
!27 = !{!6, !13, i64 128}
!28 = !{!6, !13, i64 144}
!29 = !{!6, !13, i64 160}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,TailCallElimPass