; 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_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 }
%struct.mu_Vec2 = 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 i32 @mu_get_id(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @mu_layout_next(ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mu_button_ex(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.mu_Rect, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %21

14:                                               ; preds = %4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call i64 @strlen(ptr noundef %17) #4
  %19 = trunc i64 %18 to i32
  %20 = call i32 @mu_get_id(ptr noundef %15, ptr noundef %16, i32 noundef %19)
  br label %24

21:                                               ; preds = %4
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call i32 @mu_get_id(ptr noundef %22, ptr noundef %7, i32 noundef 4)
  br label %24

24:                                               ; preds = %21, %14
  %25 = phi i32 [ %20, %14 ], [ %23, %21 ]
  store i32 %25, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call { i64, i64 } @mu_layout_next(ptr noundef %26)
  %28 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %29 = extractvalue { i64, i64 } %27, 0
  store i64 %29, ptr %28, align 4
  %30 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %31 = extractvalue { i64, i64 } %27, 1
  store i64 %31, ptr %30, align 4
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %36 = load i64, ptr %35, align 4
  %37 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %38 = load i64, ptr %37, align 4
  call void @mu_update_control(ptr noundef %32, i32 noundef %33, i64 %36, i64 %38, i32 noundef %34)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mu_Context, ptr %39, i32 0, i32 31
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %52

43:                                               ; preds = %24
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mu_Context, ptr %44, i32 0, i32 6
  %46 = load i32, ptr %45, align 4, !tbaa !18
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %52

49:                                               ; preds = %43
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = or i32 %50, 2
  store i32 %51, ptr %9, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %49, %43, %24
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %57 = load i64, ptr %56, align 4
  %58 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %59 = load i64, ptr %58, align 4
  call void @mu_draw_control_frame(ptr noundef %53, i32 noundef %54, i64 %57, i64 %59, i32 noundef 6, i32 noundef %55)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %70

62:                                               ; preds = %52
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %67 = load i64, ptr %66, align 4
  %68 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %69 = load i64, ptr %68, align 4
  call void @mu_draw_control_text(ptr noundef %63, ptr noundef %64, i64 %67, i64 %69, i32 noundef 0, i32 noundef %65)
  br label %70

70:                                               ; preds = %62, %52
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %86

73:                                               ; preds = %70
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.mu_Context, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  %79 = getelementptr inbounds %struct.mu_Style, ptr %78, i32 0, i32 8
  %80 = getelementptr inbounds [14 x %struct.mu_Color], ptr %79, i64 0, i64 0
  %81 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %82 = load i64, ptr %81, align 4
  %83 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %84 = load i64, ptr %83, align 4
  %85 = load i32, ptr %80, align 8
  call void @mu_draw_icon(ptr noundef %74, i32 noundef %75, i64 %82, i64 %84, i32 %85)
  br label %86

86:                                               ; preds = %73, %70
  %87 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %87
}

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 willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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, !10, i64 270156}
!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 = !{!12, !10, i64 132}
!19 = !{!12, !6, i64 120}


; 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: nounwind uwtable
declare dso_local i32 @mu_get_id(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @mu_layout_next(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @mu_button_ex(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  store i32 %2, ptr %5, align 4, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %10, label %6

6:                                                ; preds = %4
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #2
  %8 = trunc i64 %7 to i32
  %9 = tail call i32 @mu_get_id(ptr noundef %0, ptr noundef nonnull %1, i32 noundef %8)
  br label %12

10:                                               ; preds = %4
  %11 = call i32 @mu_get_id(ptr noundef %0, ptr noundef nonnull %5, i32 noundef 4)
  br label %12

12:                                               ; preds = %10, %6
  %13 = phi i32 [ %9, %6 ], [ %11, %10 ]
  %14 = call { i64, i64 } @mu_layout_next(ptr noundef %0)
  %15 = extractvalue { i64, i64 } %14, 0
  %16 = extractvalue { i64, i64 } %14, 1
  call void @mu_update_control(ptr noundef %0, i32 noundef %13, i64 %15, i64 %16, i32 noundef %3)
  %17 = getelementptr inbounds i8, ptr %0, i64 270156
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %24

20:                                               ; preds = %12
  %21 = getelementptr inbounds i8, ptr %0, i64 132
  %22 = load i32, ptr %21, align 4, !tbaa !17
  %23 = icmp eq i32 %22, %13
  %spec.select = select i1 %23, i32 2, i32 0
  br label %24

24:                                               ; preds = %20, %12
  %.0 = phi i32 [ 0, %12 ], [ %spec.select, %20 ]
  call void @mu_draw_control_frame(ptr noundef nonnull %0, i32 noundef %13, i64 %15, i64 %16, i32 noundef 6, i32 noundef %3)
  br i1 %.not, label %26, label %25

25:                                               ; preds = %24
  call void @mu_draw_control_text(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 %15, i64 %16, i32 noundef 0, i32 noundef %3)
  br label %26

26:                                               ; preds = %25, %24
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %.not30 = icmp eq i32 %27, 0
  br i1 %.not30, label %33, label %28

28:                                               ; preds = %26
  %29 = getelementptr inbounds i8, ptr %0, i64 120
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = getelementptr inbounds i8, ptr %30, i64 40
  %32 = load i32, ptr %31, align 8
  call void @mu_draw_icon(ptr noundef nonnull %0, i32 noundef %27, i64 %15, i64 %16, i32 %32)
  br label %33

33:                                               ; preds = %28, %26
  ret i32 %.0
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 270156}
!10 = !{!"mu_Context", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !11, i64 120, !6, i64 128, !6, i64 132, !6, i64 136, !14, i64 140, !6, i64 156, !6, i64 160, !6, i64 164, !11, i64 168, !11, i64 176, !11, i64 184, !7, i64 192, !6, 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, !13, i64 270120, !13, i64 270128, !13, i64 270136, !13, i64 270144, !6, i64 270152, !6, i64 270156, !6, i64 270160, !6, i64 270164, !7, i64 270168}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"", !11, i64 0, !13, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !7, i64 40}
!13 = !{!"", !6, i64 0, !6, i64 4}
!14 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!15 = !{!"", !6, i64 0, !7, i64 4}
!16 = !{!"", !6, i64 0, !7, i64 8}
!17 = !{!10, !6, i64 132}
!18 = !{!10, !11, i64 120}


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