; 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_Rect = type { i32, i32, i32, i32 }
%struct.mu_Vec2 = 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.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 }

; 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: nounwind uwtable
declare dso_local void @mu_push_clip_rect(ptr noundef, i64, i64) #1

; Function Attrs: nounwind uwtable
declare dso_local void @mu_pop_clip_rect(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @mu_draw_text(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i64, i32) #1

; Function Attrs: nounwind uwtable
define dso_local void @mu_draw_control_text(ptr noundef %0, ptr noundef %1, i64 %2, i64 %3, i32 noundef %4, i32 noundef %5) #1 {
  %7 = alloca %struct.mu_Rect, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.mu_Vec2, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  store i64 %2, ptr %15, align 4
  %16 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  store i64 %3, ptr %16, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  store i32 %5, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mu_Context, ptr %17, i32 0, i32 4
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.mu_Style, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  store ptr %21, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mu_Context, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !19
  %25 = load ptr, ptr %13, align 8, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = call i32 %24(ptr noundef %25, ptr noundef %26, i32 noundef -1)
  store i32 %27, ptr %14, align 4, !tbaa !9
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %30 = load i64, ptr %29, align 4
  %31 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %32 = load i64, ptr %31, align 4
  call void @mu_push_clip_rect(ptr noundef %28, i64 %30, i64 %32)
  %33 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !20
  %35 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 3
  %36 = load i32, ptr %35, align 4, !tbaa !21
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mu_Context, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = call i32 %39(ptr noundef %40)
  %42 = sub nsw i32 %36, %41
  %43 = sdiv i32 %42, 2
  %44 = add nsw i32 %34, %43
  %45 = getelementptr inbounds %struct.mu_Vec2, ptr %12, i32 0, i32 1
  store i32 %44, ptr %45, align 4, !tbaa !23
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = and i32 %46, 1
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %59

49:                                               ; preds = %6
  %50 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 0
  %51 = load i32, ptr %50, align 4, !tbaa !24
  %52 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !25
  %54 = load i32, ptr %14, align 4, !tbaa !9
  %55 = sub nsw i32 %53, %54
  %56 = sdiv i32 %55, 2
  %57 = add nsw i32 %51, %56
  %58 = getelementptr inbounds %struct.mu_Vec2, ptr %12, i32 0, i32 0
  store i32 %57, ptr %58, align 4, !tbaa !26
  br label %89

59:                                               ; preds = %6
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = and i32 %60, 2
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %78

63:                                               ; preds = %59
  %64 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 0
  %65 = load i32, ptr %64, align 4, !tbaa !24
  %66 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 2
  %67 = load i32, ptr %66, align 4, !tbaa !25
  %68 = add nsw i32 %65, %67
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = sub nsw i32 %68, %69
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mu_Context, ptr %71, i32 0, i32 4
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.mu_Style, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !27
  %76 = sub nsw i32 %70, %75
  %77 = getelementptr inbounds %struct.mu_Vec2, ptr %12, i32 0, i32 0
  store i32 %76, ptr %77, align 4, !tbaa !26
  br label %88

78:                                               ; preds = %59
  %79 = getelementptr inbounds %struct.mu_Rect, ptr %7, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !24
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.mu_Context, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !11
  %84 = getelementptr inbounds %struct.mu_Style, ptr %83, i32 0, i32 2
  %85 = load i32, ptr %84, align 8, !tbaa !27
  %86 = add nsw i32 %80, %85
  %87 = getelementptr inbounds %struct.mu_Vec2, ptr %12, i32 0, i32 0
  store i32 %86, ptr %87, align 4, !tbaa !26
  br label %88

88:                                               ; preds = %78, %63
  br label %89

89:                                               ; preds = %88, %49
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = load ptr, ptr %13, align 8, !tbaa !5
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.mu_Context, ptr %93, i32 0, i32 4
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct.mu_Style, ptr %95, i32 0, i32 8
  %97 = load i32, ptr %10, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [14 x %struct.mu_Color], ptr %96, i64 0, i64 %98
  %100 = load i64, ptr %12, align 4
  %101 = load i32, ptr %99, align 4
  call void @mu_draw_text(ptr noundef %90, ptr noundef %91, ptr noundef %92, i32 noundef -1, i64 %100, i32 %101)
  %102 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mu_pop_clip_rect(ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 120}
!12 = !{!"mu_Context", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 120, !10, i64 128, !10, i64 132, !10, i64 136, !15, i64 140, !10, i64 156, !10, i64 160, !10, i64 164, !6, i64 168, !6, i64 176, !6, i64 184, !7, i64 192, !10, 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, !14, i64 270120, !14, i64 270128, !14, i64 270136, !14, i64 270144, !10, i64 270152, !10, i64 270156, !10, i64 270160, !10, i64 270164, !7, i64 270168}
!13 = !{!"", !6, i64 0, !14, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40}
!14 = !{!"", !10, i64 0, !10, i64 4}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!16 = !{!"", !10, i64 0, !7, i64 4}
!17 = !{!"", !10, i64 0, !7, i64 8}
!18 = !{!13, !6, i64 0}
!19 = !{!12, !6, i64 0}
!20 = !{!15, !10, i64 4}
!21 = !{!15, !10, i64 12}
!22 = !{!12, !6, i64 8}
!23 = !{!14, !10, i64 4}
!24 = !{!15, !10, i64 0}
!25 = !{!15, !10, i64 8}
!26 = !{!14, !10, i64 0}
!27 = !{!13, !10, i64 16}


; 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.mu_Color = type { i8, i8, i8, i8 }

; Function Attrs: nounwind uwtable
declare dso_local void @mu_push_clip_rect(ptr noundef, i64, i64) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @mu_pop_clip_rect(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @mu_draw_text(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i64, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @mu_draw_control_text(ptr noundef %0, ptr noundef %1, i64 %2, i64 %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %.sroa.018.0.extract.trunc = trunc i64 %2 to i32
  %.sroa.622.8.extract.trunc = trunc i64 %3 to i32
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %8, align 8, !tbaa !16
  %10 = load ptr, ptr %0, align 8, !tbaa !17
  %11 = tail call i32 %10(ptr noundef %9, ptr noundef %1, i32 noundef -1) #1
  tail call void @mu_push_clip_rect(ptr noundef nonnull %0, i64 %2, i64 %3)
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %14 = tail call i32 %13(ptr noundef %9) #1
  %15 = and i32 %5, 1
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %20, label %16

16:                                               ; preds = %6
  %17 = sub nsw i32 %.sroa.622.8.extract.trunc, %11
  %18 = sdiv i32 %17, 2
  %19 = add nsw i32 %18, %.sroa.018.0.extract.trunc
  %.pre = load ptr, ptr %7, align 8, !tbaa !5
  br label %30

20:                                               ; preds = %6
  %21 = and i32 %5, 2
  %.not25 = icmp eq i32 %21, 0
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %24 = load i32, ptr %23, align 8, !tbaa !19
  br i1 %.not25, label %28, label %25

25:                                               ; preds = %20
  %.neg27 = add i32 %.sroa.622.8.extract.trunc, %.sroa.018.0.extract.trunc
  %26 = add i32 %11, %24
  %27 = sub i32 %.neg27, %26
  br label %30

28:                                               ; preds = %20
  %29 = add nsw i32 %24, %.sroa.018.0.extract.trunc
  br label %30

30:                                               ; preds = %25, %28, %16
  %31 = phi ptr [ %.pre, %16 ], [ %22, %25 ], [ %22, %28 ]
  %.sroa.0.0 = phi i32 [ %19, %16 ], [ %27, %25 ], [ %29, %28 ]
  %.sroa.5.0.extract.shift = lshr i64 %2, 32
  %.sroa.5.0.extract.trunc = trunc nuw i64 %.sroa.5.0.extract.shift to i32
  %.sroa.10.8.extract.shift = lshr i64 %3, 32
  %.sroa.10.8.extract.trunc = trunc nuw i64 %.sroa.10.8.extract.shift to i32
  %32 = sub nsw i32 %.sroa.10.8.extract.trunc, %14
  %33 = sdiv i32 %32, 2
  %34 = add nsw i32 %33, %.sroa.5.0.extract.trunc
  %35 = getelementptr inbounds i8, ptr %31, i64 40
  %36 = sext i32 %4 to i64
  %37 = getelementptr inbounds [14 x %struct.mu_Color], ptr %35, i64 0, i64 %36
  %.sroa.6.0.insert.ext = zext i32 %34 to i64
  %.sroa.6.0.insert.shift = shl nuw i64 %.sroa.6.0.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %.sroa.0.0 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.6.0.insert.shift, %.sroa.0.0.insert.ext
  %38 = load i32, ptr %37, align 4
  tail call void @mu_draw_text(ptr noundef nonnull %0, ptr noundef %9, ptr noundef %1, i32 noundef -1, i64 %.sroa.0.0.insert.insert, i32 %38)
  tail call void @mu_pop_clip_rect(ptr noundef nonnull %0)
  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 = { 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 120}
!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 = !{!10, !7, i64 0}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !7, i64 8}
!19 = !{!10, !12, i64 16}


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