; 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_state_t = type { i8, %struct.sg_desc, i32, %struct.sg_context, %struct.sg_pass, %struct.sg_pipeline, i8, i8, i8, i32, %struct._sg_pools_t, i32, %struct.sg_features, %struct.sg_limits, [64 x %struct.sg_pixelformat_info], %struct._sg_gl_backend_t, %struct._sg_commit_listeners_t }
%struct.sg_desc = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, %struct.sg_allocator, %struct.sg_logger, %struct.sg_context_desc, i32 }
%struct.sg_allocator = type { ptr, ptr, ptr }
%struct.sg_logger = type { ptr, ptr }
%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 }
%struct.sg_context = type { i32 }
%struct.sg_pass = type { i32 }
%struct.sg_pipeline = type { i32 }
%struct._sg_pools_t = type { %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._sg_pool_t = type { i32, i32, ptr, ptr }
%struct.sg_features = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 }
%struct.sg_limits = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.sg_pixelformat_info = type { i8, i8, i8, i8, i8, i8 }
%struct._sg_gl_backend_t = type { i8, i8, i8, i32, i32, ptr, ptr, %struct.sg_pass, %struct._sg_gl_state_cache_t, i8, i32, i32 }
%struct._sg_gl_state_cache_t = type { %struct.sg_depth_state, %struct.sg_stencil_state, %struct.sg_blend_state, [4 x i32], i32, i32, i8, i32, %struct.sg_color, i8, [16 x %struct._sg_gl_cache_attr_t], i32, i32, i32, i32, i32, [12 x %struct._sg_gl_texture_bind_slot], %struct._sg_gl_texture_bind_slot, i32, i32, i32, i32, ptr, %struct.sg_pipeline }
%struct.sg_depth_state = type { i32, i32, i8, float, float, float }
%struct.sg_stencil_state = type { i8, %struct.sg_stencil_face_state, %struct.sg_stencil_face_state, i8, i8, i8 }
%struct.sg_stencil_face_state = type { i32, i32, i32, i32 }
%struct.sg_blend_state = type { i8, i32, i32, i32, i32, i32, i32 }
%struct.sg_color = type { float, float, float, float }
%struct._sg_gl_cache_attr_t = type { %struct._sg_gl_attr_t, i32 }
%struct._sg_gl_attr_t = type { i8, i8, i8, i8, i8, i32, i32 }
%struct._sg_gl_texture_bind_slot = type { i32, i32 }
%struct._sg_commit_listeners_t = type { i32, i32, ptr }
%struct.sg_buffer = type { i32 }
%struct.sg_range = type { ptr, i64 }
%struct._sg_gl_buffer_t = type { %struct._sg_slot_t, %struct._sg_buffer_common_t, %struct.anon.0 }
%struct._sg_slot_t = type { i32, i32, i32 }
%struct._sg_buffer_common_t = type { i32, i32, i8, i32, i32, i32, i32, i32, i32 }
%struct.anon.0 = type { [2 x i32], i8 }

@.str.16 = external hidden unnamed_addr constant [81 x i8], align 1
@_sg = external hidden global %struct._sg_state_t, align 8
@.str.19 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__.sg_append_buffer = external hidden unnamed_addr constant [50 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [18 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @_sg_lookup_buffer(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @sg_append_buffer(i32 %0, ptr noundef %1) #2 {
  %3 = alloca %struct.sg_buffer, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = getelementptr inbounds %struct.sg_buffer, ptr %3, i32 0, i32 0
  store i32 %0, ptr %9, align 4
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load i8, ptr @_sg, align 8, !tbaa !9, !range !38, !noundef !39
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %14

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.16, i32 noundef 16671, ptr noundef @__PRETTY_FUNCTION__.sg_append_buffer) #4
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.sg_range, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !40
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  br label %24

23:                                               ; preds = %17, %14
  call void @__assert_fail(ptr noundef @.str.63, ptr noundef @.str.16, i32 noundef 16672, ptr noundef @__PRETTY_FUNCTION__.sg_append_buffer) #4
  unreachable

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %25 = getelementptr inbounds %struct.sg_buffer, ptr %3, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !43
  %27 = call ptr @_sg_lookup_buffer(ptr noundef getelementptr inbounds (%struct._sg_state_t, ptr @_sg, i32 0, i32 10), i32 noundef %26)
  store ptr %27, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %122

30:                                               ; preds = %24
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %32, i32 0, i32 6
  %34 = load i32, ptr %33, align 4, !tbaa !45
  %35 = load i32, ptr getelementptr inbounds (%struct._sg_state_t, ptr @_sg, i32 0, i32 2), align 8, !tbaa !50
  %36 = icmp ne i32 %34, %35
  br i1 %36, label %37, label %44

37:                                               ; preds = %30
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %39, i32 0, i32 1
  store i32 0, ptr %40, align 4, !tbaa !51
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %42, i32 0, i32 2
  store i8 0, ptr %43, align 4, !tbaa !52
  br label %44

44:                                               ; preds = %37, %30
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !51
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.sg_range, ptr %49, i32 0, i32 1
  %51 = load i64, ptr %50, align 8, !tbaa !53
  %52 = trunc i64 %51 to i32
  %53 = call i32 @_sg_roundup(i32 noundef %52, i32 noundef 4)
  %54 = add nsw i32 %48, %53
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 4, !tbaa !54
  %59 = icmp sgt i32 %54, %58
  br i1 %59, label %60, label %64

60:                                               ; preds = %44
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %62, i32 0, i32 2
  store i8 1, ptr %63, align 4, !tbaa !52
  br label %64

64:                                               ; preds = %60, %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !51
  store i32 %68, ptr %7, align 4, !tbaa !55
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds %struct._sg_slot_t, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !56
  %73 = icmp eq i32 %72, 2
  br i1 %73, label %74, label %120

74:                                               ; preds = %64
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = call zeroext i1 @_sg_validate_append_buffer(ptr noundef %75, ptr noundef %76)
  br i1 %77, label %78, label %119

78:                                               ; preds = %74
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %79, i32 0, i32 1
  %81 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %80, i32 0, i32 2
  %82 = load i8, ptr %81, align 4, !tbaa !52, !range !38, !noundef !39
  %83 = trunc i8 %82 to i1
  br i1 %83, label %118, label %84

84:                                               ; preds = %78
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.sg_range, ptr %85, i32 0, i32 1
  %87 = load i64, ptr %86, align 8, !tbaa !53
  %88 = icmp ugt i64 %87, 0
  br i1 %88, label %89, label %118

89:                                               ; preds = %84
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %90, i32 0, i32 1
  %92 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %91, i32 0, i32 5
  %93 = load i32, ptr %92, align 4, !tbaa !57
  %94 = load i32, ptr getelementptr inbounds (%struct._sg_state_t, ptr @_sg, i32 0, i32 2), align 8, !tbaa !50
  %95 = icmp ne i32 %93, %94
  br i1 %95, label %96, label %97

96:                                               ; preds = %89
  br label %98

97:                                               ; preds = %89
  call void @__assert_fail(ptr noundef @.str.61, ptr noundef @.str.16, i32 noundef 16689, ptr noundef @__PRETTY_FUNCTION__.sg_append_buffer) #4
  unreachable

98:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %101, i32 0, i32 1
  %103 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %102, i32 0, i32 6
  %104 = load i32, ptr %103, align 4, !tbaa !45
  %105 = load i32, ptr getelementptr inbounds (%struct._sg_state_t, ptr @_sg, i32 0, i32 2), align 8, !tbaa !50
  %106 = icmp ne i32 %104, %105
  %107 = call i32 @_sg_append_buffer(ptr noundef %99, ptr noundef %100, i1 noundef zeroext %106)
  store i32 %107, ptr %8, align 4, !tbaa !55
  %108 = load i32, ptr %8, align 4, !tbaa !55
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %109, i32 0, i32 1
  %111 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !51
  %113 = add nsw i32 %112, %108
  store i32 %113, ptr %111, align 4, !tbaa !51
  %114 = load i32, ptr getelementptr inbounds (%struct._sg_state_t, ptr @_sg, i32 0, i32 2), align 8, !tbaa !50
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._sg_gl_buffer_t, ptr %115, i32 0, i32 1
  %117 = getelementptr inbounds %struct._sg_buffer_common_t, ptr %116, i32 0, i32 6
  store i32 %114, ptr %117, align 4, !tbaa !45
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %118

118:                                              ; preds = %98, %84, %78
  br label %119

119:                                              ; preds = %118, %74
  br label %120

120:                                              ; preds = %119, %64
  %121 = load i32, ptr %7, align 4, !tbaa !55
  store i32 %121, ptr %6, align 4, !tbaa !55
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %123

122:                                              ; preds = %24
  store i32 0, ptr %6, align 4, !tbaa !55
  br label %123

123:                                              ; preds = %122, %120
  %124 = load i32, ptr %6, align 4, !tbaa !55
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 %124
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_sg_roundup(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @_sg_validate_append_buffer(ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @_sg_append_buffer(ptr noundef, ptr noundef, i1 noundef zeroext) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { 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 #3 = { inlinehint 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 #4 = { noreturn nounwind }
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 0}
!10 = !{!"", !11, i64 0, !12, i64 8, !13, i64 288, !21, i64 292, !22, i64 296, !23, i64 300, !11, i64 304, !11, i64 305, !11, i64 306, !13, i64 308, !24, i64 312, !13, i64 504, !26, i64 508, !27, i64 520, !7, i64 548, !28, i64 936, !37, i64 1616}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"sg_desc", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !11, i64 44, !14, i64 48, !15, i64 72, !16, i64 88, !13, i64 272}
!13 = !{!"int", !7, i64 0}
!14 = !{!"sg_allocator", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"sg_logger", !6, i64 0, !6, i64 8}
!16 = !{!"sg_context_desc", !13, i64 0, !13, i64 4, !13, i64 8, !17, i64 12, !18, i64 16, !19, i64 64, !20, i64 120}
!17 = !{!"sg_gl_context_desc", !11, i64 0}
!18 = !{!"sg_metal_context_desc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!"sg_d3d11_context_desc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!20 = !{!"sg_wgpu_context_desc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!21 = !{!"sg_context", !13, i64 0}
!22 = !{!"sg_pass", !13, i64 0}
!23 = !{!"sg_pipeline", !13, i64 0}
!24 = !{!"", !25, i64 0, !25, i64 24, !25, i64 48, !25, i64 72, !25, i64 96, !25, i64 120, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184}
!25 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16}
!26 = !{!"sg_features", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8}
!27 = !{!"sg_limits", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24}
!28 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !13, i64 4, !13, i64 8, !6, i64 16, !6, i64 24, !22, i64 32, !29, i64 40, !11, i64 664, !13, i64 668, !13, i64 672}
!29 = !{!"", !30, i64 0, !32, i64 24, !34, i64 64, !7, i64 92, !13, i64 108, !13, i64 112, !11, i64 116, !13, i64 120, !35, i64 124, !11, i64 140, !7, i64 144, !13, i64 464, !13, i64 468, !13, i64 472, !13, i64 476, !13, i64 480, !7, i64 484, !36, i64 580, !13, i64 588, !13, i64 592, !13, i64 596, !13, i64 600, !6, i64 608, !23, i64 616}
!30 = !{!"sg_depth_state", !13, i64 0, !13, i64 4, !11, i64 8, !31, i64 12, !31, i64 16, !31, i64 20}
!31 = !{!"float", !7, i64 0}
!32 = !{!"sg_stencil_state", !11, i64 0, !33, i64 4, !33, i64 20, !7, i64 36, !7, i64 37, !7, i64 38}
!33 = !{!"sg_stencil_face_state", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!34 = !{!"sg_blend_state", !11, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24}
!35 = !{!"sg_color", !31, i64 0, !31, i64 4, !31, i64 8, !31, i64 12}
!36 = !{!"", !13, i64 0, !13, i64 4}
!37 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8}
!38 = !{i8 0, i8 2}
!39 = !{}
!40 = !{!41, !6, i64 0}
!41 = !{!"sg_range", !6, i64 0, !42, i64 8}
!42 = !{!"long", !7, i64 0}
!43 = !{!44, !13, i64 0}
!44 = !{!"sg_buffer", !13, i64 0}
!45 = !{!46, !13, i64 36}
!46 = !{!"", !47, i64 0, !48, i64 12, !49, i64 48}
!47 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8}
!48 = !{!"", !13, i64 0, !13, i64 4, !11, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32}
!49 = !{!"", !7, i64 0, !11, i64 8}
!50 = !{!10, !13, i64 288}
!51 = !{!46, !13, i64 16}
!52 = !{!46, !11, i64 20}
!53 = !{!41, !42, i64 8}
!54 = !{!46, !13, i64 12}
!55 = !{!13, !13, i64 0}
!56 = !{!46, !13, i64 8}
!57 = !{!46, !13, i64 32}


; 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_state_t = type { i8, %struct.sg_desc, i32, %struct.sg_context, %struct.sg_pass, %struct.sg_pipeline, i8, i8, i8, i32, %struct._sg_pools_t, i32, %struct.sg_features, %struct.sg_limits, [64 x %struct.sg_pixelformat_info], %struct._sg_gl_backend_t, %struct._sg_commit_listeners_t }
%struct.sg_desc = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, %struct.sg_allocator, %struct.sg_logger, %struct.sg_context_desc, i32 }
%struct.sg_allocator = type { ptr, ptr, ptr }
%struct.sg_logger = type { ptr, ptr }
%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 }
%struct.sg_context = type { i32 }
%struct.sg_pass = type { i32 }
%struct.sg_pipeline = type { i32 }
%struct._sg_pools_t = type { %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, %struct._sg_pool_t, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._sg_pool_t = type { i32, i32, ptr, ptr }
%struct.sg_features = type { i8, i8, i8, i8, i8, i8, i8, i8, i8 }
%struct.sg_limits = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.sg_pixelformat_info = type { i8, i8, i8, i8, i8, i8 }
%struct._sg_gl_backend_t = type { i8, i8, i8, i32, i32, ptr, ptr, %struct.sg_pass, %struct._sg_gl_state_cache_t, i8, i32, i32 }
%struct._sg_gl_state_cache_t = type { %struct.sg_depth_state, %struct.sg_stencil_state, %struct.sg_blend_state, [4 x i32], i32, i32, i8, i32, %struct.sg_color, i8, [16 x %struct._sg_gl_cache_attr_t], i32, i32, i32, i32, i32, [12 x %struct._sg_gl_texture_bind_slot], %struct._sg_gl_texture_bind_slot, i32, i32, i32, i32, ptr, %struct.sg_pipeline }
%struct.sg_depth_state = type { i32, i32, i8, float, float, float }
%struct.sg_stencil_state = type { i8, %struct.sg_stencil_face_state, %struct.sg_stencil_face_state, i8, i8, i8 }
%struct.sg_stencil_face_state = type { i32, i32, i32, i32 }
%struct.sg_blend_state = type { i8, i32, i32, i32, i32, i32, i32 }
%struct.sg_color = type { float, float, float, float }
%struct._sg_gl_cache_attr_t = type { %struct._sg_gl_attr_t, i32 }
%struct._sg_gl_attr_t = type { i8, i8, i8, i8, i8, i32, i32 }
%struct._sg_gl_texture_bind_slot = type { i32, i32 }
%struct._sg_commit_listeners_t = type { i32, i32, ptr }

@.str.16 = external hidden unnamed_addr constant [81 x i8], align 1
@_sg = external hidden global %struct._sg_state_t, align 8
@.str.19 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__.sg_append_buffer = external hidden unnamed_addr constant [50 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @_sg_lookup_buffer(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @sg_append_buffer(i32 %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = load i8, ptr @_sg, align 8, !tbaa !5, !range !37, !noundef !38
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.16, i32 noundef 16671, ptr noundef nonnull @__PRETTY_FUNCTION__.sg_append_buffer) #3
  unreachable

6:                                                ; preds = %2
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %9, label %7

7:                                                ; preds = %6
  %8 = load ptr, ptr %1, align 8, !tbaa !39
  %.not27 = icmp eq ptr %8, null
  br i1 %.not27, label %9, label %10

9:                                                ; preds = %7, %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.63, ptr noundef nonnull @.str.16, i32 noundef 16672, ptr noundef nonnull @__PRETTY_FUNCTION__.sg_append_buffer) #3
  unreachable

10:                                               ; preds = %7
  %11 = tail call ptr @_sg_lookup_buffer(ptr noundef nonnull getelementptr inbounds (i8, ptr @_sg, i64 312), i32 noundef %0)
  %.not28 = icmp eq ptr %11, null
  br i1 %.not28, label %56, label %12

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %11, i64 12
  %14 = getelementptr inbounds i8, ptr %11, i64 36
  %15 = load i32, ptr %14, align 4, !tbaa !42
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @_sg, i64 288), align 8, !tbaa !47
  %.not29 = icmp eq i32 %15, %16
  %.phi.trans.insert = getelementptr inbounds i8, ptr %11, i64 16
  br i1 %.not29, label %._crit_edge, label %17

._crit_edge:                                      ; preds = %12
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !48
  br label %19

17:                                               ; preds = %12
  store i32 0, ptr %.phi.trans.insert, align 4, !tbaa !48
  %18 = getelementptr inbounds i8, ptr %11, i64 20
  store i8 0, ptr %18, align 4, !tbaa !49
  br label %19

19:                                               ; preds = %._crit_edge, %17
  %20 = phi i32 [ %.pre, %._crit_edge ], [ 0, %17 ]
  %21 = getelementptr inbounds i8, ptr %11, i64 16
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !50
  %24 = trunc i64 %23 to i32
  %25 = tail call i32 @_sg_roundup(i32 noundef %24, i32 noundef 4)
  %26 = add nsw i32 %25, %20
  %27 = load i32, ptr %13, align 4, !tbaa !51
  %28 = icmp sgt i32 %26, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %19
  %30 = getelementptr inbounds i8, ptr %11, i64 20
  store i8 1, ptr %30, align 4, !tbaa !49
  br label %31

31:                                               ; preds = %29, %19
  %32 = load i32, ptr %21, align 4, !tbaa !48
  %33 = getelementptr inbounds i8, ptr %11, i64 8
  %34 = load i32, ptr %33, align 4, !tbaa !52
  %35 = icmp eq i32 %34, 2
  br i1 %35, label %36, label %56

36:                                               ; preds = %31
  %37 = tail call zeroext i1 @_sg_validate_append_buffer(ptr noundef nonnull %11, ptr noundef nonnull %1)
  br i1 %37, label %38, label %56

38:                                               ; preds = %36
  %39 = getelementptr inbounds i8, ptr %11, i64 20
  %40 = load i8, ptr %39, align 4, !tbaa !49, !range !37, !noundef !38
  %41 = trunc nuw i8 %40 to i1
  br i1 %41, label %56, label %42

42:                                               ; preds = %38
  %43 = load i64, ptr %22, align 8, !tbaa !50
  %.not30 = icmp eq i64 %43, 0
  br i1 %.not30, label %56, label %44

44:                                               ; preds = %42
  %45 = getelementptr inbounds i8, ptr %11, i64 32
  %46 = load i32, ptr %45, align 4, !tbaa !53
  %47 = load i32, ptr getelementptr inbounds (i8, ptr @_sg, i64 288), align 8, !tbaa !47
  %.not31 = icmp eq i32 %46, %47
  br i1 %.not31, label %48, label %49

48:                                               ; preds = %44
  tail call void @__assert_fail(ptr noundef nonnull @.str.61, ptr noundef nonnull @.str.16, i32 noundef 16689, ptr noundef nonnull @__PRETTY_FUNCTION__.sg_append_buffer) #3
  unreachable

49:                                               ; preds = %44
  %50 = load i32, ptr %14, align 4, !tbaa !42
  %51 = icmp ne i32 %50, %47
  %52 = tail call i32 @_sg_append_buffer(ptr noundef nonnull %11, ptr noundef nonnull %1, i1 noundef zeroext %51)
  %53 = load i32, ptr %21, align 4, !tbaa !48
  %54 = add nsw i32 %53, %52
  store i32 %54, ptr %21, align 4, !tbaa !48
  %55 = load i32, ptr getelementptr inbounds (i8, ptr @_sg, i64 288), align 8, !tbaa !47
  store i32 %55, ptr %14, align 4, !tbaa !42
  br label %56

56:                                               ; preds = %10, %31, %38, %42, %49, %36
  %.0 = phi i32 [ %32, %36 ], [ %32, %49 ], [ %32, %42 ], [ %32, %38 ], [ %32, %31 ], [ 0, %10 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_sg_roundup(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @_sg_validate_append_buffer(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @_sg_append_buffer(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #2

attributes #0 = { noreturn 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 #1 = { 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 #2 = { inlinehint 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 #3 = { noreturn 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 = !{!"", !7, i64 0, !10, i64 8, !11, i64 288, !20, i64 292, !21, i64 296, !22, i64 300, !7, i64 304, !7, i64 305, !7, i64 306, !11, i64 308, !23, i64 312, !11, i64 504, !25, i64 508, !26, i64 520, !8, i64 548, !27, i64 936, !36, i64 1616}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"sg_desc", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !7, i64 44, !12, i64 48, !14, i64 72, !15, i64 88, !11, i64 272}
!11 = !{!"int", !8, i64 0}
!12 = !{!"sg_allocator", !13, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"sg_logger", !13, i64 0, !13, i64 8}
!15 = !{!"sg_context_desc", !11, i64 0, !11, i64 4, !11, i64 8, !16, i64 12, !17, i64 16, !18, i64 64, !19, i64 120}
!16 = !{!"sg_gl_context_desc", !7, i64 0}
!17 = !{!"sg_metal_context_desc", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40}
!18 = !{!"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}
!19 = !{!"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}
!20 = !{!"sg_context", !11, i64 0}
!21 = !{!"sg_pass", !11, i64 0}
!22 = !{!"sg_pipeline", !11, i64 0}
!23 = !{!"", !24, i64 0, !24, i64 24, !24, i64 48, !24, i64 72, !24, i64 96, !24, i64 120, !13, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !13, i64 184}
!24 = !{!"", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 16}
!25 = !{!"sg_features", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8}
!26 = !{!"sg_limits", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!27 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !11, i64 4, !11, i64 8, !13, i64 16, !13, i64 24, !21, i64 32, !28, i64 40, !7, i64 664, !11, i64 668, !11, i64 672}
!28 = !{!"", !29, i64 0, !31, i64 24, !33, i64 64, !8, i64 92, !11, i64 108, !11, i64 112, !7, i64 116, !11, i64 120, !34, i64 124, !7, i64 140, !8, i64 144, !11, i64 464, !11, i64 468, !11, i64 472, !11, i64 476, !11, i64 480, !8, i64 484, !35, i64 580, !11, i64 588, !11, i64 592, !11, i64 596, !11, i64 600, !13, i64 608, !22, i64 616}
!29 = !{!"sg_depth_state", !11, i64 0, !11, i64 4, !7, i64 8, !30, i64 12, !30, i64 16, !30, i64 20}
!30 = !{!"float", !8, i64 0}
!31 = !{!"sg_stencil_state", !7, i64 0, !32, i64 4, !32, i64 20, !8, i64 36, !8, i64 37, !8, i64 38}
!32 = !{!"sg_stencil_face_state", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!33 = !{!"sg_blend_state", !7, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!34 = !{!"sg_color", !30, i64 0, !30, i64 4, !30, i64 8, !30, i64 12}
!35 = !{!"", !11, i64 0, !11, i64 4}
!36 = !{!"", !11, i64 0, !11, i64 4, !13, i64 8}
!37 = !{i8 0, i8 2}
!38 = !{}
!39 = !{!40, !13, i64 0}
!40 = !{!"sg_range", !13, i64 0, !41, i64 8}
!41 = !{!"long", !8, i64 0}
!42 = !{!43, !11, i64 36}
!43 = !{!"", !44, i64 0, !45, i64 12, !46, i64 48}
!44 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!45 = !{!"", !11, i64 0, !11, i64 4, !7, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!46 = !{!"", !8, i64 0, !7, i64 8}
!47 = !{!6, !11, i64 288}
!48 = !{!43, !11, i64 16}
!49 = !{!43, !7, i64 20}
!50 = !{!40, !41, i64 8}
!51 = !{!43, !11, i64 12}
!52 = !{!43, !11, i64 8}
!53 = !{!43, !11, i64 32}


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