; 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_BaseCommand = type { i32, i32 }
%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 }
%struct.mu_JumpCommand = type { %struct.mu_BaseCommand, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @mu_next_command(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %19

9:                                                ; preds = %2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.mu_BaseCommand, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i8, ptr %11, i64 %16
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %17, ptr %18, align 8, !tbaa !5
  br label %25

19:                                               ; preds = %2
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mu_Context, ptr %20, i32 0, i32 17
  %22 = getelementptr inbounds %struct.anon, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds [262144 x i8], ptr %22, i64 0, i64 0
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %23, ptr %24, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %19, %9
  br label %26

26:                                               ; preds = %46, %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mu_Context, ptr %29, i32 0, i32 17
  %31 = getelementptr inbounds %struct.anon, ptr %30, i32 0, i32 1
  %32 = getelementptr inbounds [262144 x i8], ptr %31, i64 0, i64 0
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mu_Context, ptr %33, i32 0, i32 17
  %35 = getelementptr inbounds %struct.anon, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !10
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %32, i64 %37
  %39 = icmp ne ptr %28, %38
  br i1 %39, label %40, label %52

40:                                               ; preds = %26
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load i32, ptr %42, align 8, !tbaa !9
  %44 = icmp ne i32 %43, 1
  br i1 %44, label %45, label %46

45:                                               ; preds = %40
  store i32 1, ptr %3, align 4
  br label %53

46:                                               ; preds = %40
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mu_JumpCommand, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %50, ptr %51, align 8, !tbaa !5
  br label %26, !llvm.loop !18

52:                                               ; preds = %26
  store i32 0, ptr %3, align 4
  br label %53

53:                                               ; preds = %52, %45
  %54 = load i32, ptr %3, align 4
  ret i32 %54
}

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

!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 = !{!7, !7, i64 0}
!10 = !{!11, !14, i64 324}
!11 = !{!"mu_Context", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 120, !14, i64 128, !14, i64 132, !14, i64 136, !15, i64 140, !14, i64 156, !14, i64 160, !14, i64 164, !6, i64 168, !6, i64 176, !6, i64 184, !7, i64 192, !14, i64 320, !16, i64 324, !17, i64 262472, !17, i64 262736, !16, i64 263000, !16, i64 263516, !16, i64 263648, !7, i64 265892, !7, i64 266280, !7, i64 269736, !13, i64 270120, !13, i64 270128, !13, i64 270136, !13, i64 270144, !14, i64 270152, !14, i64 270156, !14, i64 270160, !14, i64 270164, !7, i64 270168}
!12 = !{!"", !6, i64 0, !13, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !7, i64 40}
!13 = !{!"", !14, i64 0, !14, i64 4}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!16 = !{!"", !14, i64 0, !7, i64 4}
!17 = !{!"", !14, i64 0, !7, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @mu_next_command(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %9, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %3, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds i8, ptr %3, i64 %7
  br label %11

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 328
  br label %11

11:                                               ; preds = %9, %4
  %storemerge = phi ptr [ %10, %9 ], [ %8, %4 ]
  %12 = getelementptr inbounds i8, ptr %0, i64 324
  %13 = getelementptr inbounds i8, ptr %0, i64 328
  %14 = load i32, ptr %12, align 4, !tbaa !10
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %13, i64 %15
  store ptr %storemerge, ptr %1, align 8, !tbaa !5
  %.not1517 = icmp eq ptr %storemerge, %16
  br i1 %.not1517, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %18
  %storemerge1418 = phi ptr [ %20, %18 ], [ %storemerge, %11 ]
  %17 = load i32, ptr %storemerge1418, align 8, !tbaa !9
  %.not16 = icmp eq i32 %17, 1
  br i1 %.not16, label %18, label %._crit_edge

18:                                               ; preds = %.lr.ph
  %19 = getelementptr inbounds i8, ptr %storemerge1418, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  store ptr %20, ptr %1, align 8, !tbaa !5
  %.not15 = icmp eq ptr %20, %16
  br i1 %.not15, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %18, %11
  %.0 = phi i32 [ 0, %11 ], [ 0, %18 ], [ 1, %.lr.ph ]
  ret i32 %.0
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !14, i64 324}
!11 = !{!"mu_Context", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 120, !14, i64 128, !14, i64 132, !14, i64 136, !15, i64 140, !14, i64 156, !14, i64 160, !14, i64 164, !6, i64 168, !6, i64 176, !6, i64 184, !7, i64 192, !14, i64 320, !16, i64 324, !17, i64 262472, !17, i64 262736, !16, i64 263000, !16, i64 263516, !16, i64 263648, !7, i64 265892, !7, i64 266280, !7, i64 269736, !13, i64 270120, !13, i64 270128, !13, i64 270136, !13, i64 270144, !14, i64 270152, !14, i64 270156, !14, i64 270160, !14, i64 270164, !7, i64 270168}
!12 = !{!"", !6, i64 0, !13, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !7, i64 40}
!13 = !{!"", !14, i64 0, !14, i64 4}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!16 = !{!"", !14, i64 0, !7, i64 4}
!17 = !{!"", !14, i64 0, !7, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass