; LLVM IR from vectozavr/3dzavr :: engine/io/microui (microui)

; 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.mu_Context = type { ptr, ptr, ptr, %struct.mu_Style, ptr, i32, i32, i32, %struct.mu_Rect, i32, i32, i32, ptr, ptr, ptr, [127 x i8], i32, %struct.anon, %struct.anon.0, %struct.anon.1, %struct.anon.2, %struct.anon.3, %struct.anon.4, [48 x %struct.mu_PoolItem], [48 x %struct.mu_Container], [48 x %struct.mu_PoolItem], %struct.mu_Vec2, %struct.mu_Vec2, %struct.mu_Vec2, %struct.mu_Vec2, i32, i32, i32, i32, [32 x i8] }
%struct.mu_Style = type { ptr, %struct.mu_Vec2, i32, i32, i32, i32, i32, i32, [14 x %struct.mu_Color] }
%struct.mu_Color = type { i8, i8, i8, i8 }
%struct.mu_Rect = type { i32, i32, i32, i32 }
%struct.anon = type { i32, [262144 x i8] }
%struct.anon.0 = type { i32, [32 x ptr] }
%struct.anon.1 = type { i32, [32 x ptr] }
%struct.anon.2 = type { i32, [32 x %struct.mu_Rect] }
%struct.anon.3 = type { i32, [32 x i32] }
%struct.anon.4 = type { i32, [16 x %struct.mu_Layout] }
%struct.mu_Layout = type { %struct.mu_Rect, %struct.mu_Rect, %struct.mu_Vec2, %struct.mu_Vec2, %struct.mu_Vec2, [16 x i32], i32, i32, i32, i32, i32 }
%struct.mu_Container = type { ptr, ptr, %struct.mu_Rect, %struct.mu_Rect, %struct.mu_Vec2, %struct.mu_Vec2, i32, i32 }
%struct.mu_PoolItem = type { i32, i32 }
%struct.mu_Vec2 = type { i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @mu_begin(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %3

3:                                                ; preds = %1
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.mu_Context, ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %13

8:                                                ; preds = %3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mu_Context, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !17
  %12 = icmp ne ptr %11, null
  br i1 %12, label %16, label %13

13:                                               ; preds = %8, %3
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 139, ptr noundef @.str.2) #3
  call void @abort() #4
  unreachable

16:                                               ; preds = %8
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mu_Context, ptr %18, i32 0, i32 17
  %20 = getelementptr inbounds %struct.anon, ptr %19, i32 0, i32 0
  store i32 0, ptr %20, align 4, !tbaa !18
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mu_Context, ptr %21, i32 0, i32 18
  %23 = getelementptr inbounds %struct.anon.0, ptr %22, i32 0, i32 0
  store i32 0, ptr %23, align 8, !tbaa !19
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mu_Context, ptr %24, i32 0, i32 14
  store ptr null, ptr %25, align 8, !tbaa !20
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mu_Context, ptr %26, i32 0, i32 13
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mu_Context, ptr %29, i32 0, i32 12
  store ptr %28, ptr %30, align 8, !tbaa !22
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mu_Context, ptr %31, i32 0, i32 13
  store ptr null, ptr %32, align 8, !tbaa !21
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mu_Context, ptr %33, i32 0, i32 26
  %35 = getelementptr inbounds %struct.mu_Vec2, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !23
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mu_Context, ptr %37, i32 0, i32 27
  %39 = getelementptr inbounds %struct.mu_Vec2, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !24
  %41 = sub nsw i32 %36, %40
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.mu_Context, ptr %42, i32 0, i32 28
  %44 = getelementptr inbounds %struct.mu_Vec2, ptr %43, i32 0, i32 0
  store i32 %41, ptr %44, align 8, !tbaa !25
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mu_Context, ptr %45, i32 0, i32 26
  %47 = getelementptr inbounds %struct.mu_Vec2, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !26
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mu_Context, ptr %49, i32 0, i32 27
  %51 = getelementptr inbounds %struct.mu_Vec2, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !27
  %53 = sub nsw i32 %48, %52
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.mu_Context, ptr %54, i32 0, i32 28
  %56 = getelementptr inbounds %struct.mu_Vec2, ptr %55, i32 0, i32 1
  store i32 %53, ptr %56, align 4, !tbaa !28
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mu_Context, ptr %57, i32 0, i32 11
  %59 = load i32, ptr %58, align 4, !tbaa !29
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %58, align 4, !tbaa !29
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @abort() #2

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 = { 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 = { 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 #3 = { nounwind }
attributes #4 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"mu_Context", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 120, !13, i64 128, !13, i64 132, !13, i64 136, !14, i64 140, !13, i64 156, !13, i64 160, !13, i64 164, !6, i64 168, !6, i64 176, !6, i64 184, !7, i64 192, !13, i64 320, !15, i64 324, !16, i64 262472, !16, i64 262736, !15, i64 263000, !15, i64 263516, !15, i64 263648, !7, i64 265892, !7, i64 266280, !7, i64 269736, !12, i64 270120, !12, i64 270128, !12, i64 270136, !12, i64 270144, !13, i64 270152, !13, i64 270156, !13, i64 270160, !13, i64 270164, !7, i64 270168}
!11 = !{!"", !6, i64 0, !12, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !7, i64 40}
!12 = !{!"", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!15 = !{!"", !13, i64 0, !7, i64 4}
!16 = !{!"", !13, i64 0, !7, i64 8}
!17 = !{!10, !6, i64 8}
!18 = !{!10, !13, i64 324}
!19 = !{!10, !13, i64 262472}
!20 = !{!10, !6, i64 184}
!21 = !{!10, !6, i64 176}
!22 = !{!10, !6, i64 168}
!23 = !{!10, !13, i64 270120}
!24 = !{!10, !13, i64 270128}
!25 = !{!10, !13, i64 270136}
!26 = !{!10, !13, i64 270124}
!27 = !{!10, !13, i64 270132}
!28 = !{!10, !13, i64 270140}
!29 = !{!10, !13, i64 164}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @mu_begin(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %6, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !16
  %.not15 = icmp eq ptr %5, null
  br i1 %.not15, label %6, label %9

6:                                                ; preds = %3, %1
  %7 = load ptr, ptr @stderr, align 8, !tbaa !17
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 139, ptr noundef nonnull @.str.2) #3
  tail call void @abort() #4
  unreachable

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 324
  store i32 0, ptr %10, align 4, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %0, i64 262472
  store i32 0, ptr %11, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr null, ptr %12, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %0, i64 176
  %14 = load ptr, ptr %13, align 8, !tbaa !21
  %15 = getelementptr inbounds i8, ptr %0, i64 168
  store ptr %14, ptr %15, align 8, !tbaa !22
  store ptr null, ptr %13, align 8, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %0, i64 270120
  %17 = getelementptr inbounds i8, ptr %0, i64 270128
  %18 = getelementptr inbounds i8, ptr %0, i64 270136
  %19 = load <2 x i32>, ptr %16, align 8, !tbaa !23
  %20 = load <2 x i32>, ptr %17, align 8, !tbaa !23
  %21 = sub nsw <2 x i32> %19, %20
  store <2 x i32> %21, ptr %18, align 8, !tbaa !23
  %22 = getelementptr inbounds i8, ptr %0, i64 164
  %23 = load i32, ptr %22, align 4, !tbaa !24
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 4, !tbaa !24
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #2

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 = { 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 #2 = { 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 #3 = { cold nounwind }
attributes #4 = { 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 = !{!"mu_Context", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 120, !12, i64 128, !12, i64 132, !12, i64 136, !13, i64 140, !12, i64 156, !12, i64 160, !12, i64 164, !7, i64 168, !7, i64 176, !7, i64 184, !8, i64 192, !12, i64 320, !14, i64 324, !15, i64 262472, !15, i64 262736, !14, i64 263000, !14, i64 263516, !14, i64 263648, !8, i64 265892, !8, i64 266280, !8, i64 269736, !11, i64 270120, !11, i64 270128, !11, i64 270136, !11, i64 270144, !12, i64 270152, !12, i64 270156, !12, i64 270160, !12, i64 270164, !8, i64 270168}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !8, i64 40}
!11 = !{!"", !12, i64 0, !12, i64 4}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!14 = !{!"", !12, i64 0, !8, i64 4}
!15 = !{!"", !12, i64 0, !8, i64 8}
!16 = !{!6, !7, i64 8}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !12, i64 324}
!19 = !{!6, !12, i64 262472}
!20 = !{!6, !7, i64 184}
!21 = !{!6, !7, i64 176}
!22 = !{!6, !7, i64 168}
!23 = !{!12, !12, i64 0}
!24 = !{!6, !12, i64 164}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass