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

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

; 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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @GuiButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) #2 {
  %4 = alloca %struct.Rectangle, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca %struct.Vector2, align 4
  %9 = alloca %struct.Color, align 1
  %10 = alloca %struct.Color, align 1
  %11 = alloca %struct.Color, align 1
  %12 = alloca %struct.Color, align 1
  %13 = alloca %struct.Rectangle, align 4
  %14 = alloca %struct.Color, align 1
  %15 = alloca %struct.Color, align 1
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %0, ptr %16, align 4
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %1, ptr %17, align 4
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %18 = load i32, ptr @guiState, align 4, !tbaa !9
  store i32 %18, 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
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp ne i32 %19, 3
  br i1 %20, label %21, label %41

21:                                               ; preds = %3
  %22 = load i8, ptr @guiLocked, align 1, !tbaa !11, !range !13, !noundef !14
  %23 = trunc i8 %22 to i1
  br i1 %23, label %41, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %25 = call <2 x float> @GetMousePosition()
  store <2 x float> %25, ptr %8, align 4
  %26 = load <2 x float>, ptr %8, align 4
  %27 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %28 = load <2 x float>, ptr %27, align 4
  %29 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %30 = load <2 x float>, ptr %29, align 4
  %31 = call zeroext i1 @CheckCollisionPointRec(<2 x float> %26, <2 x float> %28, <2 x float> %30)
  br i1 %31, label %32, label %40

32:                                               ; preds = %24
  %33 = call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br i1 %33, label %34, label %35

34:                                               ; preds = %32
  store i32 2, ptr %6, align 4, !tbaa !9
  br label %36

35:                                               ; preds = %32
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %35, %34
  %37 = call zeroext i1 @IsMouseButtonReleased(i32 noundef 0)
  br i1 %37, label %38, label %39

38:                                               ; preds = %36
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %39

39:                                               ; preds = %38, %36
  br label %40

40:                                               ; preds = %39, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %41

41:                                               ; preds = %40, %21, %3
  %42 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef 12)
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = mul i32 %43, 3
  %45 = add i32 0, %44
  %46 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %45)
  %47 = call i32 @GetColor(i32 noundef %46)
  store i32 %47, ptr %10, align 1
  %48 = load float, ptr @guiAlpha, align 4, !tbaa !15
  %49 = load i32, ptr %10, align 1
  %50 = call i32 @Fade(i32 %49, float noundef %48)
  store i32 %50, ptr %9, align 1
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = mul i32 %51, 3
  %53 = add i32 1, %52
  %54 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %53)
  %55 = call i32 @GetColor(i32 noundef %54)
  store i32 %55, ptr %12, align 1
  %56 = load float, ptr @guiAlpha, align 4, !tbaa !15
  %57 = load i32, ptr %12, align 1
  %58 = call i32 @Fade(i32 %57, float noundef %56)
  store i32 %58, ptr %11, align 1
  %59 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %60 = load <2 x float>, ptr %59, align 4
  %61 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %62 = load <2 x float>, ptr %61, align 4
  %63 = load i32, ptr %9, align 1
  %64 = load i32, ptr %11, align 1
  call void @GuiDrawRectangle(<2 x float> %60, <2 x float> %62, i32 noundef %42, i32 %63, i32 %64)
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %67 = load <2 x float>, ptr %66, align 4
  %68 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %69 = load <2 x float>, ptr %68, align 4
  %70 = call { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef 2, <2 x float> %67, <2 x float> %69)
  %71 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 0
  %72 = extractvalue { <2 x float>, <2 x float> } %70, 0
  store <2 x float> %72, ptr %71, align 4
  %73 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 1
  %74 = extractvalue { <2 x float>, <2 x float> } %70, 1
  store <2 x float> %74, ptr %73, align 4
  %75 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef 14)
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = mul i32 %76, 3
  %78 = add i32 2, %77
  %79 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %78)
  %80 = call i32 @GetColor(i32 noundef %79)
  store i32 %80, ptr %15, align 1
  %81 = load float, ptr @guiAlpha, align 4, !tbaa !15
  %82 = load i32, ptr %15, align 1
  %83 = call i32 @Fade(i32 %82, float noundef %81)
  store i32 %83, ptr %14, align 1
  %84 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 0
  %85 = load <2 x float>, ptr %84, align 4
  %86 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 1
  %87 = load <2 x float>, ptr %86, align 4
  %88 = load i32, ptr %14, align 1
  call void @GuiDrawText(ptr noundef %65, <2 x float> %85, <2 x float> %87, i32 noundef %75, i32 %88)
  %89 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %90 = trunc i8 %89 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret i1 %90
}

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

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

declare i32 @GetColor(i32 noundef) #3

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

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

declare zeroext i1 @IsMouseButtonDown(i32 noundef) #3

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

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

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) #3

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 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 = { "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 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, 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"

@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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @GuiButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = load i32, ptr @guiState, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 3
  br i1 %.not, label %14, label %5

5:                                                ; preds = %3
  %6 = load i8, ptr @guiLocked, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %14, label %8

8:                                                ; preds = %5
  %9 = tail call <2 x float> @GetMousePosition() #3
  %10 = tail call zeroext i1 @CheckCollisionPointRec(<2 x float> %9, <2 x float> %0, <2 x float> %1) #3
  br i1 %10, label %11, label %14

11:                                               ; preds = %8
  %12 = tail call zeroext i1 @IsMouseButtonDown(i32 noundef 0) #3
  %. = select i1 %12, i32 2, i32 1
  %13 = tail call zeroext i1 @IsMouseButtonReleased(i32 noundef 0) #3
  br label %14

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

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

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

declare i32 @GetColor(i32 noundef) local_unnamed_addr #2

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

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

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

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

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

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) 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 = { 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 #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 }

!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