; LLVM IR from NotManyIdeasDev/double-pendulum-sim :: double-pendulum-sim/Libraries/raygui-2.8/examples/controls_test_suite (GuiLabelButton)

; 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.Font = type { i32, i32, i32, %struct.Texture, ptr, ptr }
%struct.Texture = type { i32, i32, i32, i32, i32 }
%struct.Rectangle = type { float, float, float, float }
%struct.Vector2 = type { float, float }
%struct.Color = type { i8, i8, i8, i8 }

@guiState = external hidden global i32, align 4
@guiLocked = external hidden global i8, align 1
@guiAlpha = external hidden global float, align 4
@guiFont = external hidden global %struct.Font, align 8

; 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 @GuiGetStyle(i32 noundef, i32 noundef) #1

declare i32 @Fade(i32, float noundef) #2

declare i32 @GetColor(i32 noundef) #2

declare <2 x float> @GetMousePosition() #2

declare zeroext i1 @CheckCollisionPointRec(<2 x float>, <2 x float>, <2 x float>) #2

declare zeroext i1 @IsMouseButtonDown(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @GuiDrawText(ptr noundef, <2 x float>, <2 x float>, i32 noundef, i32) #3

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef, <2 x float>, <2 x float>) #3

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @GuiLabelButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) #3 {
  %4 = alloca %struct.Rectangle, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca %struct.Vector2, align 4
  %10 = alloca %struct.Vector2, align 4
  %11 = alloca %struct.Rectangle, align 4
  %12 = alloca %struct.Color, align 1
  %13 = alloca %struct.Color, align 1
  %14 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %0, ptr %14, align 4
  %15 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %1, ptr %15, align 4
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %16 = load i32, ptr @guiState, align 4, !tbaa !9
  store i32 %16, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  store i8 0, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %19 = sitofp i32 %18 to float
  %20 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 17)
  %21 = sitofp i32 %20 to float
  %22 = call <2 x float> @MeasureTextEx(ptr noundef byval(%struct.Font) align 8 @guiFont, ptr noundef %17, float noundef %19, float noundef %21)
  store <2 x float> %22, ptr %9, align 4
  %23 = getelementptr inbounds %struct.Vector2, ptr %9, i32 0, i32 0
  %24 = load float, ptr %23, align 4, !tbaa !13
  %25 = fptosi float %24 to i32
  store i32 %25, ptr %8, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 2
  %27 = load float, ptr %26, align 4, !tbaa !16
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sitofp i32 %28 to float
  %30 = fcmp olt float %27, %29
  br i1 %30, label %31, label %35

31:                                               ; preds = %3
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = sitofp i32 %32 to float
  %34 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 2
  store float %33, ptr %34, align 4, !tbaa !16
  br label %35

35:                                               ; preds = %31, %3
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 3
  br i1 %37, label %38, label %58

38:                                               ; preds = %35
  %39 = load i8, ptr @guiLocked, align 1, !tbaa !11, !range !18, !noundef !19
  %40 = trunc i8 %39 to i1
  br i1 %40, label %58, label %41

41:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %42 = call <2 x float> @GetMousePosition()
  store <2 x float> %42, ptr %10, align 4
  %43 = load <2 x float>, ptr %10, align 4
  %44 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %45 = load <2 x float>, ptr %44, align 4
  %46 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %47 = load <2 x float>, ptr %46, align 4
  %48 = call zeroext i1 @CheckCollisionPointRec(<2 x float> %43, <2 x float> %45, <2 x float> %47)
  br i1 %48, label %49, label %57

49:                                               ; preds = %41
  %50 = call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br i1 %50, label %51, label %52

51:                                               ; preds = %49
  store i32 2, ptr %6, align 4, !tbaa !9
  br label %53

52:                                               ; preds = %49
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %52, %51
  %54 = call zeroext i1 @IsMouseButtonReleased(i32 noundef 0)
  br i1 %54, label %55, label %56

55:                                               ; preds = %53
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %56

56:                                               ; preds = %55, %53
  br label %57

57:                                               ; preds = %56, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %58

58:                                               ; preds = %57, %38, %35
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %61 = load <2 x float>, ptr %60, align 4
  %62 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %63 = load <2 x float>, ptr %62, align 4
  %64 = call { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef 1, <2 x float> %61, <2 x float> %63)
  %65 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  %66 = extractvalue { <2 x float>, <2 x float> } %64, 0
  store <2 x float> %66, ptr %65, align 4
  %67 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  %68 = extractvalue { <2 x float>, <2 x float> } %64, 1
  store <2 x float> %68, ptr %67, align 4
  %69 = call i32 @GuiGetStyle(i32 noundef 1, i32 noundef 14)
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = mul i32 %70, 3
  %72 = add i32 2, %71
  %73 = call i32 @GuiGetStyle(i32 noundef 1, i32 noundef %72)
  %74 = call i32 @GetColor(i32 noundef %73)
  store i32 %74, ptr %13, align 1
  %75 = load float, ptr @guiAlpha, align 4, !tbaa !20
  %76 = load i32, ptr %13, align 1
  %77 = call i32 @Fade(i32 %76, float noundef %75)
  store i32 %77, ptr %12, align 1
  %78 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  %79 = load <2 x float>, ptr %78, align 4
  %80 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  %81 = load <2 x float>, ptr %80, align 4
  %82 = load i32, ptr %12, align 1
  call void @GuiDrawText(ptr noundef %59, <2 x float> %79, <2 x float> %81, i32 noundef %69, i32 %82)
  %83 = load i8, ptr %7, align 1, !tbaa !11, !range !18, !noundef !19
  %84 = trunc i8 %83 to i1
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret i1 %84
}

declare <2 x float> @MeasureTextEx(ptr noundef byval(%struct.Font) align 8, ptr noundef, float noundef, float noundef) #2

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 = { "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 uwtable "min-legal-vector-width"="64" "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 = { 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, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"Vector2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!17, !15, i64 8}
!17 = !{!"Rectangle", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!15, !15, i64 0}


; 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.Font = type { i32, i32, i32, %struct.Texture, ptr, ptr }
%struct.Texture = type { i32, i32, i32, i32, i32 }

@guiState = external hidden local_unnamed_addr global i32, align 4
@guiLocked = external hidden local_unnamed_addr global i8, align 1
@guiAlpha = external hidden local_unnamed_addr global float, align 4
@guiFont = external hidden global %struct.Font, align 8

; Function Attrs: nounwind uwtable
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @Fade(i32, float noundef) local_unnamed_addr #1

declare i32 @GetColor(i32 noundef) local_unnamed_addr #1

declare <2 x float> @GetMousePosition() local_unnamed_addr #1

declare zeroext i1 @CheckCollisionPointRec(<2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #1

declare zeroext i1 @IsMouseButtonDown(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @GuiDrawText(ptr noundef, <2 x float>, <2 x float>, i32 noundef, i32) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef, <2 x float>, <2 x float>) local_unnamed_addr #2

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @GuiLabelButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = load i32, ptr @guiState, align 4, !tbaa !5
  %5 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %6 = sitofp i32 %5 to float
  %7 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 17)
  %8 = sitofp i32 %7 to float
  %9 = tail call <2 x float> @MeasureTextEx(ptr noundef nonnull byval(%struct.Font) align 8 @guiFont, ptr noundef %2, float noundef %6, float noundef %8) #3
  %.sroa.04.0.vec.extract = extractelement <2 x float> %9, i64 0
  %10 = fptosi float %.sroa.04.0.vec.extract to i32
  %.sroa.3.8.vec.extract = extractelement <2 x float> %1, i64 0
  %11 = sitofp i32 %10 to float
  %12 = fcmp olt float %.sroa.3.8.vec.extract, %11
  %.sroa.3.8.vec.insert = insertelement <2 x float> %1, float %11, i64 0
  %.sroa.3.0 = select i1 %12, <2 x float> %.sroa.3.8.vec.insert, <2 x float> %1
  %.not = icmp eq i32 %4, 3
  br i1 %.not, label %22, label %13

13:                                               ; preds = %3
  %14 = load i8, ptr @guiLocked, align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %22, label %16

16:                                               ; preds = %13
  %17 = tail call <2 x float> @GetMousePosition() #3
  %18 = tail call zeroext i1 @CheckCollisionPointRec(<2 x float> %17, <2 x float> %0, <2 x float> %.sroa.3.0) #3
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = tail call zeroext i1 @IsMouseButtonDown(i32 noundef 0) #3
  %. = select i1 %20, i32 2, i32 1
  %21 = tail call zeroext i1 @IsMouseButtonReleased(i32 noundef 0) #3
  br label %22

22:                                               ; preds = %19, %16, %13, %3
  %.116 = phi i1 [ false, %13 ], [ false, %3 ], [ false, %16 ], [ %21, %19 ]
  %.2 = phi i32 [ %4, %13 ], [ 3, %3 ], [ %4, %16 ], [ %., %19 ]
  %23 = tail call { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef 1, <2 x float> %0, <2 x float> %.sroa.3.0)
  %24 = extractvalue { <2 x float>, <2 x float> } %23, 0
  %25 = extractvalue { <2 x float>, <2 x float> } %23, 1
  %26 = tail call i32 @GuiGetStyle(i32 noundef 1, i32 noundef 14)
  %27 = mul i32 %.2, 3
  %28 = add i32 %27, 2
  %29 = tail call i32 @GuiGetStyle(i32 noundef 1, i32 noundef %28)
  %30 = tail call i32 @GetColor(i32 noundef %29) #3
  %31 = load float, ptr @guiAlpha, align 4, !tbaa !13
  %32 = tail call i32 @Fade(i32 %30, float noundef %31) #3
  tail call void @GuiDrawText(ptr noundef %2, <2 x float> %24, <2 x float> %25, i32 noundef %26, i32 %32)
  ret i1 %.116
}

declare <2 x float> @MeasureTextEx(ptr noundef byval(%struct.Font) align 8, ptr noundef, float noundef, float noundef) local_unnamed_addr #1

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 = { "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"="64" "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 }

!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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}


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